summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2022-08-30 14:16:24 +0300
committerTor Lillqvist <tml@collabora.com>2022-08-30 17:28:20 +0200
commit238c06f070b860ff1b6dac05b4d3c2b025a0cf3e (patch)
tree048961ba0383d63a264024bf386e8484427832d6 /desktop
parenteddd37280aa69da82cde91c9b9cc8139c6ec8cdc (diff)
Filter out well-known metric-compatible font substitutions
Change-Id: I9da63c173dcc926f577052b704284065b384f960 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139038 Tested-by: Tor Lillqvist <tml@collabora.com> Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx45
1 files changed, 45 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c902af328e0f..7ff195152f23 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2658,6 +2658,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:");