Merge "Use UTF32 directly in HarfBuzz<->Skia interface." into nyc-dev

This commit is contained in:
Ben Wagner
2016-02-19 15:03:47 +00:00
committed by Android (Google) Code Review

View File

@@ -39,7 +39,6 @@
#include <SkPoint.h>
#include <SkRect.h>
#include <SkTypeface.h>
#include <SkUtils.h>
#include <hb.h>
@@ -82,17 +81,16 @@ static void SkiaGetGlyphWidthAndExtents(SkPaint* paint, hb_codepoint_t codepoint
static hb_bool_t harfbuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoint_t unicode, hb_codepoint_t variationSelector, hb_codepoint_t* glyph, void* userData)
{
HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData);
SkPaint* paint = hbFontData->m_paint;
paint->setTextEncoding(SkPaint::kUTF32_TextEncoding);
if (unicode > 0x10ffff) {
unicode = 0xfffd;
}
SkPaint* paint = hbFontData->m_paint;
// It would be better to use kUTF32_TextEncoding directly
paint->setTextEncoding(SkPaint::kUTF16_TextEncoding);
SkUnichar unichar = unicode;
uint16_t glyph16;
uint16_t unichar[2];
size_t size = SkUTF16_FromUnichar(unicode, unichar);
paint->textToGlyphs(unichar, size * sizeof(*unichar), &glyph16);
paint->textToGlyphs(&unichar, sizeof(unichar), &glyph16);
*glyph = glyph16;
return !!*glyph;
}