diff --git a/libs/minikin/Layout.cpp b/libs/minikin/Layout.cpp index 01b6599628f0f599f310792cd39bf52d4106d44a..21b83622603c738c15c25274eb834a3f8c1dbe58 100644 --- a/libs/minikin/Layout.cpp +++ b/libs/minikin/Layout.cpp @@ -258,6 +258,12 @@ static hb_bool_t harfbuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoin MinikinPaint* paint = reinterpret_cast(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;