commit 065d6d56945b92afc7d5a31a21662918dcba5bc7
parent 81723d331090b12f0e5e274eeb61f135f2f64ee5
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Tue, 2 Dec 2025 13:58:40 +0000
Bug 2002421 - Add a few null-checks to SkTypeface_win_dw. r=lsalzman
We create SkTypefaces without a DWrite font / font-family.
Remove a postscript name getter which is unnecessary and removed
upstream, see https://skia-review.googlesource.com/c/skia/+/1113856
Differential Revision: https://phabricator.services.mozilla.com/D274735
Diffstat:
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/gfx/skia/skia/src/ports/SkTypeface_win_dw.cpp b/gfx/skia/skia/src/ports/SkTypeface_win_dw.cpp
@@ -236,6 +236,9 @@ DWriteFontTypeface::Loaders::~Loaders() {
}
void DWriteFontTypeface::onGetFamilyName(SkString* familyName) const {
+ if (!fDWriteFontFamily) {
+ return;
+ }
SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
HRV(fDWriteFontFamily->GetFamilyNames(&familyNames));
@@ -246,7 +249,8 @@ bool DWriteFontTypeface::onGetPostScriptName(SkString* skPostScriptName) const {
SkString localSkPostScriptName;
SkTScopedComPtr<IDWriteLocalizedStrings> postScriptNames;
BOOL exists = FALSE;
- if (FAILED(fDWriteFont->GetInformationalStrings(
+ if (!fDWriteFont ||
+ FAILED(fDWriteFont->GetInformationalStrings(
DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_NAME,
&postScriptNames,
&exists)) ||
@@ -761,20 +765,6 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> DWriteFontTypeface::onGetAdvancedMetr
info->fDescent = SkToS16(dwfm.descent);
info->fCapHeight = SkToS16(dwfm.capHeight);
- {
- SkTScopedComPtr<IDWriteLocalizedStrings> postScriptNames;
- BOOL exists = FALSE;
- if (FAILED(fDWriteFont->GetInformationalStrings(
- DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_NAME,
- &postScriptNames,
- &exists)) ||
- !exists ||
- FAILED(sk_get_locale_string(postScriptNames.get(), nullptr, &info->fPostScriptName)))
- {
- SkDEBUGF("Unable to get postscript name for typeface %p\n", this);
- }
- }
-
DWRITE_FONT_FACE_TYPE fontType = fDWriteFontFace->GetType();
if (fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE ||
fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION)