| 126 | ID2D1Factory *pD2DFactory = 0; |
| 127 | |
| 128 | bool LoadD2D() { |
| 129 | static bool triedLoadingD2D = false; |
| 130 | if (!triedLoadingD2D) { |
| 131 | typedef HRESULT (WINAPI *D2D1CFSig)(D2D1_FACTORY_TYPE factoryType, REFIID riid, |
| 132 | CONST D2D1_FACTORY_OPTIONS *pFactoryOptions, IUnknown **factory); |
| 133 | typedef HRESULT (WINAPI *DWriteCFSig)(DWRITE_FACTORY_TYPE factoryType, REFIID iid, |
| 134 | IUnknown **factory); |
| 135 | |
| 136 | HMODULE hDLLD2D = ::LoadLibraryEx(TEXT("D2D1.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/); |
| 137 | if (hDLLD2D) { |
| 138 | D2D1CFSig fnD2DCF = (D2D1CFSig)::GetProcAddress(hDLLD2D, "D2D1CreateFactory"); |
| 139 | if (fnD2DCF) { |
| 140 | // A single threaded factory as Scintilla always draw on the GUI thread |
| 141 | fnD2DCF(D2D1_FACTORY_TYPE_SINGLE_THREADED, |
| 142 | __uuidof(ID2D1Factory), |
| 143 | 0, |
| 144 | reinterpret_cast<IUnknown**>(&pD2DFactory)); |
| 145 | } |
| 146 | } |
| 147 | HMODULE hDLLDWrite = ::LoadLibraryEx(TEXT("DWRITE.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/); |
| 148 | if (hDLLDWrite) { |
| 149 | DWriteCFSig fnDWCF = (DWriteCFSig)::GetProcAddress(hDLLDWrite, "DWriteCreateFactory"); |
| 150 | if (fnDWCF) { |
| 151 | fnDWCF(DWRITE_FACTORY_TYPE_SHARED, |
| 152 | __uuidof(IDWriteFactory), |
| 153 | reinterpret_cast<IUnknown**>(&pIDWriteFactory)); |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | triedLoadingD2D = true; |
| 158 | return pIDWriteFactory && pD2DFactory; |
| 159 | } |
| 160 | #endif |
| 161 | |
| 162 | struct FormatAndMetrics { |