From ad12e060c43b8ffb4b71af18f28f07a5a81c7ebb Mon Sep 17 00:00:00 2001 From: Chris Bowditch Date: Fri, 2 Apr 2004 10:38:29 +0000 Subject: [PATCH] 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 --- .../fop/layoutmgr/LineLayoutManager.java | 9 ++++--- .../fop/layoutmgr/TextLayoutManager.java | 27 +++++++++---------- 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; } -- 2.39.5