From: kulshin Date: Wed, 3 Feb 2016 15:22:52 +0000 (-0800) Subject: Add option to specify a font collection when creating a X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~129^2~2264 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69d160326659dcf64e1584018b713631ddbc061c;p=platform%2Fupstream%2FlibSkiaSharp.git 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 --- diff --git a/include/ports/SkTypeface_win.h b/include/ports/SkTypeface_win.h index b737398..da728ca 100644 --- a/include/ports/SkTypeface_win.h +++ b/include/ports/SkTypeface_win.h @@ -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 diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp index ef09210..11afec3 100644 --- a/src/ports/SkFontMgr_win_dw.cpp +++ b/src/ports/SkFontMgr_win_dw.cpp @@ -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 sysFontCollection; - HRNM(factory->GetSystemFontCollection(&sysFontCollection, FALSE), - "Could not get system font collection."); + SkTScopedComPtr 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"