summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-09-04 17:24:03 +0200
committerCaolán McNamara <caolanm@redhat.com>2018-09-20 17:43:30 +0200
commitfbc3818a70bad11f2b28d005d97c3491a41f711e (patch)
treea293ce053f90e34fbf6a35d95c935db074a5402b
parentsw: fix return value of DocumentRedlineManager::AppendRedline() (diff)
downloadcore-fbc3818a70bad11f2b28d005d97c3491a41f711e.tar.gz
core-fbc3818a70bad11f2b28d005d97c3491a41f711e.zip
tdf#119340 WIN don't always re-init the HFONT
After all the LogicalFontInstance refactoring, its FontSelectData is now immutable, so the HFONT will never need to be changed. Therefore we can skip the HFONT lookup in WinSalGraphics::SetFont, if the WinFontInstance already has it set. All the HFONT handling (basically WinSalGraphics::ImplDoSetFont) should be moved to the WinFontInstance to further clean this up. Reviewed-on: https://gerrit.libreoffice.org/59988 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de> (cherry picked from commit 7e7a1ff3926e86705199aa9814089e90f01c02ed) Conflicts: vcl/win/gdi/salfont.cxx Change-Id: I1c9a9e3414677d77f0f007d7ace653bb53b8474d Reviewed-on: https://gerrit.libreoffice.org/60721 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/win/gdi/salfont.cxx22
1 files changed, 14 insertions, 8 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index ae0042706e04..81c8d3a92628 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -857,11 +857,6 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const * i_pFont,
g_BoundRectCache.clear();
HFONT hNewFont = nullptr;
- HDC hdcScreen = nullptr;
- if( mbVirDev )
- // only required for virtual devices, see below for details
- hdcScreen = GetDC(nullptr);
-
LOGFONTW aLogFont;
ImplGetLogFontFromFontSelect( getHDC(), i_pFont, i_pFontFace, aLogFont );
@@ -884,8 +879,12 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const * i_pFont,
aLogFont.lfWidth = +MAXFONTHEIGHT;
aLogFont.lfHeight = FRound( aLogFont.lfHeight / o_rFontScale );
}
-
hNewFont = ::CreateFontIndirectW( &aLogFont );
+
+ HDC hdcScreen = nullptr;
+ if( mbVirDev )
+ // only required for virtual devices, see below for details
+ hdcScreen = GetDC(nullptr);
if( hdcScreen )
{
// select font into screen hdc first to get an antialiased font
@@ -957,7 +956,15 @@ void WinSalGraphics::SetFont( const FontSelectPattern* pFont, int nFallbackLevel
mpWinFontEntry[ nFallbackLevel ] = reinterpret_cast<WinFontInstance*>( pFont->mpFontInstance );
HFONT hOldFont = nullptr;
- HFONT hNewFont = ImplDoSetFont(pFont, nullptr, mfFontScale[ nFallbackLevel ], hOldFont);
+ HFONT hNewFont = mpWinFontEntry[ nFallbackLevel ] ? mpWinFontEntry[ nFallbackLevel ]->GetHFONT() : nullptr;
+ if (!hNewFont)
+ {
+ hNewFont = ImplDoSetFont(pFont->GetFontSelectPattern(), pFont->GetFontFace(), mfFontScale[ nFallbackLevel ], hOldFont);
+ mpWinFontEntry[ nFallbackLevel ]->SetHFONT(hNewFont);
+ }
+ else
+ hOldFont = ::SelectFont( getHDC(), hNewFont );
+
mfCurrentFontScale = mfFontScale[nFallbackLevel];
if( !mhDefFont )
@@ -986,7 +993,6 @@ void WinSalGraphics::SetFont( const FontSelectPattern* pFont, int nFallbackLevel
// store new font in correct layer
if (mpWinFontEntry[nFallbackLevel])
{
- mpWinFontEntry[nFallbackLevel]->SetHFONT(hNewFont);
// now the font is live => update font face
const WinFontFace* pFontFace = static_cast<const WinFontFace*>(mpWinFontEntry[nFallbackLevel]->GetFontFace());
pFontFace->UpdateFromHDC(getHDC());