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:
kulshin 2016-02-03 07:22:52 -08:00 committed by Commit bot
parent 37ed996f2d
commit 69d1603266
2 changed files with 12 additions and 6 deletions

View File

@ -40,9 +40,11 @@ SK_API void SkTypeface_SetEnsureLOGFONTAccessibleProc(void (*)(const LOGFONT&));
class SkFontMgr; class SkFontMgr;
class SkRemotableFontMgr; class SkRemotableFontMgr;
struct IDWriteFactory; struct IDWriteFactory;
struct IDWriteFontCollection;
SK_API SkFontMgr* SkFontMgr_New_GDI(); 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 * Creates an SkFontMgr which renders using DirectWrite and obtains its data

View File

@ -1067,7 +1067,8 @@ SkTypeface* SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle& pattern) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "SkTypeface_win.h" #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) { if (nullptr == factory) {
factory = sk_get_dwrite_factory(); factory = sk_get_dwrite_factory();
if (nullptr == factory) { if (nullptr == factory) {
@ -1075,9 +1076,12 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory) {
} }
} }
SkTScopedComPtr<IDWriteFontCollection> sysFontCollection; SkTScopedComPtr<IDWriteFontCollection> systemFontCollection;
HRNM(factory->GetSystemFontCollection(&sysFontCollection, FALSE), if (nullptr == collection) {
"Could not get system font collection."); HRNM(factory->GetSystemFontCollection(&systemFontCollection, FALSE),
"Could not get system font collection.");
collection = systemFontCollection.get();
}
WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH];
WCHAR* localeName = nullptr; 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" #include "SkFontMgr_indirect.h"