]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix for bug 16257 (bad ascender/descender in XML font metrics)
authorJeremias Maerki <jeremias@apache.org>
Tue, 21 Jan 2003 10:44:36 +0000 (10:44 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 21 Jan 2003 10:44:36 +0000 (10:44 +0000)
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/branches/fop-0_20_2-maintain@195875 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fonts/TTFFile.java

index 0caa42d4eb7292af4077f9eea7e7cb2a7f09d340..0de80134511b9a3393f4928e6369378b5b35188b 100644 (file)
@@ -68,6 +68,8 @@ public class TTFFile {
     int ansiWidth[];
     HashMap ansiIndex;
 
+    private TTFDirTabEntry currentDirTab;
+
     /**
      * Position inputstream to position indicated
      * in the dirtab offset + offset
@@ -77,10 +79,10 @@ public class TTFFile {
         TTFDirTabEntry dt = (TTFDirTabEntry)dirTabs.get(name);
         if (dt == null) {
             System.out.println("Dirtab " + name + " not found.");
-            return;
+        } else {
+            in.seek_set(dt.offset + offset);
+            this.currentDirTab = dt;
         }
-
-        in.seek_set(dt.offset + offset);
     }
 
     /**
@@ -638,6 +640,15 @@ public class TTFFile {
         in.skip(2 + 2 + 3 * 2 + 8 * 2);
         nhmtx = in.readTTFUShort();
         // System.out.println("Number of horizontal metrics: " + nhmtx);
+
+        //Check OS/2 table for ascender/descender if necessary
+        if (ascender == 0 || descender == 0) {
+            seek_tab(in, "OS/2", 68);
+            if (this.currentDirTab.length >= 78) {
+                ascender = in.readTTFShort(); //sTypoAscender
+                descender = in.readTTFShort(); //sTypoDescender
+            }
+        }
     }
 
     /**