aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMehdi Houshmand <mehdi@apache.org>2012-04-10 08:39:31 +0000
committerMehdi Houshmand <mehdi@apache.org>2012-04-10 08:39:31 +0000
commit59cd251daa9b13c05844c80938c765ca136a9ee5 (patch)
tree75bc4556a241ef81b824012d69941811a99ff34c
parent167cc48ba2d1811fb88853d2a6427bd25eacf0c0 (diff)
downloadxmlgraphics-fop-59cd251daa9b13c05844c80938c765ca136a9ee5.tar.gz
xmlgraphics-fop-59cd251daa9b13c05844c80938c765ca136a9ee5.zip
Bug in AFP font metrics that performed integer arithmetic when it should have been double arithemetic.
Also added some generics to the surrounding classes git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1311638 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/afp/fonts/AFPFont.java5
-rw-r--r--src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java4
-rw-r--r--src/java/org/apache/fop/afp/fonts/RasterFont.java20
-rw-r--r--status.xml4
4 files changed, 19 insertions, 14 deletions
diff --git a/src/java/org/apache/fop/afp/fonts/AFPFont.java b/src/java/org/apache/fop/afp/fonts/AFPFont.java
index f64410fdd..8a4ae3dc1 100644
--- a/src/java/org/apache/fop/afp/fonts/AFPFont.java
+++ b/src/java/org/apache/fop/afp/fonts/AFPFont.java
@@ -19,6 +19,7 @@
package org.apache.fop.afp.fonts;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -62,8 +63,8 @@ public abstract class AFPFont extends Typeface {
}
/** {@inheritDoc} */
- public Set getFamilyNames() {
- Set s = new java.util.HashSet();
+ public Set<String> getFamilyNames() {
+ Set<String> s = new HashSet<String>();
s.add(this.name);
return s;
}
diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java b/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
index e6c4e6907..4988bb949 100644
--- a/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
+++ b/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
@@ -285,12 +285,12 @@ public abstract class CharacterSetBuilder {
CharacterSetOrientation[] characterSetOrientations
= processFontOrientation(structuredFieldReader);
- int metricNormalizationFactor;
+ double metricNormalizationFactor;
if (fontControl.isRelative()) {
metricNormalizationFactor = 1;
} else {
int dpi = fontControl.getDpi();
- metricNormalizationFactor = 1000 * 72000
+ metricNormalizationFactor = 1000.0d * 72000.0d
/ fontDescriptor.getNominalFontSizeInMillipoints() / dpi;
}
diff --git a/src/java/org/apache/fop/afp/fonts/RasterFont.java b/src/java/org/apache/fop/afp/fonts/RasterFont.java
index da5060ccc..30704b2b0 100644
--- a/src/java/org/apache/fop/afp/fonts/RasterFont.java
+++ b/src/java/org/apache/fop/afp/fonts/RasterFont.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
+import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -39,9 +40,8 @@ public class RasterFont extends AFPFont {
/** Static logging instance */
protected static final Log LOG = LogFactory.getLog("org.apache.fop.afp.fonts");
- private final SortedMap/*<Integer,CharacterSet>*/ charSets
- = new java.util.TreeMap/*<Integer,CharacterSet>*/();
- private Map/*<Integer,CharacterSet>*/ substitutionCharSets;
+ private final SortedMap<Integer, CharacterSet> charSets = new TreeMap<Integer, CharacterSet>();
+ private Map<Integer, CharacterSet> substitutionCharSets;
private CharacterSet charSet = null;
@@ -92,8 +92,8 @@ public class RasterFont extends AFPFont {
// No match or substitution found, but there exist entries
// for other sizes
// Get char set with nearest, smallest font size
- SortedMap smallerSizes = charSets.headMap(requestedSize);
- SortedMap largerSizes = charSets.tailMap(requestedSize);
+ SortedMap<Integer, CharacterSet> smallerSizes = charSets.headMap(requestedSize);
+ SortedMap<Integer, CharacterSet> largerSizes = charSets.tailMap(requestedSize);
int smallerSize = smallerSizes.isEmpty() ? 0
: ((Integer)smallerSizes.lastKey()).intValue();
int largerSize = largerSizes.isEmpty() ? Integer.MAX_VALUE
@@ -112,7 +112,7 @@ public class RasterFont extends AFPFont {
// Add the substitute mapping, so subsequent calls will
// find it immediately
if (substitutionCharSets == null) {
- substitutionCharSets = new HashMap();
+ substitutionCharSets = new HashMap<Integer, CharacterSet>();
}
substitutionCharSets.put(requestedSize, csm);
// do not output the warning if the font size is closer to an integer less than 0.1
@@ -140,9 +140,9 @@ public class RasterFont extends AFPFont {
* @return the first character in this font.
*/
public int getFirstChar() {
- Iterator it = charSets.values().iterator();
+ Iterator<CharacterSet> it = charSets.values().iterator();
if (it.hasNext()) {
- CharacterSet csm = (CharacterSet) it.next();
+ CharacterSet csm = it.next();
return csm.getFirstChar();
} else {
String msg = "getFirstChar() - No character set found for font:" + getFontName();
@@ -157,9 +157,9 @@ public class RasterFont extends AFPFont {
*/
public int getLastChar() {
- Iterator it = charSets.values().iterator();
+ Iterator<CharacterSet> it = charSets.values().iterator();
if (it.hasNext()) {
- CharacterSet csm = (CharacterSet) it.next();
+ CharacterSet csm = it.next();
return csm.getLastChar();
} else {
String msg = "getLastChar() - No character set found for font:" + getFontName();
diff --git a/status.xml b/status.xml
index f58f55879..000d611ea 100644
--- a/status.xml
+++ b/status.xml
@@ -62,6 +62,10 @@
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Code" dev="MH" type="fix">
+ Bug in AFP font metrics that performed integer arithmetic when it should have been
+ double arithemetic.
+ </action>
<action context="Code" dev="GA" type="fix" fixes-bug="49754" due-to="Simon Pepping">
Bring clone() in line with the recommendations in Object.clone().
</action>