summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-10-28 14:21:20 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-10-29 10:13:54 +0100
commitf39e4b6b6f8aa8b4af22b6eb30a52e98cd5a6455 (patch)
treedb80dd3b18cadb9ab060885a9e8fd0f9c6632133 /drawinglayer
parent8beafb2849ab10e659d0c181ea1069cb9015d784 (diff)
Revert "tdf#127471 Remove font width scaling hack"
This reverts commit 8891a2fc2a4bf86add68691b7ac167a07a8add84. Reason for revert: Causes regressions like tdf#136891 Change-Id: I940c447bec38231b666eeac4212f09e22117504e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104847 Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/primitive2d/textlayoutdevice.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
index 2820ebfbc03d..0730dc397707 100644
--- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
@@ -427,6 +427,20 @@ namespace drawinglayer::primitive2d
aRetval.SetPitch(rFontAttribute.getMonospaced() ? PITCH_FIXED : PITCH_VARIABLE);
aRetval.SetLanguage(LanguageTag::convertToLanguageType( rLocale, false));
+#ifdef _WIN32
+ // for WIN32 systems, correct the FontWidth if FontScaling is used
+ if(bFontIsScaled && nHeight > 0)
+ {
+ const FontMetric aUnscaledFontMetric(Application::GetDefaultDevice()->GetFontMetric(aRetval));
+
+ if(aUnscaledFontMetric.GetAverageFontWidth() > 0)
+ {
+ const double fScaleFactor(static_cast<double>(nWidth) / static_cast<double>(nHeight));
+ const sal_uInt32 nScaledWidth(basegfx::fround(static_cast<double>(aUnscaledFontMetric.GetAverageFontWidth()) * fScaleFactor));
+ aRetval.SetAverageFontWidth(nScaledWidth);
+ }
+ }
+#endif
// handle FontRotation (if defined)
if(!basegfx::fTools::equalZero(fFontRotation))
{