diff options
Diffstat (limited to 'src/java/org/apache/fop/afp/fonts/CharacterSet.java')
-rw-r--r-- | src/java/org/apache/fop/afp/fonts/CharacterSet.java | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSet.java b/src/java/org/apache/fop/afp/fonts/CharacterSet.java index f0b671932..9573506b3 100644 --- a/src/java/org/apache/fop/afp/fonts/CharacterSet.java +++ b/src/java/org/apache/fop/afp/fonts/CharacterSet.java @@ -19,8 +19,10 @@ package org.apache.fop.afp.fonts; +import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.net.URI; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; @@ -34,6 +36,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.util.ResourceAccessor; +import org.apache.fop.afp.util.SimpleResourceAccessor; import org.apache.fop.afp.util.StringUtils; /** @@ -80,7 +84,7 @@ public class CharacterSet { protected String name; /** The path to the installed fonts */ - protected String path; + private ResourceAccessor accessor; /** Indicator as to whether to metrics have been loaded */ private boolean isMetricsLoaded = false; @@ -99,8 +103,23 @@ public class CharacterSet { * @param encoding the encoding of the font * @param name the character set name * @param path the path to the installed afp fonts + * @deprecated Please use {@link #CharacterSet(String, String, String, URI)} instead. */ public CharacterSet(String codePage, String encoding, String name, String path) { + this(codePage, encoding, name, + new SimpleResourceAccessor(path != null ? new File(path) : null)); + } + + /** + * Constructor for the CharacterSetMetric object, the character set is used + * to load the font information from the actual AFP font. + * + * @param codePage the code page identifier + * @param encoding the encoding of the font + * @param name the character set name + * @param accessor the resource accessor to load resource with + */ + public CharacterSet(String codePage, String encoding, String name, ResourceAccessor accessor) { if (name.length() > MAX_NAME_LEN) { String msg = "Character set name '" + name + "' must be a maximum of " + MAX_NAME_LEN + " characters"; @@ -123,7 +142,7 @@ public class CharacterSet { //This may happen with "Cp500" on Sun Java 1.4.2 this.encoder = null; } - this.path = path; + this.accessor = accessor; this.characterSetOrientations = new java.util.HashMap(4); } @@ -202,12 +221,11 @@ public class CharacterSet { } /** - * Returns the path where the font resources are installed - * - * @return the path where the font resources are installed + * Returns the resource accessor to load the font resources with. + * @return the resource accessor to load the font resources with */ - public String getPath() { - return path; + public ResourceAccessor getResourceAccessor() { + return this.accessor; } /** |