virtual HRESULT STDMETHODCALLTYPE CreateCustomFontCollection( IDWriteFontCollectionLoader* collectionLoader, void const* collectionKey, UINT32 collectionKeySize, IDWriteFontCollection** fontCollection ) { return orig_this->CreateCustomFontCollection(collectionLoader, collectionKey, collectionKeySize, fontCollection); }
delegate_dwritefactory(IDWriteFactory *inst) : refnum(0), orig_this(inst), mycoll(nullptr) { OutputDebugString("delegate_dwritefactory::delegate_dwritefactory"); InitializeCriticalSection(&collcs); fontfile_collection_loader &loader = fontfile_collection_loader::get_instance(); if (SUCCEEDED(orig_this->RegisterFontCollectionLoader(&loader))) { EnterCriticalSection(&fontpathscs); orig_this->CreateCustomFontCollection(&loader, nullptr, 0, &mycoll); LeaveCriticalSection(&fontpathscs); } factories.insert(this); }
void update_font_collection() { fontfile_collection_loader &loader = fontfile_collection_loader::get_instance(); EnterCriticalSection(&collcs); EnterCriticalSection(&fontpathscs); IDWriteFontCollection* coll; if (SUCCEEDED(orig_this->CreateCustomFontCollection(&loader, nullptr, 0, &coll))) { InterlockedExchangePointer((void**)&mycoll, coll); iunknown_release(coll); } LeaveCriticalSection(&fontpathscs); LeaveCriticalSection(&collcs); }