Browse Source

Removed unnecessary storing of byte[] nameBytes

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@677973 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_0
Adrian Cumiskey 16 years ago
parent
commit
3a2b3470fc
1 changed files with 39 additions and 55 deletions
  1. 39
    55
      src/java/org/apache/fop/render/afp/fonts/CharacterSet.java

+ 39
- 55
src/java/org/apache/fop/render/afp/fonts/CharacterSet.java View File

package org.apache.fop.render.afp.fonts; package org.apache.fop.render.afp.fonts;


import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map; import java.util.Map;


import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
*/ */
public class CharacterSet { public class CharacterSet {


/**
* Static logging instance
*/
/** Static logging instance */
protected static final Log log = LogFactory.getLog(CharacterSet.class.getName()); protected static final Log log = LogFactory.getLog(CharacterSet.class.getName());


/**
* The code page to which the character set relates
*/
/** The code page to which the character set relates */
protected String codePage; protected String codePage;


/**
* The encoding used for the code page
*/
/** The encoding used for the code page */
protected String encoding; protected String encoding;


/**
* The character set relating to the font
*/
/** The character set relating to the font */
protected String name; protected String name;


/**
* The name of the character set as EBCIDIC bytes
*/
private byte[] nameBytes;

/**
* The path to the installed fonts
*/
/** The path to the installed fonts */
protected String path; protected String path;


/**
* Indicator as to whether to metrics have been loaded
*/
/** Indicator as to whether to metrics have been loaded */
private boolean isMetricsLoaded = false; private boolean isMetricsLoaded = false;


/**
* The current orientation (currently only 0 is suppoted by FOP)
*/
/** The current orientation (currently only 0 is suppoted by FOP) */
private String currentOrientation = "0"; private String currentOrientation = "0";


/**
* The collection of objects for each orientation
*/
/** The collection of objects for each orientation */
private Map characterSetOrientations = null; private Map characterSetOrientations = null;


/** /**
* Constructor for the CharacterSetMetric object, the character set is used * Constructor for the CharacterSetMetric object, the character set is used
* to load the font information from the actual AFP font. * to load the font information from the actual AFP font.
*
* @param codePage the code page identifier * @param codePage the code page identifier
* @param encoding the encoding of the font * @param encoding the encoding of the font
* @param name the character set name * @param name the character set name
this.name = name; this.name = name;
} }


try {

this.nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);

} catch (UnsupportedEncodingException usee) {

this.nameBytes = name.getBytes();
log.warn(
"Constructor:: UnsupportedEncodingException translating the name "
+ name);

}

this.codePage = codePage; this.codePage = codePage;
this.encoding = encoding; this.encoding = encoding;
this.path = path; this.path = path;
this.characterSetOrientations = new HashMap(4);

this.characterSetOrientations = new java.util.HashMap(4);
} }


/** /**
* Add character set metric information for the different orientations * Add character set metric information for the different orientations
*
* @param cso the metrics for the orientation * @param cso the metrics for the orientation
*/ */
public void addCharacterSetOrientation(CharacterSetOrientation cso) { public void addCharacterSetOrientation(CharacterSetOrientation cso) {

characterSetOrientations.put( characterSetOrientations.put(
String.valueOf(cso.getOrientation()), String.valueOf(cso.getOrientation()),
cso); cso);

} }


/** /**
* Ascender Height is the character�s most positive y-axis value. * Ascender Height is the character�s most positive y-axis value.
* For bounded character boxes, for a given character having an * For bounded character boxes, for a given character having an
* ascender, ascender height and baseline offset are equal. * ascender, ascender height and baseline offset are equal.
*
* @return the ascender value in millipoints * @return the ascender value in millipoints
*/ */
public int getAscender() { public int getAscender() {
* Cap height is the average height of the uppercase characters in * Cap height is the average height of the uppercase characters in
* a font. This value is specified by the designer of a font and is * a font. This value is specified by the designer of a font and is
* usually the height of the uppercase M. * usually the height of the uppercase M.
*
* @return the cap height value in millipoints * @return the cap height value in millipoints
*/ */
public int getCapHeight() { public int getCapHeight() {
* Descender depth is the distance from the character baseline to * Descender depth is the distance from the character baseline to
* the bottom of a character box. A negative descender depth signifies * the bottom of a character box. A negative descender depth signifies
* that all of the graphic character is above the character baseline. * that all of the graphic character is above the character baseline.
*
* @return the descender value in millipoints * @return the descender value in millipoints
*/ */
public int getDescender() { public int getDescender() {


/** /**
* The first character in the character set * The first character in the character set
*
* @return the first character * @return the first character
*/ */
public int getFirstChar() { public int getFirstChar() {
} }


/** /**
* The last character in the character set
* Returns the last character in the character set
*
* @return the last character * @return the last character
*/ */
public int getLastChar() { public int getLastChar() {
} }


/** /**
* Returns the path where the font resources are installed
*
* @return the path where the font resources are installed * @return the path where the font resources are installed
*/ */
public String getPath() { public String getPath() {


/** /**
* Get the width (in 1/1000ths of a point size) of all characters * Get the width (in 1/1000ths of a point size) of all characters
*
* @return the widths of all characters * @return the widths of all characters
*/ */
public int[] getWidths() { public int[] getWidths() {
/** /**
* Get the width (in 1/1000ths of a point size) of the character * Get the width (in 1/1000ths of a point size) of the character
* identified by the parameter passed. * identified by the parameter passed.
*
* @param character the character from which the width will be calculated * @param character the character from which the width will be calculated
* @return the width of the character * @return the width of the character
*/ */
* be processed on a method call requiring the metric information. * be processed on a method call requiring the metric information.
*/ */
private void load() { private void load() {

if (!isMetricsLoaded) { if (!isMetricsLoaded) {

AFPFontReader afpFontReader = new AFPFontReader(); AFPFontReader afpFontReader = new AFPFontReader();
afpFontReader.loadCharacterSetMetric(this); afpFontReader.loadCharacterSetMetric(this);
isMetricsLoaded = true; isMetricsLoaded = true;

} }

} }


/** /**
* Returns the AFP character set identifier * Returns the AFP character set identifier
*
* @return String * @return String
*/ */
public String getName() { public String getName() {


/** /**
* Returns the AFP character set identifier * Returns the AFP character set identifier
* @return byte[]
*
* @return the AFP character set identifier
*/ */
public byte[] getNameBytes() { public byte[] getNameBytes() {
byte[] nameBytes = null;
try {
nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
} catch (UnsupportedEncodingException usee) {
nameBytes = name.getBytes();
log.warn(
"UnsupportedEncodingException translating the name "
+ name);
}
return nameBytes; return nameBytes;
} }


/** /**
* Returns the AFP code page identifier * Returns the AFP code page identifier
* @return String
*
* @return the AFP code page identifier
*/ */
public String getCodePage() { public String getCodePage() {
return codePage; return codePage;


/** /**
* Returns the AFP code page encoding * Returns the AFP code page encoding
* @return String
*
* @return the AFP code page encoding
*/ */
public String getEncoding() { public String getEncoding() {
return encoding; return encoding;
* the case for landscape prints which use an orientation of 270 degrees, * the case for landscape prints which use an orientation of 270 degrees,
* in 99.9% of cases the font metrics will be the same as the 0 degrees * in 99.9% of cases the font metrics will be the same as the 0 degrees
* therefore the implementation currely will always use 0 degrees. * therefore the implementation currely will always use 0 degrees.
*
* @return characterSetOrentation The current orientation metrics. * @return characterSetOrentation The current orientation metrics.
*/ */
private CharacterSetOrientation getCharacterSetOrientation() { private CharacterSetOrientation getCharacterSetOrientation() {
* Map a Unicode character to a code point in the font. * Map a Unicode character to a code point in the font.
* The code tables are already converted to Unicode therefore * The code tables are already converted to Unicode therefore
* we can use the identity mapping. * we can use the identity mapping.
*
* @param c character to map * @param c character to map
* @return the mapped character * @return the mapped character
*/ */

Loading…
Cancel
Save