Skip to content

Commit

Permalink
Show U+FFFD REPLACEMENT CHARACTER for invalid Unicode codepoints
Browse files Browse the repository at this point in the history
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
  • Loading branch information
behdad committed Jul 11, 2014
1 parent 6f13b6d commit efe7421
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/hb-ot-shape-normalize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor
else if (decompose_compatibility (c, buffer->cur().codepoint))
skip_char (buffer);
else
{
/* Not found, not decomposible; If codepoint is invalid Unicode and
* font supports U+FFFD REPLACEMENT CHARACTER, use that instead. */
hb_codepoint_t FFFD_glyph;
if (buffer->cur().codepoint > 0x10FFFF && c->font->get_glyph (0xFFFD, 0, &FFFD_glyph))
glyph = FFFD_glyph;
next_char (buffer, glyph); /* glyph is initialized in earlier branches. */
}
}

static inline void
Expand Down

2 comments on commit efe7421

@KonstantinRitt
Copy link
Contributor

Choose a reason for hiding this comment

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

After 976c8f4, Is this still needed?

@behdad
Copy link
Member Author

@behdad behdad commented on efe7421 Jul 17, 2014

Choose a reason for hiding this comment

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

Removed. Thanks.

Please sign in to comment.