sc/source/filter/oox/stylesbuffer.cxx |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit 5a4ab8cb3a3fbf15de11afc5d8876aaa8a7784c9
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Feb 16 16:33:29 2024 +0000
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Fri Feb 16 21:55:33 2024 +0100

    for caching if a font has glyphs, strikethrough and underline don't matter
    
    Those aren't part of the font. Likewise it's safe to assume these days
    that if the glyph appears at one size it will exist at any size.
    
    The same isn't through for Bold/Italic. A font like Freesans has,
    or had at least, glyphs in one variant not in another. So don't treat
    those properties the same.
    
    Change-Id: Iccc291642dfe7e9d2cb06a241a575fd1e4a4bb9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163509
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/sc/source/filter/oox/stylesbuffer.cxx 
b/sc/source/filter/oox/stylesbuffer.cxx
index 22ebb2025833..a7be2cb93d7b 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -794,9 +794,19 @@ void Font::finalizeImport()
     if( !maUsedFlags.mbNameUsed )
         return;
 
+    // For caching if the font has glyphs then the underline and 
strike-through don't matter.
+    // Those aren't differences in the actual font, so just zero those out for 
the cache.
+    // The weight and pitch are different faces though, and there are some 
fonts with glyphs
+    // missing in one or other variant.
+    css::awt::FontDescriptor aGlyphDesc = maApiData.maDesc;
+    aGlyphDesc.Strikeout = css::awt::FontStrikeout::NONE;
+    aGlyphDesc.Underline = css::awt::FontUnderline::NONE;
+    // Never seen that to be the case for font *sizes* however, so we can use 
a uniform 10pt size
+    aGlyphDesc.Height = 200;
+
     bool bHasAsian(false), bHasCmplx(false), bHasLatin(false);
     FontClassificationMap& rFontClassificationCache = 
getFontClassificationCache();
-    if (auto found = rFontClassificationCache.find(maApiData.maDesc); found != 
rFontClassificationCache.end())
+    if (auto found = rFontClassificationCache.find(aGlyphDesc); found != 
rFontClassificationCache.end())
     {
         FontClassification eClassification = found->second;
         bHasAsian = bool(eClassification & FontClassification::Asian);
@@ -810,7 +820,7 @@ void Font::finalizeImport()
         if( !xDevice.is() )
             return;
 
-        Reference< XFont2 > xFont( xDevice->getFont( maApiData.maDesc ), 
UNO_QUERY );
+        Reference< XFont2 > xFont( xDevice->getFont(aGlyphDesc), UNO_QUERY );
         if( !xFont.is() )
             return;
 
@@ -851,7 +861,7 @@ void Font::finalizeImport()
             eClassification = eClassification | FontClassification::Cmplx;
         if (bHasLatin)
             eClassification = eClassification | FontClassification::Latin;
-        rFontClassificationCache.emplace(maApiData.maDesc, eClassification);
+        rFontClassificationCache.emplace(aGlyphDesc, eClassification);
     }
 
     lclSetFontName( maApiData.maLatinFont, maApiData.maDesc, bHasLatin );

Reply via email to