aboutsummaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-02-07 03:16:13 +0000
committerKeiron Liddle <keiron@apache.org>2001-02-07 03:16:13 +0000
commite3b2805d52e2d575bc26a78e39dbc71eb7cdbffb (patch)
tree7728e9eaaeb8ef037fa72c855dc90bff6cdb4264 /src/org
parent2b44ece3c070ce08446d6cd69b0e87cc64548ec8 (diff)
downloadxmlgraphics-fop-e3b2805d52e2d575bc26a78e39dbc71eb7cdbffb.tar.gz
xmlgraphics-fop-e3b2805d52e2d575bc26a78e39dbc71eb7cdbffb.zip
adds vertical align to text
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194030 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r--src/org/apache/fop/fo/FOText.java20
-rw-r--r--src/org/apache/fop/fo/flow/PageNumber.java2
-rw-r--r--src/org/apache/fop/fo/flow/PageNumberCitation.java2
-rw-r--r--src/org/apache/fop/layout/LineArea.java52
4 files changed, 53 insertions, 23 deletions
diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java
index 3dffff813..32c2fbe56 100644
--- a/src/org/apache/fop/fo/FOText.java
+++ b/src/org/apache/fop/fo/FOText.java
@@ -76,6 +76,7 @@ public class FOText extends FONode {
float blue;
int wrapOption;
int whiteSpaceCollapse;
+ int verticalAlign;
// Textdecoration
protected boolean underlined = false;
@@ -152,21 +153,23 @@ public class FOText extends FONode {
this.green = c.green();
this.blue = c.blue();
+ this.verticalAlign = this.parent.properties.get("vertical-align").getEnum();
+
this.wrapOption =
this.parent.properties.get("wrap-option").getEnum();
this.whiteSpaceCollapse = this.parent.properties.get(
"white-space-collapse").getEnum();
this.ts = new TextState();
- ts.setUnderlined(underlined);
- ts.setOverlined(overlined);
- ts.setLineThrough(lineThrough);
+ ts.setUnderlined(underlined);
+ ts.setOverlined(overlined);
+ ts.setLineThrough(lineThrough);
this.marker = this.start;
}
int orig_start = this.marker;
this.marker = addText((BlockArea)area, fs, red, green, blue,
wrapOption, this.getLinkSet(), whiteSpaceCollapse, ca,
- this.marker, length, ts);
+ this.marker, length, ts, verticalAlign);
if (this.marker == -1) {
@@ -193,7 +196,7 @@ public class FOText extends FONode {
public static int addText(BlockArea ba, FontState fontState, float red, float green,
float blue, int wrapOption, LinkSet ls,
int whiteSpaceCollapse, char data[], int start, int end,
- TextState textState) {
+ TextState textState, int vAlign) {
if (fontState.getFontVariant() == FontVariant.SMALL_CAPS) {
FontState smallCapsFontState;
try {
@@ -234,7 +237,7 @@ public class FOText extends FONode {
fontStateToUse = fontState;
}
int index = addRealText(ba, fontStateToUse, red, green, blue, wrapOption, ls,
- whiteSpaceCollapse, data, caseStart, i, textState);
+ whiteSpaceCollapse, data, caseStart, i, textState, vAlign);
if (index != -1) {
return index;
}
@@ -245,13 +248,13 @@ public class FOText extends FONode {
// font-variant normal
return addRealText(ba, fontState, red, green, blue, wrapOption, ls,
- whiteSpaceCollapse, data, start, end, textState);
+ whiteSpaceCollapse, data, start, end, textState, vAlign);
}
protected static int addRealText(BlockArea ba, FontState fontState, float red, float green,
float blue, int wrapOption, LinkSet ls,
int whiteSpaceCollapse, char data[], int start, int end,
- TextState textState) {
+ TextState textState, int vAlign) {
int ts, te;
char[] ca;
@@ -268,6 +271,7 @@ public class FOText extends FONode {
la.changeColor(red, green, blue);
la.changeWrapOption(wrapOption);
la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
+ la.changeVerticalAlign(vAlign);
// la.changeHyphenation(language, country, hyphenate,
// hyphenationChar, hyphenationPushCharacterCount,
// hyphenationRemainCharacterCount);
diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java
index 0139d7f32..dc4a3bc82 100644
--- a/src/org/apache/fop/fo/flow/PageNumber.java
+++ b/src/org/apache/fop/fo/flow/PageNumber.java
@@ -129,7 +129,7 @@ public class PageNumber extends FObj {
String p = Integer.toString(area.getPage().getNumber());
this.marker = FOText.addText((BlockArea) area, fs, red, green, blue,
wrapOption, null, whiteSpaceCollapse, p.toCharArray(),
- 0, p.length(), ts);
+ 0, p.length(), ts, VerticalAlign.BASELINE);
return new Status(Status.OK);
}
}
diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java
index 86acb8923..e24a253c0 100644
--- a/src/org/apache/fop/fo/flow/PageNumberCitation.java
+++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java
@@ -206,7 +206,7 @@ public class PageNumberCitation extends FObj {
this.marker = FOText.addText((BlockArea) area, fs, red, green, blue,
wrapOption, null, whiteSpaceCollapse,
pageNumber.toCharArray(), 0, pageNumber.length(),
- ts);
+ ts, VerticalAlign.BASELINE);
} else { // add pageNumberCitation to area to be resolved during rendering
BlockArea blockArea = (BlockArea)area;
LineArea la = blockArea.getCurrentLineArea();
diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java
index 27e985aa6..8ccc24ea5 100644
--- a/src/org/apache/fop/layout/LineArea.java
+++ b/src/org/apache/fop/layout/LineArea.java
@@ -65,6 +65,7 @@ import org.apache.fop.fo.properties.Hyphenate;
import org.apache.fop.fo.properties.CountryMaker;
import org.apache.fop.fo.properties.LanguageMaker;
import org.apache.fop.fo.properties.LeaderAlignment;
+import org.apache.fop.fo.properties.VerticalAlign;
import org.apache.fop.layout.hyphenation.Hyphenation;
import org.apache.fop.layout.hyphenation.Hyphenator;
@@ -92,6 +93,7 @@ public class LineArea extends Area {
private float red, green, blue;
private int wrapOption;
private int whiteSpaceCollapse;
+ int vAlign;
/*hyphenation*/
protected int hyphenate;
@@ -109,7 +111,7 @@ public class LineArea extends Area {
protected int embeddedLinkStart = 0;
/* the width of the current word so far */
- protected int wordWidth = 0;
+// protected int wordWidth = 0;
/* values that prev (below) may take */
protected static final int NOTHING = 0;
@@ -120,10 +122,10 @@ public class LineArea extends Area {
protected int prev = NOTHING;
/* the position in data[] of the start of the current word */
- protected int wordStart;
+// protected int wordStart;
/* the length (in characters) of the current word */
- protected int wordLength = 0;
+// protected int wordLength = 0;
/* width of spaces before current word */
protected int spaceWidth = 0;
@@ -191,7 +193,6 @@ public class LineArea extends Area {
pia.setYOffset(placementOffset);
pendingAreas.addElement(pia);
pendingWidth += width;
- wordWidth = 0;
prev = TEXT;
return -1;
@@ -210,9 +211,9 @@ public class LineArea extends Area {
if(start == -1) return -1;
boolean overrun = false;
- wordStart = start;
- wordLength = 0;
- wordWidth = 0;
+ int wordStart = start;
+ int wordLength = 0;
+ int wordWidth = 0;
char[] data = new char[odata.length];
for (int count = 0; count < odata.length; count++) {
data[count] = odata[count];
@@ -316,6 +317,7 @@ public class LineArea extends Area {
prevOlState = textState.getOverlined();
ia.setLineThrough(textState.getLineThrough());
prevLTState = textState.getLineThrough();
+ ia.setVerticalAlign(vAlign);
addChild(ia);
if (ls != null) {
@@ -457,6 +459,7 @@ public class LineArea extends Area {
prevOlState = textState.getOverlined();
pia.setLineThrough(textState.getLineThrough());
prevLTState = textState.getLineThrough();
+ pia.setVerticalAlign(vAlign);
if (ls != null) {
Rectangle lr = new Rectangle(finalWidth + spaceWidth +
@@ -674,17 +677,25 @@ public class LineArea extends Area {
Box b = (Box) e.nextElement();
if(b instanceof InlineArea) {
InlineArea ia = (InlineArea)b;
+ if(ia instanceof WordArea) {
+ ia.setYOffset(placementOffset);
+ }
if(ia.getHeight() > maxHeight) {
maxHeight = ia.getHeight();
}
int vert = ia.getVerticalAlign();
-/* if(vert == VerticalAlign.SUPER) {
- int tbe = fontState.getAscender();
- ia.setYOffset(placementOffset - (tbe - h));
- }*/
+ if(vert == VerticalAlign.SUPER) {
+ int fh = fontState.getAscender();
+ ia.setYOffset((int)(placementOffset - (fh / 3.0)));
+ } else if(vert == VerticalAlign.SUB) {
+ int fh = fontState.getAscender();
+ ia.setYOffset((int)(placementOffset + (fh / 3.0)));
+ }
} else {
}
}
+ // adjust the height of this line to the
+ // resulting alignment height.
this.allocationHeight = maxHeight;
}
@@ -706,6 +717,10 @@ public class LineArea extends Area {
this.wrapOption = wrapOption;
}
+ public void changeVerticalAlign(int vAlign) {
+ this.vAlign = vAlign;
+ }
+
public int getEndIndent() {
return endIndent;
}
@@ -724,7 +739,7 @@ public class LineArea extends Area {
public boolean isEmpty() {
return !(pendingAreas.size() > 0 || children.size() > 0);
-// return (prev == 0);
+// return (prev == NOTHING);
}
public Vector getPendingAreas() {
@@ -834,7 +849,7 @@ public class LineArea extends Area {
* handles cases of inword punctuation and quotation marks at the beginning
* of words, but not in a internationalized way
*/
- private int doHyphenation (char [] characters, int position, int wordStart, int remainingWidth) {
+ public int doHyphenation (char [] characters, int position, int wordStart, int remainingWidth) {
//check whether the language property has been set
if (this.language.equalsIgnoreCase("none")) {
MessageHandler.errorln("if property 'hyphenate' is used, a language must be specified");
@@ -942,6 +957,10 @@ public class LineArea extends Area {
return this.getContentWidth() - this.getCurrentXPosition();
}
+ public void setLinkSet(LinkSet ls)
+ {
+ }
+
public void addInlineArea(Area box)
{
addPending();
@@ -950,6 +969,13 @@ public class LineArea extends Area {
finalWidth += box.getContentWidth();
}
+ public void addInlineSpace(InlineSpace is, int spaceWidth)
+ {
+ addChild(is);
+ finalWidth += spaceWidth;
+// spaceWidth = 0;
+ }
+
/** adds a single character to the line area tree*/
public int addCharacter (char data, LinkSet ls, boolean ul) {
WordArea ia = null;