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 "SkDataTable.h" | 8 #include "SkDataTable.h" |
9 #include "SkDWrite.h" | 9 #include "SkDWrite.h" |
10 #include "SkDWriteFontFileStream.h" | 10 #include "SkDWriteFontFileStream.h" |
11 #include "SkHRESULT.h" | 11 #include "SkHRESULT.h" |
12 #include "SkRemotableFontMgr.h" | 12 #include "SkRemotableFontMgr.h" |
13 #include "SkStream.h" | 13 #include "SkStream.h" |
14 #include "SkString.h" | 14 #include "SkString.h" |
15 #include "SkTArray.h" | 15 #include "SkTArray.h" |
16 #include "SkThread.h" | 16 #include "SkThread.h" |
17 #include "SkTScopedComPtr.h" | 17 #include "SkTScopedComPtr.h" |
18 #include "SkTypeface_win.h" | 18 #include "SkTypeface_win.h" |
19 #include "SkTypes.h" | 19 #include "SkTypes.h" |
20 #include "SkUtils.h" | 20 #include "SkUtils.h" |
21 | 21 |
22 #include <dwrite.h> | 22 #include <dwrite.h> |
23 | 23 |
24 struct DWriteStyle { | |
25 explicit DWriteStyle(const SkFontStyle& pattern) { | |
26 switch (pattern.slant()) { | |
27 case SkFontStyle::kUpright_Slant: | |
28 fSlant = DWRITE_FONT_STYLE_NORMAL; | |
29 break; | |
30 case SkFontStyle::kItalic_Slant: | |
31 fSlant = DWRITE_FONT_STYLE_ITALIC; | |
32 break; | |
33 default: | |
34 SkASSERT(false); | |
35 } | |
36 | |
37 fWeight = (DWRITE_FONT_WEIGHT)pattern.weight(); | |
38 fWidth = (DWRITE_FONT_STRETCH)pattern.width(); | |
39 } | |
40 DWRITE_FONT_STYLE fSlant; | |
41 DWRITE_FONT_WEIGHT fWeight; | |
42 DWRITE_FONT_STRETCH fWidth; | |
43 }; | |
44 | |
45 class SK_API SkRemotableFontMgr_DirectWrite : public SkRemotableFontMgr { | 24 class SK_API SkRemotableFontMgr_DirectWrite : public SkRemotableFontMgr { |
46 private: | 25 private: |
47 struct DataId { | 26 struct DataId { |
48 IUnknown* fLoader; // In COM only IUnknown pointers may be safely used
for identity. | 27 IUnknown* fLoader; // In COM only IUnknown pointers may be safely used
for identity. |
49 void* fKey; | 28 void* fKey; |
50 UINT32 fKeySize; | 29 UINT32 fKeySize; |
51 | 30 |
52 DataId() { } | 31 DataId() { } |
53 | 32 |
54 // This is actually a move!!! | 33 // This is actually a move!!! |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 } else { | 498 } else { |
520 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 499 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
521 if (localeNameLen) { | 500 if (localeNameLen) { |
522 localeName = localeNameStorage; | 501 localeName = localeNameStorage; |
523 }; | 502 }; |
524 } | 503 } |
525 | 504 |
526 return SkNEW_ARGS(SkRemotableFontMgr_DirectWrite, (sysFontCollection.get(), | 505 return SkNEW_ARGS(SkRemotableFontMgr_DirectWrite, (sysFontCollection.get(), |
527 localeName, localeNameLen
)); | 506 localeName, localeNameLen
)); |
528 } | 507 } |
OLD | NEW |