pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1814530 - /pdfbox/branches/2.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java
Date Tue, 07 Nov 2017 18:39:14 GMT
Author: tilman
Date: Tue Nov  7 18:39:14 2017
New Revision: 1814530

URL: http://svn.apache.org/viewvc?rev=1814530&view=rev
Log:
PDFBOX-3997: add test

Modified:
    pdfbox/branches/2.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java

Modified: pdfbox/branches/2.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java?rev=1814530&r1=1814529&r2=1814530&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java (original)
+++ pdfbox/branches/2.0/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java Tue Nov
 7 18:39:14 2017
@@ -17,9 +17,16 @@
 package org.apache.fontbox.cmap;
 
 import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 
 import junit.framework.TestCase;
 
+import static junit.framework.TestCase.assertEquals;
+import org.apache.fontbox.ttf.CmapSubtable;
+import org.apache.fontbox.ttf.TTFParser;
+import org.apache.fontbox.ttf.TrueTypeFont;
+
 /**
  * This will test the CMap implementation.
  *
@@ -40,4 +47,30 @@ public class TestCMap extends TestCase
         cMap.addCharMapping(bs, "a");
         assertTrue("a".equals(cMap.toUnicode(200)));
     }
+
+    /**
+     * PDFBOX-3997: test unicode that is above the basic bultilingual plane, here: helicopter
+     * symbol, or D83D DE81 in the Noto Emoji font.
+     *
+     * @throws IOException
+     */
+    public void testPDFBox3997() throws IOException
+    {
+        InputStream is;
+        try
+        {
+            System.out.println("Downloading Noto Emoji font...");
+            is = new URL("https://issues.apache.org/jira/secure/attachment/12896461/NotoEmoji-Regular.ttf").openStream();
+            System.out.println("Download finished!");
+        }
+        catch (IOException ex)
+        {
+            System.err.println("Noto Emoji font could not be downloaded, test skipped");
+            return;
+        }
+        TrueTypeFont ttf = new TTFParser().parse(is);
+        CmapSubtable cmap = ttf.getUnicodeCmap(false);
+        assertEquals(886, cmap.getGlyphId(0x1F681));
+        ttf.close();
+    }
 }



Mime
View raw message