You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2026/06/13 14:16:47 UTC

svn commit: r1935241 - pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font

Author: tilman
Date: Sat Jun 13 14:16:47 2026
New Revision: 1935241

Log:
PDFBOX-6211: add test for 6172

Modified:
   pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java

Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java	Sat Jun 13 14:16:43 2026	(r1935240)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java	Sat Jun 13 14:16:47 2026	(r1935241)
@@ -32,6 +32,8 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.fontbox.ttf.OTFParser;
+import org.apache.fontbox.ttf.OpenTypeFont;
 import org.apache.fontbox.ttf.TTFParser;
 import org.apache.fontbox.ttf.TrueTypeCollection;
 import org.apache.fontbox.ttf.TrueTypeFont;
@@ -531,4 +533,27 @@ public class PDFontTest
         Assert.assertEquals("\u0391 \u2126", text.trim());
         doc.close();
     }
+
+    // PDFBOX-6172: test that exception is thrown on otf font with CID and GID not identical.
+    @Test
+    public void testPDFBox6172() throws IOException
+    {
+        PDDocument document = new PDDocument();
+        InputStream is = new FileInputStream("target/fonts/NotoSansSC-Regular.otf");
+        OpenTypeFont otf = new OTFParser().parse(is);
+        try
+        {
+            PDType0Font.load(document, otf, false);
+        }
+        catch (IllegalStateException ex)
+        {
+            Assert.assertEquals("CID and GID not identical: CID 628 != GID 372, use a ttf font instead", ex.getMessage());
+            return;
+        }
+        finally
+        {
+            document.close();
+        }
+        Assert.fail("should have thrown IllegalStateException");
+    }
 }