import java.util.List;
import java.util.Map;
-import org.apache.fop.util.CharUtilities;
import org.apache.xmlgraphics.fonts.Glyphs;
+import org.apache.fop.util.CharUtilities;
+
/**
* A simple implementation of the OneByteEncoding mostly used for encodings that are constructed
* on-the-fly.
/** {@inheritDoc} */
public char mapChar(char c) {
- Character nc = charMap.get(new Character(c));
+ Character nc = charMap.get(Character.valueOf(c));
if (nc != null) {
return nc.charValue();
}
}
char newSlot = (char)(getLastChar() + 1);
this.mapping.add(ch);
- this.charMap.put(new Character(ch.getSingleUnicodeValue()), new Character(newSlot));
+ this.charMap.put(Character.valueOf(ch.getSingleUnicodeValue()), Character.valueOf(newSlot));
return newSlot;
}
if (i < 256) {
int idx = i - getFirstChar();
if (idx >= 0 && idx < width.length) {
- return size * width[i - getFirstChar()];
+ return size * width[idx];
}
} else if (this.additionalEncodings != null) {
int encodingIndex = (i / 256) - 1;
int codePoint = i % 256;
NamedCharacter nc = encoding.getCharacterForIndex(codePoint);
UnencodedCharacter uc
- = this.unencodedCharacters.get(new Character(nc.getSingleUnicodeValue()));
+ = this.unencodedCharacters.get(Character.valueOf(nc.getSingleUnicodeValue()));
return size * uc.getWidth();
}
return 0;
private char mapUnencodedChar(char ch) {
if (this.unencodedCharacters != null) {
- UnencodedCharacter unencoded = this.unencodedCharacters.get(new Character(ch));
+ UnencodedCharacter unencoded = this.unencodedCharacters.get(Character.valueOf(ch));
if (unencoded != null) {
if (this.additionalEncodings == null) {
this.additionalEncodings = new ArrayList<SimpleSingleByteEncoding>();
}
if (ch.hasSingleUnicodeValue()) {
UnencodedCharacter uc = new UnencodedCharacter(ch, width);
- this.unencodedCharacters.put(new Character(ch.getSingleUnicodeValue()), uc);
+ this.unencodedCharacters.put(Character.valueOf(ch.getSingleUnicodeValue()), uc);
} else {
//Cannot deal with unicode sequences, so ignore this character
}
for (int i = 0, c = arr.length; i < c; i++) {
NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i);
UnencodedCharacter uc = this.unencodedCharacters.get(
- new Character(nc.getSingleUnicodeValue()));
+ Character.valueOf(nc.getSingleUnicodeValue()));
arr[i] = uc.getWidth();
}
return arr;
private static final String[] AFM_EXTENSIONS = new String[] {".AFM", ".afm", ".Afm"};
/** {@inheritDoc} */
+ @Override
protected void read() throws IOException {
AFMFile afm = null;
PFMFile pfm = null;
}
}
- private Set toGlyphSet(String[] glyphNames) {
- Set glyphSet = new java.util.HashSet();
- for (int i = 0, c = glyphNames.length; i < c; i++) {
- glyphSet.add(glyphNames[i]);
+ private Set<String> toGlyphSet(String[] glyphNames) {
+ Set<String> glyphSet = new java.util.HashSet<String>();
+ for (String name : glyphNames) {
+ glyphSet.add(name);
}
return glyphSet;
}
*/
private void addUnencodedBasedOnEncoding(AFMFile afm) {
SingleByteEncoding encoding = singleFont.getEncoding();
- Set glyphNames = toGlyphSet(encoding.getCharNameMap());
- List charMetrics = afm.getCharMetrics();
- for (int i = 0, c = afm.getCharCount(); i < c; i++) {
- AFMCharMetrics metrics = (AFMCharMetrics)charMetrics.get(i);
+ Set<String> glyphNames = toGlyphSet(encoding.getCharNameMap());
+ List<AFMCharMetrics> charMetrics = afm.getCharMetrics();
+ for (AFMCharMetrics metrics : charMetrics) {
String charName = metrics.getCharName();
if (charName != null && !glyphNames.contains(charName)) {
singleFont.addUnencodedCharacter(metrics.getCharacter(),
returnFont.setFirstChar(afm.getFirstChar());
returnFont.setLastChar(afm.getLastChar());
- Iterator iter = afm.getCharMetrics().iterator();
- while (iter.hasNext()) {
- AFMCharMetrics chm = (AFMCharMetrics)iter.next();
+ for (AFMCharMetrics chm : afm.getCharMetrics()) {
if (chm.hasCharCode()) {
singleFont.setWidth(chm.getCharCode(), (int)Math.round(chm.getWidthX()));
}