diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-10-12 13:42:58 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-10-12 13:42:58 +0200 |
commit | 92b6a7a18f062c0d17270334e9656c2adcd51544 (patch) | |
tree | 4775706feba46b0ce821793515f9122aa6817734 /Libraries/LibHTML/CSS | |
parent | 3cef6a5cac06c273b08dde70df8625540e81d362 (diff) | |
download | serenity-92b6a7a18f062c0d17270334e9656c2adcd51544.zip |
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. :^)
Diffstat (limited to 'Libraries/LibHTML/CSS')
-rw-r--r-- | Libraries/LibHTML/CSS/StyleProperties.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibHTML/CSS/StyleProperties.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Libraries/LibHTML/CSS/StyleProperties.cpp b/Libraries/LibHTML/CSS/StyleProperties.cpp index 2c74171e28..e0386e63b0 100644 --- a/Libraries/LibHTML/CSS/StyleProperties.cpp +++ b/Libraries/LibHTML/CSS/StyleProperties.cpp @@ -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); +} diff --git a/Libraries/LibHTML/CSS/StyleProperties.h b/Libraries/LibHTML/CSS/StyleProperties.h index 650836eed1..c18b87ef93 100644 --- a/Libraries/LibHTML/CSS/StyleProperties.h +++ b/Libraries/LibHTML/CSS/StyleProperties.h @@ -32,6 +32,8 @@ public: return *m_font; } + int line_height() const; + private: HashMap<unsigned, NonnullRefPtr<StyleValue>> m_property_values; |