| 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 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 uint16_t fWidth; | 92 uint16_t fWidth; |
| 93 uint16_t fHeight; | 93 uint16_t fHeight; |
| 94 IDWriteFontFace* fFontFace; | 94 IDWriteFontFace* fFontFace; |
| 95 FLOAT fFontSize; | 95 FLOAT fFontSize; |
| 96 DWRITE_MATRIX fXform; | 96 DWRITE_MATRIX fXform; |
| 97 SkTDArray<uint8_t> fBits; | 97 SkTDArray<uint8_t> fBits; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 typedef HRESULT (WINAPI *DWriteCreateFactoryProc)( | |
| 101 __in DWRITE_FACTORY_TYPE factoryType, | |
| 102 __in REFIID iid, | |
| 103 __out IUnknown **factory | |
| 104 ); | |
| 105 | |
| 106 static HRESULT get_dwrite_factory(IDWriteFactory** factory) { | 100 static HRESULT get_dwrite_factory(IDWriteFactory** factory) { |
| 107 static IDWriteFactory* gDWriteFactory = NULL; | 101 static IDWriteFactory* gDWriteFactory = NULL; |
| 108 | 102 |
| 109 if (gDWriteFactory != NULL) { | 103 if (gDWriteFactory != NULL) { |
| 110 *factory = gDWriteFactory; | 104 *factory = gDWriteFactory; |
| 111 return S_OK; | 105 return S_OK; |
| 112 } | 106 } |
| 113 | 107 |
| 108 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; |
| 114 DWriteCreateFactoryProc dWriteCreateFactoryProc = | 109 DWriteCreateFactoryProc dWriteCreateFactoryProc = |
| 115 reinterpret_cast<DWriteCreateFactoryProc>( | 110 reinterpret_cast<DWriteCreateFactoryProc>( |
| 116 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory") | 111 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory") |
| 117 ) | 112 ) |
| 118 ; | 113 ; |
| 119 | 114 |
| 120 if (!dWriteCreateFactoryProc) { | 115 if (!dWriteCreateFactoryProc) { |
| 121 return E_UNEXPECTED; | 116 return E_UNEXPECTED; |
| 122 } | 117 } |
| 123 | 118 |
| (...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 printf("SkFontHost::CreateTypefaceFromFile unimplemented"); | 1835 printf("SkFontHost::CreateTypefaceFromFile unimplemented"); |
| 1841 return NULL; | 1836 return NULL; |
| 1842 } | 1837 } |
| 1843 | 1838 |
| 1844 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { | 1839 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { |
| 1845 return create_from_stream(stream, 0); | 1840 return create_from_stream(stream, 0); |
| 1846 } | 1841 } |
| 1847 | 1842 |
| 1848 #endif | 1843 #endif |
| 1849 | 1844 |
| 1845 typedef decltype(GetUserDefaultLocaleName)* GetUserDefaultLocaleNameProc; |
| 1846 static GetUserDefaultLocaleNameProc GetGetUserDefaultLocaleNameProc() { |
| 1847 return reinterpret_cast<GetUserDefaultLocaleNameProc>( |
| 1848 GetProcAddress(LoadLibraryW(L"Kernel32.dll"), "GetUserDefaultLocaleName"
) |
| 1849 ); |
| 1850 } |
| 1851 |
| 1850 SkFontMgr* SkFontMgr::Factory() { | 1852 SkFontMgr* SkFontMgr::Factory() { |
| 1851 IDWriteFactory* factory; | 1853 IDWriteFactory* factory; |
| 1852 HRNM(get_dwrite_factory(&factory), "Could not get factory."); | 1854 HRNM(get_dwrite_factory(&factory), "Could not get factory."); |
| 1853 | 1855 |
| 1854 SkTScopedComPtr<IDWriteFontCollection> sysFontCollection; | 1856 SkTScopedComPtr<IDWriteFontCollection> sysFontCollection; |
| 1855 HRNM(factory->GetSystemFontCollection(&sysFontCollection, FALSE), | 1857 HRNM(factory->GetSystemFontCollection(&sysFontCollection, FALSE), |
| 1856 "Could not get system font collection."); | 1858 "Could not get system font collection."); |
| 1857 | 1859 |
| 1858 WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; | 1860 WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; |
| 1859 WCHAR* localeName = NULL; | 1861 WCHAR* localeName = NULL; |
| 1860 int localeNameLen = GetUserDefaultLocaleName(localeNameStorage, LOCALE_NAME_
MAX_LENGTH); | 1862 int localeNameLen = 0; |
| 1861 if (localeNameLen) { | 1863 |
| 1862 localeName = localeNameStorage; | 1864 // Dynamically load GetUserDefaultLocaleName function, as it is not availabl
e on XP. |
| 1863 }; | 1865 GetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = GetGetUserDefaul
tLocaleNameProc(); |
| 1866 if (NULL == getUserDefaultLocaleNameProc) { |
| 1867 SkDebugf("Could not get GetUserDefaultLocaleName."); |
| 1868 } else { |
| 1869 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
| 1870 if (localeNameLen) { |
| 1871 localeName = localeNameStorage; |
| 1872 }; |
| 1873 } |
| 1864 | 1874 |
| 1865 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); | 1875 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); |
| 1866 } | 1876 } |
| OLD | NEW |