spepping 2004/05/29 01:50:46 Modified: src/java/org/apache/fop/fo PropertyManager.java TextInfo.java src/java/org/apache/fop/layoutmgr LineLayoutManager.java TextLayoutManager.java Log: Solve a few problems concerning hyphenation: - show the '-' at the end of the hyphenated lines - use the fo:hyphenate property to enable hyphenation, instead of the alignment - specify the hyphenation character using the fo:hyphenation-character property Patch by Luca Furini, bug 27773 Revision Changes Path 1.28 +3 -0 xml-fop/src/java/org/apache/fop/fo/PropertyManager.java Index: PropertyManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/PropertyManager.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- PropertyManager.java 26 May 2004 05:08:59 -0000 1.27 +++ PropertyManager.java 29 May 2004 08:50:46 -0000 1.28 @@ -488,6 +488,9 @@ textInfo.textTransform = this.propertyList.get(PR_TEXT_TRANSFORM).getEnum(); + textInfo.hyphChar = this.propertyList.get( + PR_HYPHENATION_CHARACTER).getCharacter(); + } return textInfo; } 1.7 +2 -2 xml-fop/src/java/org/apache/fop/fo/TextInfo.java Index: TextInfo.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/TextInfo.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- TextInfo.java 27 Feb 2004 17:57:40 -0000 1.6 +++ TextInfo.java 29 May 2004 08:50:46 -0000 1.7 @@ -50,8 +50,8 @@ /** fo:letter-spacing property */ public SpaceVal letterSpacing; - /** can this text be hyphenated? */ - public boolean bCanHyphenate = true; + /* the hyphenation character to be used */ + public char hyphChar = '-'; /** fo:text-decoration property: is text underlined? */ public boolean underlined = false; 1.22 +2 -1 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.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- LineLayoutManager.java 26 May 2004 04:22:39 -0000 1.21 +++ LineLayoutManager.java 29 May 2004 08:50:46 -0000 1.22 @@ -21,6 +21,7 @@ import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyManager; +import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonHyphenation; import org.apache.fop.layout.hyphenation.Hyphenation; @@ -209,7 +210,7 @@ // This break position doesn't fit // TODO: If we are in nowrap, we use it as is! - if (bTextAlignment == TextAlign.JUSTIFY || prevBP == null) { + if (hyphProps.hyphenate == Constants.TRUE) { // If we are already in a hyphenation loop, then stop. if (inlineLC.tryHyphenate()) { 1.17 +21 -11 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.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- TextLayoutManager.java 12 May 2004 23:19:52 -0000 1.16 +++ TextLayoutManager.java 29 May 2004 08:50:46 -0000 1.17 @@ -46,12 +46,14 @@ private short iBreakIndex; private short iWScount; private MinOptMax ipdArea; + private boolean bHyphenated; public AreaInfo(short iSIndex, short iBIndex, short iWS, - MinOptMax ipd) { + MinOptMax ipd, boolean bHyph) { iStartIndex = iSIndex; iBreakIndex = iBIndex; iWScount = iWS; ipdArea = ipd; + bHyphenated = bHyph; } } @@ -107,7 +109,7 @@ // With CID fonts, space isn't neccesary currentFontState.width(32) spaceCharIPD = foText.textInfo.fs.getCharWidth(' '); // Use hyphenationChar property - hyphIPD = foText.textInfo.fs.getCharWidth('-'); + hyphIPD = foText.textInfo.fs.getCharWidth(foText.textInfo.hyphChar); // Make half-space: <space> on either side of a word-space) SpaceVal ws = foText.textInfo.wordSpacing; halfWS = new SpaceVal(MinOptMax.multiply(ws.getSpace(), 0.5), @@ -201,7 +203,7 @@ boolean bCanHyphenate = true; int iStopIndex = iNextStart + hc.getNextHyphPoint(); - if (textArray.length < iStopIndex || foText.textInfo.bCanHyphenate == false) { + if (textArray.length < iStopIndex) { iStopIndex = textArray.length; bCanHyphenate = false; } @@ -396,7 +398,8 @@ // Position is the index of the info for this word in the vector vecAreaInfo.add( - new AreaInfo(iWordStart, iNextStart, iWScount, ipd)); + new AreaInfo(iWordStart, iNextStart, iWScount, ipd, + ((flags & BreakPoss.HYPHENATED) != 0))); BreakPoss bp = new BreakPoss( new LeafPosition(this, vecAreaInfo.size() - 1)); ipdTotal = ipd; @@ -465,6 +468,20 @@ if (ai == null) { return; } + + // ignore newline character + int adjust = 0; + if (textArray[ai.iBreakIndex - 1] == NEWLINE) { + adjust = 1; + } + String str = new String(textArray, iStart, ai.iBreakIndex - iStart - adjust); + + // add hyphenation character if the last word is hyphenated + if (ai.bHyphenated) { + str += foText.textInfo.hyphChar; + ai.ipdArea = MinOptMax.add(ai.ipdArea, new MinOptMax(hyphIPD)); + } + // Calculate total adjustment int iRealWidth = ai.ipdArea.opt; int iAdjust = 0; @@ -482,13 +499,6 @@ // Make an area containing all characters between start and end. InlineArea word = null; - int adjust = 0; - - // ignore newline character - if (textArray[ai.iBreakIndex - 1] == NEWLINE) { - adjust = 1; - } - String str = new String(textArray, iStart, ai.iBreakIndex - iStart - adjust); if (" ".equals(str)) { word = new Space();
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]