Skip to content

Commit efe7421

Browse files
committed
Show U+FFFD REPLACEMENT CHARACTER for invalid Unicode codepoints
Only if the font doesn't support it. Ie, this gives the user to use non-Unicode codepoints as private values and return a meaningful glyph for them. But if it's invalid and font callback doesn't like it, and if font has U+FFFD, show that instead. Font functions that do not want this automatic replacement to happen should return true from get_glyph() if unicode > 0x10FFFF. Replaces #27
1 parent 6f13b6d commit efe7421

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/hb-ot-shape-normalize.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,14 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor
209209
else if (decompose_compatibility (c, buffer->cur().codepoint))
210210
skip_char (buffer);
211211
else
212+
{
213+
/* Not found, not decomposible; If codepoint is invalid Unicode and
214+
* font supports U+FFFD REPLACEMENT CHARACTER, use that instead. */
215+
hb_codepoint_t FFFD_glyph;
216+
if (buffer->cur().codepoint > 0x10FFFF && c->font->get_glyph (0xFFFD, 0, &FFFD_glyph))
217+
glyph = FFFD_glyph;
212218
next_char (buffer, glyph); /* glyph is initialized in earlier branches. */
219+
}
213220
}
214221

215222
static inline void

0 commit comments

Comments
 (0)