]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Applied Luca Furini's patch from bugzilla entry 28130.
authorChris Bowditch <cbowditch@apache.org>
Fri, 2 Apr 2004 10:38:29 +0000 (10:38 +0000)
committerChris Bowditch <cbowditch@apache.org>
Fri, 2 Apr 2004 10:38:29 +0000 (10:38 +0000)
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

src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
src/java/org/apache/fop/layoutmgr/TextLayoutManager.java

index ee018aad6f9079380e9891ca6d585252fb74a59f..780d2fcc3dcbfc245f5f146892cbc7e4dc63bd3b 100644 (file)
@@ -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,
index e64b71492f99a9d7fe9f9d74e878544f53c2bcb3..d7fae3dc4d2896719a943d83e6bf2dc16f661d26 100644 (file)
@@ -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;
         }