OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
9 #undef GetGlyphIndices | 9 #undef GetGlyphIndices |
10 | 10 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } | 547 } |
548 | 548 |
549 protected: | 549 protected: |
550 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; | 550 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; |
551 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; | 551 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; |
552 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | 552 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
553 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 553 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
554 SkAdvancedTypefaceMetrics::PerGlyphInfo, | 554 SkAdvancedTypefaceMetrics::PerGlyphInfo, |
555 const uint32_t*, uint32_t) const SK_OVERRIDE; | 555 const uint32_t*, uint32_t) const SK_OVERRIDE; |
556 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; | 556 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; |
| 557 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, |
| 558 uint16_t glyphs[], int glyphCount) const SK_OVER
RIDE; |
557 virtual int onCountGlyphs() const SK_OVERRIDE; | 559 virtual int onCountGlyphs() const SK_OVERRIDE; |
558 virtual int onGetUPEM() const SK_OVERRIDE; | 560 virtual int onGetUPEM() const SK_OVERRIDE; |
559 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; | 561 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; |
560 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; | 562 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; |
561 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 563 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
562 size_t length, void* data) const SK_OVERRIDE; | 564 size_t length, void* data) const SK_OVERRIDE; |
563 virtual SkTypeface* onRefMatchingStyle(Style) const SK_OVERRIDE; | 565 virtual SkTypeface* onRefMatchingStyle(Style) const SK_OVERRIDE; |
564 }; | 566 }; |
565 | 567 |
566 class SkScalerContext_DW : public SkScalerContext { | 568 class SkScalerContext_DW : public SkScalerContext { |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 SkSMallocWCHAR dwFamilyNameChar(dwFamilyNamesLength+1); | 1118 SkSMallocWCHAR dwFamilyNameChar(dwFamilyNamesLength+1); |
1117 HRV(dwFamilyNames->GetString(0, dwFamilyNameChar.get(), dwFamilyNamesLength+
1)); | 1119 HRV(dwFamilyNames->GetString(0, dwFamilyNameChar.get(), dwFamilyNamesLength+
1)); |
1118 | 1120 |
1119 SkString utf8FamilyName; | 1121 SkString utf8FamilyName; |
1120 HRV(wchar_to_skstring(dwFamilyNameChar.get(), &utf8FamilyName)); | 1122 HRV(wchar_to_skstring(dwFamilyNameChar.get(), &utf8FamilyName)); |
1121 | 1123 |
1122 desc->setFamilyName(utf8FamilyName.c_str()); | 1124 desc->setFamilyName(utf8FamilyName.c_str()); |
1123 *isLocalStream = SkToBool(fDWriteFontFileLoader.get()); | 1125 *isLocalStream = SkToBool(fDWriteFontFileLoader.get()); |
1124 } | 1126 } |
1125 | 1127 |
| 1128 static SkUnichar next_utf8(const void** chars) { |
| 1129 return SkUTF8_NextUnichar((const char**)chars); |
| 1130 } |
| 1131 |
| 1132 static SkUnichar next_utf16(const void** chars) { |
| 1133 return SkUTF16_NextUnichar((const uint16_t**)chars); |
| 1134 } |
| 1135 |
| 1136 static SkUnichar next_utf32(const void** chars) { |
| 1137 const SkUnichar** uniChars = (const SkUnichar**)chars; |
| 1138 SkUnichar uni = **uniChars; |
| 1139 *uniChars += 1; |
| 1140 return uni; |
| 1141 } |
| 1142 |
| 1143 typedef SkUnichar (*EncodingProc)(const void**); |
| 1144 |
| 1145 static EncodingProc find_encoding_proc(SkTypeface::Encoding enc) { |
| 1146 static const EncodingProc gProcs[] = { |
| 1147 next_utf8, next_utf16, next_utf32 |
| 1148 }; |
| 1149 SkASSERT((size_t)enc < SK_ARRAY_COUNT(gProcs)); |
| 1150 return gProcs[enc]; |
| 1151 } |
| 1152 |
| 1153 int DWriteFontTypeface::onCharsToGlyphs(const void* chars, Encoding encoding, |
| 1154 uint16_t glyphs[], int glyphCount) const |
| 1155 { |
| 1156 EncodingProc next_uni_proc = find_encoding_proc(encoding); |
| 1157 |
| 1158 if (NULL == glyphs) { |
| 1159 for (int i = 0; i < glyphCount; ++i) { |
| 1160 const SkUnichar c = next_uni_proc(&chars); |
| 1161 UINT16 glyphIndex; |
| 1162 fDWriteFontFace->GetGlyphIndices((UINT32*)&c, 1, &glyphIndex); |
| 1163 if (0 == glyphIndex) { |
| 1164 return i; |
| 1165 } |
| 1166 } |
| 1167 return glyphCount; |
| 1168 } |
| 1169 |
| 1170 int first = glyphCount; |
| 1171 for (int i = 0; i < glyphCount; ++i) { |
| 1172 const SkUnichar c = next_uni_proc(&chars); |
| 1173 UINT16 glyphIndex; |
| 1174 fDWriteFontFace->GetGlyphIndices((UINT32*)&c, 1, &glyphIndex); |
| 1175 glyphs[i] = glyphIndex; |
| 1176 if (0 == glyphIndex && i < first) { |
| 1177 first = i; |
| 1178 } |
| 1179 } |
| 1180 return first; |
| 1181 } |
| 1182 |
1126 int DWriteFontTypeface::onCountGlyphs() const { | 1183 int DWriteFontTypeface::onCountGlyphs() const { |
1127 return fDWriteFontFace->GetGlyphCount(); | 1184 return fDWriteFontFace->GetGlyphCount(); |
1128 } | 1185 } |
1129 | 1186 |
1130 int DWriteFontTypeface::onGetUPEM() const { | 1187 int DWriteFontTypeface::onGetUPEM() const { |
1131 DWRITE_FONT_METRICS metrics; | 1188 DWRITE_FONT_METRICS metrics; |
1132 fDWriteFontFace->GetMetrics(&metrics); | 1189 fDWriteFontFace->GetMetrics(&metrics); |
1133 return metrics.designUnitsPerEm; | 1190 return metrics.designUnitsPerEm; |
1134 } | 1191 } |
1135 | 1192 |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1923 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); | 1980 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); |
1924 } else { | 1981 } else { |
1925 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 1982 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
1926 if (localeNameLen) { | 1983 if (localeNameLen) { |
1927 localeName = localeNameStorage; | 1984 localeName = localeNameStorage; |
1928 }; | 1985 }; |
1929 } | 1986 } |
1930 | 1987 |
1931 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); | 1988 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); |
1932 } | 1989 } |
OLD | NEW |