drawinglayer/source/primitive2d/textlayoutdevice.cxx |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

New commits:
commit d578bd6582131e52c1752f16f21ba2164ccdc970
Author:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
AuthorDate: Wed Oct 28 14:22:45 2020 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Oct 29 10:10:54 2020 +0100

    Revert "tdf#127471 Remove font width scaling hack"
    
    This reverts commit d935040e8f586ccb9dcf7fef30d72715a9f0ac98.
    
    Reason for revert: Causes regressions like tdf#136891
    
    Change-Id: Ief7ddf084161ba143cd5ec40c9a0f3645f592e74
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104948
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx 
b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
index de2f76cb74f6..e3e57b2b5997 100644
--- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
@@ -401,6 +401,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))
             {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to