commit 1b85a6952057f7129bc7386e4bdb3e80010b8c45
parent 1e71b78835d44acbda502918b2fc8dd0da8abe33
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Tue, 2 Dec 2025 13:58:40 +0000
Bug 2002421 - Plumb dwrite font down to Skia. r=lsalzman
Mostly untested because not on windows right now.
This should fix it or at least move the crash around to the next one,
and pretty sure it's the right thing to do.
Differential Revision: https://phabricator.services.mozilla.com/D274073
Diffstat:
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/gfx/2d/ScaledFontDWrite.cpp b/gfx/2d/ScaledFontDWrite.cpp
@@ -117,9 +117,11 @@ SkTypeface* ScaledFontDWrite::CreateSkTypeface() {
clearTypeLevel = 1.0f;
}
- return SkCreateTypefaceFromDWriteFont(factory, mFontFace, mStyle,
- (int)settings.RenderingMode(), gamma,
- contrast, clearTypeLevel);
+ IDWriteFont* font =
+ static_cast<UnscaledFontDWrite*>(mUnscaledFont.get())->GetFont();
+ return SkCreateTypefaceFromDWriteFont(
+ factory, mFontFace, font, mStyle,
+ (int)settings.RenderingMode(), gamma, contrast, clearTypeLevel);
}
void ScaledFontDWrite::SetupSkFontDrawOptions(SkFont& aFont) {
diff --git a/gfx/skia/skia/include/ports/SkTypeface_win.h b/gfx/skia/skia/include/ports/SkTypeface_win.h
@@ -49,9 +49,10 @@ SK_API void SkTypeface_SetEnsureLOGFONTAccessibleProc(void (*)(const LOGFONT&));
//
class SkFontMgr;
struct IDWriteFactory;
+struct IDWriteFont;
struct IDWriteFontCollection;
-struct IDWriteFontFallback;
struct IDWriteFontFace;
+struct IDWriteFontFallback;
/**
* Like the other Typeface create methods, this returns a new reference to the
@@ -60,6 +61,7 @@ struct IDWriteFontFace;
*/
SK_API SkTypeface* SkCreateTypefaceFromDWriteFont(IDWriteFactory* aFactory,
IDWriteFontFace* aFontFace,
+ IDWriteFont* aFont,
SkFontStyle aStyle,
int aRenderingMode,
float aGamma,
diff --git a/gfx/skia/skia/src/ports/SkFontHost_win.cpp b/gfx/skia/skia/src/ports/SkFontHost_win.cpp
@@ -373,13 +373,14 @@ sk_sp<SkTypeface> SkCreateTypefaceFromLOGFONT(const LOGFONT& origLF) {
*/
SkTypeface* SkCreateTypefaceFromDWriteFont(IDWriteFactory* aFactory,
IDWriteFontFace* aFontFace,
+ IDWriteFont* aFont,
SkFontStyle aStyle,
int aRenderingMode,
float aGamma,
float aContrast,
float aClearTypeLevel)
{
- return DWriteFontTypeface::Create(aFactory, aFontFace, aStyle,
+ return DWriteFontTypeface::Create(aFactory, aFontFace, aFont, aStyle,
(DWRITE_RENDERING_MODE)aRenderingMode,
aGamma, aContrast, aClearTypeLevel);
}
diff --git a/gfx/skia/skia/src/ports/SkTypeface_win_dw.h b/gfx/skia/skia/src/ports/SkTypeface_win_dw.h
@@ -115,6 +115,7 @@ public:
static DWriteFontTypeface* Create(IDWriteFactory* factory,
IDWriteFontFace* fontFace,
+ IDWriteFont* font,
SkFontStyle aStyle,
DWRITE_RENDERING_MODE aRenderingMode,
float aGamma,
@@ -122,7 +123,7 @@ public:
float aClearTypeLevel) {
DWriteFontTypeface* typeface =
new DWriteFontTypeface(aStyle, factory, fontFace,
- nullptr, nullptr,
+ font, nullptr,
nullptr, SkFontArguments::Palette{0, nullptr, 0});
typeface->fRenderingMode = aRenderingMode;
typeface->fGamma = aGamma;