diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-06 11:03:10 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-06 11:03:10 +0100 |
commit | 0a86366c71e852b93dda40942ef468f9e5f9b48d (patch) | |
tree | a1738e148a6234f694d5276934da9c05b9531bec /SharedGraphics/Font.h | |
parent | b85fe0bd076e4c5f4e353ad2d9fe6ed003d818d1 (diff) | |
download | serenity-0a86366c71e852b93dda40942ef468f9e5f9b48d.zip |
Make a preparation pass for variable-width fonts.
Diffstat (limited to 'SharedGraphics/Font.h')
-rw-r--r-- | SharedGraphics/Font.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/SharedGraphics/Font.h b/SharedGraphics/Font.h index c72152dc60..e1bde4722e 100644 --- a/SharedGraphics/Font.h +++ b/SharedGraphics/Font.h @@ -54,21 +54,30 @@ public: GlyphBitmap glyph_bitmap(char ch) const { return GlyphBitmap(&m_rows[(byte)ch * m_glyph_height], { m_glyph_width, m_glyph_height }); } - byte glyph_width() const { return m_glyph_width; } + byte glyph_width(char ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[(byte)ch]; } byte glyph_height() const { return m_glyph_height; } - int width(const String& string) const { return string.length() * glyph_width(); } + byte min_glyph_width() const { return m_min_glyph_width; } + byte max_glyph_width() const { return m_max_glyph_width; } + int width(const String& string) const; String name() const { return m_name; } void set_name(const String& name) { m_name = name; } + bool is_fixed_width() const { return m_fixed_width; } + private: Font(const String& name, unsigned* rows, byte glyph_width, byte glyph_height); String m_name; unsigned* m_rows { nullptr }; + byte* m_glyph_widths { nullptr }; void* m_mmap_ptr { nullptr }; byte m_glyph_width { 0 }; byte m_glyph_height { 0 }; + byte m_min_glyph_width { 0 }; + byte m_max_glyph_width { 0 }; + + bool m_fixed_width { false }; }; |