xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sstei...@apache.org
Subject svn commit: r1729397 - in /xmlgraphics/fop-pdf-images/trunk: src/java/org/apache/fop/render/pdf/pdfbox/ test/java/org/apache/fop/render/pdf/
Date Tue, 09 Feb 2016 14:53:49 GMT
Author: ssteiner
Date: Tue Feb  9 14:53:48 2016
New Revision: 1729397

URL: http://svn.apache.org/viewvc?rev=1729397&view=rev
Log:
FOP-2575: Merge unicode cmap

Modified:
    xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
    xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java
    xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java
    xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java

Modified: xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java?rev=1729397&r1=1729396&r2=1729397&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
(original)
+++ xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
Tue Feb  9 14:53:48 2016
@@ -179,11 +179,11 @@ public class FOPPDFSingleByteFont extend
             for (CMAPEncodingEntry c : cmapList) {
                 MergeTTFonts.Cmap tempCmap = getNewCmap(c.getPlatformId(), c.getPlatformEncodingId());
                 for (int i = 0; i < 256 * 256; i++) {
-                    if (c.getGlyphId(i) != 0) {
-                        tempCmap.glyphIdToCharacterCode.put(i, c.getGlyphId(i));
+                    int gid = c.getGlyphId(i);
+                    if (gid != 0) {
+                        tempCmap.glyphIdToCharacterCode.put(i, gid);
                     }
                 }
-                newCmap.add(tempCmap);
             }
             FOPPDFMultiByteFont.mergeMaxp(ttfont, mergeTTFonts.maxp);
         }
@@ -195,7 +195,9 @@ public class FOPPDFSingleByteFont extend
                 return cmap;
             }
         }
-        return new MergeTTFonts.Cmap(platformID, platformEncodingID);
+        MergeTTFonts.Cmap cmap = new MergeTTFonts.Cmap(platformID, platformEncodingID);
+        newCmap.add(cmap);
+        return cmap;
     }
 
     @Override

Modified: xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java?rev=1729397&r1=1729396&r2=1729397&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java
(original)
+++ xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeFontsPDFWriter.java
Tue Feb  9 14:53:48 2016
@@ -211,6 +211,12 @@ public class MergeFontsPDFWriter extends
         if (cs.getClass().getName().equals("org.apache.fontbox.cff.CFFParser$Format1Charset"))
{
             extra += "f1cs";
         }
+        if (font.getFontEncoding() != null) {
+            String enc = font.getFontEncoding().getClass().getSimpleName();
+            if (!"DictionaryEncoding".equals(enc)) {
+                extra += enc;
+            }
+        }
         return name + extra;
     }
 

Modified: xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java?rev=1729397&r1=1729396&r2=1729397&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java
(original)
+++ xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java
Tue Feb  9 14:53:48 2016
@@ -322,6 +322,8 @@ public class MergeTTFonts extends TTFSub
     }
 
     private void writeCMAP(List<Cmap> cmaps) {
+        mergeUniCmap(cmaps);
+
         int checksum = currentPos;
         pad4();
         int cmapPos = currentPos;
@@ -388,6 +390,20 @@ public class MergeTTFonts extends TTFSub
         realSize += currentPos - cmapPos;
     }
 
+    private void mergeUniCmap(List<Cmap> cmaps) {
+        Cmap uniCmap = null;
+        for (Cmap cmap : cmaps) {
+            if (cmap.platformId == 3 && cmap.platformEncodingId == 1) {
+                uniCmap = cmap;
+            }
+        }
+        if (uniCmap != null) {
+            for (Cmap cmap : cmaps) {
+                uniCmap.glyphIdToCharacterCode.putAll(cmap.glyphIdToCharacterCode);
+            }
+        }
+    }
+
     private int getCmapOffset(List<Cmap> cmaps, int index) {
         int result = 0;
         for (int i = 0; i < index; i++) {

Modified: xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java?rev=1729397&r1=1729396&r2=1729397&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
(original)
+++ xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
Tue Feb  9 14:53:48 2016
@@ -285,7 +285,7 @@ public class PDFBoxAdapterTestCase {
         Assert.assertEquals(name, "TimesNewRomanPSMT_TrueType");
         Assert.assertEquals(mbfont.getFontName(), "TimesNewRomanPSMT_TrueType");
         byte[] is = IOUtils.toByteArray(mbfont.getInputStream());
-        Assert.assertEquals(is.length, 41352);
+        Assert.assertEquals(is.length, 41112);
         doc.close();
         doc2.close();
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message