diff options
author | Mehdi Houshmand <mehdi@apache.org> | 2012-08-10 09:50:47 +0000 |
---|---|---|
committer | Mehdi Houshmand <mehdi@apache.org> | 2012-08-10 09:50:47 +0000 |
commit | ce3600f7549c58e279737aeff6b707730f9d27b3 (patch) | |
tree | 1deaf535844c555cec4f8a80aea6165694e7443e /src/java/org/apache/fop | |
parent | 6c9c875c0d1429d392cd7e4e810bb146c063ea27 (diff) | |
download | xmlgraphics-fop-ce3600f7549c58e279737aeff6b707730f9d27b3.tar.gz xmlgraphics-fop-ce3600f7549c58e279737aeff6b707730f9d27b3.zip |
Buzilla#53657 - AFP fonts use nominal character increment when the glyph metrics aren't available
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1371629 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
4 files changed, 39 insertions, 35 deletions
diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSet.java b/src/java/org/apache/fop/afp/fonts/CharacterSet.java index 49e7f99ba..d54d478bc 100644 --- a/src/java/org/apache/fop/afp/fonts/CharacterSet.java +++ b/src/java/org/apache/fop/afp/fonts/CharacterSet.java @@ -363,4 +363,12 @@ public class CharacterSet { return getCharacterSetOrientation().getEmSpaceIncrement(); } + /** + * Returns the nominal character increment. + * @return the nominal character increment + */ + public int getNominalCharIncrement() { + return getCharacterSetOrientation().getNominalCharIncrement(); + } + } diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java b/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java index 7331178f5..2aa5a9eea 100644 --- a/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java +++ b/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java @@ -446,20 +446,15 @@ public abstract class CharacterSetBuilder { position++; if (position == 26) { - position = 0; int orientation = determineOrientation(fnoData[2]); - // Space Increment - int space = ((fnoData[8] & 0xFF ) << 8) + (fnoData[9] & 0xFF); - // Em-Space Increment - int em = ((fnoData[14] & 0xFF ) << 8) + (fnoData[15] & 0xFF); - - CharacterSetOrientation cso = new CharacterSetOrientation(orientation); - cso.setSpaceIncrement(space); - cso.setEmSpaceIncrement(em); - orientations.add(cso); + int spaceIncrement = getUBIN(fnoData, 8); + int emIncrement = getUBIN(fnoData, 14); + int nominalCharacterIncrement = getUBIN(fnoData, 20); + orientations.add(new CharacterSetOrientation(orientation, spaceIncrement, + emIncrement, nominalCharacterIncrement)); } } return orientations.toArray(EMPTY_CSO_ARRAY); diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java b/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java index 7ac8ae96b..a730525d2 100644 --- a/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java +++ b/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java @@ -60,7 +60,7 @@ public class CharacterSetOrientation { /** * The character widths in the character set (indexed using Unicode codepoints) */ - private int[] charsWidths = null; + private int[] charsWidths; /** * The height of lowercase letters @@ -77,25 +77,26 @@ public class CharacterSetOrientation { */ private char lastChar; - - /** - * The character set orientation - */ - private int orientation = 0; - + /** The character set orientation */ + private final int orientation; /** space increment */ - private int spaceIncrement; + private final int spaceIncrement; /** em space increment */ - private int emSpaceIncrement = -1; - + private final int emSpaceIncrement; + /** Nominal Character Increment */ + private final int nomCharIncrement; /** * Constructor for the CharacterSetOrientation, the orientation is * expressed as the degrees rotation (i.e 0, 90, 180, 270) * @param orientation the character set orientation */ - public CharacterSetOrientation(int orientation) { + public CharacterSetOrientation(int orientation, int spaceIncrement, int emSpaceIncrement, + int nomCharIncrement) { this.orientation = orientation; + this.spaceIncrement = spaceIncrement; + this.emSpaceIncrement = emSpaceIncrement; + this.nomCharIncrement = nomCharIncrement; charsWidths = new int[256]; Arrays.fill(charsWidths, -1); } @@ -284,14 +285,6 @@ public class CharacterSetOrientation { } /** - * Sets the space increment. - * @param value the space increment - */ - public void setSpaceIncrement(int value) { - this.spaceIncrement = value; - } - - /** * Returns the em space increment. * @return the em space increment */ @@ -300,11 +293,10 @@ public class CharacterSetOrientation { } /** - * Sets the em space increment. - * @param value the em space increment + * Returns the nominal character increment. + * @return the nominal character increment */ - public void setEmSpaceIncrement(int value) { - this.emSpaceIncrement = value; + public int getNominalCharIncrement() { + return this.nomCharIncrement; } - } diff --git a/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java b/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java index 0e6cc20c2..78da6ea82 100644 --- a/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java +++ b/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java @@ -80,11 +80,20 @@ public class DoubleByteFont extends AbstractOutlineFont { } if (charWidth == -1) { - charWidth = inferCharWidth(character); + charWidth = getDefaultCharacterWidth(character); } return charWidth * size; } + private int getDefaultCharacterWidth(int character) { + int nominalCharIncrement = charSet.getNominalCharIncrement(); + if (nominalCharIncrement > 0) { + return nominalCharIncrement; + } else { + return inferCharWidth(character); + } + } + private int inferCharWidth(int character) { //Is this character an ideograph? |