[poppler] poppler/GfxFont.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat May 27 22:53:34 UTC 2023


 poppler/GfxFont.cc |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

New commits:
commit 333b04802a3a9dbdb0d0e0caec553fd1037c4c92
Author: Khaled Hosny <khaled at aliftype.com>
Date:   Mon May 8 18:35:10 2023 +0300

    Try harder to get Type 3 font name
    
    There is no BaseFont in Type 3 fonts, so we first try fontDescriptor’s
    FontName, but fontDescriptor is optional so we then try the Name key.
    
    Fixes #1396

diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 954fb8b3..20e02bb0 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -209,6 +209,25 @@ std::unique_ptr<GfxFont> GfxFont::makeFont(XRef *xref, const char *tagA, Ref idA
         name = obj1.getName();
     }
 
+    // There is no BaseFont in Type 3 fonts, try fontDescriptor.FontName
+    if (!name) {
+        Object fontDesc = fontDict->lookup("FontDescriptor");
+        if (fontDesc.isDict()) {
+            Object obj2 = fontDesc.dictLookup("FontName");
+            if (obj2.isName()) {
+                name = obj2.getName();
+            }
+        }
+    }
+
+    // As a last resort try the Name key
+    if (!name) {
+        Object obj2 = fontDict->lookup("Name");
+        if (obj2.isName()) {
+            name = obj2.getName();
+        }
+    }
+
     // get embedded font ID and font type
     typeA = getFontType(xref, fontDict, &embFontIDA);
 


More information about the poppler mailing list