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..715bed52912c68da221ea976828aaf512c7c5308 100644 |
--- a/src/ports/SkFontMgr_win_dw.cpp |
+++ b/src/ports/SkFontMgr_win_dw.cpp |
@@ -25,6 +25,8 @@ |
#if SK_HAS_DWRITE_2_H |
#include <dwrite_2.h> |
+#else |
+struct IDWriteFontFallback; |
#endif |
//////////////////////////////////////////////////////////////////////////////// |
@@ -264,10 +266,13 @@ class SkFontMgr_DirectWrite : public SkFontMgr { |
public: |
/** localeNameLength must include the null terminator. */ |
SkFontMgr_DirectWrite(IDWriteFactory* factory, IDWriteFontCollection* fontCollection, |
- WCHAR* localeName, int localeNameLength) |
+ WCHAR* localeName, int localeNameLength, IDWriteFontFallback* fallback) |
: fFactory(SkRefComPtr(factory)) |
, fFontCollection(SkRefComPtr(fontCollection)) |
, fLocaleName(localeNameLength) |
+#if SK_HAS_DWRITE_2_H |
+ , fFontFallback(SkSafeRefComPtr(fallback)) |
+#endif |
{ |
#if SK_HAS_DWRITE_2_H |
if (!SUCCEEDED(fFactory->QueryInterface(&fFactory2))) { |
@@ -309,6 +314,7 @@ private: |
SkTScopedComPtr<IDWriteFactory> fFactory; |
#if SK_HAS_DWRITE_2_H |
SkTScopedComPtr<IDWriteFactory2> fFactory2; |
+ SkTScopedComPtr<IDWriteFontFallback> fFontFallback; |
#endif |
SkTScopedComPtr<IDWriteFontCollection> fFontCollection; |
SkSMallocWCHAR fLocaleName; |
@@ -762,10 +768,7 @@ 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."); |
- |
+ if (fFactory2.get() && fFontFallback.get()) { |
SkTScopedComPtr<IDWriteNumberSubstitution> numberSubstitution; |
HRNM(fFactory2->CreateNumberSubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE, nullptr, TRUE, |
&numberSubstitution), |
@@ -776,17 +779,17 @@ SkTypeface* SkFontMgr_DirectWrite::onMatchFamilyStyleCharacter(const char family |
UINT32 mappedLength; |
SkTScopedComPtr<IDWriteFont> font; |
FLOAT scale; |
- HRNM(fontFallback->MapCharacters(fontFallbackSource.get(), |
- 0, // textPosition, |
- strLen, |
- fFontCollection.get(), |
- dwFamilyName, |
- dwStyle.fWeight, |
- dwStyle.fSlant, |
- dwStyle.fWidth, |
- &mappedLength, |
- &font, |
- &scale), |
+ HRNM(fFontFallback->MapCharacters(fontFallbackSource.get(), |
+ 0, // textPosition, |
+ strLen, |
+ fFontCollection.get(), |
+ dwFamilyName, |
+ dwStyle.fWeight, |
+ dwStyle.fSlant, |
+ dwStyle.fWidth, |
+ &mappedLength, |
+ &font, |
+ &scale), |
"Could not map characters"); |
if (!font.get()) { |
return nullptr; |
@@ -1083,6 +1086,18 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory, |
collection = systemFontCollection.get(); |
} |
+ IDWriteFontFallback *fontFallback = nullptr; |
+#if SK_HAS_DWRITE_2_H |
+ SkTScopedComPtr<IDWriteFontFallback> systemFontFallback; |
+ SkTScopedComPtr<IDWriteFactory2> fFactory2; |
+ factory->QueryInterface(&fFactory2); |
+ if (fFactory2.get()) { |
+ HRNM(fFactory2->GetSystemFontFallback(&systemFontFallback), |
+ "Could not get system fallback."); |
+ fontFallback = systemFontFallback.get(); |
+ } |
+#endif |
bungeman-skia
2016/03/08 19:02:44
This is now somewhat squirrelly, in that we're all
|
+ |
WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; |
WCHAR* localeName = nullptr; |
int localeNameLen = 0; |
@@ -1099,7 +1114,8 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory, |
}; |
} |
- return new SkFontMgr_DirectWrite(factory, collection, localeName, localeNameLen); |
+ return new SkFontMgr_DirectWrite( |
+ factory, collection, localeName, localeNameLen, fontFallback); |
} |
#include "SkFontMgr_indirect.h" |