xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r463581 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFile.java
Date Fri, 13 Oct 2006 07:45:23 GMT
Author: bdelacretaz
Date: Fri Oct 13 00:45:19 2006
New Revision: 463581

URL: http://svn.apache.org/viewvc?view=rev&rev=463581
Log:
Do not stop building the metrics file if the unicode index is not found for a kerning entry.
In my tests with OpenType fonts provided with Ubuntu, this happened quite often, probably

caused by extraneous kerning entries which do not point to valid glyphs.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFile.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFile.java?view=diff&rev=463581&r1=463580&r2=463581
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFile.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFile.java Fri Oct 13 00:45:19
2006
@@ -1269,12 +1269,21 @@
                     if (kpx != 0) {
                         // CID kerning table entry, using unicode indexes
                         final Integer iObj = glyphToUnicode(i);
-                        Map adjTab = (Map)kerningTab.get(iObj);
-                        if (adjTab == null) {
-                            adjTab = new java.util.HashMap();
+                        final Integer u2 = glyphToUnicode(j);
+                        if(iObj==null) {
+                            // happens for many fonts (Ubuntu font set),
+                            // stray entries in the kerning table?? 
+                            log.warn("Unicode index (1) not found for glyph " + i);
+                        } else if(u2==null) {
+                            log.warn("Unicode index (2) not found for glyph " + i);
+                        } else {
+                            Map adjTab = (Map)kerningTab.get(iObj);
+                            if (adjTab == null) {
+                                adjTab = new java.util.HashMap();
+                            }
+                            adjTab.put(u2,new Integer((int)convertTTFUnit2PDFUnit(kpx)));
+                            kerningTab.put(iObj, adjTab);
                         }
-                        adjTab.put(glyphToUnicode(j),new Integer((int)convertTTFUnit2PDFUnit(kpx)));
-                        kerningTab.put(iObj, adjTab);
                     }
                 }
             }
@@ -1442,13 +1451,7 @@
      * @throws IOException if glyphIndex not found
      */
     private Integer glyphToUnicode(int glyphIndex) throws IOException {
-        final Integer result = 
-            (Integer) glyphToUnicodeMap.get(new Integer(glyphIndex));
-        if (result == null) {
-            throw new IOException(
-                    "Unicode index not found for glyph " + glyphIndex);
-        }
-        return result;
+        return (Integer) glyphToUnicodeMap.get(new Integer(glyphIndex));
     }
     
     /**



---------------------------------------------------------------------
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