aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorAdrian Cumiskey <acumiskey@apache.org>2008-06-02 14:12:49 +0000
committerAdrian Cumiskey <acumiskey@apache.org>2008-06-02 14:12:49 +0000
commitf12468ebca3f5ccb89483380af3b0955bd756622 (patch)
tree9243bd08359859461982894a5e203487dfda4436 /src/java/org/apache
parent209279e7e51cde75a3b04c4433aa7c6dd112e389 (diff)
downloadxmlgraphics-fop-f12468ebca3f5ccb89483380af3b0955bd756622.tar.gz
xmlgraphics-fop-f12468ebca3f5ccb89483380af3b0955bd756622.zip
Just cleanup.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@662444 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/render/afp/modca/MapCodedFont.java42
1 files changed, 16 insertions, 26 deletions
diff --git a/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java b/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java
index d4b868bcb..4518be9f1 100644
--- a/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java
+++ b/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java
@@ -42,7 +42,7 @@ import org.apache.fop.render.afp.tools.BinaryUtils;
*
* @author <a href="mailto:pete@townsend.uk.com">Pete Townsend </a>
*/
-public class MapCodedFont extends AbstractAFPObject {
+public class MapCodedFont extends AbstractStructuredAFPObject {
/**
* The collection of map coded fonts (maximum of 254)
@@ -53,32 +53,30 @@ public class MapCodedFont extends AbstractAFPObject {
* Constructor for the MapCodedFont
*/
public MapCodedFont() {
-
fontList = new java.util.ArrayList();
-
}
/**
- * Accessor method to write the AFP datastream for the Map Coded Font
- * @param os The stream to write to
- * @throws java.io.IOException an I/O exception of some sort has occurred
+ * {@inheritDoc}
*/
public void write(OutputStream os) throws IOException {
-
+ byte[] startData = new byte[] {
+ 0x5A,
+ 0x00, // Reserved
+ 0x00, // Reserved
+ (byte)0xD3,
+ (byte)0xAB, // Format 2
+ (byte)0x8A,
+ 0x00, // Reserved
+ 0x00, // Reserved
+ 0x00, // Reserved
+ };
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- baos.write(0x5A);
- baos.write(new byte[] {0x00, 0x00});
-
- // Field identifier for a MapCodedFont
- baos.write(new byte[] {(byte) 0xD3, (byte) 0xAB, (byte) 0x8A});
+ baos.write(startData);
- // Reserved
- baos.write(new byte[] {0x00, 0x00, 0x00});
-
-
Iterator iter = fontList.iterator();
while (iter.hasNext()) {
-
FontDefinition fd = (FontDefinition) iter.next();
// Start of repeating groups (occurs 1 to 254)
@@ -186,9 +184,7 @@ public class MapCodedFont extends AbstractAFPObject {
}
try {
-
if (font instanceof RasterFont) {
-
RasterFont raster = (RasterFont) font;
CharacterSet cs = raster.getCharacterSet(size);
if (cs == null) {
@@ -218,7 +214,6 @@ public class MapCodedFont extends AbstractAFPObject {
}
} else if (font instanceof OutlineFont) {
-
OutlineFont outline = (OutlineFont) font;
CharacterSet cs = outline.getCharacterSet();
fd.characterSet = cs.getNameBytes();
@@ -236,7 +231,6 @@ public class MapCodedFont extends AbstractAFPObject {
AFPConstants.EBCIDIC_ENCODING)
+ " must have a fixed length of 8 characters.");
}
-
} else {
String msg = "Font of type " + font.getClass().getName()
+ " not recognized.";
@@ -245,22 +239,19 @@ public class MapCodedFont extends AbstractAFPObject {
}
if (fontList.size() > 253) {
-
// Throw an exception if the size is exceeded
throw new MaximumSizeExceededException();
-
} else {
fontList.add(fd);
}
} catch (UnsupportedEncodingException ex) {
-
throw new FontRuntimeException("Failed to create font "
+ " due to a UnsupportedEncodingException", ex);
-
}
}
+
/**
* Private utility class used as a container for font attributes
*/
@@ -290,7 +281,6 @@ public class MapCodedFont extends AbstractAFPObject {
* The scale (only specified for outline fonts)
*/
private int scale = 0;
-
}
} \ No newline at end of file