summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-09-04 17:24:03 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2018-09-04 19:20:53 +0200
commit7e7a1ff3926e86705199aa9814089e90f01c02ed (patch)
tree815837e8490b6f9fe23f2fe7b691cbfe144455d0 /vcl/win
parent6db1448eaa30ac7e2ebc64ad561b1d4a2c6e4ff2 (diff)
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. Change-Id: I1c9a9e3414677d77f0f007d7ace653bb53b8474d Reviewed-on: https://gerrit.libreoffice.org/59988 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/salfont.cxx38
1 files changed, 18 insertions, 20 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 969cefd17279..8c1a6651bbd5 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -851,11 +851,6 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont,
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_rFont, i_pFontFace, aLogFont );
@@ -878,8 +873,12 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont,
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
@@ -934,12 +933,18 @@ void WinSalGraphics::SetFont(LogicalFontInstance* pFont, int nFallbackLevel)
return;
}
- // WinSalGraphics::GetEmbedFontData does not set mpFontInstance
- // since it is interested in font file data only.
- mpWinFontEntry[ nFallbackLevel ] = reinterpret_cast<WinFontInstance*>(pFont);
+ mpWinFontEntry[ nFallbackLevel ] = static_cast<WinFontInstance*>(pFont);
HFONT hOldFont = nullptr;
- HFONT hNewFont = ImplDoSetFont(pFont->GetFontSelectPattern(), pFont->GetFontFace(), mfFontScale[ nFallbackLevel ], hOldFont);
+ HFONT hNewFont = mpWinFontEntry[ nFallbackLevel ]->GetHFONT();
+ 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 )
@@ -962,16 +967,9 @@ void WinSalGraphics::SetFont(LogicalFontInstance* 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());
- }
- else
- mhFonts[ nFallbackLevel ] = hNewFont;
+ // now the font is live => update font face
+ const WinFontFace* pFontFace = static_cast<const WinFontFace*>(mpWinFontEntry[nFallbackLevel]->GetFontFace());
+ pFontFace->UpdateFromHDC(getHDC());
}
void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFallbackLevel )