deweese 02/05/22 14:50:40
Modified: sources/org/apache/batik/extension/svg
BatikExtConstants.java
SVGFlowTextElementBridge.java
sources/org/apache/batik/gvt/text
GVTAttributedCharacterIterator.java
GlyphIterator.java
Added: samples/extensions/flow flow1.svg flowFonts.svg
Log:
1) A totally ugly SVG font for testing flowText.
2) First 'tricky' flowText test.
3) Fix for preceeding space hiding in flowParas
4) Added support for a preformatted attribute to flowText.
Revision Changes Path
1.1 xml-batik/samples/extensions/flow/flow1.svg
Index: flow1.svg
===================================================================
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- ====================================================================== -->
<!-- Copyright (C) The Apache Software Foundation. All rights reserved. -->
<!-- -->
<!-- This software is published under the terms of the Apache Software -->
<!-- License version 1.1, a copy of which has been included with this -->
<!-- distribution in the LICENSE file. -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!-- Draws <text> elements using SVG fonts with glyphs -->
<!-- using the d attribute. Tests glyph layout by -->
<!-- comparing equivalent SVG for the <text> element, both -->
<!-- on a grid and as a mask. -->
<!-- Kerning is also tested. -->
<!-- -->
<!-- @author [EMAIL PROTECTED] -->
<!-- @version $Id: flow1.svg,v 1.1 2002/05/22 21:50:39 deweese Exp $ -->
<!-- ====================================================================== -->
<?xml-stylesheet type="text/css" href="../../tests/resources/style/test.css" ?>
<svg id="body" width="450" height="500" viewBox="0 0 450 500"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" >
<title>Test of font fit in flow regions.</title>
<g id="content">
<text class="title" x="50%" y="50">SVG fonts for flow test</text>
<defs>
<pattern id="gridPattern" viewBox="-4.5 -4.5 10 10"
x="-4.5" y="-4.5" width="10" height="10"
patternContentUnits="userSpaceOnUse"
patternUnits="userSpaceOnUse">
<g stroke="rgb(225, 225, 245)" stroke-width="0.5">
<line x1="0" y1="-6" x2="0" y2="6" />
<line x1="-6" y1="0" x2="6" y2="0" />
</g>
</pattern>
<font-face font-family="Shapes">
<font-face-src>
<font-face-uri xlink:href="flowFonts.svg#Shapes"/>
</font-face-src>
</font-face>
<font-face font-family="ShapesKernTogeather">
<font-face-src>
<font-face-uri xlink:href="flowFonts.svg#ShapesKernTogeather"/>
</font-face-src>
</font-face>
<font-face font-family="ShapesKernApart">
<font-face-src>
<font-face-uri xlink:href="flowFonts.svg#ShapesKernApart"/>
</font-face-src>
</font-face>
</defs>
<g transform="translate(10, 70)">
<g font-size="20" fill="black" stroke="none"
xmlns:batik="http://xml.apache.org/batik/ext">
<g transform="translate(0,0)">
<path fill="lightblue" d="M0,0h8v150h-8z"/>
<batik:flowText font-family="Shapes">
<batik:flowRegion>
<batik:region x="0" y="0" width="8" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(20,0)">
<path fill="lightblue" d="M0,0h11.9v150h-11.9z"/>
<batik:flowText font-family="Shapes">
<batik:flowRegion>
<batik:region x="0" y="0" width="11.9" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(40,0)">
<path fill="lightblue" d="M0,0h12v150h-12z"/>
<batik:flowText font-family="Shapes">
<batik:flowRegion>
<batik:region x="0" y="0" width="12" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(80,0)">
<path fill="lightblue" d="M0,0h8v150h-8z"/>
<batik:flowText font-family="ShapesKernTogeather">
<batik:flowRegion>
<batik:region x="0" y="0" width="8" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(100,0)">
<path fill="lightblue" d="M0,0h11.9v150h-11.9z"/>
<batik:flowText font-family="ShapesKernTogeather">
<batik:flowRegion>
<batik:region x="0" y="0" width="11.9" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(120,0)">
<path fill="lightblue" d="M0,0h12v150h-12z"/>
<batik:flowText font-family="ShapesKernTogeather">
<batik:flowRegion>
<batik:region x="0" y="0" width="12" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(160,0)">
<path fill="lightblue" d="M0,0h8v150h-8z"/>
<batik:flowText font-family="ShapesKernApart">
<batik:flowRegion>
<batik:region x="0" y="0" width="8" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(180,0)">
<path fill="lightblue" d="M0,0h11.9v150h-11.9z"/>
<batik:flowText font-family="ShapesKernApart">
<batik:flowRegion>
<batik:region x="0" y="0" width="11.9" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(200,0)">
<path fill="lightblue" d="M0,0h12v150h-12z"/>
<batik:flowText font-family="ShapesKernApart">
<batik:flowRegion>
<batik:region x="0" y="0" width="12" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
</g>
<g font-size="20" fill="black" stroke="none"
xmlns:batik="http://xml.apache.org/batik/ext">
<g transform="translate(0,180)">
<path fill="lightblue" d="M0,0h8v150h-8z"/>
<path fill="lightblue" d="M20,0h11.9v150h-11.9z"/>
<path fill="lightblue" d="M40,0h12v150h-12z"/>
<batik:flowText font-family="Shapes">
<batik:flowRegion>
<batik:region x="0" y="0" width="8" height="150"/>
<batik:region x="20" y="0" width="11.9" height="150"/>
<batik:region x="40" y="0" width="12" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(80,180)">
<path fill="lightblue" d="M0,0h8v150h-8z"/>
<path fill="lightblue" d="M20,0h11.9v150h-11.9z"/>
<path fill="lightblue" d="M40,0h12v150h-12z"/>
<batik:flowText font-family="ShapesKernTogeather">
<batik:flowRegion>
<batik:region x="0" y="0" width="8" height="150"/>
<batik:region x="20" y="0" width="11.9" height="150"/>
<batik:region x="40" y="0" width="12" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(160,180)">
<path fill="lightblue" d="M0,0h8v150h-8z"/>
<path fill="lightblue" d="M20,0h11.9v150h-11.9z"/>
<path fill="lightblue" d="M40,0h12v150h-12z"/>
<batik:flowText font-family="ShapesKernApart">
<batik:flowRegion>
<batik:region x="0" y="0" width="8" height="150"/>
<batik:region x="20" y="0" width="11.9" height="150"/>
<batik:region x="40" y="0" width="12" height="150"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
</g>
<g font-size="20" fill="black" stroke="none"
xmlns:batik="http://xml.apache.org/batik/ext">
<g transform="translate(240,0)">
<!-- The height calc is a bit tricky since you need
to take the units-per-em and ascent and descent
into account
-->
<path fill="lightblue" d="M0,0h150v20h-150z"/>
<batik:flowText font-family="Shapes">
<batik:flowRegion>
<batik:region width="150" height="20"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(240,40)">
<path fill="lightblue" d="M0,0h150v24h-150z"/>
<batik:flowText font-family="Shapes">
<batik:flowRegion>
<batik:region width="150" height="24"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(240,80)">
<path fill="lightblue" d="M0,0h150v20h-150z"/>
<batik:flowText font-family="Shapes">
<batik:flowRegion>
<batik:region width="150" height="20"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc<batik:flowSpan font-size="21">
</batik:flowSpan>defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<g transform="translate(240,120)">
<path fill="lightblue" d="M0,0h150v20h-150z"/>
<batik:flowText font-family="Shapes">
<batik:flowRegion>
<batik:region width="150" height="20"/>
</batik:flowRegion>
<batik:flowDiv>
<batik:flowPara>abc defg</batik:flowPara>
</batik:flowDiv>
</batik:flowText>
</g>
<!-- ========================================================== -->
<!-- Font as text -->
<!-- ========================================================== -->
<g transform="translate(30,360)">
<text font-family="Shapes">abcdefg- -ᨊ</text>
</g>
<g transform="translate(30,380)">
<text font-family="ShapesKernTogeather">abcdefg- -ᨊ</text>
</g>
<g transform="translate(30,400)">
<text font-family="ShapesKernApart">abcdefg- -ᨊ</text>
</g>
</g>
</g>
</g>
<!-- ============================================================= -->
<!-- Batik sample mark -->
<!-- ============================================================= -->
<use xlink:href="../../batikLogo.svg#Batik_Tag_Box" />
</svg>
1.1 xml-batik/samples/extensions/flow/flowFonts.svg
Index: flowFonts.svg
===================================================================
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- ====================================================================== -->
<!-- Copyright (C) The Apache Software Foundation. All rights reserved. -->
<!-- -->
<!-- This software is published under the terms of the Apache Software -->
<!-- License version 1.1, a copy of which has been included with this -->
<!-- distribution in the LICENSE file. -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!-- Draws <text> elements using SVG fonts with glyphs -->
<!-- using the d attribute. Tests glyph layout by -->
<!-- comparing equivalent SVG for the <text> element, both -->
<!-- on a grid and as a mask. -->
<!-- Kerning is also tested. -->
<!-- -->
<!-- @author [EMAIL PROTECTED] -->
<!-- @version $Id: flowFonts.svg,v 1.1 2002/05/22 21:50:40 deweese Exp $ -->
<!-- ====================================================================== -->
<?xml-stylesheet type="text/css" href="../../tests/resources/style/test.css" ?>
<svg id="body" width="450" height="500" viewBox="0 0 450 500"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" >
<title>SVGFonts for text-flow tests</title>
<!-- ============================= -->
<!-- SVG Font Definition -->
<!-- ============================= -->
<font horiz-adv-x="1000" id="Shapes">
<font-face font-family="Shapes" units-per-em="2000"
ascent="1600" descent="400"/>
<missing-glyph horiz-adv-x="1000"
d="M100 0V1500H900V0H100z M200,100H800V1400H200V100z"/>
<!-- "a" glyph -->
<glyph unicode="a" glyph-name="a" horiz-adv-x="1000"
d="M100,0 L500,1500 L900,0 z"/>
<!-- "b" glyph -->
<glyph unicode="b" glyph-name="b" horiz-adv-x="1200"
d="M100,0 V1500 C1000,1500 1000,750 300,750
C1200,750 1200,0 100,0 z"/>
<!-- "c" glyph -->
<glyph unicode="c" glyph-name="c" horiz-adv-x="1000"
d="M850,1000 A400,750 0 1,1 850,500 H300 V1000 z"/>
<!-- "d" glyph -->
<glyph unicode="d" glyph-name="d" horiz-adv-x="1200"
d="M100,0 V1500 C900,1500 1100,1300 1100,750
C1100,200 900,0 100,0 z"/>
<!-- "e" glyph -->
<glyph unicode="e" glyph-name="e" horiz-adv-x="1100"
d="M100,0V1500H1000V1400H200V800H700V700H200V100H1000V0z"/>
<!-- "f" glyph -->
<glyph unicode="f" glyph-name="f" horiz-adv-x="1100"
d="M100,0 V1500 H1000 V1400 H200 V800 H700 V700 H200 V0 z"/>
<!-- "g" glyph -->
<glyph unicode="g" glyph-name="g" horiz-adv-x="1000"
d="M850,1000 A400,750 0 1,1 850,500
H950 V600 H500 V500 H350 V1000 z"/>
<!-- "u" glyph -->
<glyph unicode="u" glyph-name="u" horiz-adv-x="1000"
d="M250,1400 A400,850 0 1,1 850,1400
H700 A250,700 0 1,0 400,1400 z"/>
<!-- "v" glyph -->
<glyph unicode="v" glyph-name="v" horiz-adv-x="1000"
d="M500,0 L100,1500 H900 z"/>
<!-- "w" glyph -->
<glyph unicode="w" glyph-name="w" horiz-adv-x="1400"
d="M"/>
<glyph unicode=" " glyph-name="space"
horiz-adv-x="1000" d="M0 0z"/>
<glyph unicode="-" glyph-name="hyphen" horiz-adv-x="1000"
d="M200,650 l700,0 c100,0 100,175 0,175
l-700,0 c-100,0 -100,-175 0,-175 z"/>
<glyph unicode="­" glyph-name="softhyphen"
horiz-adv-x="1000"
d="M200,650 l700,0 c100,0 100,175 0,175
l-700,0 c-100,0 -100,-175 0,-175 z"/>
</font>
<font horiz-adv-x="1000" id="ShapesKernTogeather">
<font-face font-family="ShapesKernTogeather"
units-per-em="2000" ascent="1600" descent="400"/>
<hkern g1="a" g2="b" k="500"/>
<hkern g1="b" g2="c" k="500"/>
<hkern g1="c" g2="d" k="500"/>
<hkern g1="d" g2="e" k="500"/>
<hkern g1="e" g2="f" k="500"/>
<hkern g1="f" g2="g" k="500"/>
<hkern g1="g" g2="h" k="500"/>
<hkern g1="h" g2="u" k="500"/>
<hkern g1="u" g2="v" k="500"/>
<missing-glyph horiz-adv-x="1000"
d="M100 0V1500H900V0H100z M200,100H800V1400H200V100z"/>
<!-- "a" glyph -->
<glyph unicode="a" glyph-name="a" horiz-adv-x="1000"
d="M100,0 L500,1500 L900,0 z"/>
<!-- "b" glyph -->
<glyph unicode="b" glyph-name="b" horiz-adv-x="1200"
d="M100,0 V1500 C1000,1500 1000,750 300,750
C1200,750 1200,0 100,0 z"/>
<!-- "c" glyph -->
<glyph unicode="c" glyph-name="c" horiz-adv-x="1000"
d="M850,1000 A400,750 0 1,1 850,500 H300 V1000 z"/>
<!-- "d" glyph -->
<glyph unicode="d" glyph-name="d" horiz-adv-x="1200"
d="M100,0 V1500 C900,1500 1100,1300 1100,750
C1100,200 900,0 100,0 z"/>
<!-- "e" glyph -->
<glyph unicode="e" glyph-name="e" horiz-adv-x="1100"
d="M100,0V1500H1000V1400H200V800H700V700H200V100H1000V0z"/>
<!-- "f" glyph -->
<glyph unicode="f" glyph-name="f" horiz-adv-x="1100"
d="M100,0 V1500 H1000 V1400 H200 V800 H700 V700 H200 V0 z"/>
<!-- "g" glyph -->
<glyph unicode="g" glyph-name="g" horiz-adv-x="1000"
d="M850,1000 A400,750 0 1,1 850,500
H950 V600 H500 V500 H350 V1000 z"/>
<!-- "u" glyph -->
<glyph unicode="u" glyph-name="u" horiz-adv-x="1000"
d="M250,1400 A400,850 0 1,1 850,1400
H700 A250,700 0 1,0 400,1400 z"/>
<!-- "v" glyph -->
<glyph unicode="v" glyph-name="v" horiz-adv-x="1000"
d="M500,0 L100,1500 H900 z"/>
<!-- "w" glyph -->
<glyph unicode="w" glyph-name="w" horiz-adv-x="1400"
d="M"/>
<glyph unicode=" " glyph-name="space"
horiz-adv-x="1000" d="M0 0z"/>
<glyph unicode="-" glyph-name="hyphen" horiz-adv-x="1000"
d="M200,650 l700,0 c100,0 100,175 0,175
l-700,0 c-100,0 -100,-175 0,-175 z"/>
<glyph unicode="­" glyph-name="softhyphen"
horiz-adv-x="1000"
d="M200,650 l700,0 c100,0 100,175 0,175
l-700,0 c-100,0 -100,-175 0,-175 z"/>
</font>
<font horiz-adv-x="1000" id="ShapesKernApart">
<font-face font-family="ShapesKernApart"
units-per-em="2000" ascent="1600" descent="400"/>
<hkern g1="a" g2="b" k="-250"/>
<hkern g1="b" g2="c" k="-250"/>
<hkern g1="c" g2="d" k="-250"/>
<hkern g1="d" g2="e" k="-250"/>
<hkern g1="e" g2="f" k="-250"/>
<hkern g1="f" g2="g" k="-250"/>
<hkern g1="g" g2="h" k="-250"/>
<hkern g1="h" g2="u" k="-250"/>
<hkern g1="u" g2="v" k="-250"/>
<missing-glyph horiz-adv-x="1000"
d="M100 0V1500H900V0H100z M200,100H800V1400H200V100z"/>
<!-- "a" glyph -->
<glyph unicode="a" glyph-name="a" horiz-adv-x="1000"
d="M100,0 L500,1500 L900,0 z"/>
<!-- "b" glyph -->
<glyph unicode="b" glyph-name="b" horiz-adv-x="1200"
d="M100,0 V1500 C1000,1500 1000,750 300,750
C1200,750 1200,0 100,0 z"/>
<!-- "c" glyph -->
<glyph unicode="c" glyph-name="c" horiz-adv-x="1000"
d="M850,1000 A400,750 0 1,1 850,500 H300 V1000 z"/>
<!-- "d" glyph -->
<glyph unicode="d" glyph-name="d" horiz-adv-x="1200"
d="M100,0 V1500 C900,1500 1100,1300 1100,750
C1100,200 900,0 100,0 z"/>
<!-- "e" glyph -->
<glyph unicode="e" glyph-name="e" horiz-adv-x="1100"
d="M100,0V1500H1000V1400H200V800H700V700H200V100H1000V0z"/>
<!-- "f" glyph -->
<glyph unicode="f" glyph-name="f" horiz-adv-x="1100"
d="M100,0 V1500 H1000 V1400 H200 V800 H700 V700 H200 V0 z"/>
<!-- "g" glyph -->
<glyph unicode="g" glyph-name="g" horiz-adv-x="1000"
d="M850,1000 A400,750 0 1,1 850,500
H950 V600 H500 V500 H350 V1000 z"/>
<!-- "u" glyph -->
<glyph unicode="u" glyph-name="u" horiz-adv-x="1000"
d="M250,1400 A400,850 0 1,1 850,1400
H700 A250,700 0 1,0 400,1400 z"/>
<!-- "v" glyph -->
<glyph unicode="v" glyph-name="v" horiz-adv-x="1000"
d="M500,0 L100,1500 H900 z"/>
<!-- "w" glyph -->
<glyph unicode="w" glyph-name="w" horiz-adv-x="1400"
d="M"/>
<glyph unicode=" " glyph-name="space"
horiz-adv-x="1000" d="M0 0z"/>
<glyph unicode="-" glyph-name="hyphen" horiz-adv-x="1000"
d="M200,650 l700,0 c100,0 100,175 0,175
l-700,0 c-100,0 -100,-175 0,-175 z"/>
<glyph unicode="­" glyph-name="softhyphen"
horiz-adv-x="1000"
d="M200,650 l700,0 c100,0 100,175 0,175
l-700,0 c-100,0 -100,-175 0,-175 z"/>
</font>
<text x="10" y="80" font-size="30" font-family="Shapes"
>abcdefguv-</text>
<text x="10" y="130" font-size="30" font-family="ShapesKernTogeather"
>abcdefguv-</text>
<text x="10" y="180" font-size="30" font-family="ShapesKernApart"
>abcdefguv-</text>
</svg>
1.12 +4 -1
xml-batik/sources/org/apache/batik/extension/svg/BatikExtConstants.java
Index: BatikExtConstants.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/extension/svg/BatikExtConstants.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- BatikExtConstants.java 30 Apr 2002 19:08:47 -0000 1.11
+++ BatikExtConstants.java 22 May 2002 21:50:40 -0000 1.12
@@ -68,9 +68,12 @@
/** Attribute name for first-line-right-margin attribute */
public static final String BATIK_EXT_FIRST_LINE_RIGHT_MARGIN_ATTRIBUTE =
"first-line-right-margin";
- /** Attribute name for margine psudo-attribute */
+ /** Attribute name for justification */
public static final String BATIK_EXT_JUSTIFICATION_ATTRIBUTE =
"justification";
+ /** Attribute name for preformated data */
+ public static final String BATIK_EXT_PREFORMATTED_ATTRIBUTE =
+ "preformatted";
/** Tag name for Batik's flowText extension div element SVG 1.1). */
1.6 +23 -1
xml-batik/sources/org/apache/batik/extension/svg/SVGFlowTextElementBridge.java
Index: SVGFlowTextElementBridge.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/extension/svg/SVGFlowTextElementBridge.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SVGFlowTextElementBridge.java 15 May 2002 14:14:31 -0000 1.5
+++ SVGFlowTextElementBridge.java 22 May 2002 21:50:40 -0000 1.6
@@ -38,12 +38,13 @@
import org.apache.batik.gvt.TextNode;
import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
import org.apache.batik.gvt.text.MarginInfo;
+import org.apache.batik.gvt.text.TextPath;
/**
* Bridge class for the <flowText> element.
*
* @author <a href="[EMAIL PROTECTED]">Thomas DeWeese</a>
- * @version $Id: SVGFlowTextElementBridge.java,v 1.5 2002/05/15 14:14:31 deweese
Exp $
+ * @version $Id: SVGFlowTextElementBridge.java,v 1.6 2002/05/22 21:50:40 deweese
Exp $
*/
public class SVGFlowTextElementBridge extends SVGTextElementBridge
implements BatikExtConstants {
@@ -61,6 +62,9 @@
public static final AttributedCharacterIterator.Attribute FLOW_REGIONS
= GVTAttributedCharacterIterator.TextAttribute.FLOW_REGIONS;
+ public static final AttributedCharacterIterator.Attribute PREFORMATTED
+ = GVTAttributedCharacterIterator.TextAttribute.PREFORMATTED;
+
/**
* Constructs a new bridge for the <flowText> element.
*/
@@ -531,6 +535,24 @@
first = false;
}
}
+
+ /**
+ * Returns the map to pass to the current characters.
+ */
+ protected Map getAttributeMap(BridgeContext ctx,
+ Element element,
+ TextPath textPath) {
+ Map result = super.getAttributeMap(ctx, element, textPath);
+ String s;
+ s = element.getAttributeNS(null, BATIK_EXT_PREFORMATTED_ATTRIBUTE);
+ if (s.length() != 0) {
+ if (s.equals("true")) {
+ result.put(PREFORMATTED, Boolean.TRUE);
+ }
+ }
+ return result;
+ }
+
protected void checkMap(Map attrs) {
if (attrs.containsKey(TEXTPATH)) {
1.19 +4 -1
xml-batik/sources/org/apache/batik/gvt/text/GVTAttributedCharacterIterator.java
Index: GVTAttributedCharacterIterator.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/text/GVTAttributedCharacterIterator.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- GVTAttributedCharacterIterator.java 29 Mar 2002 20:00:55 -0000 1.18
+++ GVTAttributedCharacterIterator.java 22 May 2002 21:50:40 -0000 1.19
@@ -23,7 +23,7 @@
* SVGAttributedCharacterIterator.TextAttributes.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Haneman</a>
- * @version $Id: GVTAttributedCharacterIterator.java,v 1.18 2002/03/29 20:00:55
deweese Exp $
+ * @version $Id: GVTAttributedCharacterIterator.java,v 1.19 2002/05/22 21:50:40
deweese Exp $
*/
public interface GVTAttributedCharacterIterator extends AttributedCharacterIterator
{
@@ -210,6 +210,9 @@
public final static TextAttribute FLOW_REGIONS =
new TextAttribute("FLOW_REGIONS");
+
+ public final static TextAttribute PREFORMATTED =
+ new TextAttribute("PREFORMATTED");
/** Attribute span delimiter - new tspan, tref, or textelement.*/
public final static TextAttribute TEXT_COMPOUND_DELIMITER =
1.7 +16 -11 xml-batik/sources/org/apache/batik/gvt/text/GlyphIterator.java
Index: GlyphIterator.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/text/GlyphIterator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GlyphIterator.java 8 May 2002 09:42:47 -0000 1.6
+++ GlyphIterator.java 22 May 2002 21:50:40 -0000 1.7
@@ -19,6 +19,9 @@
import org.apache.batik.gvt.font.GVTLineMetrics;
public class GlyphIterator {
+ public static final AttributedCharacterIterator.Attribute PREFORMATTED
+ = GVTAttributedCharacterIterator.TextAttribute.PREFORMATTED;
+
public static final AttributedCharacterIterator.Attribute FLOW_LINE_BREAK
= GVTAttributedCharacterIterator.TextAttribute.FLOW_LINE_BREAK;
@@ -366,10 +369,20 @@
leftShiftIdx = null;
leftShiftAmt = null;
+ float lineInfoChW;
+ int hideIdx;
+ // System.out.println("ChIdx: " + chIdx);
+ if ((chIdx != 0) || (isPrinting())) {
+ lineInfoChW = getCharWidth(chIdx);
+ hideIdx = chIdx+1;
+ } else {
+ lineInfoChW = 0;
+ hideIdx = 0;
+ }
+
int lineInfoIdx = idx+1;
float lineInfoAdv = adv;
float lineInfoAdj = adj;
-
while (!done()) {
adv=0;
adj=0;
@@ -388,16 +401,6 @@
}
// hide trailing spaces if any
- float lineInfoChW;
- int hideIdx;
- // System.out.println("ChIdx: " + chIdx);
- if (chIdx != -1) {
- lineInfoChW = getCharWidth(chIdx);
- hideIdx = chIdx+1;
- } else {
- lineInfoChW = 0;
- hideIdx = 0;
- }
for (int i = hideIdx; i<lineInfoIdx; i++) {
gv.setGlyphVisible(i, false);
}
@@ -414,6 +417,8 @@
}
public boolean isPrinting() {
+ if (aci.getAttribute(PREFORMATTED) == Boolean.TRUE)
+ return true;
return isPrinting(ch);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]