diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-12-10 20:44:03 +0200 |
---|---|---|
committer | خالد حسني <khaled@aliftype.com> | 2022-12-10 21:22:32 +0000 |
commit | 840904c05f4799986d78033f05b4d38f58a59994 (patch) | |
tree | a915b1324c07463c62dad3cc9e5b6ce2cb190e2e | |
parent | 7a3ecdd0ab66d516bd8934a7cd32654b85fef312 (diff) |
tdf#152267: Strike out changed to underline in small zoom
The font has bogus value in the regular style. Add configuration
support for ignoring metrics of such fonts, similar to what we do with
line metrics.
Change-Id: Ia7cfb44400601e89b8425c9a1144f630f67569f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143648
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Common.xcs | 12 | ||||
-rw-r--r-- | vcl/inc/impfontmetricdata.hxx | 1 | ||||
-rw-r--r-- | vcl/source/font/fontmetric.cxx | 23 |
3 files changed, 36 insertions, 0 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 4214307173da..e85864df367d 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -5443,6 +5443,18 @@ <it>DIN Light,1509,-503,1509,-483,1997,483</it> </value> </prop> + <prop oor:name="FontsDontUseUnderlineMetrics" oor:type="oor:string-list" oor:nillable="false"> + <info> + <desc> + Fonts where the underline or striketout metrics need to be ignored in order to draw the underline or strikeout correctly. + Fonts are identified by their name and the underline metrics (see fontmetric.cxx:ShouldNotUseUnderlineMetrics). + </desc> + </info> + <value> + <!-- tdf#152267 --> + <it>Liberation Serif,100,-123,100,420</it> + </value> + </prop> <prop oor:name="PluginsEnabled" oor:type="xs:boolean" oor:nillable="false"> <!-- UIHints: Tools Options Browser Other Plug-Ins Enable --> <info> diff --git a/vcl/inc/impfontmetricdata.hxx b/vcl/inc/impfontmetricdata.hxx index a94e41540755..5625cfa726b5 100644 --- a/vcl/inc/impfontmetricdata.hxx +++ b/vcl/inc/impfontmetricdata.hxx @@ -102,6 +102,7 @@ public: void ImplInitBaselines(LogicalFontInstance *pFontInstance); private: + bool ShouldNotUseUnderlineMetrics(int, int, int, int) const; bool ImplInitTextLineSizeHarfBuzz(LogicalFontInstance *pFontInstance); bool ShouldUseWinMetrics(int, int, int, int, int, int) const; diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx index a0959dfc6900..4ee3020b23f4 100644 --- a/vcl/source/font/fontmetric.cxx +++ b/vcl/source/font/fontmetric.cxx @@ -176,6 +176,25 @@ ImplFontMetricData::ImplFontMetricData( const vcl::font::FontSelectPattern& rFon SetStyleName( rFontSelData.GetStyleName() ); } +bool ImplFontMetricData::ShouldNotUseUnderlineMetrics(int nUnderlineSize, int nUnderlineOffset, + int nStrikeoutSize, + int nStrikeoutOffset) const +{ + OUString aFontIdentifier(GetFamilyName() + "," + OUString::number(nUnderlineSize) + "," + + OUString::number(nUnderlineOffset) + "," + + OUString::number(nStrikeoutSize) + "," + + OUString::number(nStrikeoutOffset)); + + css::uno::Sequence<OUString> rNoUnderlineMetricsList( + officecfg::Office::Common::Misc::FontsDontUseUnderlineMetrics::get()); + if (comphelper::findValue(rNoUnderlineMetricsList, aFontIdentifier) != -1) + { + SAL_INFO("vcl.gdi.fontmetric", "Not using underline metrics for: " << aFontIdentifier); + return true; + } + return false; +} + bool ImplFontMetricData::ImplInitTextLineSizeHarfBuzz(LogicalFontInstance* pFont) { auto* pHbFont = pFont->GetHbFont(); @@ -193,6 +212,10 @@ bool ImplFontMetricData::ImplInitTextLineSizeHarfBuzz(LogicalFontInstance* pFont if (!hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, &nStrikeoutOffset)) return false; + if (ShouldNotUseUnderlineMetrics(nUnderlineSize, nUnderlineOffset, nStrikeoutSize, + nStrikeoutOffset)) + return false; + double fScale = 0; pFont->GetScale(nullptr, &fScale); |