aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorChris Bowditch <cbowditch@apache.org>2004-04-02 10:38:29 +0000
committerChris Bowditch <cbowditch@apache.org>2004-04-02 10:38:29 +0000
commitad12e060c43b8ffb4b71af18f28f07a5a81c7ebb (patch)
tree7fec61718bb6ce2e0d3bab24c88797a25eb3a7f1 /src/java
parent7058885ff92727ac05a27924fcb843904ed5aeb1 (diff)
downloadxmlgraphics-fop-ad12e060c43b8ffb4b71af18f28f07a5a81c7ebb.tar.gz
xmlgraphics-fop-ad12e060c43b8ffb4b71af18f28f07a5a81c7ebb.zip
Applied Luca Furini's patch from bugzilla entry 28130.
Corrections to space adjustment for text justification git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197482 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/layoutmgr/LineLayoutManager.java9
-rw-r--r--src/java/org/apache/fop/layoutmgr/TextLayoutManager.java27
2 files changed, 18 insertions, 18 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
index ee018aad6..780d2fcc3 100644
--- a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
@@ -566,7 +566,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
realWidth = targetWith;
} else {
ipdAdjust = -1;
- realWidth = actual.max;
+ realWidth = actual.min;
}
} else {
if (targetWith - actual.opt < actual.max - actual.opt) {
@@ -575,7 +575,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
realWidth = targetWith;
} else {
ipdAdjust = 1;
- realWidth = actual.min;
+ realWidth = actual.max;
}
}
@@ -586,7 +586,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
switch (textalign) {
case TextAlign.JUSTIFY:
if (realWidth != 0) {
- dAdjust = (targetWith - realWidth) / realWidth;
+ dAdjust = (double)(targetWith - realWidth) / realWidth;
}
break;
case TextAlign.START:
@@ -601,6 +601,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
indent = targetWith - realWidth;
break;
}
+ //System.err.println(" ");
+ //System.err.println("LineLayoutManager> difference to fill= " + (targetWith - realWidth));
+ //System.err.println("LineLayoutManager> ipdAdjust= " + ipdAdjust + " dAdjust= " + dAdjust);
LineBreakPosition lbp;
lbp = new LineBreakPosition(this,
diff --git a/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
index e64b71492..d7fae3dc4 100644
--- a/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
@@ -466,23 +466,19 @@ public class TextLayoutManager extends AbstractLayoutManager {
return;
}
// Calculate total adjustment
+ int iRealWidth = ai.ipdArea.opt;
int iAdjust = 0;
+ double dIPDAdjust = context.getIPDAdjust();
double dSpaceAdjust = context.getSpaceAdjust();
- if (dSpaceAdjust > 0.0) {
- // Stretch by factor
- // System.err.println("Potential stretch = " +
- // (ai.ipdArea.max - ai.ipdArea.opt));
- iAdjust = (int)((double)(ai.ipdArea.max
- - ai.ipdArea.opt) * dSpaceAdjust);
- } else if (dSpaceAdjust < 0.0) {
- // Shrink by factor
- // System.err.println("Potential shrink = " +
- // (ai.ipdArea.opt - ai.ipdArea.min));
- iAdjust = (int)((double)(ai.ipdArea.opt
- - ai.ipdArea.min) * dSpaceAdjust);
+ if (dIPDAdjust > 0.0) {
+ iRealWidth += (int)((double)(ai.ipdArea.max - ai.ipdArea.opt) * dIPDAdjust);
}
-// System.err.println("\nText adjustment factor = " + dSpaceAdjust +
-// " total=" + iAdjust + "; breakIndex = " + ai.iBreakIndex);
+ else {
+ iRealWidth += (int)((double)(ai.ipdArea.opt - ai.ipdArea.min) * dIPDAdjust);
+ }
+ iAdjust = (int)((double)(iRealWidth * dSpaceAdjust));
+ //System.err.println(" ");
+ //System.err.println("TextLayoutManager> recreated difference to fill= " + iAdjust);
// Make an area containing all characters between start and end.
InlineArea word = null;
@@ -498,12 +494,13 @@ public class TextLayoutManager extends AbstractLayoutManager {
word = new Space();
word.setWidth(ai.ipdArea.opt + iAdjust);
} else {
- TextArea t = createTextArea(str, ai.ipdArea.opt + iAdjust,
+ TextArea t = createTextArea(str, iRealWidth + iAdjust,
context.getBaseline());
if (iWScount > 0) {
//getLogger().error("Adjustment per word-space= " +
// iAdjust / iWScount);
t.setTSadjust(iAdjust / iWScount);
+ //System.err.println("TextLayoutManager> word spaces= " + iWScount + " adjustment per word space= " + (iAdjust/iWScount));
}
word = t;
}