officecfg/registry/schema/org/openoffice/Office/Common.xcs |   12 ++++++
 vcl/inc/impfontmetricdata.hxx                              |    1 
 vcl/source/font/fontmetric.cxx                             |   23 +++++++++++++
 3 files changed, 36 insertions(+)

New commits:
commit 494d2e94b3c9cdf1ea527f21e6bc945fb03ea954
Author:     Khaled Hosny <kha...@aliftype.com>
AuthorDate: Sat Dec 10 20:44:03 2022 +0200
Commit:     خالد حسني <kha...@aliftype.com>
CommitDate: Sun Dec 11 04:55:31 2022 +0000

    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: خالد حسني <kha...@aliftype.com>
    (cherry picked from commit 840904c05f4799986d78033f05b4d38f58a59994)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143927

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);
 

Reply via email to