svx/source/svdraw/svdpdf.cxx |   40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

New commits:
commit 66299196a134894b4aa10ff03d22a963af540a46
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Sep 30 12:22:40 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Wed Oct 15 09:23:49 2025 +0200

    If there is no font version, use the cid font version
    
    Change-Id: Ia350f768dcb75e5e6f5df79c3d3fe938113c9d04
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191681
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 440a09f17ee7019cc94bb7f864a146d374a7a686)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192350
    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 086aba1d4b97..711532b65c5b 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1004,7 +1004,7 @@ static bool toPfaCID(SubSetInfo& rSubSetInfo, const 
OUString& fileUrl,
     OUString nameToCIDMapUrl = fileUrl + u".nametocidmap";
     OUString toMergedMapUrl = fileUrl + u".tomergedmap";
 
-    OString version, Notice, FullName, FamilyName, CIDFontName, srcFontType;
+    OString version, Notice, FullName, FamilyName, CIDFontName, 
CIDFontVersion, srcFontType;
     FontName = postScriptName.toUtf8();
     std::map<sal_Int32, OString> glyphIndexToName;
 
@@ -1032,6 +1032,8 @@ static bool toPfaCID(SubSetInfo& rSubSetInfo, const 
OUString& fileUrl,
     {
         if (extractEntry(sLine, "version", version))
             continue;
+        if (extractEntry(sLine, "cid.CIDFontVersion", CIDFontVersion))
+            continue;
         if (extractEntry(sLine, "Notice", Notice))
             continue;
         if (extractEntry(sLine, "FullName", FullName))
@@ -1101,7 +1103,11 @@ static bool toPfaCID(SubSetInfo& rSubSetInfo, const 
OUString& fileUrl,
         }
     }
     SAL_INFO("sd.filter", "details are: " << version << Notice << FullName << 
FamilyName << Weight
-                                          << srcFontType << FontName);
+                                          << srcFontType << FontName << 
CIDFontName
+                                          << CIDFontVersion);
+
+    if (version.isEmpty())
+        version = CIDFontVersion;
 
     // Always create cidFontInfo, we will need it if we need to merge fonts
     OString AdobeCopyright, Trademark;
commit f65479d52bc8d66e38f02bcd4278e9d3160c0c9d
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Sep 30 12:18:00 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Wed Oct 15 09:23:37 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]>
    (cherry picked from commit 471415fbfc901a35e64808d90e89dd1257f32ffa)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192349
    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 6dce90ac3c1f..086aba1d4b97 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -955,8 +955,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)
@@ -965,17 +965,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);
@@ -996,7 +1004,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;
 
@@ -1042,6 +1050,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;
@@ -1152,7 +1168,7 @@ static bool toPfaCID(SubSetInfo& rSubSetInfo, const 
OUString& fileUrl,
     }
 
     if (bBrokenFontName)
-        rewriteBrokenFontName(FontName, postScriptName.toUtf8(), pfaCIDUrl);
+        rewriteBrokenFontName(FontName, CIDFontName, postScriptName.toUtf8(), 
pfaCIDUrl);
 
     return true;
 }

Reply via email to