| Index: src/ports/SkFontHost_win_dw.cpp
|
| ===================================================================
|
| --- src/ports/SkFontHost_win_dw.cpp (revision 10894)
|
| +++ src/ports/SkFontHost_win_dw.cpp (working copy)
|
| @@ -554,6 +554,8 @@
|
| SkAdvancedTypefaceMetrics::PerGlyphInfo,
|
| const uint32_t*, uint32_t) const SK_OVERRIDE;
|
| virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE;
|
| + virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
|
| + uint16_t glyphs[], int glyphCount) const SK_OVERRIDE;
|
| virtual int onCountGlyphs() const SK_OVERRIDE;
|
| virtual int onGetUPEM() const SK_OVERRIDE;
|
| virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE;
|
| @@ -1123,6 +1125,61 @@
|
| *isLocalStream = SkToBool(fDWriteFontFileLoader.get());
|
| }
|
|
|
| +static SkUnichar next_utf8(const void** chars) {
|
| + return SkUTF8_NextUnichar((const char**)chars);
|
| +}
|
| +
|
| +static SkUnichar next_utf16(const void** chars) {
|
| + return SkUTF16_NextUnichar((const uint16_t**)chars);
|
| +}
|
| +
|
| +static SkUnichar next_utf32(const void** chars) {
|
| + const SkUnichar** uniChars = (const SkUnichar**)chars;
|
| + SkUnichar uni = **uniChars;
|
| + *uniChars += 1;
|
| + return uni;
|
| +}
|
| +
|
| +typedef SkUnichar (*EncodingProc)(const void**);
|
| +
|
| +static EncodingProc find_encoding_proc(SkTypeface::Encoding enc) {
|
| + static const EncodingProc gProcs[] = {
|
| + next_utf8, next_utf16, next_utf32
|
| + };
|
| + SkASSERT((size_t)enc < SK_ARRAY_COUNT(gProcs));
|
| + return gProcs[enc];
|
| +}
|
| +
|
| +int DWriteFontTypeface::onCharsToGlyphs(const void* chars, Encoding encoding,
|
| + uint16_t glyphs[], int glyphCount) const
|
| +{
|
| + EncodingProc next_uni_proc = find_encoding_proc(encoding);
|
| +
|
| + if (NULL == glyphs) {
|
| + for (int i = 0; i < glyphCount; ++i) {
|
| + const SkUnichar c = next_uni_proc(&chars);
|
| + UINT16 glyphIndex;
|
| + fDWriteFontFace->GetGlyphIndices((UINT32*)&c, 1, &glyphIndex);
|
| + if (0 == glyphIndex) {
|
| + return i;
|
| + }
|
| + }
|
| + return glyphCount;
|
| + }
|
| +
|
| + int first = glyphCount;
|
| + for (int i = 0; i < glyphCount; ++i) {
|
| + const SkUnichar c = next_uni_proc(&chars);
|
| + UINT16 glyphIndex;
|
| + fDWriteFontFace->GetGlyphIndices((UINT32*)&c, 1, &glyphIndex);
|
| + glyphs[i] = glyphIndex;
|
| + if (0 == glyphIndex && i < first) {
|
| + first = i;
|
| + }
|
| + }
|
| + return first;
|
| +}
|
| +
|
| int DWriteFontTypeface::onCountGlyphs() const {
|
| return fDWriteFontFace->GetGlyphCount();
|
| }
|
|
|