From: Jeremias Maerki Date: Thu, 9 Jan 2003 13:47:26 +0000 (+0000) Subject: Fixed bug #15877: ArrayIndexOutOfBoundException with certain TrueType fonts. X-Git-Tag: fop-0_20_5rc2~55 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c9c36a1a4d0044faf188ec44877a3c712556c8d1;p=xmlgraphics-fop.git Fixed bug #15877: ArrayIndexOutOfBoundException with certain TrueType fonts. 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 --- diff --git a/CHANGES b/CHANGES index dbd67007e..9c1e173b3 100644 --- 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 (see bug #14948) - Fixed infinite loop when page-height="auto" (Oleg Tkachenko) diff --git a/src/org/apache/fop/fonts/TTFFile.java b/src/org/apache/fop/fonts/TTFFile.java index 94424f4b4..0caa42d4e 100644 --- a/src/org/apache/fop/fonts/TTFFile.java +++ b/src/org/apache/fop/fonts/TTFFile.java @@ -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]; + } } } diff --git a/src/org/apache/fop/fonts/TTFMtxEntry.java b/src/org/apache/fop/fonts/TTFMtxEntry.java index 67451d447..3a71afaf9 100644 --- a/src/org/apache/fop/fonts/TTFMtxEntry.java +++ b/src/org/apache/fop/fonts/TTFMtxEntry.java @@ -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()); + } + } + + }