From: Finn Bock Date: Tue, 19 Oct 2004 20:15:13 +0000 (+0000) Subject: Third phase of performance improvement. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~439 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3204f5d0924de0b98e4591ae63b0cef1f9d03824;p=xmlgraphics-fop.git Third phase of performance improvement. - Remove use of TextInfo. PR: 31699 git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198068 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index 7417f7a53..9c3b653ba 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -109,7 +109,6 @@ public class FOText extends FONode { */ private Block ancestorBlock = null; - public TextInfo textInfo; private static final int IS_WORD_CHAR_FALSE = 0; private static final int IS_WORD_CHAR_TRUE = 1; private static final int IS_WORD_CHAR_MAYBE = 2; @@ -122,14 +121,12 @@ public class FOText extends FONode { * @param end ending index into char[] for the text in this object * @param parent FONode that is the parent of this object */ - public FOText(char[] chars, int start, int end, FObj parent) { + public FOText(char[] chars, int start, int end, FONode parent) { super(parent); endIndex = end - start; this.ca = new char[endIndex]; System.arraycopy(chars, start, ca, 0, endIndex); // System.out.println("->" + new String(ca) + "<-"); - textInfo = parent.propMgr.getTextLayoutProps(parent.getFOEventHandler().getFontInfo()); - } /** diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 53a9919c0..f5b6d5f47 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -23,8 +23,8 @@ import java.util.ArrayList; 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; @@ -39,7 +39,8 @@ import org.apache.fop.traits.MinOptMax; * LayoutManager for a block FO. */ public class BlockLayoutManager extends BlockStackingLayoutManager { - + private org.apache.fop.fo.flow.Block fobj; + private Block curBlockArea; protected ListIterator proxyLMiter; @@ -71,17 +72,15 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { 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(); } /** diff --git a/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java index 26eb51663..57d110567 100644 --- a/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java @@ -19,7 +19,7 @@ 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; @@ -32,10 +32,10 @@ import java.util.LinkedList; * 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 @@ -45,16 +45,14 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { */ 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) { @@ -102,20 +100,18 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { 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; diff --git a/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java index 28e05f3ea..bcd153f2a 100644 --- a/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java @@ -24,6 +24,7 @@ import java.util.LinkedList; 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; @@ -108,6 +109,7 @@ public class TextLayoutManager extends AbstractLayoutManager { 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; @@ -130,15 +132,17 @@ public class TextLayoutManager extends AbstractLayoutManager { 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: 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; @@ -149,12 +153,9 @@ public class TextLayoutManager extends AbstractLayoutManager { // 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()); } /** @@ -201,8 +202,7 @@ public class TextLayoutManager extends AbstractLayoutManager { */ 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 @@ -255,7 +255,7 @@ public class TextLayoutManager extends AbstractLayoutManager { 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 @@ -362,7 +362,7 @@ public class TextLayoutManager extends AbstractLayoutManager { bSawNonSuppressible = true; spaceIPD.add(pendingSpace.resolve(false)); pendingSpace.clear(); - wordIPD += foText.textInfo.fs.getCharWidth(c); + wordIPD += fs.getCharWidth(c); } } @@ -392,7 +392,7 @@ public class TextLayoutManager extends AbstractLayoutManager { 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])))))) { @@ -400,8 +400,7 @@ public class TextLayoutManager extends AbstractLayoutManager { if (c != SPACE) { iNextStart++; if (c != NEWLINE) { - wordIPD - += foText.textInfo.fs.getCharWidth(c); + wordIPD += fs.getCharWidth(c); } else { iFlags |= BreakPoss.FORCE; } @@ -421,7 +420,7 @@ public class TextLayoutManager extends AbstractLayoutManager { 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. } @@ -454,7 +453,7 @@ public class TextLayoutManager extends AbstractLayoutManager { 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 @@ -533,7 +532,7 @@ public class TextLayoutManager extends AbstractLayoutManager { // 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)); } @@ -611,16 +610,14 @@ public class TextLayoutManager extends AbstractLayoutManager { 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; } @@ -739,7 +736,7 @@ public class TextLayoutManager extends AbstractLayoutManager { // 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))); @@ -830,7 +827,7 @@ public class TextLayoutManager extends AbstractLayoutManager { 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