Add option to specify a font collection when creating a
DirectWrite font manager. The corresponding Chromium change can be found at https://codereview.chromium.org/1591883002/ . TBR=reed This is a trivial and long planned addition to the API. Review URL: https://codereview.chromium.org/1607083003
This commit is contained in:
parent
37ed996f2d
commit
69d1603266
@ -40,9 +40,11 @@ SK_API void SkTypeface_SetEnsureLOGFONTAccessibleProc(void (*)(const LOGFONT&));
|
||||
class SkFontMgr;
|
||||
class SkRemotableFontMgr;
|
||||
struct IDWriteFactory;
|
||||
struct IDWriteFontCollection;
|
||||
|
||||
SK_API SkFontMgr* SkFontMgr_New_GDI();
|
||||
SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory = NULL);
|
||||
SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory = NULL,
|
||||
IDWriteFontCollection* collection = NULL);
|
||||
|
||||
/**
|
||||
* Creates an SkFontMgr which renders using DirectWrite and obtains its data
|
||||
|
@ -1067,7 +1067,8 @@ SkTypeface* SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle& pattern) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "SkTypeface_win.h"
|
||||
|
||||
SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory) {
|
||||
SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
|
||||
IDWriteFontCollection* collection) {
|
||||
if (nullptr == factory) {
|
||||
factory = sk_get_dwrite_factory();
|
||||
if (nullptr == factory) {
|
||||
@ -1075,9 +1076,12 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory) {
|
||||
}
|
||||
}
|
||||
|
||||
SkTScopedComPtr<IDWriteFontCollection> sysFontCollection;
|
||||
HRNM(factory->GetSystemFontCollection(&sysFontCollection, FALSE),
|
||||
"Could not get system font collection.");
|
||||
SkTScopedComPtr<IDWriteFontCollection> systemFontCollection;
|
||||
if (nullptr == collection) {
|
||||
HRNM(factory->GetSystemFontCollection(&systemFontCollection, FALSE),
|
||||
"Could not get system font collection.");
|
||||
collection = systemFontCollection.get();
|
||||
}
|
||||
|
||||
WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH];
|
||||
WCHAR* localeName = nullptr;
|
||||
@ -1095,7 +1099,7 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory) {
|
||||
};
|
||||
}
|
||||
|
||||
return new SkFontMgr_DirectWrite(factory, sysFontCollection.get(), localeName, localeNameLen);
|
||||
return new SkFontMgr_DirectWrite(factory, collection, localeName, localeNameLen);
|
||||
}
|
||||
|
||||
#include "SkFontMgr_indirect.h"
|
||||
|
Loading…
Reference in New Issue
Block a user