From 10d2871a4accc07921a770113fd134f8c6c3e778 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 21 Jan 2003 10:44:36 +0000 Subject: [PATCH] Fix for bug 16257 (bad ascender/descender in XML font metrics) Ascender and Descender are now read from the OS/2 table if the values in the hhea table are zero. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195875 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fonts/truetype/TTFFile.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/org/apache/fop/fonts/truetype/TTFFile.java b/src/org/apache/fop/fonts/truetype/TTFFile.java index 1efe0f88c..e1140e947 100644 --- a/src/org/apache/fop/fonts/truetype/TTFFile.java +++ b/src/org/apache/fop/fonts/truetype/TTFFile.java @@ -83,6 +83,8 @@ public class TTFFile extends AbstractLogEnabled { private int ansiWidth[]; private Map ansiIndex; + + private TTFDirTabEntry currentDirTab; /** * Position inputstream to position indicated @@ -93,10 +95,10 @@ public class TTFFile extends AbstractLogEnabled { TTFDirTabEntry dt = (TTFDirTabEntry)dirTabs.get(name); if (dt == null) { getLogger().error("Dirtab " + name + " not found."); - return; + } else { + in.seekSet(dt.getOffset() + offset); + this.currentDirTab = dt; } - - in.seekSet(dt.getOffset() + offset); } /** @@ -711,6 +713,16 @@ public class TTFFile extends AbstractLogEnabled { in.skip(2 + 2 + 3 * 2 + 8 * 2); nhmtx = in.readTTFUShort(); getLogger().debug("Number of horizontal metrics: " + nhmtx); + + //Check OS/2 table for ascender/descender if necessary + if (ascender == 0 || descender == 0) { + seekTab(in, "OS/2", 68); + if (this.currentDirTab.getLength() >= 78) { + ascender = in.readTTFShort(); //sTypoAscender + descender = in.readTTFShort(); //sTypoDescender + } + } + } /** -- 2.39.5