From 02a6009a4d0cbea8a48e7e026b766a14ccbc469d Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Thu, 27 May 2004 15:38:15 +0000 Subject: [PATCH] Get fontData object from foTree. Construct attriute map for font, getFopFont based on atribute map, add text decorations to git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197641 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/flow/FoPcdata.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/fop/fo/flow/FoPcdata.java b/src/java/org/apache/fop/fo/flow/FoPcdata.java index 105aabe7d..4ec072a07 100644 --- a/src/java/org/apache/fop/fo/flow/FoPcdata.java +++ b/src/java/org/apache/fop/fo/flow/FoPcdata.java @@ -20,8 +20,12 @@ package org.apache.fop.fo.flow; // FOP +import java.awt.Font; +import java.awt.font.TextAttribute; +import java.text.AttributedString; import java.util.Arrays; import java.util.BitSet; +import java.util.Map; import org.apache.fop.apps.FOPException; import org.apache.fop.datastructs.TreeException; @@ -31,6 +35,8 @@ import org.apache.fop.fo.FOTree; import org.apache.fop.fo.FObjectNames; import org.apache.fop.fo.PropNames; import org.apache.fop.fo.PropertySets; +import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.fonts.FontException; import org.apache.fop.render.FontData; import org.apache.fop.xml.XmlEvent; @@ -134,7 +140,7 @@ public class FoPcdata extends FOPageSeqNode { super(foTree, FObjectNames.PCDATA, pageSequence, parent, event, stateFlags, sparsePropsMap, sparseIndices); characters = event.getChars(); - fontData = foTree.getFontData(); + makeSparsePropsSet(); } @@ -153,9 +159,25 @@ public class FoPcdata extends FOPageSeqNode { * Generates a TextMeasurer from the PCDATA text. The font and text * attributes of the text are applied. */ - private void processText() { - // Get the font - + private void processText() throws PropertyException, FontException { + // Get the font, size, style and weight attributes + Map attributes = getFontAttributes(); + Font font = getFopFont(attributes); + // Add the text decorations + // TODO separate color support for text decorations + if (decorations.underlined()) { + attributes.put(TextAttribute.UNDERLINE, + TextAttribute.UNDERLINE_LOW_ONE_PIXEL); + } + if (decorations.overlined()) { + // Not supported yet + } + if (decorations.struckthrough()) { + attributes.put(TextAttribute.STRIKETHROUGH, + TextAttribute.STRIKETHROUGH_ON); + } + AttributedString attText = + new AttributedString(characters, attributes); } } -- 2.39.5