aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBertrand Delacretaz <bdelacretaz@apache.org>2006-10-13 07:45:19 +0000
committerBertrand Delacretaz <bdelacretaz@apache.org>2006-10-13 07:45:19 +0000
commite4019e2538a7049ff75d568b61f5b4913a999d81 (patch)
tree84a6a5bcbf909e8bd49bf5d3127f833d7ce147b6 /src
parent1171644b9ee3732e7c671fdb7303e4d1554dcd10 (diff)
downloadxmlgraphics-fop-e4019e2538a7049ff75d568b61f5b4913a999d81.tar.gz
xmlgraphics-fop-e4019e2538a7049ff75d568b61f5b4913a999d81.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFFile.java27
1 files changed, 15 insertions, 12 deletions
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));
}
/**