From 1a8a662bda6d5f9f08973074555dd0f10990e3ef Mon Sep 17 00:00:00 2001 From: Bertrand Delacretaz Date: Tue, 10 Oct 2006 09:40:56 +0000 Subject: [PATCH] Throw exception if font does not provide a loca table (happens when attempting to read an OpenType font with CFF outlines) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@454671 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fonts/truetype/TTFFile.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java index 3ff335a4a..092d17104 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java @@ -116,15 +116,17 @@ public class TTFFile { * Position inputstream to position indicated * in the dirtab offset + offset */ - void seekTab(FontFileReader in, String name, + boolean seekTab(FontFileReader in, String name, long offset) throws IOException { TTFDirTabEntry dt = (TTFDirTabEntry)dirTabs.get(name); if (dt == null) { log.error("Dirtab " + name + " not found."); + return false; } else { in.seekSet(dt.getOffset() + offset); this.currentDirTab = dt; } + return true; } /** @@ -930,7 +932,9 @@ public class TTFFile { */ protected final void readIndexToLocation(FontFileReader in) throws IOException { - seekTab(in, "loca", 0); + if(!seekTab(in, "loca", 0)) { + throw new IOException("'loca' table not found, happens when the font file doesn't contain TrueType outlines (trying to read an OpenType CFF font maybe?)"); + } for (int i = 0; i < numberOfGlyphs; i++) { mtxTab[i].setOffset(locaFormat == 1 ? in.readTTFULong() : (in.readTTFUShort() << 1)); -- 2.39.5