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 2017/11/07 18:39:19 UTC

svn commit: r1814531 - /pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java

Author: tilman
Date: Tue Nov  7 18:39:19 2017
New Revision: 1814531

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

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

Modified: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java?rev=1814531&r1=1814530&r2=1814531&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java (original)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java Tue Nov  7 18:39:19 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,31 @@ 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;
+        }
+        try (TrueTypeFont ttf = new TTFParser().parse(is))
+        {
+            CmapSubtable cmap = ttf.getUnicodeCmap(false);
+            assertEquals(886, cmap.getGlyphId(0x1F681));
+        }
+    }
 }