Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31af215b authored by Ben Wagner's avatar Ben Wagner Committed by Android (Google) Code Review
Browse files

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

parents 477ecd76 c1fa6d0d
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -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;
}