aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-01-25 12:53:29 +0000
committerJeremias Maerki <jeremias@apache.org>2005-01-25 12:53:29 +0000
commit1b772f22b98915dd18cc02e7e3aa019bd65b7479 (patch)
tree85b959b613cfed240cea70a2ddb5e14e71f7fb50 /src
parentfd4766c634f2a3bdd62fee03ca2f9aa2d80ea445 (diff)
downloadxmlgraphics-fop-1b772f22b98915dd18cc02e7e3aa019bd65b7479.tar.gz
xmlgraphics-fop-1b772f22b98915dd18cc02e7e3aa019bd65b7479.zip
Get the mark colors for text-decorations right.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198317 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonTextDecoration.java23
-rw-r--r--src/java/org/apache/fop/layoutmgr/TraitSetter.java3
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderer.java20
3 files changed, 43 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java b/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java
index 49df7b24c..8385013c6 100644
--- a/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java
+++ b/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java
@@ -67,6 +67,7 @@ public class CommonTextDecoration {
//Parent is checked first
deco = calcTextDecoration(parentList);
}
+ //For rules, see XSL 1.0, chapters 5.5.6 and 7.16.4
List list = pList.get(Constants.PR_TEXT_DECORATION).getList();
Iterator i = list.iterator();
while (i.hasNext()) {
@@ -82,27 +83,33 @@ public class CommonTextDecoration {
deco = new CommonTextDecoration();
}
deco.decoration |= UNDERLINE;
+ deco.underColor = pList.get(Constants.PR_COLOR).getColorType();
} else if (enum == Constants.EN_NO_UNDERLINE) {
if (deco != null) {
deco.decoration &= OVERLINE | LINE_THROUGH | BLINK;
+ deco.underColor = pList.get(Constants.PR_COLOR).getColorType();
}
} else if (enum == Constants.EN_OVERLINE) {
if (deco == null) {
deco = new CommonTextDecoration();
}
deco.decoration |= OVERLINE;
+ deco.overColor = pList.get(Constants.PR_COLOR).getColorType();
} else if (enum == Constants.EN_NO_OVERLINE) {
if (deco != null) {
deco.decoration &= UNDERLINE | LINE_THROUGH | BLINK;
+ deco.overColor = pList.get(Constants.PR_COLOR).getColorType();
}
} else if (enum == Constants.EN_LINE_THROUGH) {
if (deco == null) {
deco = new CommonTextDecoration();
}
deco.decoration |= LINE_THROUGH;
+ deco.throughColor = pList.get(Constants.PR_COLOR).getColorType();
} else if (enum == Constants.EN_NO_LINE_THROUGH) {
if (deco != null) {
deco.decoration &= UNDERLINE | OVERLINE | BLINK;
+ deco.throughColor = pList.get(Constants.PR_COLOR).getColorType();
}
} else if (enum == Constants.EN_BLINK) {
if (deco == null) {
@@ -139,4 +146,20 @@ public class CommonTextDecoration {
public boolean isBlinking() {
return (this.decoration & BLINK) != 0;
}
+
+ /** @return the color of the underline mark */
+ public ColorType getUnderlineColor() {
+ return this.underColor;
+ }
+
+ /** @return the color of the overline mark */
+ public ColorType getOverlineColor() {
+ return this.overColor;
+ }
+
+ /** @return the color of the line-through mark */
+ public ColorType getLineThroughColor() {
+ return this.throughColor;
+ }
+
}
diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java
index 927da246b..afa516dc5 100644
--- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java
+++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java
@@ -274,12 +274,15 @@ public class TraitSetter {
if (deco != null) {
if (deco.hasUnderline()) {
area.addTrait(Trait.UNDERLINE, Boolean.TRUE);
+ area.addTrait(Trait.UNDERLINE_COLOR, deco.getUnderlineColor());
}
if (deco.hasOverline()) {
area.addTrait(Trait.OVERLINE, Boolean.TRUE);
+ area.addTrait(Trait.OVERLINE_COLOR, deco.getOverlineColor());
}
if (deco.hasLineThrough()) {
area.addTrait(Trait.LINETHROUGH, Boolean.TRUE);
+ area.addTrait(Trait.LINETHROUGH_COLOR, deco.getLineThroughColor());
}
if (deco.isBlinking()) {
area.addTrait(Trait.BLINK, Boolean.TRUE);
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
index ef7f7f672..82b4afb50 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
@@ -1067,9 +1067,7 @@ public class PDFRenderer extends PrintRenderer {
updateFont(name, size, pdf);
ColorType ct = (ColorType) text.getTrait(Trait.COLOR);
- if (ct != null) {
- updateColor(ct, true, pdf);
- }
+ updateColor(ct, true, pdf);
// word.getOffset() = only height of text itself
// currentBlockIPPosition: 0 for beginning of line; nonzero
@@ -1138,14 +1136,20 @@ public class PDFRenderer extends PrintRenderer {
updateLineWidth(fs.getDescender() / -8 / 1000f);
float endx = (startx + inline.getIPD()) / 1000f;
if (inline.hasUnderline()) {
+ ColorType ct = (ColorType) inline.getTrait(Trait.UNDERLINE_COLOR);
+ updateColor(ct, false, null);
float y = baseline - fs.getDescender() / 2;
drawLine(startx / 1000f, y / 1000f, endx, y / 1000f);
}
if (inline.hasOverline()) {
+ ColorType ct = (ColorType) inline.getTrait(Trait.OVERLINE_COLOR);
+ updateColor(ct, false, null);
float y = (float)(baseline - (1.1 * fs.getCapHeight()));
drawLine(startx / 1000f, y / 1000f, endx, y / 1000f);
}
if (inline.hasLineThrough()) {
+ ColorType ct = (ColorType) inline.getTrait(Trait.LINETHROUGH_COLOR);
+ updateColor(ct, false, null);
float y = (float)(baseline - (0.45 * fs.getCapHeight()));
drawLine(startx / 1000f, y / 1000f, endx, y / 1000f);
}
@@ -1228,7 +1232,17 @@ public class PDFRenderer extends PrintRenderer {
}
}
+ /**
+ * Establishes a new foreground or fill color.
+ * @param col the color to apply (null skips this operation)
+ * @param fill true to set the fill color, false for the foreground color
+ * @param pdf StringBuffer to write the PDF code to, if null, the code is
+ * written to the current stream.
+ */
private void updateColor(ColorType col, boolean fill, StringBuffer pdf) {
+ if (col == null) {
+ return;
+ }
Color newCol = new Color(col.getRed(), col.getGreen(), col.getBlue());
boolean update = false;
if (fill) {