desktop/source/lib/init.cxx | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
New commits: commit 76e908371cdc89223f98483e749af21b2e9357a6 Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Tue Aug 30 14:16:24 2022 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Thu Sep 1 12:25:49 2022 +0200 Filter out well-known metric-compatible font substitutions Change-Id: I9da63c173dcc926f577052b704284065b384f960 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139056 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Jan Holesovsky <ke...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index bf37ae65c9d0..3c5749539ea2 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2670,6 +2670,51 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis, } } + // Filter out substitutions where a proprietary font has been substituded by a + // metric-compatible one. Onviously this is just a heuristic and implemented only for some + // well-known cases. + + for (std::size_t i = 0; i < aFontMappingUseData.size();) + { + // Again, handle only cases where the original font does not include a style. Unclear + // whether there ever will be a style part included in the mOriginalFont. + + if (aFontMappingUseData[i].mOriginalFont.indexOf('/') == -1) + { + bool bSubstitutedByMetricCompatible = false; + for (const auto &j : aFontMappingUseData[i].mUsedFonts) + { + if ((aFontMappingUseData[i].mOriginalFont == "Arial" && + j.startsWith("Liberation Sans/")) || + (aFontMappingUseData[i].mOriginalFont == "Times New Roman" && + j.startsWith("Liberation Serif/")) || + (aFontMappingUseData[i].mOriginalFont == "Courier New" && + j.startsWith("Liberation Mono/")) || + (aFontMappingUseData[i].mOriginalFont == "Arial Narrow" && + j.startsWith("Liberation Sans Narrow/")) || + (aFontMappingUseData[i].mOriginalFont == "Cambria" && + j.startsWith("Caladea/")) || + (aFontMappingUseData[i].mOriginalFont == "Calibri" && + j.startsWith("Carlito/")) || + (aFontMappingUseData[i].mOriginalFont == "Palatino Linotype" && + j.startsWith("P052/"))) + { + bSubstitutedByMetricCompatible = true; + break; + } + } + + if (bSubstitutedByMetricCompatible) + aFontMappingUseData.erase(aFontMappingUseData.begin() + i); + else + i++; + } + else + { + i++; + } + } + if (aFontMappingUseData.size() > 0) { SAL_INFO("lok.fontsubst", "================ Pruned substitutions:");