Skip to content

Conversation

@implicitfield
Copy link
Contributor

@implicitfield implicitfield commented Oct 30, 2025

When viewing websites in Browser that use the default font (which resolves to "Roman Regular"), nothing was being drawn for missing glyphs because that font didn't contain the replacement character (which is now implemented in this PR, it's visually the same as in the "Katica Regular" font). Previously, those glyphs would've been replaced with the question mark character, but that is no longer the case as of 9e66662 (and I noticed that the documentation also referred to this, so I've also updated that now).

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Oct 30, 2025
Comment on lines 123 to 128
if (code_point == 0xFFFD) {
dbgln("FIXME: Font \"{}\" does not contain the replacement character", m_font->name());
continue;
}
dbgln("Font \"{}\" does not contain code point {:X} (this should've been filtered out earlier)", m_font->name(), code_point);
VERIFY_NOT_REACHED();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that reachable with user-provided fonts? If a PDF or a webpage gives us a font and asks to draw text that contains glyphs that are not in the font, we should not crash (and not print a FIXME either).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't really crash in any case, since I think LibWeb is the only user of GlyphRun, and there the glyphs are collected with Gfx::for_each_glyph_position(), which should only call the provided callback (that collects the glyphs to be passed to this constructor) with a glyph that is in the font, or the replacement character if it isn't (which is why this does a continue before the VERIFY_NOT_REACHED() in case that's missing - because we didn't check that that's actually in the font).

But I guess the dbgln would end up being quite spammy if we actually ended up here in a real-world scenario, and this debug code has kind of served it's purpose already, so I've dropped this commit.

The question mark is no longer used as a fallback as of 9e66662.
@implicitfield implicitfield changed the title Base+LibGfx: Glyph-related tweaks Base: Glyph-related tweaks Oct 30, 2025
@spholz spholz merged commit 9ee1d44 into SerenityOS:master Nov 13, 2025
15 checks passed
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Nov 13, 2025
@implicitfield implicitfield deleted the glyphs branch November 13, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants