Chromium Code Reviews| 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 "SkDWrite.h" |
| 16 #include "SkDWriteFontFileStream.h" | 16 #include "SkDWriteFontFileStream.h" |
| 17 #include "SkFontDescriptor.h" | 17 #include "SkFontDescriptor.h" |
| 18 #include "SkFontStream.h" | 18 #include "SkFontStream.h" |
| 19 #include "SkOTTable_head.h" | 19 #include "SkOTTable_head.h" |
| 20 #include "SkOTTable_hhea.h" | 20 #include "SkOTTable_hhea.h" |
| 21 #include "SkOTTable_OS_2.h" | 21 #include "SkOTTable_OS_2.h" |
| 22 #include "SkOTTable_post.h" | 22 #include "SkOTTable_post.h" |
| 23 #include "SkOTUtils.h" | |
| 23 #include "SkScalerContext.h" | 24 #include "SkScalerContext.h" |
| 24 #include "SkScalerContext_win_dw.h" | 25 #include "SkScalerContext_win_dw.h" |
| 25 #include "SkTypeface_win_dw.h" | 26 #include "SkTypeface_win_dw.h" |
| 26 #include "SkUtils.h" | 27 #include "SkUtils.h" |
| 27 | 28 |
| 28 void DWriteFontTypeface::onGetFamilyName(SkString* familyName) const { | 29 void DWriteFontTypeface::onGetFamilyName(SkString* familyName) const { |
| 29 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; | 30 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; |
|
drott
2015/08/19 08:28:11
How about here? Should this implementation perhaps
| |
| 30 HRV(fDWriteFontFamily->GetFamilyNames(&familyNames)); | 31 HRV(fDWriteFontFamily->GetFamilyNames(&familyNames)); |
| 31 | 32 |
| 32 sk_get_locale_string(familyNames.get(), NULL/*fMgr->fLocaleName.get()*/, fam ilyName); | 33 sk_get_locale_string(familyNames.get(), NULL/*fMgr->fLocaleName.get()*/, fam ilyName); |
| 33 } | 34 } |
| 34 | 35 |
| 35 void DWriteFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc, | 36 void DWriteFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
| 36 bool* isLocalStream) const { | 37 bool* isLocalStream) const { |
| 37 // Get the family name. | 38 // Get the family name. |
| 38 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; | 39 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; |
| 39 HRV(fDWriteFontFamily->GetFamilyNames(&familyNames)); | 40 HRV(fDWriteFontFamily->GetFamilyNames(&familyNames)); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 ++fIndex; | 163 ++fIndex; |
| 163 return true; | 164 return true; |
| 164 } | 165 } |
| 165 | 166 |
| 166 private: | 167 private: |
| 167 UINT32 fIndex; | 168 UINT32 fIndex; |
| 168 SkTScopedComPtr<IDWriteLocalizedStrings> fStrings; | 169 SkTScopedComPtr<IDWriteLocalizedStrings> fStrings; |
| 169 }; | 170 }; |
| 170 | 171 |
| 171 SkTypeface::LocalizedStrings* DWriteFontTypeface::onCreateFamilyNameIterator() c onst { | 172 SkTypeface::LocalizedStrings* DWriteFontTypeface::onCreateFamilyNameIterator() c onst { |
| 172 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; | 173 SkTypeface::LocalizedStrings* nameIter = |
| 173 HRNM(fDWriteFontFamily->GetFamilyNames(&familyNames), "Could not obtain fami ly names."); | 174 SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*this); |
| 174 | 175 if (NULL == nameIter) { |
| 175 return new LocalizedStrings_IDWriteLocalizedStrings(familyNames.release()); | 176 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; |
| 177 HRNM(fDWriteFontFamily->GetFamilyNames(&familyNames), "Could not obtain family names."); | |
| 178 nameIter = new LocalizedStrings_IDWriteLocalizedStrings(familyNames.rele ase()); | |
| 179 } | |
| 180 return nameIter; | |
| 176 } | 181 } |
| 177 | 182 |
| 178 int DWriteFontTypeface::onGetTableTags(SkFontTableTag tags[]) const { | 183 int DWriteFontTypeface::onGetTableTags(SkFontTableTag tags[]) const { |
| 179 DWRITE_FONT_FACE_TYPE type = fDWriteFontFace->GetType(); | 184 DWRITE_FONT_FACE_TYPE type = fDWriteFontFace->GetType(); |
| 180 if (type != DWRITE_FONT_FACE_TYPE_CFF && | 185 if (type != DWRITE_FONT_FACE_TYPE_CFF && |
| 181 type != DWRITE_FONT_FACE_TYPE_TRUETYPE && | 186 type != DWRITE_FONT_FACE_TYPE_TRUETYPE && |
| 182 type != DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION) | 187 type != DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION) |
| 183 { | 188 { |
| 184 return 0; | 189 return 0; |
| 185 } | 190 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 getAdvanceData(fDWriteFontFace.get(), | 452 getAdvanceData(fDWriteFontFace.get(), |
| 448 glyphCount, | 453 glyphCount, |
| 449 glyphIDs, | 454 glyphIDs, |
| 450 glyphIDsCount, | 455 glyphIDsCount, |
| 451 getWidthAdvance)); | 456 getWidthAdvance)); |
| 452 } | 457 } |
| 453 } | 458 } |
| 454 | 459 |
| 455 return info; | 460 return info; |
| 456 } | 461 } |
| OLD | NEW |