/** Static logging instance */
protected static final Log log = LogFactory.getLog(CharacterSet.class.getName());
+ private static final int MAX_NAME_LEN = 8;
+
/** The code page to which the character set relates */
protected String codePage;
/** Indicator as to whether to metrics have been loaded */
private boolean isMetricsLoaded = false;
- /** The current orientation (currently only 0 is suppoted by FOP) */
+ /** The current orientation (currently only 0 is supported by FOP) */
private String currentOrientation = "0";
/** The collection of objects for each orientation */
* @param name the character set name
* @param path the path to the installed afp fonts
*/
- public CharacterSet(
- String codePage,
- String encoding,
- String name,
- String path) {
-
- if (name.length() > 8) {
- String msg = "Character set name must be a maximum of 8 characters " + name;
+ public CharacterSet(String codePage, String encoding, String name, String path) {
+ if (name.length() > MAX_NAME_LEN) {
+ String msg = "Character set name '" + name + "' must be a maximum of "
+ + MAX_NAME_LEN + " characters";
log.error("Constructor:: " + msg);
throw new IllegalArgumentException(msg);
}
- if (name.length() < 8) {
- this.name = StringUtils.rpad(name, ' ', 8);
+ if (name.length() < MAX_NAME_LEN) {
+ this.name = StringUtils.rpad(name, ' ', MAX_NAME_LEN);
} else {
this.name = name;
}
-
this.codePage = codePage;
this.encoding = encoding;
this.path = path;
+
this.characterSetOrientations = new java.util.HashMap(4);
}
* a character rotation other than 0, ascender height loses its
* meaning when the character is lying on its side or is upside down
* with respect to normal viewing orientation. For the general case,
- * Ascender Height is the character�s most positive y-axis value.
+ * Ascender Height is the characters most positive y-axis value.
* For bounded character boxes, for a given character having an
* ascender, ascender height and baseline offset are equal.
*
}
/**
- * The first character in the character set
+ * Returns the first character in the character set
*
- * @return the first character
+ * @return the first character in the character set
*/
public int getFirstChar() {
load();
/**
* Returns the last character in the character set
*
- * @return the last character
+ * @return the last character in the character set
*/
public int getLastChar() {
load();
/**
* XHeight refers to the height of the lower case letters above the baseline.
+ *
* @return the typical height of characters
*/
public int getXHeight() {
/**
* Returns the AFP character set identifier
*
- * @return String
+ * @return the AFP character set identifier
*/
public String getName() {
return name;
}
/**
- * Returns the AFP character set identifier
+ * Returns the AFP character set identifier as a byte array
*
- * @return the AFP character set identifier
+ * @return the AFP character set identifier as a byte array
*/
public byte[] getNameBytes() {
byte[] nameBytes = null;
} catch (UnsupportedEncodingException usee) {
nameBytes = name.getBytes();
log.warn(
- "UnsupportedEncodingException translating the name "
- + name);
+ "UnsupportedEncodingException translating the name " + name);
}
return nameBytes;
}
* implementation (whenever FOP implement the mechanism). This is also
* 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
- * therefore the implementation currely will always use 0 degrees.
+ * therefore the implementation currently will always use 0 degrees.
+ *
*
* @return characterSetOrentation The current orientation metrics.
*/
private CharacterSetOrientation getCharacterSetOrientation() {
-
CharacterSetOrientation c
= (CharacterSetOrientation) characterSetOrientations.get(currentOrientation);
return c;
-
}
/**