diff options
author | Stephan Unverwerth <s.unverwerth@gmx.de> | 2021-01-03 19:37:34 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-15 08:50:48 +0100 |
commit | 05d31cbeeb5683ba7b351d462302a46a9026c686 (patch) | |
tree | c4e3997883f2e50a7652ad368bb6c35443b03e7f /Userland | |
parent | 53d2073a66307dc8141c8fb77528d92b88b5ba02 (diff) | |
download | serenity-05d31cbeeb5683ba7b351d462302a46a9026c686.zip |
LibTTF: Add hack for recognizing fixed-width fonts
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibTTF/Font.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibTTF/Font.h | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibTTF/Font.cpp b/Userland/Libraries/LibTTF/Font.cpp index aa7166683b..81efaa7ca9 100644 --- a/Userland/Libraries/LibTTF/Font.cpp +++ b/Userland/Libraries/LibTTF/Font.cpp @@ -510,6 +510,13 @@ u16 Font::weight() const return 400; } +bool Font::is_fixed_width() const +{ + // FIXME: Read this information from the font file itself. + // FIXME: Although, it appears some application do similar hacks + return glyph_metrics(glyph_id_for_codepoint('.'), 1, 1).advance_width == glyph_metrics(glyph_id_for_codepoint('X'), 1, 1).advance_width; +} + int ScaledFont::width(const StringView& string) const { Utf8View utf8 { string }; diff --git a/Userland/Libraries/LibTTF/Font.h b/Userland/Libraries/LibTTF/Font.h index d1e96c0267..2448e8f6af 100644 --- a/Userland/Libraries/LibTTF/Font.h +++ b/Userland/Libraries/LibTTF/Font.h @@ -78,7 +78,7 @@ public: String family() const; String variant() const; u16 weight() const; - bool is_fixed_width() const { return false; } /* TODO */ + bool is_fixed_width() const; private: enum class Offsets { |