aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/afp/fonts
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/afp/fonts')
-rw-r--r--src/java/org/apache/fop/afp/fonts/CharacterSet.java8
-rw-r--r--src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java51
-rw-r--r--src/java/org/apache/fop/afp/fonts/FopCharacterSet.java4
3 files changed, 29 insertions, 34 deletions
diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSet.java b/src/java/org/apache/fop/afp/fonts/CharacterSet.java
index fad5e95e6..8881a2649 100644
--- a/src/java/org/apache/fop/afp/fonts/CharacterSet.java
+++ b/src/java/org/apache/fop/afp/fonts/CharacterSet.java
@@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.fop.afp.AFPConstants;
import org.apache.fop.afp.AFPEventProducer;
import org.apache.fop.afp.fonts.CharactersetEncoder.EncodedChars;
-import org.apache.fop.afp.util.ResourceAccessor;
+import org.apache.fop.afp.util.AFPResourceAccessor;
import org.apache.fop.afp.util.StringUtils;
/**
@@ -77,7 +77,7 @@ public class CharacterSet {
protected final String name;
/** The path to the installed fonts */
- private final ResourceAccessor accessor;
+ private final AFPResourceAccessor accessor;
/** The current orientation (currently only 0 is supported by FOP) */
private final String currentOrientation = "0";
@@ -100,7 +100,7 @@ public class CharacterSet {
* @param eventProducer for handling AFP related events
*/
CharacterSet(String codePage, String encoding, CharacterSetType charsetType, String name,
- ResourceAccessor accessor, AFPEventProducer eventProducer) {
+ AFPResourceAccessor accessor, AFPEventProducer eventProducer) {
if (name.length() > MAX_NAME_LEN) {
String msg = "Character set name '" + name + "' must be a maximum of "
+ MAX_NAME_LEN + " characters";
@@ -211,7 +211,7 @@ public class CharacterSet {
* Returns the resource accessor to load the font resources with.
* @return the resource accessor to load the font resources with
*/
- public ResourceAccessor getResourceAccessor() {
+ public AFPResourceAccessor getResourceAccessor() {
return this.accessor;
}
diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java b/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
index 18eaf41ee..3cada1ed3 100644
--- a/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
+++ b/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
@@ -19,9 +19,9 @@
package org.apache.fop.afp.fonts;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -38,7 +38,7 @@ import org.apache.xmlgraphics.image.loader.util.SoftMapCache;
import org.apache.fop.afp.AFPConstants;
import org.apache.fop.afp.AFPEventProducer;
-import org.apache.fop.afp.util.ResourceAccessor;
+import org.apache.fop.afp.util.AFPResourceAccessor;
import org.apache.fop.afp.util.StructuredFieldReader;
import org.apache.fop.fonts.Typeface;
@@ -138,28 +138,24 @@ public abstract class CharacterSetBuilder {
* Returns an InputStream to a given file path and filename
*
* * @param accessor the resource accessor
- * @param filename the file name
+ * @param uriStr the URI
* @param eventProducer for handling AFP related events
* @return an inputStream
- *
* @throws IOException in the event that an I/O exception of some sort has occurred
*/
- protected InputStream openInputStream(ResourceAccessor accessor, String filename,
+ protected InputStream openInputStream(AFPResourceAccessor accessor, String uriStr,
AFPEventProducer eventProducer)
throws IOException {
URI uri;
try {
- uri = new URI(filename.trim());
+ uri = new URI(uriStr.trim());
} catch (URISyntaxException e) {
- throw new FileNotFoundException("Invalid filename: "
- + filename + " (" + e.getMessage() + ")");
+ throw new MalformedURLException("Invalid uri: " + uriStr + " (" + e.getMessage() + ")");
}
-
if (LOG.isDebugEnabled()) {
LOG.debug("Opening " + uri);
}
- InputStream inputStream = accessor.createInputStream(uri);
- return inputStream;
+ return accessor.createInputStream(uri);
}
/**
@@ -191,7 +187,7 @@ public abstract class CharacterSetBuilder {
* @throws IOException if an I/O error occurs
*/
public CharacterSet buildSBCS(String characterSetName, String codePageName, String encoding,
- ResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
+ AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
return processFont(characterSetName, codePageName, encoding, CharacterSetType.SINGLE_BYTE,
accessor, eventProducer);
}
@@ -211,7 +207,7 @@ public abstract class CharacterSetBuilder {
* @throws IOException if an I/O error occurs
*/
public CharacterSet buildDBCS(String characterSetName, String codePageName, String encoding,
- CharacterSetType charsetType, ResourceAccessor accessor, AFPEventProducer eventProducer)
+ CharacterSetType charsetType, AFPResourceAccessor accessor, AFPEventProducer eventProducer)
throws IOException {
return processFont(characterSetName, codePageName, encoding, charsetType, accessor,
eventProducer);
@@ -236,7 +232,7 @@ public abstract class CharacterSetBuilder {
}
private CharacterSet processFont(String characterSetName, String codePageName, String encoding,
- CharacterSetType charsetType, ResourceAccessor accessor, AFPEventProducer eventProducer)
+ CharacterSetType charsetType, AFPResourceAccessor accessor, AFPEventProducer eventProducer)
throws IOException {
// check for cached version of the characterset
String descriptor = characterSetName + "_" + encoding + "_" + codePageName;
@@ -329,7 +325,7 @@ public abstract class CharacterSetBuilder {
* @throws IOException if an I/O exception of some sort has occurred.
*/
protected Map<String, String> loadCodePage(String codePage, String encoding,
- ResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
+ AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
// Create the HashMap to store code page information
Map<String, String> codePages = new HashMap<String, String>();
@@ -337,7 +333,11 @@ public abstract class CharacterSetBuilder {
InputStream inputStream = null;
try {
inputStream = openInputStream(accessor, codePage.trim(), eventProducer);
-
+ } catch (IOException e) {
+ eventProducer.codePageNotFound(this, e);
+ throw e;
+ }
+ try {
StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream);
byte[] data = structuredFieldReader.getNext(CHARACTER_TABLE_SF);
@@ -367,8 +367,6 @@ public abstract class CharacterSetBuilder {
position++;
}
}
- } catch (FileNotFoundException e) {
- eventProducer.codePageNotFound(this, e);
} finally {
closeInputStream(inputStream);
}
@@ -709,21 +707,21 @@ public abstract class CharacterSetBuilder {
}
protected Map<String, String> loadCodePage(String codePage, String encoding,
- ResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
-
+ AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
// Create the HashMap to store code page information
Map<String, String> codePages = new HashMap<String, String>();
-
InputStream inputStream = null;
try {
inputStream = openInputStream(accessor, codePage.trim(), eventProducer);
-
- StructuredFieldReader structuredFieldReader
- = new StructuredFieldReader(inputStream);
+ } catch (IOException e) {
+ eventProducer.codePageNotFound(this, e);
+ throw e;
+ }
+ try {
+ StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream);
byte[] data;
while ((data = structuredFieldReader.getNext(CHARACTER_TABLE_SF)) != null) {
int position = 0;
-
byte[] gcgiBytes = new byte[8];
byte[] charBytes = new byte[2];
// Read data, ignoring bytes 0 - 2
@@ -751,12 +749,9 @@ public abstract class CharacterSetBuilder {
}
}
}
- } catch (FileNotFoundException e) {
- eventProducer.codePageNotFound(this, e);
} finally {
closeInputStream(inputStream);
}
-
return codePages;
}
diff --git a/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java b/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java
index f83c38621..7c2b68506 100644
--- a/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java
+++ b/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java
@@ -20,7 +20,7 @@
package org.apache.fop.afp.fonts;
import org.apache.fop.afp.AFPEventProducer;
-import org.apache.fop.afp.util.ResourceAccessor;
+import org.apache.fop.afp.util.AFPResourceAccessor;
import org.apache.fop.fonts.Typeface;
/**
@@ -42,7 +42,7 @@ public class FopCharacterSet extends CharacterSet {
*/
public FopCharacterSet(String codePage, String encoding, String name, Typeface charSet,
AFPEventProducer eventProducer) {
- super(codePage, encoding, CharacterSetType.SINGLE_BYTE, name, (ResourceAccessor) null,
+ super(codePage, encoding, CharacterSetType.SINGLE_BYTE, name, (AFPResourceAccessor) null,
eventProducer);
this.charSet = charSet;
}