Explorar o código

LibGfx: Report font glyph presence based on glyph's specific width

This uses the per glyph width to determine if the glyph is actually
present in the font, and not just inside the range the font can covers

This means that characters that are in the font's range but that are
missing a glyph will show up as the missing character glyph instead of
being invisible.
Idan Horowitz %!s(int64=4) %!d(string=hai) anos
pai
achega
397269d21e
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      Userland/Libraries/LibGfx/BitmapFont.h

+ 1 - 1
Userland/Libraries/LibGfx/BitmapFont.h

@@ -63,7 +63,7 @@ public:
     void set_weight(u16 weight) { m_weight = weight; }
     void set_weight(u16 weight) { m_weight = weight; }
 
 
     Glyph glyph(u32 code_point) const;
     Glyph glyph(u32 code_point) const;
-    bool contains_glyph(u32 code_point) const { return code_point < (u32)glyph_count(); }
+    bool contains_glyph(u32 code_point) const { return code_point < (u32)glyph_count() && m_glyph_widths[code_point] > 0; }
 
 
     u8 glyph_width(size_t ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[ch]; }
     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;
     int glyph_or_emoji_width(u32 code_point) const;