cbowditch 2004/04/02 02:38:29
Modified: src/java/org/apache/fop/layoutmgr LineLayoutManager.java
TextLayoutManager.java
Log:
Applied Luca Furini's patch from bugzilla entry 28130.
Corrections to space adjustment for text justification
Revision Changes Path
1.17 +6 -3 xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
Index: LineLayoutManager.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- LineLayoutManager.java 21 Mar 2004 12:03:08 -0000 1.16
+++ LineLayoutManager.java 2 Apr 2004 10:38:29 -0000 1.17
@@ -566,7 +566,7 @@
realWidth = targetWith;
} else {
ipdAdjust = -1;
- realWidth = actual.max;
+ realWidth = actual.min;
}
} else {
if (targetWith - actual.opt < actual.max - actual.opt) {
@@ -575,7 +575,7 @@
realWidth = targetWith;
} else {
ipdAdjust = 1;
- realWidth = actual.min;
+ realWidth = actual.max;
}
}
@@ -586,7 +586,7 @@
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 @@
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,
1.13 +12 -15 xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
Index: TextLayoutManager.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TextLayoutManager.java 17 Mar 2004 03:37:32 -0000 1.12
+++ TextLayoutManager.java 2 Apr 2004 10:38:29 -0000 1.13
@@ -466,23 +466,19 @@
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 @@
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;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]