Correctly call SkFontMgr_DirectWrite constructor.
The passed localeName and defaultFamilyName and associated lengths are expected to include the terminating NULL (mostly due to the way LOGFONT and GetUserDefaultLocaleName are defined). This implies that in the case where these values cannot be retrieved the empty string should be passed. Bug: chromium:973361 Change-Id: I0ac98f5250e1cb2d7fa426b255c5e2c2619dc51c Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221417 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
parent
e7f8c34384
commit
c6628127dc
@ -269,8 +269,8 @@ public:
|
||||
/** localeNameLength and defaultFamilyNameLength must include the null terminator. */
|
||||
SkFontMgr_DirectWrite(IDWriteFactory* factory, IDWriteFontCollection* fontCollection,
|
||||
IDWriteFontFallback* fallback,
|
||||
WCHAR* localeName, int localeNameLength,
|
||||
WCHAR* defaultFamilyName, int defaultFamilyNameLength)
|
||||
const WCHAR* localeName, int localeNameLength,
|
||||
const WCHAR* defaultFamilyName, int defaultFamilyNameLength)
|
||||
: fFactory(SkRefComPtr(factory))
|
||||
, fFontFallback(SkSafeRefComPtr(fallback))
|
||||
, fFontCollection(SkRefComPtr(fontCollection))
|
||||
@ -1183,8 +1183,8 @@ SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
|
||||
}
|
||||
}
|
||||
|
||||
WCHAR* defaultFamilyName = nullptr;
|
||||
int defaultFamilyNameLen = 0;
|
||||
const WCHAR* defaultFamilyName = L"";
|
||||
int defaultFamilyNameLen = 1;
|
||||
NONCLIENTMETRICSW metrics;
|
||||
metrics.cbSize = sizeof(metrics);
|
||||
if (nullptr == fallback) {
|
||||
@ -1195,8 +1195,8 @@ SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
|
||||
}
|
||||
|
||||
WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH];
|
||||
WCHAR* localeName = nullptr;
|
||||
int localeNameLen = 0;
|
||||
const WCHAR* localeName = L"";
|
||||
int localeNameLen = 1;
|
||||
|
||||
// Dynamically load GetUserDefaultLocaleName function, as it is not available on XP.
|
||||
SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = nullptr;
|
||||
@ -1204,9 +1204,10 @@ SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
|
||||
if (nullptr == getUserDefaultLocaleNameProc) {
|
||||
SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName.");
|
||||
} else {
|
||||
localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_NAME_MAX_LENGTH);
|
||||
if (localeNameLen) {
|
||||
int size = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_NAME_MAX_LENGTH);
|
||||
if (size) {
|
||||
localeName = localeNameStorage;
|
||||
localeNameLen = size;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user