Don't pass invalid Unicode codepoint to Skia

Bug: 15849380
Change-Id: Ib5285e57c5806bd399600fadd56e8bc809da323f
This commit is contained in:
Behdad Esfahbod
2014-07-11 11:30:06 -04:00
parent 264f497c91
commit 29eb45e667

View File

@@ -258,6 +258,12 @@ static hb_bool_t harfbuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoin
MinikinPaint* paint = reinterpret_cast<MinikinPaint*>(fontData);
MinikinFont* font = paint->font;
uint32_t glyph_id;
/* HarfBuzz replaces broken input codepoints with (unsigned int) -1.
* Skia expects valid Unicode.
* Replace invalid codepoints with U+FFFD REPLACEMENT CHARACTER.
*/
if (unicode > 0x10FFFF)
unicode = 0xFFFD;
bool ok = font->GetGlyph(unicode, &glyph_id);
if (ok) {
*glyph = glyph_id;