ASF Bugzilla – Attachment 23820 Details for
Bug 47359
[PATCH] Nested baseline-shift are not additive
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
minor formatting fix
baseline-shift.diff3 (text/plain), 6.36 KB, created by
Nicolas Socheleau
on 2009-06-16 13:24:15 UTC
(
hide
)
Description:
minor formatting fix
Filename:
MIME Type:
Creator:
Nicolas Socheleau
Created:
2009-06-16 13:24:15 UTC
Size:
6.36 KB
patch
obsolete
>Index: sources/org/apache/batik/bridge/SVGTextElementBridge.java >=================================================================== >--- sources/org/apache/batik/bridge/SVGTextElementBridge.java (revision 784025) >+++ sources/org/apache/batik/bridge/SVGTextElementBridge.java (working copy) >@@ -853,7 +853,7 @@ > Element element) { > > AttributedStringBuffer asb = new AttributedStringBuffer(); >- fillAttributedStringBuffer(ctx, element, true, null, null, null, asb); >+ fillAttributedStringBuffer(ctx, element, true, null, null, null, null, asb); > return asb.toAttributedString(); > } > >@@ -875,6 +875,7 @@ > TextPath textPath, > Integer bidiLevel, > Map initialAttributes, >+ Map parentAttributes, > AttributedStringBuffer asb) { > // 'requiredFeatures', 'requiredExtensions', 'systemLanguage' & > // 'display="none". >@@ -899,8 +900,17 @@ > Map map = initialAttributes == null > ? new HashMap() > : new HashMap(initialAttributes); >+ Map elementAttributes = new HashMap(); > initialAttributes = >- getAttributeMap(ctx, element, textPath, bidiLevel, map); >+ getAttributeMap(ctx, element, textPath, bidiLevel, elementAttributes); >+ >+ //Adjust the baseline-shift for the element based on the >+ //value of the parent and build the parent attributes map >+ //for the child of the element >+ parentAttributes = handleNestedBaselineShift(parentAttributes, elementAttributes); >+ >+ map.putAll(elementAttributes); >+ > Object o = map.get(TextAttribute.BIDI_EMBEDDING); > Integer subBidiLevel = bidiLevel; > if (o != null) { >@@ -939,6 +949,7 @@ > textPath, > subBidiLevel, > initialAttributes, >+ parentAttributes, > asb); > if (asb.count != before) { > initialAttributes = null; >@@ -956,6 +967,7 @@ > newTextPath, > subBidiLevel, > initialAttributes, >+ parentAttributes, > asb); > if (asb.count != before) { > initialAttributes = null; >@@ -1003,6 +1015,7 @@ > textPath, > subBidiLevel, > initialAttributes, >+ parentAttributes, > asb); > if (asb.count != before) { > initialAttributes = null; >@@ -1047,6 +1060,33 @@ > tpi.endChar = elementEndChar; > } > >+ /* >+ * Nested baseline-shift are additive, so keep track of all the >+ * baseline-shift value to calculate the final baseline shift >+ */ >+ private Map handleNestedBaselineShift(Map parentAttributes, Map elementAttributes) >+ { >+ if ( elementAttributes.containsKey(BASELINE_SHIFT) ) >+ { >+ ArrayList list = new ArrayList(); >+ if ( parentAttributes != null && parentAttributes.containsKey(BASELINE_SHIFT) ) >+ { >+ list.addAll((List)parentAttributes.get(BASELINE_SHIFT)); >+ } >+ list.add(elementAttributes.get(BASELINE_SHIFT)); >+ elementAttributes.put(BASELINE_SHIFT,list); >+ >+ Map newParentAttributes = new HashMap(); >+ newParentAttributes.put(BASELINE_SHIFT,list); >+ return newParentAttributes; >+ } >+ else if ( parentAttributes != null && parentAttributes.containsKey(BASELINE_SHIFT) ) >+ { >+ elementAttributes.put(BASELINE_SHIFT,parentAttributes.get(BASELINE_SHIFT)); >+ } >+ return parentAttributes; >+ } >+ > /** > * Normalizes the given string. > */ >Index: sources/org/apache/batik/gvt/text/GlyphLayout.java >=================================================================== >--- sources/org/apache/batik/gvt/text/GlyphLayout.java (revision 784025) >+++ sources/org/apache/batik/gvt/text/GlyphLayout.java (working copy) >@@ -34,6 +34,7 @@ > import java.text.AttributedCharacterIterator; > import java.text.CharacterIterator; > import java.util.HashSet; >+import java.util.List; > import java.util.Set; > > import org.apache.batik.gvt.font.AWTGVTFont; >@@ -1224,14 +1225,20 @@ > > float baselineAdjust = 0f; > if (baseline != null) { >- if (baseline instanceof Integer) { >- if (baseline==TextAttribute.SUPERSCRIPT_SUPER) { >- baselineAdjust = baselineAscent*0.5f; >- } else if (baseline==TextAttribute.SUPERSCRIPT_SUB) { >- baselineAdjust = -baselineAscent*0.5f; >+ List values = (List)baseline; >+ Object baselineValue; >+ for(int k = 0; k < values.size(); k++) >+ { >+ baselineValue = values.get(k); >+ if (baselineValue instanceof Integer) { >+ if (baselineValue == TextAttribute.SUPERSCRIPT_SUPER) { >+ baselineAdjust += baselineAscent*0.5f; >+ } else if (baselineValue==TextAttribute.SUPERSCRIPT_SUB) { >+ baselineAdjust -= baselineAscent*0.5f; >+ } >+ } else if (baselineValue instanceof Float) { >+ baselineAdjust += ((Float) baselineValue).floatValue(); > } >- } else if (baseline instanceof Float) { >- baselineAdjust = ((Float) baseline).floatValue(); > } > if (vertical) { > ox = baselineAdjust; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47359
:
23803
|
23804
|
23805
|
23811
|
23814
|
23815
| 23820