Skip to content

Commit

Permalink
LibGfx: Do not draw U+FFFD for unknown glyphs
Browse files Browse the repository at this point in the history
The Replacement Character (U+FFFD) is most commonly used to signal a
text encoding error, i.e. when a stream of bytes couldn't be converted
to a sequence of code points. For glyphs that don't exist in a
particular font, our rendering logic already does the right thing by
drawing empty boxes (`.notdef`); let's not forcibly turn these into
U+FFFD during rendering.
  • Loading branch information
BertalanD authored and gmta committed Jul 5, 2024
1 parent 0a3082e commit 947606a
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions Userland/Libraries/LibGfx/TextLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,9 @@ DrawGlyphOrEmoji prepare_draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIter
};
}

// If that failed, but we have a text glyph fallback, draw that.
if (font_contains_glyph) {
return DrawGlyph {
.position = point,
.code_point = code_point,
};
}

// No suitable glyph found, draw a replacement character.
dbgln_if(EMOJI_DEBUG, "Failed to find a glyph or emoji for code_point {}", code_point);
return DrawGlyph {
.position = point,
.code_point = 0xFFFD,
.code_point = code_point,
};
}

Expand Down

0 comments on commit 947606a

Please sign in to comment.