Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: src/ports/SkTypeface_win_dw.cpp

Issue 574873002: Add onGetFamilyName to SkTypeface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add .get() for DirectWrite. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ports/SkTypeface_win_dw.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « src/ports/SkTypeface_win_dw.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698