From: Bertrand Delacretaz Date: Fri, 13 Oct 2006 07:45:19 +0000 (+0000) Subject: Do not stop building the metrics file if the unicode index is not found for a kerning... X-Git-Tag: fop-0_93~46 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e4019e2538a7049ff75d568b61f5b4913a999d81;p=xmlgraphics-fop.git 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. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@463581 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java index defe1e01b..8eb7ecf62 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java @@ -1269,12 +1269,21 @@ public class TTFFile { 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 @@ public class TTFFile { * @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)); } /**