You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by tk...@apache.org on 2001/12/03 14:01:40 UTC
cvs commit: xml-batik/sources/org/apache/batik/bridge SVGTextElementBridge.java
tkormann 01/12/03 05:01:40
Modified: sources/org/apache/batik/bridge SVGTextElementBridge.java
Added: samples/tests/spec/structure systemLanguage.svg
Log:
add support for systemLanguage on tspan
add a new complete test for that
Revision Changes Path
1.1 xml-batik/samples/tests/spec/structure/systemLanguage.svg
Index: systemLanguage.svg
===================================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//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. -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!-- Tests text-anchor on multiple text chunks on single tspan element -->
<!-- -->
<!-- @author tkormann@ilog.fr -->
<!-- @version $Id: systemLanguage.svg,v 1.1 2001/12/03 13:01:40 tkormann Exp $ -->
<!-- ====================================================================== -->
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
<svg width="450" height="500" viewBox="0 0 450 500" >
<!-- ============================================================= -->
<!-- Test content -->
<!-- ============================================================= -->
<g id="testContent">
<text x="225" y="50" class="title">Test the 'systemLanguage' attribute</text>
<g style="fill:#eee; stroke:black">
<rect x="50" y="80" width="360" height="20" />
<rect x="30" y="100" width="20" height="85" />
<rect x="30" y="185" width="20" height="65" />
<rect x="30" y="250" width="20" height="65" />
<rect x="30" y="315" width="20" height="65" />
<rect x="30" y="380" width="20" height="65" />
</g>
<g style="fill:none; stroke:black">
<rect x="50" y="80" width="360" height="365" />
<line x1="170" y1="80" x2="170" y2="445" />
<line x1="290" y1="80" x2="290" y2="445" />
<line x1="50" y1="185" x2="410" y2="185" />
<line x1="50" y1="250" x2="410" y2="250" />
<line x1="50" y1="315" x2="410" y2="315" />
<line x1="50" y1="380" x2="410" y2="380" />
</g>
<g style="fill:black; text-anchor:middle;">
<text x="110" y="94">default</text>
<text x="230" y="94">english (en)</text>
<text x="350" y="94">french (fr)</text>
<text x="0" y="0" transform="translate(44, 145) rotate(-90)">Graphic Obj.</text>
<text x="0" y="0" transform="translate(44, 220) rotate(-90)"><svg></text>
<text x="0" y="0" transform="translate(44, 285) rotate(-90)"><g></text>
<text x="0" y="0" transform="translate(44, 350) rotate(-90)"><use></text>
<text x="0" y="0" transform="translate(44, 415) rotate(-90)"><tspan></text>
</g>
<defs>
</defs>
<!-- ####################################################################################### -->
<g transform="translate(60, 110)">
<g>
<rect x="0" y="0" width="30" height="20" style="fill:crimson" />
<circle cx="50" cy="10" r="10" style="fill:crimson" />
<ellipse cx="85" cy="10" rx="15" ry="10" style="fill:crimson" />
</g>
<g style="stroke-width:3; fill:none">
<line x1="0" y1="25" x2="30" y2="45" style="stroke:crimson" />
<polyline points="35 25 45 42 55 25 65 42" style="stroke:crimson" />
<polygon points="70 25 80 42 90 25 100 42" style="fill:crimson" />
</g>
<g style="stroke-width:3; fill:none">
<path d="M0 60C5 55 10 55 15 60C20 65 25 65 30 60" style="stroke:crimson" />
<image xlink:href="../../resources/images/tde.jpg" x="35" y="50" width="30" height="20" />
<text x="85" y="65" style="fill:black; stroke:none; text-anchor:middle">text</text>
</g>
</g>
<g transform="translate(180, 110)">
<g>
<rect x="0" y="0" width="30" height="20" style="fill:orange" systemLanguage="en" />
<circle cx="50" cy="10" r="10" style="fill:orange" systemLanguage="en" />
<ellipse cx="85" cy="10" rx="15" ry="10" style="fill:orange" systemLanguage="en" />
</g>
<g style="stroke-width:3; fill:none">
<line x1="0" y1="25" x2="30" y2="45" style="stroke:orange" systemLanguage="en"/>
<polyline points="35 25 45 42 55 25 65 42" style="stroke:orange" systemLanguage="en"/>
<polygon points="70 25 80 42 90 25 100 42" style="fill:orange" systemLanguage="en"/>
</g>
<g style="stroke-width:3; fill:none">
<path d="M0 60C5 55 10 55 15 60C20 65 25 65 30 60" style="stroke:orange" systemLanguage="en"/>
<image xlink:href="../../resources/images/tde.jpg" x="35" y="50" width="30" height="20" systemLanguage="en"/>
<text x="85" y="65" style="fill:black; stroke:none; text-anchor:middle" systemLanguage="en">text</text>
</g>
</g>
<g transform="translate(300, 110)">
<g>
<rect x="0" y="0" width="30" height="20" style="fill:gold" systemLanguage="fr"/>
<circle cx="50" cy="10" r="10" style="fill:gold" systemLanguage="fr"/>
<ellipse cx="85" cy="10" rx="15" ry="10" style="fill:gold" systemLanguage="fr"/>
</g>
<g style="stroke-width:3; fill:none">
<line x1="0" y1="25" x2="30" y2="45" style="stroke:gold" systemLanguage="fr"/>
<polyline points="35 25 45 42 55 25 65 42" style="stroke:gold" systemLanguage="fr"/>
<polygon points="70 25 80 42 90 25 100 42" style="fill: gold" systemLanguage="fr"/>
</g>
<g style="stroke-width:3; fill:none">
<path d="M0 60C5 55 10 55 15 60C20 65 25 65 30 60" style="stroke:gold" systemLanguage="fr"/>
<image xlink:href="../../resources/images/tde.jpg" x="35" y="50" width="30" height="20" systemLanguage="fr"/>
<text x="85" y="65" style="fill:black; stroke:none; text-anchor:middle" systemLanguage="fr">text</text>
</g>
</g>
<!-- ####################################################################################### -->
<g>
<svg x="52" y="187" width="116" height="62">
<rect x="0" y="0" width="100%" height="100%" style="fill:crimson" />
</svg>
<svg x="172" y="187" width="116" height="62" style="fill:orange" systemLanguage="en">
<rect x="0" y="0" width="100%" height="100%" />
</svg>
<svg x="292" y="187" width="116" height="62" style="fill:gold" systemLanguage="fr">
<rect x="0" y="0" width="100%" height="100%" />
</svg>
</g>
<!-- ####################################################################################### -->
<g transform="translate(0 65)">
<g>
<rect x="52" y="187" width="116" height="62" style="fill:crimson"/>
</g>
<g>
<rect x="172" y="187" width="116" height="62" style="fill:orange" systemLanguage="en" />
</g>
<g>
<rect x="292" y="187" width="116" height="62" style="fill:gold" systemLanguage="fr" />
</g>
</g>
<!-- ####################################################################################### -->
<defs>
<rect id="use" x="0" y="0" width="116" height="61" />
</defs>
<g>
<use xlink:href="#use" x="52" y="317" style="fill:crimson" />
<use xlink:href="#use" x="172" y="317" style="fill:orange" systemLanguage="en" />
<use xlink:href="#use" x="292" y="317" style="fill:gold" systemLanguage="fr" />
</g>
<!-- ####################################################################################### -->
<text style="text-anchor:middle">
<tspan x="110" y="420" style="fill:crimson">simple <tspan></tspan>
<tspan x="230" y="420" style="fill:orange" systemLanguage="en">simple <tspan></tspan>
<tspan x="350" y="420" style="fill:gold" systemLanguage="fr">simple <tspan></tspan>
</text>
</g>
<!-- ============================================================= -->
<!-- Batik sample mark -->
<!-- ============================================================= -->
<use xlink:href="../../../batikLogo.svg#Batik_Tag_Box" />
</svg>
1.42 +30 -18 xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java
Index: SVGTextElementBridge.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- SVGTextElementBridge.java 2001/11/14 10:54:23 1.41
+++ SVGTextElementBridge.java 2001/12/03 13:01:40 1.42
@@ -56,7 +56,7 @@
* Bridge class for the <text> element.
*
* @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
- * @version $Id: SVGTextElementBridge.java,v 1.41 2001/11/14 10:54:23 tkormann Exp $
+ * @version $Id: SVGTextElementBridge.java,v 1.42 2001/12/03 13:01:40 tkormann Exp $
*/
public class SVGTextElementBridge extends AbstractSVGBridge
implements GraphicsNodeBridge, ErrorConstants {
@@ -82,17 +82,17 @@
* @return a graphics node that represents the specified element
*/
public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
- // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
- if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
- return null;
- }
+ // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
+ if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
+ return null;
+ }
TextNode node = new TextNode();
- // specify the text painter to use if one has been provided in the
- // bridge context
- if (ctx.getTextPainter() != null) {
- node.setTextPainter(ctx.getTextPainter());
- }
+ // specify the text painter to use if one has been provided in the
+ // bridge context
+ if (ctx.getTextPainter() != null) {
+ node.setTextPainter(ctx.getTextPainter());
+ }
// 'transform'
String s = e.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE);
@@ -290,6 +290,11 @@
TextPath textPath,
LinkedList result) {
+ // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
+ if (!SVGUtilities.matchUserAgent(element, ctx.getUserAgent())) {
+ return result;
+ }
+
// !!! return two lists
Map m = getAttributeMap(ctx, element, node, textPath);
String s = XMLSupport.getXMLSpace(element);
@@ -325,7 +330,7 @@
if (n.getLocalName().equals(SVG_TSPAN_TAG) ||
n.getLocalName().equals(SVG_ALT_GLYPH_TAG) ||
- n.getLocalName().equals(SVG_A_TAG)) {
+ n.getLocalName().equals(SVG_A_TAG)) {
buildAttributedStrings(ctx,
nodeElement,
@@ -333,7 +338,6 @@
false,
textPath,
result);
-
} else if (n.getLocalName().equals(SVG_TEXT_PATH_TAG)) {
SVGTextPathElementBridge textPathBridge
@@ -380,7 +384,7 @@
}
break;
case Node.TEXT_NODE:
- case Node.CDATA_SECTION_NODE:
+ case Node.CDATA_SECTION_NODE:
s = n.getNodeValue();
int[] indexMap = new int[s.length()];
as = createAttributedString
@@ -531,6 +535,10 @@
Element element,
BridgeContext ctx) {
+ // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
+ if (!SVGUtilities.matchUserAgent(element, ctx.getUserAgent())) {
+ return;
+ }
// get all of the glyph position attribute values
String xAtt = element.getAttributeNS(null, SVG_X_ATTRIBUTE);
String yAtt = element.getAttributeNS(null, SVG_Y_ATTRIBUTE);
@@ -662,6 +670,10 @@
BridgeContext ctx) {
+ // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
+ if (!SVGUtilities.matchUserAgent(element, ctx.getUserAgent())) {
+ return;
+ }
AttributedCharacterIterator aci = as.getIterator();
// calculate which chars in the string belong to this element
@@ -693,7 +705,7 @@
// Fill
Paint p = PaintServer.convertFillPaint(element, node, ctx);
- as.addAttribute(TextAttribute.FOREGROUND, p,
+ as.addAttribute(TextAttribute.FOREGROUND, p,
firstChar, lastChar+1);
// Stroke Paint
@@ -711,7 +723,7 @@
// Text decoration
if (textDecoration != null) {
as.addAttribute(GVTAttributedCharacterIterator.
- TextAttribute.UNDERLINE_PAINT,
+ TextAttribute.UNDERLINE_PAINT,
textDecoration.underlinePaint,
firstChar, lastChar+1);
@@ -719,14 +731,14 @@
TextAttribute.UNDERLINE_STROKE_PAINT,
textDecoration.underlineStrokePaint,
firstChar, lastChar+1);
-
+
as.addAttribute(GVTAttributedCharacterIterator.
TextAttribute.UNDERLINE_STROKE,
textDecoration.underlineStroke,
firstChar, lastChar+1);
as.addAttribute(GVTAttributedCharacterIterator.
- TextAttribute.OVERLINE_PAINT,
+ TextAttribute.OVERLINE_PAINT,
textDecoration.overlinePaint,
firstChar, lastChar+1);
@@ -744,7 +756,7 @@
TextAttribute.STRIKETHROUGH_PAINT,
textDecoration.strikethroughPaint,
firstChar, lastChar+1);
-
+
as.addAttribute(GVTAttributedCharacterIterator.
TextAttribute.STRIKETHROUGH_STROKE_PAINT,
textDecoration.strikethroughStrokePaint,
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org