Преглед на файлове

Fixed some FindBugs issues.

Added some generics.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1142192 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_1rc1old
Jeremias Maerki преди 13 години
родител
ревизия
8b266c1f6d

+ 4
- 3
src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java Целия файл

import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;


import org.apache.fop.util.CharUtilities;
import org.apache.xmlgraphics.fonts.Glyphs; 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 * A simple implementation of the OneByteEncoding mostly used for encodings that are constructed
* on-the-fly. * on-the-fly.


/** {@inheritDoc} */ /** {@inheritDoc} */
public char mapChar(char c) { public char mapChar(char c) {
Character nc = charMap.get(new Character(c));
Character nc = charMap.get(Character.valueOf(c));
if (nc != null) { if (nc != null) {
return nc.charValue(); return nc.charValue();
} }
} }
char newSlot = (char)(getLastChar() + 1); char newSlot = (char)(getLastChar() + 1);
this.mapping.add(ch); 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; return newSlot;
} }



+ 5
- 5
src/java/org/apache/fop/fonts/SingleByteFont.java Целия файл

if (i < 256) { if (i < 256) {
int idx = i - getFirstChar(); int idx = i - getFirstChar();
if (idx >= 0 && idx < width.length) { if (idx >= 0 && idx < width.length) {
return size * width[i - getFirstChar()];
return size * width[idx];
} }
} else if (this.additionalEncodings != null) { } else if (this.additionalEncodings != null) {
int encodingIndex = (i / 256) - 1; int encodingIndex = (i / 256) - 1;
int codePoint = i % 256; int codePoint = i % 256;
NamedCharacter nc = encoding.getCharacterForIndex(codePoint); NamedCharacter nc = encoding.getCharacterForIndex(codePoint);
UnencodedCharacter uc UnencodedCharacter uc
= this.unencodedCharacters.get(new Character(nc.getSingleUnicodeValue()));
= this.unencodedCharacters.get(Character.valueOf(nc.getSingleUnicodeValue()));
return size * uc.getWidth(); return size * uc.getWidth();
} }
return 0; return 0;


private char mapUnencodedChar(char ch) { private char mapUnencodedChar(char ch) {
if (this.unencodedCharacters != null) { if (this.unencodedCharacters != null) {
UnencodedCharacter unencoded = this.unencodedCharacters.get(new Character(ch));
UnencodedCharacter unencoded = this.unencodedCharacters.get(Character.valueOf(ch));
if (unencoded != null) { if (unencoded != null) {
if (this.additionalEncodings == null) { if (this.additionalEncodings == null) {
this.additionalEncodings = new ArrayList<SimpleSingleByteEncoding>(); this.additionalEncodings = new ArrayList<SimpleSingleByteEncoding>();
} }
if (ch.hasSingleUnicodeValue()) { if (ch.hasSingleUnicodeValue()) {
UnencodedCharacter uc = new UnencodedCharacter(ch, width); UnencodedCharacter uc = new UnencodedCharacter(ch, width);
this.unencodedCharacters.put(new Character(ch.getSingleUnicodeValue()), uc);
this.unencodedCharacters.put(Character.valueOf(ch.getSingleUnicodeValue()), uc);
} else { } else {
//Cannot deal with unicode sequences, so ignore this character //Cannot deal with unicode sequences, so ignore this character
} }
for (int i = 0, c = arr.length; i < c; i++) { for (int i = 0, c = arr.length; i < c; i++) {
NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i); NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i);
UnencodedCharacter uc = this.unencodedCharacters.get( UnencodedCharacter uc = this.unencodedCharacters.get(
new Character(nc.getSingleUnicodeValue()));
Character.valueOf(nc.getSingleUnicodeValue()));
arr[i] = uc.getWidth(); arr[i] = uc.getWidth();
} }
return arr; return arr;

+ 9
- 11
src/java/org/apache/fop/fonts/type1/Type1FontLoader.java Целия файл

private static final String[] AFM_EXTENSIONS = new String[] {".AFM", ".afm", ".Afm"}; private static final String[] AFM_EXTENSIONS = new String[] {".AFM", ".afm", ".Afm"};


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
protected void read() throws IOException { protected void read() throws IOException {
AFMFile afm = null; AFMFile afm = null;
PFMFile pfm = 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; return glyphSet;
} }
*/ */
private void addUnencodedBasedOnEncoding(AFMFile afm) { private void addUnencodedBasedOnEncoding(AFMFile afm) {
SingleByteEncoding encoding = singleFont.getEncoding(); 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(); String charName = metrics.getCharName();
if (charName != null && !glyphNames.contains(charName)) { if (charName != null && !glyphNames.contains(charName)) {
singleFont.addUnencodedCharacter(metrics.getCharacter(), singleFont.addUnencodedCharacter(metrics.getCharacter(),


returnFont.setFirstChar(afm.getFirstChar()); returnFont.setFirstChar(afm.getFirstChar());
returnFont.setLastChar(afm.getLastChar()); 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()) { if (chm.hasCharCode()) {
singleFont.setWidth(chm.getCharCode(), (int)Math.round(chm.getWidthX())); singleFont.setWidth(chm.getCharCode(), (int)Math.round(chm.getWidthX()));
} }

Loading…
Отказ
Запис