svx/source/svdraw/svdpdf.cxx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
New commits: commit 8d5b41af4659814a541a315550b993a8293906d5 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Oct 23 19:48:31 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Jan 13 12:42:36 2026 +0100 handle multiple glyphs mapped to the same unicode character Just use the first seen and drop the other in the absense of a better idea. Change-Id: I591ba777be56cec5f4c14f850b00715920b73d94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197081 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 9b9ee5c0e38f..2ad97c9c4ab0 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -83,6 +83,7 @@ #include <osl/diagnose.h> #include <osl/file.hxx> #include <unicode/normalizer2.h> +#include <set> using namespace com::sun::star; @@ -1375,8 +1376,8 @@ static void buildCMapAndFeatures(const OUString& CMapUrl, SvFileStream& Features if (!tud.bfcharlines.empty()) { - OString beginline = OString::number(tud.bfcharlines.size()) + " begincidchar"; - CMap.WriteLine(beginline); + std::set<OString> usedCodes; + std::vector<OString> outputlines; for (const auto& charline : tud.bfcharlines) { assert(charline[0] == '<'); @@ -1398,12 +1399,25 @@ static void buildCMapAndFeatures(const OUString& CMapUrl, SvFileStream& Features if (!sLegacy.isEmpty()) ligatureGlyphToChars[nGlyphIndex] = sLegacy; } + if (usedCodes.insert(sChars).second == false) + { + // This can happen with e.g. unicode '1' mapped to from two variants of that glyph, + // in the absense of a better idea, prefer the first one seen + SAL_INFO("sd.filter", "code: " << sChars << " for glyph " << nGlyphIndex + << " already used earlier"); + continue; + } OString cidcharline = sChars + " " + OString::number(nGlyphIndex); glyphs.push_back(nGlyphIndex); rSubSetInfo.aComponents.back().glyphToChars[nGlyphIndex] = sContents; rSubSetInfo.aComponents.back().charsToGlyph[sContents] = nGlyphIndex; - CMap.WriteLine(cidcharline); + outputlines.push_back(cidcharline); } + + OString beginline = OString::number(outputlines.size()) + " begincidchar"; + CMap.WriteLine(beginline); + for (const auto& cidcharline : outputlines) + CMap.WriteLine(cidcharline); CMap.WriteLine("endcidchar"); rSubSetInfo.aComponents.back().nGlyphCount = tud.bfcharlines.size();
