diff options
author | Aron Budea <aron.budea@collabora.com> | 2020-11-12 07:02:57 +0100 |
---|---|---|
committer | Aron Budea <aron.budea@collabora.com> | 2020-11-12 21:43:54 +0100 |
commit | 5db34391ebf7a51d26196f3fe28f3d9327ea2eb6 (patch) | |
tree | 0e12d96578a19c21b17db5c1131d374678357510 /drawinglayer/source | |
parent | 8927bea9fafae63898f1d6099af7c305c063a067 (diff) |
Revert "tdf#127471 Remove font width scaling hack"
This reverts commit 8891a2fc2a4bf86add68691b7ac167a07a8add84.
Reason: Causes regression, tdf#136891
Revert #2 "-Werror,-Wunused-variable (clang-cl)"
This reverts commit a879b15d59618e73797ad779666f72cd040ff99a.
Reason: Variables are necessary for the other revert.
Change-Id: Ic1c3efe22f5c069f666ea6ba3193612cb44203ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105620
Tested-by: Jenkins
Reviewed-by: Aron Budea <aron.budea@collabora.com>
Diffstat (limited to 'drawinglayer/source')
-rw-r--r-- | drawinglayer/source/primitive2d/textlayoutdevice.cxx | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index 2820ebfbc03d..43afce5d0f1e 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -394,6 +394,8 @@ namespace drawinglayer::primitive2d { // detect FontScaling const sal_uInt32 nHeight(basegfx::fround(fabs(fFontScaleY))); + const sal_uInt32 nWidth(basegfx::fround(fabs(fFontScaleX))); + const bool bFontIsScaled(nHeight != nWidth); #ifdef _WIN32 // for WIN32 systems, start with creating an unscaled font. If FontScaling @@ -403,15 +405,12 @@ namespace drawinglayer::primitive2d rFontAttribute.getFamilyName(), rFontAttribute.getStyleName(), Size(0, nHeight)); - (void)fFontScaleX; #else // for non-WIN32 systems things are easier since these accept a Font creation // with initially nWidth != nHeight for FontScaling. Despite that, use zero for // FontWidth when no scaling is used to explicitly have that zero when e.g. the // Font would be recorded in a MetaFile (The MetaFile FontAction WILL record a // set FontWidth; import that in a WIN32 system, and trouble is there) - const sal_uInt32 nWidth(basegfx::fround(fabs(fFontScaleX))); - const bool bFontIsScaled(nHeight != nWidth); vcl::Font aRetval( rFontAttribute.getFamilyName(), rFontAttribute.getStyleName(), @@ -427,6 +426,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)) { |