svx/source/svdraw/svdpdf.cxx | 64 +++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 17 deletions(-)
New commits: commit a2bb039e7d8f17881dee33ff767101fc255185c3 Author: Caolán McNamara <[email protected]> AuthorDate: Tue Oct 14 12:48:26 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 17 09:24:09 2025 +0200 do conversion of ttf if FontToUnicode data is present example has name keyed ttf font with glyphs at arbitrary locations Change-Id: I270d0107c7a84103449e593a21cf567f43f1e610 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192384 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 9f34c115344e..cc9ea95efb19 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -312,13 +312,11 @@ void ImpSdrPdfImport::CollectFonts() SAL_WARN("sd.filter", "ttf not written"); else SAL_INFO("sd.filter", "ttf written to: " << fileUrl); - // TODO: Only the PFB case will rename later subsets of the same font name to - // separate font names to keep the various subsets from clobbering each other. - if (!bTTF) + std::vector<uint8_t> aToUnicodeData; + if (!pPageObject->getFontToUnicode(font, aToUnicodeData)) + SAL_WARN("sd.filter", "that's maybe worrying"); + if (!bTTF || !aToUnicodeData.empty()) { - std::vector<uint8_t> aToUnicodeData; - if (!pPageObject->getFontToUnicode(font, aToUnicodeData)) - SAL_WARN("sd.filter", "that's maybe worrying"); EmbeddedFontInfo fontInfo = convertToOTF(*pSubSetInfo, fileUrl, sFontName, sPostScriptName, sFontFileName, aToUnicodeData); commit 1a87d4a46b91297d542b48e77b3391c14222e465 Author: Caolán McNamara <[email protected]> AuthorDate: Wed Oct 15 13:07:33 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Oct 17 09:24:00 2025 +0200 transfer single point ranges from bfcharranges to bfcharlines Change-Id: I764c76792f2d50728e803bba07c6844a989ec45b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192451 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index a3f3e5ee42de..9f34c115344e 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -1316,9 +1316,8 @@ static void buildCMapAndFeatures(const OUString& CMapUrl, SvFileStream& Features if (!bfcharranges.empty()) { - assert(!bNameKeyed); - OString beginline = OString::number(bfcharranges.size()) + " begincidrange"; - CMap.WriteLine(beginline); + std::vector<OString> cidranges; + for (const auto& charrange : bfcharranges) { assert(charrange[0] == '<'); @@ -1334,29 +1333,62 @@ static void buildCMapAndFeatures(const OUString& CMapUrl, SvFileStream& Features sal_Int32 nGlyphRangeLen = nGlyphRangeEnd - nGlyphRangeStart; - assert(nGlyphRangeLen > 0); + assert(nGlyphRangeLen >= 0); OString sChars(o3tl::trim(remainder.subView(nEnd + 1))); assert(sChars[0] == '<' && sChars[sChars.getLength() - 1] == '>'); + + // move simple single glyph->char ranges to bfcharlines instead + if (nGlyphRangeLen == 0) + { + OStringBuffer aBuffer("<"); + appendFourByteHex(aBuffer, nGlyphRangeStart); + aBuffer.append("> " + sChars); + bfcharlines.push_back(aBuffer.toString()); + continue; + } + OString sContents = sChars.copy(1, sChars.getLength() - 2); - //TODO, it might be that there are cases of ligatures here too in - //which case I presume that it can only be with a range of a single - //glyph(?). If that's how it works, then we could push the entry - //instead into bfcharlines. + //The assumption that is that cases of ligatures are with a range + //of a single glyph(?). In which case we have pushed such entries + //into bfcharlines above. assert(sContents.getLength() == 4); sal_Int32 nCharRangeStart = o3tl::toInt32(sContents, 16); + sal_Int32 nCharRangeEnd = nCharRangeStart + nGlyphRangeLen; + + // move simple single glyph->char ranges to bfcharlines instead + if (nCharRangeStart == nCharRangeEnd) + { + OStringBuffer aBuffer("<"); + appendFourByteHex(aBuffer, nGlyphRangeStart); + aBuffer.append("> <"); + appendFourByteHex(aBuffer, nCharRangeStart); + aBuffer.append(">"); + bfcharlines.push_back(aBuffer.toString()); + continue; + } + OStringBuffer aBuffer("<"); appendFourByteHex(aBuffer, nCharRangeStart); aBuffer.append("> <"); - sal_Int32 nCharRangeEnd = nCharRangeStart + nGlyphRangeLen; appendFourByteHex(aBuffer, nCharRangeEnd); aBuffer.append("> "_ostr + OString::number(nGlyphRangeStart)); OString cidrangeline = aBuffer.toString(); + cidranges.push_back(cidrangeline); rSubSetInfo.aComponents.back().glyphRangesToChars[nGlyphRangeStart] = Range(nCharRangeStart, nCharRangeEnd); - CMap.WriteLine(cidrangeline); } - CMap.WriteLine("endcidrange"); + + if (!cidranges.empty()) + { + // searching for real world examples where this occurs + assert(!bNameKeyed); + OString beginline = OString::number(cidranges.size()) + " begincidrange"; + CMap.WriteLine(beginline); + for (const auto& rLine : cidranges) + CMap.WriteLine(rLine); + CMap.WriteLine("endcidrange"); + } } if (!bfcharlines.empty())
