Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Unified Diff: src/ports/SkFontMgr_win_dw.cpp

Issue 1878843002: Add option to specify font fallback when creating the skia font manager (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Fix indent Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/ports/SkTypeface_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontMgr_win_dw.cpp
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index 11afec3b53623205dad6612ab7cc0057c958181e..cac9c03710305e2df718e97404ba3ea8ed8190f1 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -264,8 +264,11 @@ class SkFontMgr_DirectWrite : public SkFontMgr {
public:
/** localeNameLength must include the null terminator. */
SkFontMgr_DirectWrite(IDWriteFactory* factory, IDWriteFontCollection* fontCollection,
- WCHAR* localeName, int localeNameLength)
+ IDWriteFontFallback* fallback, WCHAR* localeName, int localeNameLength)
: fFactory(SkRefComPtr(factory))
+#if SK_HAS_DWRITE_2_H
+ , fFontFallback(SkSafeRefComPtr(fallback))
+#endif
, fFontCollection(SkRefComPtr(fontCollection))
, fLocaleName(localeNameLength)
{
@@ -275,6 +278,10 @@ public:
// http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
SkASSERT_RELEASE(nullptr == fFactory2.get());
}
+ if (fFontFallback.get()) {
+ // factory must be provied if fallback is non-null, else the fallback will not be used.
+ SkASSERT(fFactory2.get());
+ }
#endif
memcpy(fLocaleName.get(), localeName, localeNameLength * sizeof(WCHAR));
}
@@ -309,6 +316,7 @@ private:
SkTScopedComPtr<IDWriteFactory> fFactory;
#if SK_HAS_DWRITE_2_H
SkTScopedComPtr<IDWriteFactory2> fFactory2;
+ SkTScopedComPtr<IDWriteFontFallback> fFontFallback;
#endif
SkTScopedComPtr<IDWriteFontCollection> fFontCollection;
SkSMallocWCHAR fLocaleName;
@@ -763,8 +771,13 @@ SkTypeface* SkFontMgr_DirectWrite::onMatchFamilyStyleCharacter(const char family
#if SK_HAS_DWRITE_2_H
if (fFactory2.get()) {
- SkTScopedComPtr<IDWriteFontFallback> fontFallback;
- HRNM(fFactory2->GetSystemFontFallback(&fontFallback), "Could not get system fallback.");
+ SkTScopedComPtr<IDWriteFontFallback> systemFontFallback;
+ IDWriteFontFallback* fontFallback = fFontFallback.get();
+ if (!fontFallback) {
+ HRNM(fFactory2->GetSystemFontFallback(&systemFontFallback),
+ "Could not get system fallback.");
+ fontFallback = systemFontFallback.get();
+ }
SkTScopedComPtr<IDWriteNumberSubstitution> numberSubstitution;
HRNM(fFactory2->CreateNumberSubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE, nullptr, TRUE,
@@ -1069,6 +1082,12 @@ SkTypeface* SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle& pattern) {
SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
IDWriteFontCollection* collection) {
+ return SkFontMgr_New_DirectWrite(factory, collection, nullptr);
+}
+
+SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
+ IDWriteFontCollection* collection,
+ IDWriteFontFallback* fallback) {
if (nullptr == factory) {
factory = sk_get_dwrite_factory();
if (nullptr == factory) {
@@ -1099,7 +1118,7 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
};
}
- return new SkFontMgr_DirectWrite(factory, collection, localeName, localeNameLen);
+ return new SkFontMgr_DirectWrite(factory, collection, fallback, localeName, localeNameLen);
}
#include "SkFontMgr_indirect.h"
« no previous file with comments | « include/ports/SkTypeface_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698