OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #undef GetGlyphIndices | 9 #undef GetGlyphIndices |
10 | 10 |
11 #include "SkAdvancedTypefaceMetrics.h" | 11 #include "SkAdvancedTypefaceMetrics.h" |
12 #include "SkColorFilter.h" | 12 #include "SkColorFilter.h" |
13 #include "SkDWriteFontFileStream.h" | 13 #include "SkDWriteFontFileStream.h" |
14 #include "SkDWriteGeometrySink.h" | 14 #include "SkDWriteGeometrySink.h" |
15 #include "SkDescriptor.h" | 15 #include "SkDescriptor.h" |
16 #include "SkEndian.h" | 16 #include "SkEndian.h" |
17 #include "SkFontDescriptor.h" | 17 #include "SkFontDescriptor.h" |
18 #include "SkFontHost.h" | 18 #include "SkFontHost.h" |
19 #include "SkFontMgr.h" | 19 #include "SkFontMgr.h" |
20 #include "SkFontStream.h" | 20 #include "SkFontStream.h" |
21 #include "SkGlyph.h" | 21 #include "SkGlyph.h" |
22 #include "SkHRESULT.h" | 22 #include "SkHRESULT.h" |
23 #include "SkMaskGamma.h" | 23 #include "SkMaskGamma.h" |
| 24 #include "SkOnce.h" |
24 #include "SkOTTable_head.h" | 25 #include "SkOTTable_head.h" |
25 #include "SkOTTable_hhea.h" | 26 #include "SkOTTable_hhea.h" |
26 #include "SkOTTable_OS_2.h" | 27 #include "SkOTTable_OS_2.h" |
27 #include "SkOTTable_post.h" | 28 #include "SkOTTable_post.h" |
28 #include "SkPath.h" | 29 #include "SkPath.h" |
29 #include "SkStream.h" | 30 #include "SkStream.h" |
30 #include "SkString.h" | 31 #include "SkString.h" |
31 #include "SkTScopedComPtr.h" | 32 #include "SkTScopedComPtr.h" |
32 #include "SkThread.h" | 33 #include "SkThread.h" |
33 #include "SkTypeface_win.h" | 34 #include "SkTypeface_win.h" |
34 #include "SkTypefaceCache.h" | 35 #include "SkTypefaceCache.h" |
35 #include "SkUtils.h" | 36 #include "SkUtils.h" |
36 | 37 |
37 #include <dwrite.h> | 38 #include <dwrite.h> |
38 | 39 |
39 static bool isLCD(const SkScalerContext::Rec& rec) { | 40 static bool isLCD(const SkScalerContext::Rec& rec) { |
40 return SkMask::kLCD16_Format == rec.fMaskFormat || | 41 return SkMask::kLCD16_Format == rec.fMaskFormat || |
41 SkMask::kLCD32_Format == rec.fMaskFormat; | 42 SkMask::kLCD32_Format == rec.fMaskFormat; |
42 } | 43 } |
43 | 44 |
44 /** Prefer to use this type to prevent template proliferation. */ | 45 /** Prefer to use this type to prevent template proliferation. */ |
45 typedef SkAutoSTMalloc<16, WCHAR> SkSMallocWCHAR; | 46 typedef SkAutoSTMalloc<16, WCHAR> SkSMallocWCHAR; |
46 | 47 |
| 48 /** Converts a utf8 string to a WCHAR string. */ |
47 static HRESULT cstring_to_wchar(const char* skname, SkSMallocWCHAR* name) { | 49 static HRESULT cstring_to_wchar(const char* skname, SkSMallocWCHAR* name) { |
48 int wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, NULL, 0); | 50 int wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, NULL, 0); |
49 if (0 == wlen) { | 51 if (0 == wlen) { |
50 HRM(HRESULT_FROM_WIN32(GetLastError()), | 52 HRM(HRESULT_FROM_WIN32(GetLastError()), |
51 "Could not get length for wchar to utf-8 conversion."); | 53 "Could not get length for wchar to utf-8 conversion."); |
52 } | 54 } |
53 name->reset(wlen); | 55 name->reset(wlen); |
54 wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, name->get(), wlen); | 56 wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, name->get(), wlen); |
55 if (0 == wlen) { | 57 if (0 == wlen) { |
56 HRM(HRESULT_FROM_WIN32(GetLastError()), "Could not convert wchar to utf-
8."); | 58 HRM(HRESULT_FROM_WIN32(GetLastError()), "Could not convert wchar to utf-
8."); |
57 } | 59 } |
58 return S_OK; | 60 return S_OK; |
59 } | 61 } |
60 | 62 |
| 63 /** Converts a WCHAR string to a utf8 string. */ |
61 static HRESULT wchar_to_skstring(WCHAR* name, SkString* skname) { | 64 static HRESULT wchar_to_skstring(WCHAR* name, SkString* skname) { |
62 int len = WideCharToMultiByte(CP_UTF8, 0, name, -1, NULL, 0, NULL, NULL); | 65 int len = WideCharToMultiByte(CP_UTF8, 0, name, -1, NULL, 0, NULL, NULL); |
63 if (0 == len) { | 66 if (0 == len) { |
64 HRM(HRESULT_FROM_WIN32(GetLastError()), | 67 HRM(HRESULT_FROM_WIN32(GetLastError()), |
65 "Could not get length for utf-8 to wchar conversion."); | 68 "Could not get length for utf-8 to wchar conversion."); |
66 } | 69 } |
67 skname->resize(len - 1); | 70 skname->resize(len - 1); |
68 len = WideCharToMultiByte(CP_UTF8, 0, name, -1, skname->writable_str(), len,
NULL, NULL); | 71 len = WideCharToMultiByte(CP_UTF8, 0, name, -1, skname->writable_str(), len,
NULL, NULL); |
69 if (0 == len) { | 72 if (0 == len) { |
70 HRM(HRESULT_FROM_WIN32(GetLastError()), "Could not convert utf-8 to wcha
r."); | 73 HRM(HRESULT_FROM_WIN32(GetLastError()), "Could not convert utf-8 to wcha
r."); |
71 } | 74 } |
72 return S_OK; | 75 return S_OK; |
73 } | 76 } |
74 | 77 |
75 /////////////////////////////////////////////////////////////////////////////// | 78 /////////////////////////////////////////////////////////////////////////////// |
76 | 79 |
| 80 static void create_dwrite_factory(IDWriteFactory** factory) { |
| 81 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; |
| 82 DWriteCreateFactoryProc dWriteCreateFactoryProc = reinterpret_cast<DWriteCre
ateFactoryProc>( |
| 83 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory")); |
| 84 |
| 85 if (!dWriteCreateFactoryProc) { |
| 86 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); |
| 87 if (!IS_ERROR(hr)) { |
| 88 hr = ERROR_PROC_NOT_FOUND; |
| 89 } |
| 90 HRVM(hr, "Could not get DWriteCreateFactory proc."); |
| 91 } |
| 92 |
| 93 HRVM(dWriteCreateFactoryProc(DWRITE_FACTORY_TYPE_SHARED, |
| 94 __uuidof(IDWriteFactory), |
| 95 reinterpret_cast<IUnknown**>(&factory)), |
| 96 "Could not create DirectWrite factory."); |
| 97 } |
| 98 |
| 99 static IDWriteFactory* get_dwrite_factory() { |
| 100 static IDWriteFactory* gDWriteFactory = NULL; |
| 101 SK_DECLARE_STATIC_ONCE(once); |
| 102 SkOnce(&once, create_dwrite_factory, &gDWriteFactory); |
| 103 |
| 104 return gDWriteFactory; |
| 105 } |
| 106 |
| 107 /////////////////////////////////////////////////////////////////////////////// |
| 108 |
77 class StreamFontFileLoader; | 109 class StreamFontFileLoader; |
78 | 110 |
79 class SkFontMgr_DirectWrite : public SkFontMgr { | 111 class SkFontMgr_DirectWrite : public SkFontMgr { |
80 public: | 112 public: |
81 /** localeNameLength must include the null terminator. */ | 113 /** localeNameLength must include the null terminator. */ |
82 SkFontMgr_DirectWrite(IDWriteFontCollection* fontCollection, | 114 SkFontMgr_DirectWrite(IDWriteFontCollection* fontCollection, |
83 WCHAR* localeName, int localeNameLength) | 115 WCHAR* localeName, int localeNameLength) |
84 : fFontCollection(SkRefComPtr(fontCollection)) | 116 : fFontCollection(SkRefComPtr(fontCollection)) |
85 , fLocaleName(localeNameLength) | 117 , fLocaleName(localeNameLength) |
86 { | 118 { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 198 |
167 private: | 199 private: |
168 uint16_t fWidth; | 200 uint16_t fWidth; |
169 uint16_t fHeight; | 201 uint16_t fHeight; |
170 IDWriteFontFace* fFontFace; | 202 IDWriteFontFace* fFontFace; |
171 FLOAT fFontSize; | 203 FLOAT fFontSize; |
172 DWRITE_MATRIX fXform; | 204 DWRITE_MATRIX fXform; |
173 SkTDArray<uint8_t> fBits; | 205 SkTDArray<uint8_t> fBits; |
174 }; | 206 }; |
175 | 207 |
176 static HRESULT get_dwrite_factory(IDWriteFactory** factory) { | |
177 static IDWriteFactory* gDWriteFactory = NULL; | |
178 | |
179 if (gDWriteFactory != NULL) { | |
180 *factory = gDWriteFactory; | |
181 return S_OK; | |
182 } | |
183 | |
184 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; | |
185 DWriteCreateFactoryProc dWriteCreateFactoryProc = | |
186 reinterpret_cast<DWriteCreateFactoryProc>( | |
187 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory") | |
188 ) | |
189 ; | |
190 if (!dWriteCreateFactoryProc) { | |
191 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); | |
192 if (!IS_ERROR(hr)) { | |
193 hr = ERROR_PROC_NOT_FOUND; | |
194 } | |
195 return hr; | |
196 } | |
197 | |
198 HRM(dWriteCreateFactoryProc(DWRITE_FACTORY_TYPE_SHARED, | |
199 __uuidof(IDWriteFactory), | |
200 reinterpret_cast<IUnknown**>(&gDWriteFactory)), | |
201 "Could not create DirectWrite factory."); | |
202 | |
203 *factory = gDWriteFactory; | |
204 return S_OK; | |
205 } | |
206 | |
207 const void* DWriteOffscreen::draw(const SkGlyph& glyph, bool isBW) { | 208 const void* DWriteOffscreen::draw(const SkGlyph& glyph, bool isBW) { |
208 IDWriteFactory* factory; | 209 IDWriteFactory* factory = get_dwrite_factory(); |
209 HRNM(get_dwrite_factory(&factory), "Could not get factory."); | 210 SkASSERT(factory != NULL); |
210 | 211 |
211 if (fWidth < glyph.fWidth || fHeight < glyph.fHeight) { | 212 if (fWidth < glyph.fWidth || fHeight < glyph.fHeight) { |
212 fWidth = SkMax32(fWidth, glyph.fWidth); | 213 fWidth = SkMax32(fWidth, glyph.fWidth); |
213 fHeight = SkMax32(fHeight, glyph.fHeight); | 214 fHeight = SkMax32(fHeight, glyph.fHeight); |
214 | 215 |
215 if (isBW) { | 216 if (isBW) { |
216 fBits.setCount(fWidth * fHeight); | 217 fBits.setCount(fWidth * fHeight); |
217 } else { | 218 } else { |
218 fBits.setCount(fWidth * fHeight * 3); | 219 fBits.setCount(fWidth * fHeight * 3); |
219 } | 220 } |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 SkTypeface::Style style = get_style(font); | 547 SkTypeface::Style style = get_style(font); |
547 SkFontID fontID = SkTypefaceCache::NewFontID(); | 548 SkFontID fontID = SkTypefaceCache::NewFontID(); |
548 return SkNEW_ARGS(DWriteFontTypeface, (style, fontID, | 549 return SkNEW_ARGS(DWriteFontTypeface, (style, fontID, |
549 fontFace, font, fontFamily, | 550 fontFace, font, fontFamily, |
550 fontFileLoader, fontCollectionLoa
der)); | 551 fontFileLoader, fontCollectionLoa
der)); |
551 } | 552 } |
552 | 553 |
553 ~DWriteFontTypeface() { | 554 ~DWriteFontTypeface() { |
554 if (fDWriteFontCollectionLoader.get() == NULL) return; | 555 if (fDWriteFontCollectionLoader.get() == NULL) return; |
555 | 556 |
556 IDWriteFactory* factory; | 557 IDWriteFactory* factory = get_dwrite_factory(); |
557 HRVM(get_dwrite_factory(&factory), "Could not get factory."); | 558 SkASSERT(factory != NULL); |
558 HRV(factory->UnregisterFontCollectionLoader(fDWriteFontCollectionLoader.
get())); | 559 HRV(factory->UnregisterFontCollectionLoader(fDWriteFontCollectionLoader.
get())); |
559 HRV(factory->UnregisterFontFileLoader(fDWriteFontFileLoader.get())); | 560 HRV(factory->UnregisterFontFileLoader(fDWriteFontFileLoader.get())); |
560 } | 561 } |
561 | 562 |
562 protected: | 563 protected: |
563 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; | 564 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; |
564 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; | 565 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; |
565 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | 566 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
566 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 567 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
567 SkAdvancedTypefaceMetrics::PerGlyphInfo, | 568 SkAdvancedTypefaceMetrics::PerGlyphInfo, |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 DWRITE_GLYPH_RUN run; | 800 DWRITE_GLYPH_RUN run; |
800 run.glyphCount = 1; | 801 run.glyphCount = 1; |
801 run.glyphAdvances = &advance; | 802 run.glyphAdvances = &advance; |
802 run.fontFace = fTypeface->fDWriteFontFace.get(); | 803 run.fontFace = fTypeface->fDWriteFontFace.get(); |
803 run.fontEmSize = SkScalarToFloat(fRec.fTextSize); | 804 run.fontEmSize = SkScalarToFloat(fRec.fTextSize); |
804 run.bidiLevel = 0; | 805 run.bidiLevel = 0; |
805 run.glyphIndices = &glyphId; | 806 run.glyphIndices = &glyphId; |
806 run.isSideways = FALSE; | 807 run.isSideways = FALSE; |
807 run.glyphOffsets = &offset; | 808 run.glyphOffsets = &offset; |
808 | 809 |
809 IDWriteFactory* factory; | 810 IDWriteFactory* factory = get_dwrite_factory(); |
810 HRVM(get_dwrite_factory(&factory), "Could not get factory."); | 811 SkASSERT(factory != NULL); |
811 | 812 |
812 const bool isBW = SkMask::kBW_Format == fRec.fMaskFormat; | 813 const bool isBW = SkMask::kBW_Format == fRec.fMaskFormat; |
813 DWRITE_RENDERING_MODE renderingMode; | 814 DWRITE_RENDERING_MODE renderingMode; |
814 DWRITE_TEXTURE_TYPE textureType; | 815 DWRITE_TEXTURE_TYPE textureType; |
815 if (isBW) { | 816 if (isBW) { |
816 renderingMode = DWRITE_RENDERING_MODE_ALIASED; | 817 renderingMode = DWRITE_RENDERING_MODE_ALIASED; |
817 textureType = DWRITE_TEXTURE_ALIASED_1x1; | 818 textureType = DWRITE_TEXTURE_ALIASED_1x1; |
818 } else { | 819 } else { |
819 renderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; | 820 renderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; |
820 textureType = DWRITE_TEXTURE_CLEARTYPE_3x1; | 821 textureType = DWRITE_TEXTURE_CLEARTYPE_3x1; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 | 1266 |
1266 HRESULT unregister(IDWriteFactory* factory, IDWriteFontCollectionLoader* unr
egister) { | 1267 HRESULT unregister(IDWriteFactory* factory, IDWriteFontCollectionLoader* unr
egister) { |
1267 return factory->UnregisterFontCollectionLoader(unregister); | 1268 return factory->UnregisterFontCollectionLoader(unregister); |
1268 } | 1269 } |
1269 | 1270 |
1270 IDWriteFactory* fFactory; | 1271 IDWriteFactory* fFactory; |
1271 T* fUnregister; | 1272 T* fUnregister; |
1272 }; | 1273 }; |
1273 | 1274 |
1274 static SkTypeface* create_from_stream(SkStream* stream, int ttcIndex) { | 1275 static SkTypeface* create_from_stream(SkStream* stream, int ttcIndex) { |
1275 IDWriteFactory* factory; | 1276 IDWriteFactory* factory = get_dwrite_factory(); |
1276 HRN(get_dwrite_factory(&factory)); | 1277 if (NULL == factory) { |
| 1278 return NULL; |
| 1279 } |
1277 | 1280 |
1278 SkTScopedComPtr<StreamFontFileLoader> fontFileLoader; | 1281 SkTScopedComPtr<StreamFontFileLoader> fontFileLoader; |
1279 HRN(StreamFontFileLoader::Create(stream, &fontFileLoader)); | 1282 HRN(StreamFontFileLoader::Create(stream, &fontFileLoader)); |
1280 HRN(factory->RegisterFontFileLoader(fontFileLoader.get())); | 1283 HRN(factory->RegisterFontFileLoader(fontFileLoader.get())); |
1281 SkAutoIDWriteUnregister<StreamFontFileLoader> autoUnregisterFontFileLoader( | 1284 SkAutoIDWriteUnregister<StreamFontFileLoader> autoUnregisterFontFileLoader( |
1282 factory, fontFileLoader.get()); | 1285 factory, fontFileLoader.get()); |
1283 | 1286 |
1284 SkTScopedComPtr<StreamFontCollectionLoader> fontCollectionLoader; | 1287 SkTScopedComPtr<StreamFontCollectionLoader> fontCollectionLoader; |
1285 HRN(StreamFontCollectionLoader::Create(fontFileLoader.get(), &fontCollection
Loader)); | 1288 HRN(StreamFontCollectionLoader::Create(fontFileLoader.get(), &fontCollection
Loader)); |
1286 HRN(factory->RegisterFontCollectionLoader(fontCollectionLoader.get())); | 1289 HRN(factory->RegisterFontCollectionLoader(fontCollectionLoader.get())); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 SkScalerContext::kLCD_BGROrder_Flag | | 1369 SkScalerContext::kLCD_BGROrder_Flag | |
1367 SkScalerContext::kLCD_Vertical_Flag; | 1370 SkScalerContext::kLCD_Vertical_Flag; |
1368 rec->fFlags &= ~flagsWeDontSupport; | 1371 rec->fFlags &= ~flagsWeDontSupport; |
1369 | 1372 |
1370 SkPaint::Hinting h = rec->getHinting(); | 1373 SkPaint::Hinting h = rec->getHinting(); |
1371 // DirectWrite does not provide for hinting hints. | 1374 // DirectWrite does not provide for hinting hints. |
1372 h = SkPaint::kSlight_Hinting; | 1375 h = SkPaint::kSlight_Hinting; |
1373 rec->setHinting(h); | 1376 rec->setHinting(h); |
1374 | 1377 |
1375 #if SK_FONT_HOST_USE_SYSTEM_SETTINGS | 1378 #if SK_FONT_HOST_USE_SYSTEM_SETTINGS |
1376 IDWriteFactory* factory; | 1379 IDWriteFactory* factory = get_dwrite_factory(); |
1377 if (SUCCEEDED(get_dwrite_factory(&factory))) { | 1380 if (factory != NULL) { |
1378 SkTScopedComPtr<IDWriteRenderingParams> defaultRenderingParams; | 1381 SkTScopedComPtr<IDWriteRenderingParams> defaultRenderingParams; |
1379 if (SUCCEEDED(factory->CreateRenderingParams(&defaultRenderingParams)))
{ | 1382 if (SUCCEEDED(factory->CreateRenderingParams(&defaultRenderingParams)))
{ |
1380 float gamma = defaultRenderingParams->GetGamma(); | 1383 float gamma = defaultRenderingParams->GetGamma(); |
1381 rec->setDeviceGamma(gamma); | 1384 rec->setDeviceGamma(gamma); |
1382 rec->setPaintGamma(gamma); | 1385 rec->setPaintGamma(gamma); |
1383 | 1386 |
1384 rec->setContrast(defaultRenderingParams->GetEnhancedContrast()); | 1387 rec->setContrast(defaultRenderingParams->GetEnhancedContrast()); |
1385 } | 1388 } |
1386 } | 1389 } |
1387 #endif | 1390 #endif |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); | 1876 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); |
1874 if (!IS_ERROR(hr)) { | 1877 if (!IS_ERROR(hr)) { |
1875 hr = ERROR_PROC_NOT_FOUND; | 1878 hr = ERROR_PROC_NOT_FOUND; |
1876 } | 1879 } |
1877 return hr; | 1880 return hr; |
1878 } | 1881 } |
1879 return S_OK; | 1882 return S_OK; |
1880 } | 1883 } |
1881 | 1884 |
1882 SkFontMgr* SkFontMgr_New_DirectWrite() { | 1885 SkFontMgr* SkFontMgr_New_DirectWrite() { |
1883 IDWriteFactory* factory; | 1886 IDWriteFactory* factory = get_dwrite_factory(); |
1884 HRNM(get_dwrite_factory(&factory), "Could not get factory."); | 1887 if (NULL == factory) { |
| 1888 return NULL; |
| 1889 } |
1885 | 1890 |
1886 SkTScopedComPtr<IDWriteFontCollection> sysFontCollection; | 1891 SkTScopedComPtr<IDWriteFontCollection> sysFontCollection; |
1887 HRNM(factory->GetSystemFontCollection(&sysFontCollection, FALSE), | 1892 HRNM(factory->GetSystemFontCollection(&sysFontCollection, FALSE), |
1888 "Could not get system font collection."); | 1893 "Could not get system font collection."); |
1889 | 1894 |
1890 WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; | 1895 WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; |
1891 WCHAR* localeName = NULL; | 1896 WCHAR* localeName = NULL; |
1892 int localeNameLen = 0; | 1897 int localeNameLen = 0; |
1893 | 1898 |
1894 // Dynamically load GetUserDefaultLocaleName function, as it is not availabl
e on XP. | 1899 // Dynamically load GetUserDefaultLocaleName function, as it is not availabl
e on XP. |
1895 GetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = NULL; | 1900 GetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = NULL; |
1896 HRESULT hr = GetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc); | 1901 HRESULT hr = GetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc); |
1897 if (NULL == getUserDefaultLocaleNameProc) { | 1902 if (NULL == getUserDefaultLocaleNameProc) { |
1898 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); | 1903 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); |
1899 } else { | 1904 } else { |
1900 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 1905 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
1901 if (localeNameLen) { | 1906 if (localeNameLen) { |
1902 localeName = localeNameStorage; | 1907 localeName = localeNameStorage; |
1903 }; | 1908 }; |
1904 } | 1909 } |
1905 | 1910 |
1906 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); | 1911 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); |
1907 } | 1912 } |
OLD | NEW |