You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by bc...@apache.org on 2004/10/19 22:12:21 UTC
cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr CharacterLayoutManager.java TextLayoutManager.java
bckfnn 2004/10/19 13:12:21
Modified: src/java/org/apache/fop/fo FOText.java
src/java/org/apache/fop/layoutmgr
CharacterLayoutManager.java TextLayoutManager.java
Log:
Third phase of performance improvement.
- Remove use of TextInfo.
PR: 31699
Revision Changes Path
1.32 +1 -4 xml-fop/src/java/org/apache/fop/fo/FOText.java
Index: FOText.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOText.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- FOText.java 19 Oct 2004 13:30:53 -0000 1.31
+++ FOText.java 19 Oct 2004 20:12:21 -0000 1.32
@@ -109,7 +109,6 @@
*/
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 @@
* @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());
-
}
/**
1.5 +14 -18 xml-fop/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java
Index: CharacterLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CharacterLayoutManager.java 22 Sep 2004 08:24:32 -0000 1.4
+++ CharacterLayoutManager.java 19 Oct 2004 20:12:21 -0000 1.5
@@ -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 @@
* 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 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 @@
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;
1.23 +26 -29 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.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- TextLayoutManager.java 12 Oct 2004 05:07:47 -0000 1.22
+++ TextLayoutManager.java 19 Oct 2004 20:12:21 -0000 1.23
@@ -24,6 +24,7 @@
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 @@
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 @@
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;
@@ -149,12 +153,9 @@
// 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 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 @@
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 @@
bSawNonSuppressible = true;
spaceIPD.add(pendingSpace.resolve(false));
pendingSpace.clear();
- wordIPD += foText.textInfo.fs.getCharWidth(c);
+ wordIPD += fs.getCharWidth(c);
}
}
@@ -392,7 +392,7 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org