aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorAdrian Cumiskey <acumiskey@apache.org>2008-10-24 13:25:03 +0000
committerAdrian Cumiskey <acumiskey@apache.org>2008-10-24 13:25:03 +0000
commit00de9a8fc1a67e93c512ba67451d1e8815d57b39 (patch)
treece9264205b1814179972c055983f27e7c8c44200 /src/java
parentbccf87ccbf0aef8db1601b8d4db2fd7e7bfb3bf5 (diff)
downloadxmlgraphics-fop-00de9a8fc1a67e93c512ba67451d1e8815d57b39.tar.gz
xmlgraphics-fop-00de9a8fc1a67e93c512ba67451d1e8815d57b39.zip
Merged revisions 707627 via svnmerge from
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r707627 | acumiskey | 2008-10-24 14:20:51 +0100 (Fri, 24 Oct 2008) | 3 lines AFPFontReader a lot more robust now with less copy/pasted code but still far from ideal, the whole AFP FOCA parsing/handling still in need of a rewrite at some point. CharacterSetOrientation width() renamed to getWidth() and now protects itself against a possible ArrayIndexOutOfBoundsException. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@707629 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/fonts/Font.java11
-rw-r--r--src/java/org/apache/fop/fonts/FontSetup.java5
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java406
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/CharacterSet.java15
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java10
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java2
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/OutlineFont.java2
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/RasterFont.java2
-rw-r--r--src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java7
9 files changed, 224 insertions, 236 deletions
diff --git a/src/java/org/apache/fop/fonts/Font.java b/src/java/org/apache/fop/fonts/Font.java
index de6904d9b..ebd45457d 100644
--- a/src/java/org/apache/fop/fonts/Font.java
+++ b/src/java/org/apache/fop/fonts/Font.java
@@ -64,16 +64,16 @@ public class Font {
/** logger */
private static Log log = LogFactory.getLog(Font.class);
- private String fontName;
- private FontTriplet triplet;
- private int fontSize;
+ private final String fontName;
+ private final FontTriplet triplet;
+ private final int fontSize;
/**
* normal or small-caps font
*/
//private int fontVariant;
- private FontMetrics metric;
+ private final FontMetrics metric;
/**
* Main constructor
@@ -268,7 +268,8 @@ public class Font {
width = getCharWidth(' ');
} else {
if (hasChar(c)) {
- width = getWidth(mapChar(c));
+ int mappedChar = mapChar(c);
+ width = getWidth(mappedChar);
} else {
width = -1;
}
diff --git a/src/java/org/apache/fop/fonts/FontSetup.java b/src/java/org/apache/fop/fonts/FontSetup.java
index eea04a580..f7ad6fc65 100644
--- a/src/java/org/apache/fop/fonts/FontSetup.java
+++ b/src/java/org/apache/fop/fonts/FontSetup.java
@@ -27,7 +27,6 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.fonts.base14.Courier;
import org.apache.fop.fonts.base14.CourierBold;
import org.apache.fop.fonts.base14.CourierBoldOblique;
@@ -202,7 +201,7 @@ public class FontSetup {
if (resolver == null) {
//Ensure that we have minimal font resolution capabilities
- resolver = createMinimalFontResolver1();
+ resolver = createMinimalFontResolver();
}
String internalName = null;
@@ -225,7 +224,7 @@ public class FontSetup {
}
/** @return a new FontResolver to be used by the font subsystem */
- public static FontResolver createMinimalFontResolver1() {
+ public static FontResolver createMinimalFontResolver() {
return new FontResolver() {
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java b/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java
index 731acdaee..f72d23d47 100644
--- a/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java
+++ b/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java
@@ -26,13 +26,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.render.afp.AFPConstants;
-import org.apache.fop.render.afp.exceptions.FontRuntimeException;
import org.apache.fop.render.afp.tools.StructuredFieldReader;
/**
@@ -111,143 +109,19 @@ public final class AFPFontReader {
/**
* The collection of code pages
*/
- private HashMap codePages = new HashMap();
+ private final Map/*<String, Map<String, String>>*/ codePages
+ = new java.util.HashMap/*<String, Map<String, String>>*/();
/**
- * Load the font details and metrics into the CharacterSetMetric object,
- * this will use the actual afp code page and character set files to load
- * the object with the necessary metrics.
+ * Returns an InputStream to a given file path and filename
*
- * @param characterSet the CharacterSetMetric object to populate
- */
- public void loadCharacterSetMetric(CharacterSet characterSet) {
-
- InputStream inputStream = null;
-
- try {
-
- /**
- * Get the code page which contains the character mapping
- * information to map the unicode character id to the graphic
- * chracter global identifier.
- */
- String cp = new String(characterSet.getCodePage());
- String path = characterSet.getPath();
-
- HashMap codepage = (HashMap) codePages.get(cp);
-
- if (codepage == null) {
- codepage = loadCodePage(cp, characterSet.getEncoding(), path);
- codePages.put(cp, codepage);
- }
-
- /**
- * Load the character set metric information, no need to cache this
- * information as it should be cached by the objects that wish to
- * load character set metric information.
- */
- final String characterset = characterSet.getName();
-
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- if (classLoader == null) {
- classLoader = AFPFontReader.class.getClassLoader();
- }
-
- URL url = classLoader.getResource(path);
- if (url == null) {
- try {
- File file = new File(path);
- url = file.toURI().toURL();
- if (url == null) {
- String msg = "CharacterSet file not found for "
- + characterset + " in classpath: " + path;
- log.error(msg);
- throw new FileNotFoundException(msg);
- }
- } catch (MalformedURLException ex) {
- String msg = "CharacterSet file not found for "
- + characterset + " in classpath: " + path;
- log.error(msg);
- throw new FileNotFoundException(msg);
- }
-
- }
-
- File directory = new File(url.getPath());
-
- final String filterpattern = characterset.trim();
- FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.startsWith(filterpattern);
- }
- };
-
- File[] csfont = directory.listFiles(filter);
- if (csfont.length < 1) {
- String msg = "CharacterSet file search for " + characterset
- + " located " + csfont.length + " files";
- log.error(msg);
- throw new FileNotFoundException(msg);
- } else if (csfont.length > 1) {
- String msg = "CharacterSet file search for " + characterset
- + " located " + csfont.length + " files";
- log.warn(msg);
- }
-
- inputStream = csfont[0].toURI().toURL().openStream();
- if (inputStream == null) {
- String msg = "Failed to open character set resource "
- + characterset;
- log.error(msg);
- throw new FileNotFoundException(msg);
- }
-
- StructuredFieldReader sfr = new StructuredFieldReader(inputStream);
-
- // Process D3A789 Font Control
- FontControl fnc = processFontControl(sfr);
-
- //process D3AE89 Font Orientation
- CharacterSetOrientation[] csoArray = processFontOrientation(sfr);
-
- //process D3AC89 Font Position
- processFontPosition(sfr, csoArray, fnc.getDpi());
-
- //process D38C89 Font Index (per orientation)
- for (int i = 0; i < csoArray.length; i++) {
- processFontIndex(sfr, csoArray[i], codepage, fnc.getDpi());
- characterSet.addCharacterSetOrientation(csoArray[i]);
- }
-
- } catch (Exception ex) {
- throw new FontRuntimeException(
- "Failed to load the character set metrics for code page "
- + characterSet.getCodePage(), ex);
- } finally {
- try {
- inputStream.close();
- } catch (Exception ex) {
- // Ignore
- }
- }
-
- }
-
- /**
- * Load the code page information from the appropriate file. The file name
- * to load is determined by the code page name and the file extension 'CDP'.
+ * @param path the file path
+ * @param filename the file name
+ * @return an inputStream
*
- * @param codePage
- * the code page identifier
- * @param encoding
- * the encoding to use for the character decoding
+ * @throws IOException in the event that an I/O exception of some sort has occurred
*/
- private static HashMap loadCodePage(String codePage, String encoding,
- String path) throws IOException {
-
- // Create the HashMap to store code page information
- HashMap codepages = new HashMap();
-
+ private InputStream openInputStream(String path, String filename) throws IOException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = AFPFontReader.class.getClassLoader();
@@ -260,14 +134,12 @@ public final class AFPFontReader {
File file = new File(path);
url = file.toURI().toURL();
if (url == null) {
- String msg = "CodePage file not found for " + codePage
- + " in classpath: " + path;
+ String msg = "file not found " + filename + " in classpath: " + path;
log.error(msg);
throw new FileNotFoundException(msg);
}
} catch (MalformedURLException ex) {
- String msg = "CodePage file not found for " + codePage
- + " in classpath: " + path;
+ String msg = "file not found " + filename + " in classpath: " + path;
log.error(msg);
throw new FileNotFoundException(msg);
}
@@ -280,115 +152,220 @@ public final class AFPFontReader {
throw new FileNotFoundException(msg);
}
- final String filterpattern = codePage.trim();
+ final String filterpattern = filename.trim();
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith(filterpattern);
}
};
- File[] codepage = directory.listFiles(filter);
+ File[] files = directory.listFiles(filter);
- if (codepage.length < 1) {
- String msg = "CodePage file search for " + codePage + " located "
- + codepage.length + " files";
+ if (files.length < 1) {
+ String msg = "file search for " + filename + " located "
+ + files.length + " files";
log.error(msg);
throw new FileNotFoundException(msg);
- } else if (codepage.length > 1) {
- String msg = "CodePage file search for " + codePage + " located "
- + codepage.length + " files";
+ } else if (files.length > 1) {
+ String msg = "file search for " + filename + " located "
+ + files.length + " files";
log.warn(msg);
}
- InputStream is = codepage[0].toURI().toURL().openStream();
+ InputStream inputStream = files[0].toURI().toURL().openStream();
- if (is == null) {
- String msg = "AFPFontReader:: loadCodePage(String):: code page file not found for "
- + codePage;
+ if (inputStream == null) {
+ String msg = "AFPFontReader:: getInputStream():: file not found for " + filename;
log.error(msg);
throw new FileNotFoundException(msg);
}
- StructuredFieldReader sfr = new StructuredFieldReader(is);
- byte[] data = sfr.getNext(CHARACTER_TABLE_SF);
+ return inputStream;
+ }
- int position = 0;
- byte[] gcgiBytes = new byte[8];
- byte[] charBytes = new byte[1];
+ /**
+ * Closes the inputstream
+ *
+ * @param inputStream the inputstream to close
+ */
+ private void closeInputStream(InputStream inputStream) {
+ try {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ } catch (Exception ex) {
+ // Lets log at least!
+ log.error(ex.getMessage());
+ }
+ }
- // Read data, ignoring bytes 0 - 2
- for (int index = 3; index < data.length; index++) {
- if (position < 8) {
- // Build the graphic character global identifier key
- gcgiBytes[position] = data[index];
- position++;
- } else if (position == 9) {
- position = 0;
- // Set the character
- charBytes[0] = data[index];
- String gcgiString = new String(gcgiBytes,
- AFPConstants.EBCIDIC_ENCODING);
- String charString = new String(charBytes, encoding);
-// int value = charString.charAt(0);
- codepages.put(gcgiString, charString);
+ /**
+ * Load the font details and metrics into the CharacterSetMetric object,
+ * this will use the actual afp code page and character set files to load
+ * the object with the necessary metrics.
+ *
+ * @param characterSet the CharacterSetMetric object to populate
+ * @throws IOException if an I/O exception of some sort has occurred.
+ */
+ public void loadCharacterSetMetric(CharacterSet characterSet) throws IOException {
+
+ InputStream inputStream = null;
+
+ try {
+
+ /**
+ * Get the code page which contains the character mapping
+ * information to map the unicode character id to the graphic
+ * chracter global identifier.
+ */
+ String codePageId = new String(characterSet.getCodePage());
+ String path = characterSet.getPath();
+
+ Map/*<String,String>*/ codePage = (Map/*<String,String>*/)codePages.get(codePageId);
+
+ if (codePage == null) {
+ codePage = loadCodePage(codePageId, characterSet.getEncoding(), path);
+ codePages.put(codePageId, codePage);
+ }
+
+ /**
+ * Load the character set metric information, no need to cache this
+ * information as it should be cached by the objects that wish to
+ * load character set metric information.
+ */
+ final String characterSetName = characterSet.getName();
+
+ inputStream = openInputStream(path, characterSetName);
+
+ StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream);
+
+ // Process D3A789 Font Control
+ FontControl fontControl = processFontControl(structuredFieldReader);
+
+ if (fontControl != null) {
+ //process D3AE89 Font Orientation
+ CharacterSetOrientation[] characterSetOrientations
+ = processFontOrientation(structuredFieldReader);
+
+ int dpi = fontControl.getDpi();
+
+ //process D3AC89 Font Position
+ processFontPosition(structuredFieldReader, characterSetOrientations, dpi);
+
+ //process D38C89 Font Index (per orientation)
+ for (int i = 0; i < characterSetOrientations.length; i++) {
+ processFontIndex(structuredFieldReader,
+ characterSetOrientations[i], codePage, dpi);
+ characterSet.addCharacterSetOrientation(characterSetOrientations[i]);
+ }
} else {
- position++;
+ throw new IOException(
+ "Failed to read font control structured field in character set "
+ + characterSetName);
}
+
+ } finally {
+ closeInputStream(inputStream);
}
+ }
+
+ /**
+ * Load the code page information from the appropriate file. The file name
+ * to load is determined by the code page name and the file extension 'CDP'.
+ *
+ * @param codePage
+ * the code page identifier
+ * @param encoding
+ * the encoding to use for the character decoding
+ * @returns a code page mapping
+ */
+ private Map/*<String,String>*/ loadCodePage(String codePage, String encoding,
+ String path) throws IOException {
+
+ // Create the HashMap to store code page information
+ Map/*<String,String>*/ codePages = new java.util.HashMap/*<String,String>*/();
+
+ InputStream inputStream = null;
try {
- is.close();
- } catch (Exception ex) {
- // Ignore
+ inputStream = openInputStream(path, codePage.trim());
+
+ StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream);
+ byte[] data = structuredFieldReader.getNext(CHARACTER_TABLE_SF);
+
+ int position = 0;
+ byte[] gcgiBytes = new byte[8];
+ byte[] charBytes = new byte[1];
+
+ // Read data, ignoring bytes 0 - 2
+ for (int index = 3; index < data.length; index++) {
+ if (position < 8) {
+ // Build the graphic character global identifier key
+ gcgiBytes[position] = data[index];
+ position++;
+ } else if (position == 9) {
+ position = 0;
+ // Set the character
+ charBytes[0] = data[index];
+ String gcgiString = new String(gcgiBytes,
+ AFPConstants.EBCIDIC_ENCODING);
+ String charString = new String(charBytes, encoding);
+// int value = charString.charAt(0);
+ codePages.put(gcgiString, charString);
+ } else {
+ position++;
+ }
+ }
+ } finally {
+ closeInputStream(inputStream);
}
- return codepages;
-
+ return codePages;
}
/**
* Process the font control details using the structured field reader.
*
- * @param sfr
+ * @param structuredFieldReader
* the structured field reader
*/
- private static FontControl processFontControl(StructuredFieldReader sfr)
+ private FontControl processFontControl(StructuredFieldReader structuredFieldReader)
throws IOException {
- byte[] fncData = sfr.getNext(FONT_CONTROL_SF);
+ byte[] fncData = structuredFieldReader.getNext(FONT_CONTROL_SF);
// int position = 0;
+ FontControl fontControl = null;
+ if (fncData != null) {
+ fontControl = new FontControl();
- FontControl fontControl = new AFPFontReader().new FontControl();
-
- if (fncData[7] == (byte) 0x02) {
- fontControl.setRelative(true);
- }
-
- int dpi = (((fncData[9] & 0xFF) << 8) + (fncData[10] & 0xFF)) / 10;
+ if (fncData[7] == (byte) 0x02) {
+ fontControl.setRelative(true);
+ }
- fontControl.setDpi(dpi);
+ int dpi = (((fncData[9] & 0xFF) << 8) + (fncData[10] & 0xFF)) / 10;
+ fontControl.setDpi(dpi);
+ }
return fontControl;
-
}
/**
* Process the font orientation details from using the structured field
* reader.
*
- * @param sfr
+ * @param structuredFieldReader
* the structured field reader
*/
- private static CharacterSetOrientation[] processFontOrientation(
- StructuredFieldReader sfr) throws IOException {
+ private CharacterSetOrientation[] processFontOrientation(
+ StructuredFieldReader structuredFieldReader) throws IOException {
- byte[] data = sfr.getNext(FONT_ORIENTATION_SF);
+ byte[] data = structuredFieldReader.getNext(FONT_ORIENTATION_SF);
int position = 0;
byte[] fnoData = new byte[26];
- ArrayList orientations = new ArrayList();
+ List orientations = new java.util.ArrayList();
// Read data, ignoring bytes 0 - 2
for (int index = 3; index < data.length; index++) {
@@ -434,20 +411,20 @@ public final class AFPFontReader {
* Populate the CharacterSetOrientation object in the suplied array with the
* font position details using the supplied structured field reader.
*
- * @param sfr
+ * @param structuredFieldReader
* the structured field reader
- * @param csoArray
+ * @param characterSetOrientations
* the array of CharacterSetOrientation objects
*/
- private static void processFontPosition(StructuredFieldReader sfr,
- CharacterSetOrientation[] csoArray, int dpi) throws IOException {
+ private void processFontPosition(StructuredFieldReader structuredFieldReader,
+ CharacterSetOrientation[] characterSetOrientations, int dpi) throws IOException {
- byte[] data = sfr.getNext(FONT_POSITION_SF);
+ byte[] data = structuredFieldReader.getNext(FONT_POSITION_SF);
int position = 0;
byte[] fpData = new byte[26];
- int csoIndex = 0;
+ int characterSetOrientationIndex = 0;
int fopFactor = 0;
switch (dpi) {
@@ -475,7 +452,8 @@ public final class AFPFontReader {
position = 0;
- CharacterSetOrientation cso = csoArray[csoIndex];
+ CharacterSetOrientation characterSetOrientation
+ = characterSetOrientations[characterSetOrientationIndex];
int xHeight = ((fpData[2] & 0xFF) << 8) + (fpData[3] & 0xFF);
int capHeight = ((fpData[4] & 0xFF) << 8) + (fpData[5] & 0xFF);
@@ -484,12 +462,12 @@ public final class AFPFontReader {
dscHeight = dscHeight * -1;
- cso.setXHeight(xHeight * fopFactor);
- cso.setCapHeight(capHeight * fopFactor);
- cso.setAscender(ascHeight * fopFactor);
- cso.setDescender(dscHeight * fopFactor);
+ characterSetOrientation.setXHeight(xHeight * fopFactor);
+ characterSetOrientation.setCapHeight(capHeight * fopFactor);
+ characterSetOrientation.setAscender(ascHeight * fopFactor);
+ characterSetOrientation.setDescender(dscHeight * fopFactor);
- csoIndex++;
+ characterSetOrientationIndex++;
fpData[position] = data[index];
@@ -503,18 +481,18 @@ public final class AFPFontReader {
/**
* Process the font index details for the character set orientation.
*
- * @param sfr
+ * @param structuredFieldReader
* the structured field reader
* @param cso
* the CharacterSetOrientation object to populate
* @param codepage
* the map of code pages
*/
- private static void processFontIndex(StructuredFieldReader sfr,
- CharacterSetOrientation cso, HashMap codepage, int dpi)
+ private void processFontIndex(StructuredFieldReader structuredFieldReader,
+ CharacterSetOrientation cso, Map/*<String,String>*/ codepage, int dpi)
throws IOException {
- byte[] data = sfr.getNext(FONT_INDEX_SF);
+ byte[] data = structuredFieldReader.getNext(FONT_INDEX_SF);
int fopFactor = 0;
@@ -545,14 +523,14 @@ public final class AFPFontReader {
// Read data, ignoring bytes 0 - 2
for (int index = 3; index < data.length; index++) {
if (position < 8) {
- gcgid[position] = (byte) data[index];
+ gcgid[position] = data[index];
position++;
} else if (position < 27) {
- fiData[position - 8] = (byte) data[index];
+ fiData[position - 8] = data[index];
position++;
} else if (position == 27) {
- fiData[position - 8] = (byte) data[index];
+ fiData[position - 8] = data[index];
position = 0;
diff --git a/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java b/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java
index d33f093f1..fc0ab8b16 100644
--- a/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java
+++ b/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java
@@ -19,6 +19,7 @@
package org.apache.fop.render.afp.fonts;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
@@ -217,9 +218,9 @@ public class CharacterSet {
* @param character the character from which the width will be calculated
* @return the width of the character
*/
- public int width(int character) {
+ public int getWidth(int character) {
load();
- return getCharacterSetOrientation().width(character);
+ return getCharacterSetOrientation().getWidth(character);
}
/**
@@ -229,8 +230,14 @@ public class CharacterSet {
private void load() {
if (!isMetricsLoaded) {
AFPFontReader afpFontReader = new AFPFontReader();
- afpFontReader.loadCharacterSetMetric(this);
- isMetricsLoaded = true;
+ try {
+ afpFontReader.loadCharacterSetMetric(this);
+ isMetricsLoaded = true;
+ } catch (IOException e) {
+ String msg = "Failed to load the character set metrics for code page " + codePage;
+ log.error(msg);
+ throw new RuntimeException(e.getMessage());
+ }
}
}
diff --git a/src/java/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java b/src/java/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java
index be6dbf6ea..e13029717 100644
--- a/src/java/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java
+++ b/src/java/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java
@@ -183,11 +183,15 @@ public class CharacterSetOrientation {
/**
* Get the width (in 1/1000ths of a point size) of the character
* identified by the parameter passed.
- * @param character the character to evaluate
+ * @param characterIndex the character to evaluate
* @return the widths of the character
*/
- public int width(int character) {
- return chars[character];
+ public int getWidth(int characterIndex) {
+ if (characterIndex >= chars.length) {
+ throw new IllegalArgumentException("Invalid character index: "
+ + characterIndex + ", maximum is " + (chars.length - 1));
+ }
+ return chars[characterIndex];
}
/**
diff --git a/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java b/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java
index f6864d73f..d5beb5a33 100644
--- a/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java
+++ b/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java
@@ -125,7 +125,7 @@ public class FopCharacterSet extends CharacterSet {
* @param character the character from which the width will be calculated
* @return the width of the character
*/
- public int width(int character) {
+ public int getWidth(int character) {
return charSet.getWidth(character, size);
}
diff --git a/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java b/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java
index f8dd9a1ed..71c5dfb6f 100644
--- a/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java
+++ b/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java
@@ -136,7 +136,7 @@ public class OutlineFont extends AFPFont {
* @return the width of the character for the specified point size
*/
public int getWidth(int character, int size) {
- return charSet.width(character) / 1000 * size;
+ return charSet.getWidth(character) / 1000 * size;
}
/**
diff --git a/src/java/org/apache/fop/render/afp/fonts/RasterFont.java b/src/java/org/apache/fop/render/afp/fonts/RasterFont.java
index 44dcd0e9f..ee4bfba6c 100644
--- a/src/java/org/apache/fop/render/afp/fonts/RasterFont.java
+++ b/src/java/org/apache/fop/render/afp/fonts/RasterFont.java
@@ -195,7 +195,7 @@ public class RasterFont extends AFPFont {
* @return the width for the given point size
*/
public int getWidth(int character, int size) {
- return getCharacterSet(size).width(character);
+ return getCharacterSet(size).getWidth(character);
}
/**
diff --git a/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java b/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java
index 1939d2dda..48beff023 100644
--- a/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java
+++ b/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java
@@ -58,14 +58,14 @@ public class StructuredFieldReader {
* parameter (this must be a valid MO:DCA structured field.
* @param identifier the three byte identifier
* @throws IOException if an I/O exception occurred
- * @return the next structured field
+ * @return the next structured field or null when there are no more
*/
public byte[] getNext(byte[] identifier) throws IOException {
int bufferPointer = 0;
byte[] bufferData = new byte[identifier.length + 2];
for (int x = 0; x < identifier.length; x++) {
- bufferData[x] = (byte) 0;
+ bufferData[x] = 0x00;
}
int c;
@@ -128,7 +128,6 @@ public class StructuredFieldReader {
}
- return new byte[] {
- };
+ return null;
}
}