Skip to content

Commit 725e89a

Browse files
committed
LibGfx: Validate that (almost) all glyphs in a GlyphRun can be drawn
1 parent 91a15cb commit 725e89a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Userland/Libraries/LibGfx/TextLayout.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ class GlyphRun : public RefCounted<GlyphRun> {
114114
, m_font(move(font))
115115
, m_text_type(text_type)
116116
{
117+
for (auto const& glyph_or_emoji : m_glyphs) {
118+
if (!glyph_or_emoji.has<DrawGlyph>())
119+
continue;
120+
auto code_point = glyph_or_emoji.get<DrawGlyph>().code_point;
121+
if (m_font->contains_glyph(code_point))
122+
continue;
123+
if (code_point == 0xFFFD) {
124+
dbgln("FIXME: Font \"{}\" does not contain the replacement character", m_font->name());
125+
continue;
126+
}
127+
dbgln("Font \"{}\" does not contain code point {:X} (this should've been filtered out earlier)", m_font->name(), code_point);
128+
VERIFY_NOT_REACHED();
129+
}
117130
}
118131

119132
[[nodiscard]] Font const& font() const { return m_font; }

0 commit comments

Comments
 (0)