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;
// 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()) {
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;
}
}
// 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),
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;
}
// 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;
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;
// 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();