import java.util.List;
import org.apache.fop.datatypes.PercentBase;
-import org.apache.fop.fo.TextInfo;
import org.apache.fop.fo.PropertyManager;
+import org.apache.fop.fonts.Font;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.area.BlockParent;
* LayoutManager for a block FO.
*/
public class BlockLayoutManager extends BlockStackingLayoutManager {
-
+ private org.apache.fop.fo.flow.Block fobj;
+
private Block curBlockArea;
protected ListIterator proxyLMiter;
protected List childBreaks = new java.util.ArrayList();
public BlockLayoutManager(org.apache.fop.fo.flow.Block inBlock) {
- super.setFObj(inBlock);
+ super(inBlock);
+ fobj = inBlock;
proxyLMiter = new ProxyLMiter();
- userAgent = inBlock.getUserAgent();
- setBlockTextInfo(inBlock.getPropertyManager().getTextLayoutProps(
- inBlock.getFOEventHandler().getFontInfo()));
- }
- private void setBlockTextInfo(TextInfo ti) {
- lead = ti.fs.getAscender();
- follow = -ti.fs.getDescender();
- lineHeight = ti.lineHeight;
+ Font fs = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo());
+
+ lead = fs.getAscender();
+ follow = -fs.getDescender();
+ lineHeight = fobj.getLineHeight().getOptimum().getLength().getValue();
}
/**
package org.apache.fop.layoutmgr;
import org.apache.fop.fo.flow.Character;
-import org.apache.fop.fo.TextInfo;
+import org.apache.fop.fonts.Font;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.Trait;
import org.apache.fop.traits.MinOptMax;
* LayoutManager for the fo:character formatting object
*/
public class CharacterLayoutManager extends LeafNodeLayoutManager {
-
+ private Character fobj;
private MinOptMax letterSpaceIPD;
private int hyphIPD;
- private TextInfo textInfo;
+ private Font fs;
/**
* Constructor
*/
public CharacterLayoutManager(Character node) {
super(node);
+ fobj = node;
InlineArea inline = getCharacterInlineArea(node);
setCurrentArea(inline);
+ fs = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo());
- textInfo = node.getPropertyManager().getTextLayoutProps
- (node.getFOEventHandler().getFontInfo());
- SpaceVal ls = textInfo.letterSpacing;
- letterSpaceIPD = new MinOptMax(ls.getSpace().min,
- ls.getSpace().opt,
- ls.getSpace().max);
- hyphIPD = textInfo.fs.getCharWidth(textInfo.hyphChar);
+ SpaceVal ls = SpaceVal.makeLetterSpacing(fobj.getLetterSpacing());
+ letterSpaceIPD = ls.getSpace();
+ hyphIPD = fs.getCharWidth(fobj.getCommonHyphenation().hyphenationChar);
}
private InlineArea getCharacterInlineArea(Character node) {
return null;
}
- ipd = new MinOptMax(textInfo.fs.getCharWidth(((org.apache.fop.area.inline.Character) curArea).getChar().charAt(0)));
+ ipd = new MinOptMax(fs.getCharWidth(((org.apache.fop.area.inline.Character) curArea).getChar().charAt(0)));
curArea.setIPD(ipd.opt);
- curArea.setBPD(textInfo.fs.getAscender()
- - textInfo.fs.getDescender());
+ curArea.setBPD(fs.getAscender() - fs.getDescender());
// offset is set in the offsetArea() method
//curArea.setOffset(textInfo.fs.getAscender());
//curArea.setOffset(context.getBaseline());
- curArea.addTrait(Trait.FONT_NAME, textInfo.fs.getFontName());
- curArea.addTrait(Trait.FONT_SIZE,
- new Integer(textInfo.fs.getFontSize()));
- curArea.addTrait(Trait.COLOR, textInfo.color);
+ curArea.addTrait(Trait.FONT_NAME, fs.getFontName());
+ curArea.addTrait(Trait.FONT_SIZE, new Integer(fs.getFontSize()));
+ curArea.addTrait(Trait.COLOR, fobj.getColor());
int bpd = curArea.getBPD();
int lead = 0;
import java.util.ListIterator;
import org.apache.fop.fo.FOText;
+import org.apache.fop.fonts.Font;
import org.apache.fop.traits.SpaceVal;
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.InlineArea;
private SpaceVal halfWS;
/** Number of space characters after previous possible break position. */
private int iNbSpacesPending;
+ private Font fs;
private boolean bChanged = false;
private int iReturnedIndex = 0;
vecAreaInfo = new java.util.ArrayList();
+ fs = foText.getCommonFont().getFontState(foText.getFOEventHandler().getFontInfo());
+
// With CID fonts, space isn't neccesary currentFontState.width(32)
- spaceCharIPD = foText.textInfo.fs.getCharWidth(' ');
+ spaceCharIPD = fs.getCharWidth(' ');
// Use hyphenationChar property
- hyphIPD = foText.textInfo.fs.getCharWidth(foText.textInfo.hyphChar);
+ hyphIPD = fs.getCharWidth(foText.getCommonHyphenation().hyphenationChar);
// Make half-space: <space> on either side of a word-space)
- SpaceVal ws = foText.textInfo.wordSpacing;
+ SpaceVal ls = SpaceVal.makeLetterSpacing(foText.getLetterSpacing());
+ SpaceVal ws = SpaceVal.makeWordSpacing(foText.getWordSpacing(), ls, fs);
halfWS = new SpaceVal(MinOptMax.multiply(ws.getSpace(), 0.5),
ws.isConditional(), ws.isForcing(), ws.getPrecedence());
- SpaceVal ls = foText.textInfo.letterSpacing;
// letter space applies only to consecutive non-space characters,
// while word space applies to space characters;
// set letter space and word space dimension;
// the default value "normal" was converted into a MinOptMax value
- // in the PropertyManager.getTextLayoutProps() method
- letterSpaceIPD = new MinOptMax(ls.getSpace().min,
- ls.getSpace().opt, ls.getSpace().max);
- wordSpaceIPD = new MinOptMax(spaceCharIPD + ws.getSpace().min,
- spaceCharIPD + ws.getSpace().opt,
- spaceCharIPD + ws.getSpace().max);
+ // in the SpaceVal.makeWordSpacing() method
+ letterSpaceIPD = ls.getSpace();
+ wordSpaceIPD = MinOptMax.add(new MinOptMax(spaceCharIPD), ws.getSpace());
}
/**
*/
public boolean canBreakBefore(LayoutContext context) {
char c = textArray[iNextStart];
- return ((c == NEWLINE)
- || (foText.textInfo.bWrap
+ return ((c == NEWLINE) || (foText.getWrapOption() == WRAP
&& (CharUtilities.isBreakableSpace(c)
|| (BREAK_CHARS.indexOf(c) >= 0
&& (iNextStart == 0
for (; iNextStart < iStopIndex; iNextStart++) {
char c = textArray[iNextStart];
- hyphIPD.opt += foText.textInfo.fs.getCharWidth(c);
+ hyphIPD.opt += fs.getCharWidth(c);
// letter-space?
}
// Need to include hyphen size too, but don't count it in the
bSawNonSuppressible = true;
spaceIPD.add(pendingSpace.resolve(false));
pendingSpace.clear();
- wordIPD += foText.textInfo.fs.getCharWidth(c);
+ wordIPD += fs.getCharWidth(c);
}
}
for (; iNextStart < textArray.length; iNextStart++) {
char c = textArray[iNextStart];
// Include any breakable white-space as break char
- if ((c == NEWLINE) || (foText.textInfo.bWrap
+ if ((c == NEWLINE) || (foText.getWrapOption() == WRAP
&& (CharUtilities.isBreakableSpace(c)
|| (BREAK_CHARS.indexOf(c) >= 0 && (iNextStart == 0
|| Character.isLetterOrDigit(textArray[iNextStart-1])))))) {
if (c != SPACE) {
iNextStart++;
if (c != NEWLINE) {
- wordIPD
- += foText.textInfo.fs.getCharWidth(c);
+ wordIPD += fs.getCharWidth(c);
} else {
iFlags |= BreakPoss.FORCE;
}
context.getLeadingSpace(), null,
iFlags, iWScount);
}
- wordIPD += foText.textInfo.fs.getCharWidth(c);
+ wordIPD += fs.getCharWidth(c);
// Note, if a normal non-breaking space, is it stretchable???
// If so, keep a count of these embedded spaces.
}
bp.setStackingSize(ipd);
}
// TODO: make this correct (see Keiron's vertical alignment code)
- bp.setNonStackingSize(new MinOptMax(foText.textInfo.lineHeight));
+ bp.setNonStackingSize(new SpaceVal(foText.getLineHeight()).getSpace());
/* Set max ascender and descender (offset from baseline),
* used for calculating the bpd of the line area containing
// add hyphenation character if the last word is hyphenated
if (context.isLastArea() && ai.bHyphenated) {
- str += foText.textInfo.hyphChar;
+ str += foText.getCommonHyphenation().hyphenationChar;
realWidth.add(new MinOptMax(hyphIPD));
}
protected TextArea createTextArea(String str, int width, int base) {
TextArea textArea = new TextArea();
textArea.setIPD(width);
- textArea.setBPD(foText.textInfo.fs.getAscender()
- - foText.textInfo.fs.getDescender());
- textArea.setOffset(foText.textInfo.fs.getAscender());
+ textArea.setBPD(fs.getAscender() - fs.getDescender());
+ textArea.setOffset(fs.getAscender());
textArea.setOffset(base);
textArea.setTextArea(str);
- textArea.addTrait(Trait.FONT_NAME, foText.textInfo.fs.getFontName());
- textArea.addTrait(Trait.FONT_SIZE,
- new Integer(foText.textInfo.fs.getFontSize()));
- textArea.addTrait(Trait.COLOR, foText.textInfo.color);
+ textArea.addTrait(Trait.FONT_NAME, fs.getFontName());
+ textArea.addTrait(Trait.FONT_SIZE, new Integer(fs.getFontSize()));
+ textArea.addTrait(Trait.COLOR, foText.getColor());
return textArea;
}
// ignore newline characters
if (textArray[iTempStart] != NEWLINE) {
wordIPD.add
- (new MinOptMax(foText.textInfo.fs.getCharWidth(textArray[iTempStart])));
+ (new MinOptMax(fs.getCharWidth(textArray[iTempStart])));
}
}
wordIPD.add(MinOptMax.multiply(letterSpaceIPD, (iTempStart - iThisStart - 1)));
for (int i = iStartIndex; i < iStopIndex; i++) {
char c = textArray[i];
- newIPD.add(new MinOptMax(foText.textInfo.fs.getCharWidth(c)));
+ newIPD.add(new MinOptMax(fs.getCharWidth(c)));
}
// add letter spaces
boolean bIsWordEnd