svx/source/svdraw/svdpdf.cxx | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
New commits: commit 471415fbfc901a35e64808d90e89dd1257f32ffa Author: Caolán McNamara <[email protected]> AuthorDate: Tue Sep 30 12:18:00 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Oct 2 08:44:09 2025 +0200 The cid.CIDFontName can mismatch expectations as well Change-Id: Ifae9c2bc7466f478b17479c8eddb65bf77487d20 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191680 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 83a4e83d8c1c..3ad8a2ca651e 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -952,8 +952,8 @@ static bool isSimpleFamilyName(std::string_view Weight) || Weight == "BoldItalic"; } -static void rewriteBrokenFontName(std::string_view brokenName, std::string_view fixedName, - const OUString& pfaCIDUrl) +static void rewriteBrokenFontName(std::string_view brokenName, std::string_view brokenCIDName, + std::string_view fixedName, const OUString& pfaCIDUrl) { OUString oldCIDUrl = pfaCIDUrl + ".broken"; if (osl::File::move(pfaCIDUrl, oldCIDUrl) != osl::File::E_None) @@ -962,17 +962,25 @@ static void rewriteBrokenFontName(std::string_view brokenName, std::string_view return; } - const OString sBrokenLine = "/FontName /"_ostr + brokenName + " def"_ostr; - const OString sFixedLine = "/FontName /"_ostr + fixedName + " def"_ostr; + const OString sBrokenFontLine = "/FontName /"_ostr + brokenName + " def"_ostr; + const OString sFixedFontLine = "/FontName /"_ostr + fixedName + " def"_ostr; + + const OString sBrokenCIDFontLine = "/CIDFontName /"_ostr + brokenCIDName + " def"_ostr; + const OString sFixedCIDFontLine = "/CIDFontName /"_ostr + fixedName + " def"_ostr; SvFileStream input(oldCIDUrl, StreamMode::READ); SvFileStream output(pfaCIDUrl, StreamMode::WRITE | StreamMode::TRUNC); OString sLine; while (input.ReadLine(sLine)) { - if (sLine == sBrokenLine) + if (sLine == sBrokenFontLine) + { + output.WriteLine(sFixedFontLine); + continue; + } + else if (sLine == sBrokenCIDFontLine) { - output.WriteLine(sFixedLine); + output.WriteLine(sFixedCIDFontLine); continue; } output.WriteLine(sLine); @@ -993,7 +1001,7 @@ static bool toPfaCID(SubSetInfo& rSubSetInfo, const OUString& fileUrl, OUString nameToCIDMapUrl = fileUrl + u".nametocidmap"; OUString toMergedMapUrl = fileUrl + u".tomergedmap"; - OString version, Notice, FullName, FamilyName, srcFontType; + OString version, Notice, FullName, FamilyName, CIDFontName, srcFontType; FontName = postScriptName.toUtf8(); std::map<sal_Int32, OString> glyphIndexToName; @@ -1039,6 +1047,14 @@ static bool toPfaCID(SubSetInfo& rSubSetInfo, const OUString& fileUrl, << postScriptName << ">"); continue; } + if (extractEntry(sLine, "cid.CIDFontName", CIDFontName)) + { + SAL_WARN_IF(CIDFontName != postScriptName.toUtf8(), "sd.filter", + "expected that cid.CIDFontName of <" + << CIDFontName << "> matches PostScriptName of <" << postScriptName + << ">"); + continue; + } if (sLine.startsWith("glyph[")) { sal_Int32 i = 6; @@ -1149,7 +1165,7 @@ static bool toPfaCID(SubSetInfo& rSubSetInfo, const OUString& fileUrl, } if (bBrokenFontName) - rewriteBrokenFontName(FontName, postScriptName.toUtf8(), pfaCIDUrl); + rewriteBrokenFontName(FontName, CIDFontName, postScriptName.toUtf8(), pfaCIDUrl); return true; }
