summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2023-03-18 00:52:04 +0200
committerخالد حسني <khaled@aliftype.com>2023-03-18 02:08:39 +0000
commit6f54b54ec3dc51fb8824adb08620fde4c70d10f2 (patch)
treec6d7246740e33b5797f349a0d790a0762bbefa76
parentf30e9a6143128421c8fabd2ebb4eafcb43c1e16a (diff)
tdf#154235: Ignore underline metrics for all Liberation fonts
They all have bad metrics and we are better off synthesising metrics for them instead. Also simplify the exception list to only use family name. Change-Id: I9e13bc05bdf56a31e9805fcd348439d191ed3a3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149072 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs6
-rw-r--r--vcl/inc/impfontmetricdata.hxx2
-rw-r--r--vcl/source/font/fontmetric.cxx20
3 files changed, 11 insertions, 17 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index fb262b8e7ab3..714fa8ccc485 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -5613,8 +5613,10 @@
</desc>
</info>
<value>
- <!-- tdf#152267 -->
- <it>Liberation Serif,100,-123,100,420</it>
+ <!-- tdf#152267, tdf#154235 -->
+ <it>Liberation Serif</it>
+ <it>Liberation Sans</it>
+ <it>Liberation Mono</it>
</value>
</prop>
<prop oor:name="PluginsEnabled" oor:type="xs:boolean" oor:nillable="false">
diff --git a/vcl/inc/impfontmetricdata.hxx b/vcl/inc/impfontmetricdata.hxx
index 5625cfa726b5..63394a93eb23 100644
--- a/vcl/inc/impfontmetricdata.hxx
+++ b/vcl/inc/impfontmetricdata.hxx
@@ -102,7 +102,7 @@ public:
void ImplInitBaselines(LogicalFontInstance *pFontInstance);
private:
- bool ShouldNotUseUnderlineMetrics(int, int, int, int) const;
+ bool ShouldNotUseUnderlineMetrics() 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 3f87950d5314..8a998c6815c6 100644
--- a/vcl/source/font/fontmetric.cxx
+++ b/vcl/source/font/fontmetric.cxx
@@ -176,23 +176,16 @@ ImplFontMetricData::ImplFontMetricData( const vcl::font::FontSelectPattern& rFon
SetStyleName( rFontSelData.GetStyleName() );
}
-bool ImplFontMetricData::ShouldNotUseUnderlineMetrics(int nUnderlineSize, int nUnderlineOffset,
- int nStrikeoutSize,
- int nStrikeoutOffset) const
+bool ImplFontMetricData::ShouldNotUseUnderlineMetrics() const
{
if (utl::ConfigManager::IsFuzzing())
return false;
- 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)
+ if (comphelper::findValue(rNoUnderlineMetricsList, GetFamilyName()) != -1)
{
- SAL_INFO("vcl.gdi.fontmetric", "Not using underline metrics for: " << aFontIdentifier);
+ SAL_INFO("vcl.gdi.fontmetric", "Not using underline metrics for: " << GetFamilyName());
return true;
}
return false;
@@ -200,6 +193,9 @@ bool ImplFontMetricData::ShouldNotUseUnderlineMetrics(int nUnderlineSize, int nU
bool ImplFontMetricData::ImplInitTextLineSizeHarfBuzz(LogicalFontInstance* pFont)
{
+ if (ShouldNotUseUnderlineMetrics())
+ return false;
+
auto* pHbFont = pFont->GetHbFont();
hb_position_t nUnderlineSize;
@@ -215,10 +211,6 @@ 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);