diff options
author | Andreas Kling <kling@serenityos.org> | 2020-08-07 20:29:32 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-07 20:29:32 +0200 |
commit | 0bbced444b86ef9eab4cccf34c75849fa38f3022 (patch) | |
tree | 3e0545f2512a651b86f3a2e8a097ab2be6d1c7b2 | |
parent | fae9c9f81f9b5b65b94393c1c0ebd9982d8abdf7 (diff) | |
download | serenity-0bbced444b86ef9eab4cccf34c75849fa38f3022.zip |
LibGfx: Add dummy Font::x_height() getter
Right now we just guess that the x-height is glyph_height/2, which is
obviously not accurate. We currently don't store the x-height in fonts,
so that's something we'll need to fix.
-rw-r--r-- | Libraries/LibGfx/Font.cpp | 3 | ||||
-rw-r--r-- | Libraries/LibGfx/Font.h | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibGfx/Font.cpp b/Libraries/LibGfx/Font.cpp index b0e21f47e9..2002d16a38 100644 --- a/Libraries/LibGfx/Font.cpp +++ b/Libraries/LibGfx/Font.cpp @@ -137,6 +137,9 @@ Font::Font(const StringView& name, unsigned* rows, u8* widths, bool is_fixed_wid , m_glyph_spacing(glyph_spacing) , m_fixed_width(is_fixed_width) { + // FIXME: This is just a dumb guess. It would be cool to know the actual x-height of the font! + m_x_height = glyph_height / 2; + m_glyph_count = glyph_count_by_type(m_type); if (!m_fixed_width) { diff --git a/Libraries/LibGfx/Font.h b/Libraries/LibGfx/Font.h index 001b55bfb8..475f3a13e6 100644 --- a/Libraries/LibGfx/Font.h +++ b/Libraries/LibGfx/Font.h @@ -94,6 +94,8 @@ public: u8 glyph_width(size_t ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[ch]; } int glyph_or_emoji_width(u32 code_point) const; u8 glyph_height() const { return m_glyph_height; } + int x_height() const { return m_x_height; } + u8 min_glyph_width() const { return m_min_glyph_width; } u8 max_glyph_width() const { return m_max_glyph_width; } u8 glyph_fixed_width() const { return m_glyph_width; } @@ -121,6 +123,7 @@ public: FontTypes type() { return m_type; } void set_type(FontTypes type); + private: Font(const StringView& name, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, FontTypes type); @@ -137,6 +140,7 @@ private: u8 m_glyph_width { 0 }; u8 m_glyph_height { 0 }; + u8 m_x_height { 0 }; u8 m_min_glyph_width { 0 }; u8 m_max_glyph_width { 0 }; u8 m_glyph_spacing { 0 }; |