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 de...@apache.org on 2003/05/24 03:05:26 UTC
cvs commit: xml-batik/sources/org/apache/batik/extension/svg SVGFlowTextElementBridge.java
deweese 2003/05/23 18:05:26
Modified: . build.sh
samples/tests/spec/text textBiDi.svg
sources/org/apache/batik/bridge SVGTextElementBridge.java
SVGUseElementBridge.java URIResolver.java
sources/org/apache/batik/extension/svg
SVGFlowTextElementBridge.java
Log:
Runs of RTL Text now work with JDK 1.4.
Nested embed and bidi-override properties should now work.
Fixed another bug with use and URL resolutions.
Revision Changes Path
1.13 +2 -0 xml-batik/build.sh
Index: build.sh
===================================================================
RCS file: /home/cvs/xml-batik/build.sh,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- build.sh 7 Mar 2003 14:31:53 -0000 1.12
+++ build.sh 24 May 2003 01:05:25 -0000 1.13
@@ -44,4 +44,6 @@
shift 1
fi
+# $JAVA_HOME/bin/java -version
+
$JAVA_HOME/bin/java $ANT_OPTS -classpath $CP org.apache.tools.ant.Main -emacs -Dant.home=$ANT_HOME $TARGET -Dargs="$*"
1.5 +12 -26 xml-batik/samples/tests/spec/text/textBiDi.svg
Index: textBiDi.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/tests/spec/text/textBiDi.svg,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- textBiDi.svg 14 Mar 2002 10:56:30 -0000 1.4
+++ textBiDi.svg 24 May 2003 01:05:25 -0000 1.5
@@ -37,35 +37,21 @@
<g font-family="dialog" font-size="15" text-anchor="start">
<text id="latin" fill="MidnightBlue" x="10%" y="45%">latin:
ABCDEFG
- abcdefg
- hijklmnop
- qrstuvwxyz
- </text>
+ abcdefghijklmnopqrstuvwxyz</text>
<text id="latin-extended" fill="Sienna" x="10%" y="50%">latin-extended:
- æçèéêëì
- íîïðñòóô
- </text>
+ æçèéêëìíîïðñòóô</text>
<text id="cyrillic" fill="Indigo" x="10%" y="55%">cyrillic:
- БВГДЕЖЗИЙ
- КЛМНОПРСТ
- УФХЦЧ
- </text>
+ БВГДЕЖЗИЙКЛМНОПРСТУФХЦЧ</text>
<text id="greek" fill="Maroon" x="10%" y="60%">greek:
- ΑΒΓΔαβγδε
- ζηθικλμνξ
- οπρςστυφχ
- ψω
- </text>
+ ΑΒΓΔ αβγδεζηθικλμνξοπρςστυφχψω</text>
<text id="hebrew" fill="DarkOliveGreen" x="10%" y="65%">hebrew:
- אבגדהוזחט
- יךכלםמןנס
- עףפץצקרשת
- </text>
- <text id="arabic" fill="DarkRed" x="10%" y="70%">arabic:
- ءأؤإئابةت
- ثجحخدذرزس
- شصضطظعـفق
- كلمنهوىِᙶ</text>
+ אבגדהוזחטיךכלםמןנסעףפץצקרשת</text>
+ <text fill="DarkOliveGreen" x="10%" y="70%"
+ >אבגדהוזחטיךכלםמןנסעףפץצקרשת</text>
+ <text id="arabic" fill="DarkRed" x="10%" y="75%">arabic:
+ ءأؤإئابةتثجحخدذرزسشصضطظعـفقكلمنهوىِٶ</text>
+ <text fill="DarkRed" x="10%" y="80%"
+ >ءأؤإئابةتثجحخدذرزسشصضطظعـفقكلمنهوىِٶ</text>
</g>
</g>
1.80 +40 -38 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.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- SVGTextElementBridge.java 11 Apr 2003 13:54:54 -0000 1.79
+++ SVGTextElementBridge.java 24 May 2003 01:05:25 -0000 1.80
@@ -636,7 +636,7 @@
Element element) {
AttributedStringBuffer asb = new AttributedStringBuffer();
- fillAttributedStringBuffer(ctx, element, true, null, asb);
+ fillAttributedStringBuffer(ctx, element, true, null, null, asb);
return asb.toAttributedString();
}
@@ -647,6 +647,7 @@
Element element,
boolean top,
TextPath textPath,
+ Integer bidiLevel,
AttributedStringBuffer asb) {
// 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
if (!SVGUtilities.matchUserAgent(element, ctx.getUserAgent())) {
@@ -657,10 +658,15 @@
boolean preserve = s.equals(SVG_PRESERVE_VALUE);
boolean first = true;
boolean last;
- boolean stripFirst = !preserve;
- boolean stripLast = !preserve;
+ boolean stripFirst = !preserve;
+ boolean stripLast = !preserve;
Element nodeElement = element;
- Map map = null;
+
+ Map map = getAttributeMap(ctx, element, textPath, bidiLevel);
+ Object o = map.get(TextAttribute.BIDI_EMBEDDING);
+ Integer subBidiLevel = bidiLevel;
+ if (o != null)
+ subBidiLevel = ((Integer)o);
for (Node n = element.getFirstChild();
n != null;
@@ -687,6 +693,7 @@
nodeElement,
false,
textPath,
+ subBidiLevel,
asb);
} else if (ln.equals(SVG_TEXT_PATH_TAG)) {
SVGTextPathElementBridge textPathBridge
@@ -698,6 +705,7 @@
nodeElement,
false,
newTextPath,
+ subBidiLevel,
asb);
}
} else if (ln.equals(SVG_TREF_TAG)) {
@@ -710,7 +718,8 @@
if (stripLast && !asb.isEmpty()) {
asb.stripLast();
}
- Map m = getAttributeMap(ctx, nodeElement, textPath);
+ Map m = getAttributeMap(ctx, nodeElement,
+ textPath, bidiLevel);
asb.append(s, m);
}
} else if (ln.equals(SVG_A_TAG)) {
@@ -724,6 +733,7 @@
nodeElement,
false,
textPath,
+ subBidiLevel,
asb);
}
break;
@@ -733,12 +743,8 @@
s = normalizeString(s, preserve, stripFirst, last && top);
if (s != null) {
stripLast = !preserve && s.charAt(0) == ' ';
- if (stripLast && !asb.isEmpty()) {
+ if (stripLast && !asb.isEmpty())
asb.stripLast();
- }
- if (map == null) {
- map = getAttributeMap(ctx, element, textPath);
- }
asb.append(s, map);
}
}
@@ -1299,7 +1305,8 @@
*/
protected Map getAttributeMap(BridgeContext ctx,
Element element,
- TextPath textPath) {
+ TextPath textPath,
+ Integer bidiLevel) {
UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element);
Map result = new HashMap();
@@ -1383,7 +1390,8 @@
(element, SVGCSSEngine.UNICODE_BIDI_INDEX);
s = val.getStringValue();
if (s.charAt(0) == 'n') {
- result.put(TextAttribute.BIDI_EMBEDDING, ZERO);
+ if (bidiLevel != null)
+ result.put(TextAttribute.BIDI_EMBEDDING, bidiLevel);
} else {
// Text direction
@@ -1399,38 +1407,32 @@
val = CSSUtilities.getComputedStyle
(element, SVGCSSEngine.DIRECTION_INDEX);
String rs = val.getStringValue();
+ int cbidi = 0;
+ if (bidiLevel != null) cbidi = bidiLevel.intValue();
+
+ // We don't care if it was embed or override we just want
+ // it's level here. So map override to positive value.
+ if (cbidi < 0) cbidi = -cbidi;
+
switch (rs.charAt(0)) {
case 'l':
result.put(TextAttribute.RUN_DIRECTION,
TextAttribute.RUN_DIRECTION_LTR);
-
- switch (s.charAt(0)) {
- case 'b': // bidi-override
- result.put(TextAttribute.BIDI_EMBEDDING,
- new Integer(-2));
- break;
- case 'e': // embed
- result.put(TextAttribute.BIDI_EMBEDDING,
- new Integer(2));
- break;
- }
-
- break;
+ if ((cbidi & 0x1) == 1) cbidi++; // was odd now even
+ else cbidi+=2; // next greater even number
case 'r':
result.put(TextAttribute.RUN_DIRECTION,
TextAttribute.RUN_DIRECTION_RTL);
- switch (s.charAt(0)) {
- case 'b': // bidi-override
- result.put(TextAttribute.BIDI_EMBEDDING,
- new Integer(-1));
- break;
- case 'e': // embed
- result.put(TextAttribute.BIDI_EMBEDDING,
- new Integer(1));
- break;
- }
- break;
- }
+ if ((cbidi & 0x1) == 1) cbidi+=2; // next greater odd number
+ else cbidi++; // was even now odd
+ }
+
+ switch (s.charAt(0)) {
+ case 'b': // bidi-override
+ cbidi = -cbidi; // For bidi-override we want a negative number.
+ break;
+ }
+ result.put(TextAttribute.BIDI_EMBEDDING, new Integer(cbidi));
}
// Writing mode
1.31 +2 -2 xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java
Index: SVGUseElementBridge.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- SVGUseElementBridge.java 11 Apr 2003 13:54:56 -0000 1.30
+++ SVGUseElementBridge.java 24 May 2003 01:05:26 -0000 1.31
@@ -72,7 +72,7 @@
if (uri.length() == 0)
throw new BridgeException(e, ERR_URI_MALFORMED,
new Object[] {uri});
-
+
Element refElement = ctx.getReferencedElement(e, uri);
SVGOMDocument document
= (SVGOMDocument)e.getOwnerDocument();
1.22 +2 -2 xml-batik/sources/org/apache/batik/bridge/URIResolver.java
Index: URIResolver.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/URIResolver.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- URIResolver.java 23 Apr 2003 00:46:11 -0000 1.21
+++ URIResolver.java 24 May 2003 01:05:26 -0000 1.22
@@ -117,7 +117,7 @@
UserAgent userAgent = documentLoader.getUserAgent();
userAgent.checkLoadExternalResource(purl, pDocURL);
-
+
Document doc = documentLoader.loadDocument(purl.toString());
if (frag != null)
return doc.getElementById(frag);
1.10 +21 -13 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SVGFlowTextElementBridge.java 11 Apr 2003 13:58:20 -0000 1.9
+++ SVGFlowTextElementBridge.java 24 May 2003 01:05:26 -0000 1.10
@@ -8,6 +8,7 @@
package org.apache.batik.extension.svg;
+import java.awt.font.TextAttribute;
import java.awt.geom.Point2D;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
@@ -280,12 +281,12 @@
String ln = e.getLocalName();
if (ln.equals(BATIK_EXT_FLOW_PARA_TAG)) {
- fillAttributedStringBuffer(ctx, e, true, asb, lnLocs);
+ fillAttributedStringBuffer(ctx, e, true, null, asb, lnLocs);
paraElems.add(e);
paraEnds.add(new Integer(asb.length()));
} else if (ln.equals(BATIK_EXT_FLOW_REGION_BREAK_TAG)) {
- fillAttributedStringBuffer(ctx, e, true, asb, lnLocs);
+ fillAttributedStringBuffer(ctx, e, true, null, asb, lnLocs);
paraElems.add(e);
paraEnds.add(new Integer(asb.length()));
@@ -456,6 +457,7 @@
protected void fillAttributedStringBuffer(BridgeContext ctx,
Element element,
boolean top,
+ Integer bidiLevel,
AttributedStringBuffer asb,
List lnLocs) {
// 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
@@ -470,7 +472,12 @@
boolean stripFirst = !preserve;
boolean stripLast = !preserve;
Element nodeElement = element;
- Map map = null;
+
+ Map map = getAttributeMap(ctx, element, null, bidiLevel);
+ Object o = map.get(TextAttribute.BIDI_EMBEDDING);
+ Integer subBidiLevel = bidiLevel;
+ if (o != null)
+ subBidiLevel = (Integer)o;
for (Node n = element.getFirstChild();
n != null;
@@ -494,14 +501,16 @@
String ln = n.getLocalName();
if (ln.equals(BATIK_EXT_FLOW_LINE_TAG)) {
fillAttributedStringBuffer(ctx, nodeElement,
- false, asb, lnLocs);
+ false, subBidiLevel,
+ asb, lnLocs);
// System.out.println("Line: " + asb.length() +
// " - '" + asb + "'");
lnLocs.add(new Integer(asb.length()));
} else if (ln.equals(BATIK_EXT_FLOW_SPAN_TAG) ||
ln.equals(SVG_ALT_GLYPH_TAG)) {
fillAttributedStringBuffer(ctx, nodeElement,
- false, asb, lnLocs);
+ false, subBidiLevel,
+ asb, lnLocs);
} else if (ln.equals(SVG_A_TAG)) {
EventTarget target = (EventTarget)nodeElement;
UserAgent ua = ctx.getUserAgent();
@@ -521,7 +530,7 @@
false);
fillAttributedStringBuffer(ctx,
nodeElement,
- false,
+ false, subBidiLevel,
asb, lnLocs);
} else if (ln.equals(SVG_TREF_TAG)) {
String uriStr = XLinkSupport.getXLinkHref((Element)n);
@@ -533,7 +542,8 @@
if (stripLast && !asb.isEmpty()) {
asb.stripLast();
}
- Map m = getAttributeMap(ctx, nodeElement, null);
+ Map m = getAttributeMap(ctx, nodeElement, null,
+ bidiLevel);
asb.append(s, m);
}
}
@@ -548,9 +558,6 @@
if (stripLast && !asb.isEmpty()) {
asb.stripLast();
}
- if (map == null) {
- map = getAttributeMap(ctx, element, null);
- }
asb.append(s, map);
}
}
@@ -563,8 +570,9 @@
*/
protected Map getAttributeMap(BridgeContext ctx,
Element element,
- TextPath textPath) {
- Map result = super.getAttributeMap(ctx, element, textPath);
+ TextPath textPath,
+ Integer bidiLevel) {
+ Map result = super.getAttributeMap(ctx, element, textPath, bidiLevel);
String s;
s = element.getAttribute(BATIK_EXT_PREFORMATTED_ATTRIBUTE);
if (s.length() != 0) {
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org