aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-12-11 16:41:53 +0000
committerJeremias Maerki <jeremias@apache.org>2008-12-11 16:41:53 +0000
commit3beeea67b665a3fdd6331f8c6fb99d24dc683f78 (patch)
treec1b44b6c6770a9d092fcd5615d2260821cca2c3e
parentc530c134e8bd16ce37ad9a79dab4706623d7ac44 (diff)
downloadxmlgraphics-fop-3beeea67b665a3fdd6331f8c6fb99d24dc683f78.tar.gz
xmlgraphics-fop-3beeea67b665a3fdd6331f8c6fb99d24dc683f78.zip
Fixed another little kerning bug.
Trim down dx array to the maximum size necessary. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@725738 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFRenderer.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
index b3748dc2e..f4df51b8e 100644
--- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
@@ -1025,7 +1025,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
private class TextUtil {
private static final int INITIAL_BUFFER_SIZE = 16;
private int[] dx = new int[INITIAL_BUFFER_SIZE];
- private boolean hasDX = false;
+ private int lastDXPos = 0;
private StringBuffer text = new StringBuffer();
private int startx, starty;
@@ -1035,7 +1035,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
void adjust(int adjust) {
if (adjust != 0) {
- int idx = text.length();
+ int idx = text.length() - 1;
if (idx > dx.length - 1) {
int newSize = Math.max(dx.length, idx + 1) + INITIAL_BUFFER_SIZE;
int[] newDX = new int[newSize];
@@ -1043,7 +1043,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
dx = newDX;
}
dx[idx] += adjust;
- hasDX = true;
+ lastDXPos = idx;
}
}
@@ -1051,7 +1051,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
if (text.length() > 0) {
text.setLength(0);
Arrays.fill(dx, 0);
- hasDX = false;
+ lastDXPos = 0;
}
}
@@ -1063,7 +1063,13 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
void flush() {
if (text.length() > 0) {
try {
- painter.drawText(startx, starty, (hasDX ? dx : null), null, text.toString());
+ int[] effDX = null;
+ if (lastDXPos > 0) {
+ int size = lastDXPos + 1;
+ effDX = new int[size];
+ System.arraycopy(dx, 0, effDX, 0, size);
+ }
+ painter.drawText(startx, starty, effDX, null, text.toString());
} catch (IFException e) {
handleIFException(e);
}