From: Peter Bernard West Date: Fri, 28 May 2004 15:27:05 +0000 (+0000) Subject: Create TextMeasurer and TextLayout X-Git-Tag: Defoe_export~127 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=666b23b376b6bdf75d85622438c46bbb3f34575a;p=xmlgraphics-fop.git Create TextMeasurer and TextLayout git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197648 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/flow/FoPcdata.java b/src/java/org/apache/fop/fo/flow/FoPcdata.java index 4ec072a07..72a1697b7 100644 --- a/src/java/org/apache/fop/fo/flow/FoPcdata.java +++ b/src/java/org/apache/fop/fo/flow/FoPcdata.java @@ -21,7 +21,11 @@ package org.apache.fop.fo.flow; // FOP import java.awt.Font; +import java.awt.font.FontRenderContext; import java.awt.font.TextAttribute; +import java.awt.font.TextLayout; +import java.awt.font.TextMeasurer; +import java.text.AttributedCharacterIterator; import java.text.AttributedString; import java.util.Arrays; import java.util.BitSet; @@ -152,6 +156,8 @@ public class FoPcdata extends FOPageSeqNode { return characters; } + public static final boolean IS_ANTI_ALIASED = true; + public static final boolean USES_FRACTIONAL_METRICS = true; // PCDATA provides sequences of inline-areas to fill line-areas in the // parent block area. // Generate a text-layout for the PCDATA. @@ -178,6 +184,13 @@ public class FoPcdata extends FOPageSeqNode { } AttributedString attText = new AttributedString(characters, attributes); + AttributedCharacterIterator iter = attText.getIterator(); + FontRenderContext identityFRC = + new FontRenderContext( + null, IS_ANTI_ALIASED, USES_FRACTIONAL_METRICS); + TextMeasurer measurer = new TextMeasurer(iter, identityFRC); + TextLayout layout = new TextLayout(iter, identityFRC); + // Find minima and maxima for this text } }