mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibHTML: Add StyleProperties::line_height()
We currently hard-code the line height to 140% of the font glyph height and this patch doesn't fix the hard-coding, but at least moves it out of LayoutText and into StyleProperties where it can be re-used until the day we go and do a proper implementation of CSS line-height. :^)
This commit is contained in:
parent
3cef6a5cac
commit
92b6a7a18f
3 changed files with 9 additions and 2 deletions
|
@ -91,3 +91,9 @@ void StyleProperties::load_font() const
|
|||
|
||||
m_font = Font::load_from_file(String::format("/res/fonts/%s", file_name.characters()));
|
||||
}
|
||||
|
||||
int StyleProperties::line_height() const
|
||||
{
|
||||
// FIXME: Allow overriding the line-height. We currently default to 140% which seems to look nice.
|
||||
return (int)(font().glyph_height() * 1.4f);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
return *m_font;
|
||||
}
|
||||
|
||||
int line_height() const;
|
||||
|
||||
private:
|
||||
HashMap<unsigned, NonnullRefPtr<StyleValue>> m_property_values;
|
||||
|
||||
|
|
|
@ -123,8 +123,7 @@ void LayoutText::split_into_lines(LayoutBlock& container)
|
|||
{
|
||||
auto& font = style().font();
|
||||
int space_width = font.glyph_width(' ') + font.glyph_spacing();
|
||||
// FIXME: Allow overriding the line-height. We currently default to 140% which seems to look nice.
|
||||
int line_height = (int)(font.glyph_height() * 1.4f);
|
||||
int line_height = style().line_height();
|
||||
|
||||
auto& line_boxes = container.line_boxes();
|
||||
if (line_boxes.is_empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue