]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed bug #15877: ArrayIndexOutOfBoundException with certain TrueType fonts.
authorJeremias Maerki <jeremias@apache.org>
Thu, 9 Jan 2003 13:47:26 +0000 (13:47 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 9 Jan 2003 13:47:26 +0000 (13:47 +0000)
Reserved name indexes were not ignored.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@195837 13f79535-47bb-0310-9956-ffa450edef68

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

diff --git a/CHANGES b/CHANGES
index dbd67007e0239f9856e961636697cbd32a017840..9c1e173b3ca971ba58e566b92e78916e9041cafa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
 ==============================================================================
 Done since 0.20.4 release
+- Fixed bug #15877: ArrayIndexOutOfBoundException with certain TrueType fonts.
+  Reserved name indexes were not ignored. (Jeremias Maerki)
 - Fixed resolution of relative URLs in FopImageFactory with IBM JDK
   Submitted by: Manuel Mall <mm@arcus.com.au> (see bug #14948)
 - Fixed infinite loop when page-height="auto" (Oleg Tkachenko)
index 94424f4b4e27ec3ab07d77463d49f0b235dbb558..0caa42d4eb7292af4077f9eea7e7cb2a7f09d340 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * $Id$
- * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
@@ -138,7 +138,7 @@ public class TTFFile {
             // " Encoding: "+cmap_eid);
 
             if (cmap_pid == 3 && cmap_eid == 1) {
-                cmap_unioffset = cmap_offset; 
+                cmap_unioffset = cmap_offset;
             }
         }
 
@@ -731,12 +731,14 @@ public class TTFFile {
                     mtx_tab[i].name =
                         Glyphs.mac_glyph_names[mtx_tab[i].index];
                 } else {
-                    k = mtx_tab[i].index - NMACGLYPHS;
-                    /*
-                     * System.out.println(k+" i="+i+" mtx="+mtx_tab.length+
-                     * " ps="+ps_glyphs_buf.length);
-                     */
-                    mtx_tab[i].name = ps_glyphs_buf[k];
+                    if (!mtx_tab[i].isIndexReserved()) {
+                        k = mtx_tab[i].index - NMACGLYPHS;
+                        /*
+                         * System.out.println(k+" i="+i+" mtx="+mtx_tab.length+
+                         * " ps="+ps_glyphs_buf.length);
+                         */
+                        mtx_tab[i].name = ps_glyphs_buf[k];
+                    }
                 }
             }
 
index 67451d447025296324a62c60fa42a2fb4fe16229..3a71afaf9e918511392d407e553d6a9a6b2c9edf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
@@ -28,12 +28,42 @@ class TTFMtxEntry {
     }
 
     public String toString(TTFFile t) {
-        return new String("Glyph " + name + " index: " + index + " bbox [ "
+        return new String("Glyph " + name + " index: " + getIndexAsString() + " bbox ["
                           + t.get_ttf_funit(bbox[0]) + " "
                           + t.get_ttf_funit(bbox[1]) + " "
                           + t.get_ttf_funit(bbox[2]) + " "
-                          + t.get_ttf_funit(bbox[3]) + "]" + "wx: "
+                          + t.get_ttf_funit(bbox[3]) + "] wx: "
                           + t.get_ttf_funit(wx));
     }
 
+    /**
+     * Returns the index.
+     * @return int
+     */
+    public int getIndex() {
+        return index;
+    }
+
+    /**
+     * Determines whether this index represents a reserved character.
+     * @return True if it is reserved
+     */
+    public boolean isIndexReserved() {
+        return (getIndex() >= 32768) && (getIndex() <= 65535);
+    }
+
+    /**
+     * Returns a String representation of the index taking into account if
+     * the index is in the reserved range.
+     * @return index as String
+     */
+    public String getIndexAsString() {
+        if (isIndexReserved()) {
+            return Integer.toString(getIndex()) + " (reserved)";
+        } else {
+            return Integer.toString(getIndex());
+        }
+    }
+
+
 }