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 #include "SkTypes.h" | 7 #include "SkTypes.h" |
8 #if defined(SK_BUILD_FOR_WIN32) | 8 #if defined(SK_BUILD_FOR_WIN32) |
9 | 9 |
10 #include "SkDWrite.h" | 10 #include "SkDWrite.h" |
11 #include "SkDWriteFontFileStream.h" | 11 #include "SkDWriteFontFileStream.h" |
12 #include "SkDataTable.h" | 12 #include "SkDataTable.h" |
13 #include "SkHRESULT.h" | 13 #include "SkHRESULT.h" |
14 #include "SkMutex.h" | 14 #include "SkMutex.h" |
15 #include "SkRemotableFontMgr.h" | 15 #include "SkRemotableFontMgr.h" |
16 #include "SkStream.h" | 16 #include "SkStream.h" |
17 #include "SkString.h" | 17 #include "SkString.h" |
18 #include "SkTArray.h" | 18 #include "SkTArray.h" |
19 #include "SkTScopedComPtr.h" | 19 #include "SkTScopedComPtr.h" |
20 #include "SkTypeface_win.h" | 20 #include "SkTypeface_win_dw.h" |
21 #include "SkTypes.h" | 21 #include "SkTypes.h" |
22 #include "SkUtils.h" | 22 #include "SkUtils.h" |
23 | 23 |
24 #include <dwrite.h> | 24 #include <dwrite.h> |
25 | 25 |
26 class SK_API SkRemotableFontMgr_DirectWrite : public SkRemotableFontMgr { | 26 class SK_API SkRemotableFontMgr_DirectWrite : public SkRemotableFontMgr { |
27 private: | 27 private: |
28 struct DataId { | 28 struct DataId { |
29 IUnknown* fLoader; // In COM only IUnknown pointers may be safely used
for identity. | 29 IUnknown* fLoader; // In COM only IUnknown pointers may be safely used
for identity. |
30 void* fKey; | 30 void* fKey; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 const void* refKey; | 130 const void* refKey; |
131 UINT32 refKeySize; | 131 UINT32 refKeySize; |
132 HR(fontFile->GetReferenceKey(&refKey, &refKeySize)); | 132 HR(fontFile->GetReferenceKey(&refKey, &refKeySize)); |
133 | 133 |
134 fontId->fDataId = FindOrAdd(fontFileLoader.get(), refKey, refKeySize); | 134 fontId->fDataId = FindOrAdd(fontFileLoader.get(), refKey, refKeySize); |
135 | 135 |
136 // index | 136 // index |
137 fontId->fTtcIndex = fontFace->GetIndex(); | 137 fontId->fTtcIndex = fontFace->GetIndex(); |
138 | 138 |
139 // style | 139 // style |
140 SkFontStyle::Slant slant; | 140 fontId->fFontStyle = get_style(font); |
141 switch (font->GetStyle()) { | |
142 case DWRITE_FONT_STYLE_NORMAL: | |
143 slant = SkFontStyle::kUpright_Slant; | |
144 break; | |
145 case DWRITE_FONT_STYLE_OBLIQUE: | |
146 case DWRITE_FONT_STYLE_ITALIC: | |
147 slant = SkFontStyle::kItalic_Slant; | |
148 break; | |
149 default: | |
150 SkASSERT(false); | |
151 } | |
152 | |
153 int weight = font->GetWeight(); | |
154 int width = font->GetStretch(); | |
155 | |
156 fontId->fFontStyle = SkFontStyle(weight, width, slant); | |
157 return S_OK; | 141 return S_OK; |
158 } | 142 } |
159 | 143 |
160 SkRemotableFontIdentitySet* getIndex(int familyIndex) const override { | 144 SkRemotableFontIdentitySet* getIndex(int familyIndex) const override { |
161 SkTScopedComPtr<IDWriteFontFamily> fontFamily; | 145 SkTScopedComPtr<IDWriteFontFamily> fontFamily; |
162 HRNM(fFontCollection->GetFontFamily(familyIndex, &fontFamily), | 146 HRNM(fFontCollection->GetFontFamily(familyIndex, &fontFamily), |
163 "Could not get requested family."); | 147 "Could not get requested family."); |
164 | 148 |
165 int count = fontFamily->GetFontCount(); | 149 int count = fontFamily->GetFontCount(); |
166 SkFontIdentity* fontIds; | 150 SkFontIdentity* fontIds; |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 } else { | 481 } else { |
498 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 482 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
499 if (localeNameLen) { | 483 if (localeNameLen) { |
500 localeName = localeNameStorage; | 484 localeName = localeNameStorage; |
501 }; | 485 }; |
502 } | 486 } |
503 | 487 |
504 return new SkRemotableFontMgr_DirectWrite(sysFontCollection.get(), localeNam
e, localeNameLen); | 488 return new SkRemotableFontMgr_DirectWrite(sysFontCollection.get(), localeNam
e, localeNameLen); |
505 } | 489 } |
506 #endif//defined(SK_BUILD_FOR_WIN32) | 490 #endif//defined(SK_BUILD_FOR_WIN32) |
OLD | NEW |