sc/source/filter/oox/stylesbuffer.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
New commits: commit dd89169a16011a389190cff03f82da0d5f26a46c 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:52:48 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/+/163516 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> 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 e38b5cd13002..dab5c2de145f 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -793,9 +793,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); @@ -809,7 +819,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; @@ -850,7 +860,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 );