| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 // SkTypes will include Windows.h, which will pull in all of the GDI defines. | 9 // SkTypes will include Windows.h, which will pull in all of the GDI defines. |
| 10 // GDI #defines GetGlyphIndices to GetGlyphIndicesA or GetGlyphIndicesW, but | 10 // GDI #defines GetGlyphIndices to GetGlyphIndicesA or GetGlyphIndicesW, but |
| 11 // IDWriteFontFace has a method called GetGlyphIndices. Since this file does | 11 // IDWriteFontFace has a method called GetGlyphIndices. Since this file does |
| 12 // not use GDI, undefing GetGlyphIndices makes things less confusing. | 12 // not use GDI, undefing GetGlyphIndices makes things less confusing. |
| 13 #undef GetGlyphIndices | 13 #undef GetGlyphIndices |
| 14 | 14 |
| 15 #include "SkDWrite.h" |
| 15 #include "SkDWriteFontFileStream.h" | 16 #include "SkDWriteFontFileStream.h" |
| 16 #include "SkFontDescriptor.h" | 17 #include "SkFontDescriptor.h" |
| 17 #include "SkFontStream.h" | 18 #include "SkFontStream.h" |
| 18 #include "SkOTTable_head.h" | 19 #include "SkOTTable_head.h" |
| 19 #include "SkOTTable_hhea.h" | 20 #include "SkOTTable_hhea.h" |
| 20 #include "SkOTTable_OS_2.h" | 21 #include "SkOTTable_OS_2.h" |
| 21 #include "SkOTTable_post.h" | 22 #include "SkOTTable_post.h" |
| 22 #include "SkScalerContext.h" | 23 #include "SkScalerContext.h" |
| 23 #include "SkScalerContext_win_dw.h" | 24 #include "SkScalerContext_win_dw.h" |
| 24 #include "SkTypeface_win_dw.h" | 25 #include "SkTypeface_win_dw.h" |
| 25 #include "SkUtils.h" | 26 #include "SkUtils.h" |
| 26 | 27 |
| 28 void DWriteFontTypeface::onGetFamilyName(SkString* familyName) const { |
| 29 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; |
| 30 HRV(fDWriteFontFamily->GetFamilyNames(&familyNames)); |
| 31 |
| 32 sk_get_locale_string(familyNames.get(), NULL/*fMgr->fLocaleName.get()*/, fam
ilyName); |
| 33 } |
| 34 |
| 27 void DWriteFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc, | 35 void DWriteFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
| 28 bool* isLocalStream) const { | 36 bool* isLocalStream) const { |
| 29 // Get the family name. | 37 // Get the family name. |
| 30 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; | 38 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; |
| 31 HRV(fDWriteFontFamily->GetFamilyNames(&familyNames)); | 39 HRV(fDWriteFontFamily->GetFamilyNames(&familyNames)); |
| 32 | 40 |
| 33 UINT32 familyNamesLen; | |
| 34 HRV(familyNames->GetStringLength(0, &familyNamesLen)); | |
| 35 | |
| 36 SkSMallocWCHAR familyName(familyNamesLen+1); | |
| 37 HRV(familyNames->GetString(0, familyName.get(), familyNamesLen+1)); | |
| 38 | |
| 39 SkString utf8FamilyName; | 41 SkString utf8FamilyName; |
| 40 HRV(sk_wchar_to_skstring(familyName.get(), familyNamesLen, &utf8FamilyName))
; | 42 sk_get_locale_string(familyNames.get(), NULL/*fMgr->fLocaleName.get()*/, &ut
f8FamilyName); |
| 41 | 43 |
| 42 desc->setFamilyName(utf8FamilyName.c_str()); | 44 desc->setFamilyName(utf8FamilyName.c_str()); |
| 43 *isLocalStream = SkToBool(fDWriteFontFileLoader.get()); | 45 *isLocalStream = SkToBool(fDWriteFontFileLoader.get()); |
| 44 } | 46 } |
| 45 | 47 |
| 46 static SkUnichar next_utf8(const void** chars) { | 48 static SkUnichar next_utf8(const void** chars) { |
| 47 return SkUTF8_NextUnichar((const char**)chars); | 49 return SkUTF8_NextUnichar((const char**)chars); |
| 48 } | 50 } |
| 49 | 51 |
| 50 static SkUnichar next_utf16(const void** chars) { | 52 static SkUnichar next_utf16(const void** chars) { |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 getAdvanceData(fDWriteFontFace.get(), | 457 getAdvanceData(fDWriteFontFace.get(), |
| 456 glyphCount, | 458 glyphCount, |
| 457 glyphIDs, | 459 glyphIDs, |
| 458 glyphIDsCount, | 460 glyphIDsCount, |
| 459 getWidthAdvance)); | 461 getWidthAdvance)); |
| 460 } | 462 } |
| 461 } | 463 } |
| 462 | 464 |
| 463 return info; | 465 return info; |
| 464 } | 466 } |
| OLD | NEW |