summaryrefslogtreecommitdiff
path: root/vcl/skia/win
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-03-27 12:51:19 +0100
committerLuboš Luňák <l.lunak@collabora.com>2020-03-27 15:56:10 +0100
commit7b23e0f3ae6b2fb1cebe97c6517eb18f9ed4a76e (patch)
tree2c28105cfc1d08bd53e972e6380a1fab1b1a0e4d /vcl/skia/win
parent4aa7dec62068bdc6ff20ffbfee40616cba758a79 (diff)
fix LOGFONTA/GetObjectW() mismatch and remove Skia HFONT hack (tdf#131426)
The GetObjectA/W() functions are type-unsafe, and since we #undef GetObject I accidentally used GetObjectW() with LOGFONT that was LOGFONTA. This caused the font name to be broken, which made Skia use a different font. This means that Skia doesn't actually need the HFONT passing hack. Change-Id: I67b8d18fef6a92f8839b1652e051da96d01c3a4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91202 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/skia/win')
-rw-r--r--vcl/skia/win/gdiimpl.cxx26
1 files changed, 16 insertions, 10 deletions
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 221819ca1c4f..e7d0b576e37a 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -118,29 +118,35 @@ bool WinSkiaSalGraphicsImpl::DrawTextLayout(const GenericSalLayout& rLayout)
const WinFontInstance* pWinFont = static_cast<const WinFontInstance*>(&rLayout.GetFont());
const HFONT hLayoutFont = pWinFont->GetHFONT();
LOGFONT logFont;
- if (::GetObjectW(hLayoutFont, sizeof(logFont), &logFont) == 0)
+// Bring back GetObject that got #undef-ed in include/postwin.hxx .
+// The GetObjectA/W() functions are type-unsafe, so they should match the LOGFONTA/W,
+// otherwise the font name will be incorrect and Skia will choose an incorrect font.
+#ifdef UNICODE
+#define GetObject GetObjectW
+#else
+#define GetObject GetObjectA
+#endif
+ if (GetObject(hLayoutFont, sizeof(logFont), &logFont) == 0)
{
assert(false);
return false;
}
- // Wrap the font in Skia's SkTypeFace subclass that's been patched
- // to use it.
- sk_sp<SkTypeface> typeface(SkCreateTypefaceFromLOGFONT(logFont, hLayoutFont));
+ sk_sp<SkTypeface> typeface(SkCreateTypefaceFromLOGFONT(logFont));
// lfHeight actually depends on DPI, so it's not really font height as such,
// but for LOGFONT-based typefaces Skia simply sets lfHeight back to this value
// directly.
- // This is probably not necessary since we pass also the HFONT itself, but better
- // forward that information too, in case SkFont uses it somehow.
double fontHeight = logFont.lfHeight;
if (fontHeight < 0)
fontHeight = -fontHeight;
SkFont font(typeface, fontHeight, fHScale, 0);
// Skia needs to be explicitly told what kind of antialiasing should be used,
// get it from system settings. This does not actually matter for the text
- // rendering itself, since it will use the font passed to Skia in the code above
- // (and that one uses DEFAULT_QUALITY, so Windows will select the appropriate AA setting),
- // but Skia internally chooses the format to which the glyphs will be rendered
- // based on this setting (subpixel AA requires colors, others do not).
+ // rendering itself, since Skia has been patched to simply use the setting
+ // from the LOGFONT, which gets set by VCL's ImplGetLogFontFromFontSelect()
+ // and that one normally uses DEFAULT_QUALITY, so Windows will select
+ // the appropriate AA setting. But Skia internally chooses the format to which
+ // the glyphs will be rendered based on this setting (subpixel AA requires colors,
+ // others do not).
BOOL set;
if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &set, 0) && set)
{