From 2f529db909f99a2a503ca0347a9d70742b7f05ba Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 23 Mar 2018 14:41:01 +0100 Subject: tdf#116498 Use win metrics for 'DIN Light' font This adds a special treatment for fonts which rely on the win metrics for correct line spacing calculation. At the moment, only 'DIN Light' is known to need that treatment. Change-Id: Idd9fd6f63083ab7a706e0cbcd33a947d4949d4e9 Reviewed-on: https://gerrit.libreoffice.org/53962 Reviewed-by: Samuel Mehrbrodt Tested-by: Samuel Mehrbrodt --- .../schema/org/openoffice/Office/Common.xcs | 12 ++++++++++ vcl/inc/impfontmetricdata.hxx | 3 +++ vcl/source/font/fontmetric.cxx | 26 +++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 88b6f3b07f1b..3d73cc94deb2 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -5295,6 +5295,18 @@ EmojiOne Color + + + + Fonts where the win metrics need to be considered in order to display the font correctly + Fonts are identified by their name and the font metrics (see fontmetric.cxx:ShouldUseWinMetrics). + + + + + DIN Light,1509,-503,1509,-483,1997,483 + + diff --git a/vcl/inc/impfontmetricdata.hxx b/vcl/inc/impfontmetricdata.hxx index f08e86fdc914..28e0ab3798a2 100644 --- a/vcl/inc/impfontmetricdata.hxx +++ b/vcl/inc/impfontmetricdata.hxx @@ -23,6 +23,7 @@ #include #include #include "fontattributes.hxx" +#include "sft.hxx" #include @@ -96,6 +97,8 @@ public: int nUPEM); private: + bool ShouldUseWinMetrics(vcl::TTGlobalFontInfo& rInfo); + // font instance attributes from the font request long mnHeight; // Font size long mnWidth; // Reference Width diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx index b619219c44ce..b54e41a1202a 100644 --- a/vcl/source/font/fontmetric.cxx +++ b/vcl/source/font/fontmetric.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -28,6 +29,8 @@ #include #include +#include + #include #include #include @@ -398,6 +401,27 @@ void ImplFontMetricData::ImplInitFlags( const OutputDevice* pDev ) SetFullstopCenteredFlag( bCentered ); } +bool ImplFontMetricData::ShouldUseWinMetrics(vcl::TTGlobalFontInfo& rInfo) +{ + OUString aFontIdentifier( + GetFamilyName() + "," + + OUString::number(rInfo.ascender) + "," + OUString::number(rInfo.descender) + "," + + OUString::number(rInfo.typoAscender) + "," + OUString::number(rInfo.typoDescender) + "," + + OUString::number(rInfo.winAscent) + "," + OUString::number(rInfo.winDescent)); + + css::uno::Sequence rWinMetricFontList( + officecfg::Office::Common::Misc::FontsUseWinMetrics::get()); + for (int i = 0; i < rWinMetricFontList.getLength(); ++i) + { + if (aFontIdentifier == rWinMetricFontList[i]) + { + SAL_INFO("vcl.gdi.fontmetric", "Using win metrics for: " << aFontIdentifier); + return true; + } + } + return false; +} + /* * Calculate line spacing: * @@ -440,7 +464,7 @@ void ImplFontMetricData::ImplCalcLineSpacing(const std::vector& rHheaDa if (rInfo.winAscent || rInfo.winDescent || rInfo.typoAscender || rInfo.typoDescender) { - if (fAscent == 0 && fDescent == 0) + if (ShouldUseWinMetrics(rInfo) || (fAscent == 0.0 && fDescent == 0.0)) { fAscent = rInfo.winAscent * fScale; fDescent = rInfo.winDescent * fScale; -- cgit