1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

LibTTF: Add hack for recognizing fixed-width fonts

This commit is contained in:
Stephan Unverwerth 2021-01-03 19:37:34 +01:00 committed by Andreas Kling
parent 53d2073a66
commit 05d31cbeeb
2 changed files with 8 additions and 1 deletions

View file

@ -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 };

View file

@ -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 {