View | Details | Raw Unified | Return to bug 47359
Collapse All | Expand All

(-)sources/org/apache/batik/bridge/SVGTextElementBridge.java (-2 / +42 lines)
Lines 853-859 Link Here
853
                                                     Element element) {
853
                                                     Element element) {
854
854
855
        AttributedStringBuffer asb = new AttributedStringBuffer();
855
        AttributedStringBuffer asb = new AttributedStringBuffer();
856
        fillAttributedStringBuffer(ctx, element, true, null, null, null, asb);
856
        fillAttributedStringBuffer(ctx, element, true, null, null, null, null, asb);
857
        return asb.toAttributedString();
857
        return asb.toAttributedString();
858
    }
858
    }
859
859
Lines 875-880 Link Here
875
                                              TextPath textPath,
875
                                              TextPath textPath,
876
                                              Integer bidiLevel,
876
                                              Integer bidiLevel,
877
                                              Map initialAttributes,
877
                                              Map initialAttributes,
878
                                              Map parentAttributes,
878
                                              AttributedStringBuffer asb) {
879
                                              AttributedStringBuffer asb) {
879
        // 'requiredFeatures', 'requiredExtensions', 'systemLanguage' &
880
        // 'requiredFeatures', 'requiredExtensions', 'systemLanguage' &
880
        // 'display="none".
881
        // 'display="none".
Lines 899-906 Link Here
899
        Map map = initialAttributes == null
900
        Map map = initialAttributes == null
900
                ? new HashMap()
901
                ? new HashMap()
901
                : new HashMap(initialAttributes);
902
                : new HashMap(initialAttributes);
903
        Map elementAttributes = new HashMap();
902
        initialAttributes =
904
        initialAttributes =
903
            getAttributeMap(ctx, element, textPath, bidiLevel, map);
905
            getAttributeMap(ctx, element, textPath, bidiLevel, elementAttributes);
906
907
        //Adjust the baseline-shift for the element based on the
908
        //value of the parent and build the parent attributes map
909
        //for the child of the element
910
        parentAttributes = handleNestedBaselineShift(parentAttributes, elementAttributes);
911
912
        map.putAll(elementAttributes);
913
904
        Object o = map.get(TextAttribute.BIDI_EMBEDDING);
914
        Object o = map.get(TextAttribute.BIDI_EMBEDDING);
905
        Integer subBidiLevel = bidiLevel;
915
        Integer subBidiLevel = bidiLevel;
906
        if (o != null) {
916
        if (o != null) {
Lines 939-944 Link Here
939
                                               textPath,
949
                                               textPath,
940
                                               subBidiLevel,
950
                                               subBidiLevel,
941
                                               initialAttributes,
951
                                               initialAttributes,
952
                                               parentAttributes,
942
                                               asb);
953
                                               asb);
943
                    if (asb.count != before) {
954
                    if (asb.count != before) {
944
                        initialAttributes = null;
955
                        initialAttributes = null;
Lines 956-961 Link Here
956
                                                   newTextPath,
967
                                                   newTextPath,
957
                                                   subBidiLevel,
968
                                                   subBidiLevel,
958
                                                   initialAttributes,
969
                                                   initialAttributes,
970
                                                   parentAttributes,
959
                                                   asb);
971
                                                   asb);
960
                        if (asb.count != before) {
972
                        if (asb.count != before) {
961
                            initialAttributes = null;
973
                            initialAttributes = null;
Lines 1003-1008 Link Here
1003
                                               textPath,
1015
                                               textPath,
1004
                                               subBidiLevel,
1016
                                               subBidiLevel,
1005
                                               initialAttributes,
1017
                                               initialAttributes,
1018
                                               parentAttributes,
1006
                                               asb);
1019
                                               asb);
1007
                    if (asb.count != before) {
1020
                    if (asb.count != before) {
1008
                        initialAttributes = null;
1021
                        initialAttributes = null;
Lines 1047-1052 Link Here
1047
        tpi.endChar   = elementEndChar;
1060
        tpi.endChar   = elementEndChar;
1048
    }
1061
    }
1049
1062
1063
    /*
1064
     * Nested baseline-shift are additive, so keep track of all the 
1065
     * baseline-shift value to calculate the final baseline shift 
1066
     */
1067
    private Map handleNestedBaselineShift(Map parentAttributes, Map elementAttributes)
1068
    {
1069
        if ( elementAttributes.containsKey(BASELINE_SHIFT) )
1070
        {
1071
           ArrayList list = new ArrayList();
1072
           if ( parentAttributes != null && parentAttributes.containsKey(BASELINE_SHIFT) )
1073
           {
1074
               list.addAll((List)parentAttributes.get(BASELINE_SHIFT));
1075
           }
1076
           list.add(elementAttributes.get(BASELINE_SHIFT));
1077
           elementAttributes.put(BASELINE_SHIFT,list);
1078
1079
           Map newParentAttributes = new HashMap();
1080
           newParentAttributes.put(BASELINE_SHIFT,list);
1081
           return newParentAttributes;
1082
        }
1083
        else if ( parentAttributes != null && parentAttributes.containsKey(BASELINE_SHIFT) )
1084
        {
1085
            elementAttributes.put(BASELINE_SHIFT,parentAttributes.get(BASELINE_SHIFT));
1086
        }
1087
        return parentAttributes;
1088
    }
1089
1050
    /**
1090
    /**
1051
     * Normalizes the given string.
1091
     * Normalizes the given string.
1052
     */
1092
     */
(-)sources/org/apache/batik/gvt/text/GlyphLayout.java (-7 / +14 lines)
Lines 34-39 Link Here
34
import java.text.AttributedCharacterIterator;
34
import java.text.AttributedCharacterIterator;
35
import java.text.CharacterIterator;
35
import java.text.CharacterIterator;
36
import java.util.HashSet;
36
import java.util.HashSet;
37
import java.util.List;
37
import java.util.Set;
38
import java.util.Set;
38
39
39
import org.apache.batik.gvt.font.AWTGVTFont;
40
import org.apache.batik.gvt.font.AWTGVTFont;
Lines 1224-1237 Link Here
1224
1225
1225
                float baselineAdjust = 0f;
1226
                float baselineAdjust = 0f;
1226
                if (baseline != null) {
1227
                if (baseline != null) {
1227
                    if (baseline instanceof Integer) {
1228
                    List values = (List)baseline;
1228
                        if (baseline==TextAttribute.SUPERSCRIPT_SUPER) {
1229
                    Object baselineValue;
1229
                            baselineAdjust = baselineAscent*0.5f;
1230
                    for(int k = 0; k < values.size(); k++)
1230
                        } else if (baseline==TextAttribute.SUPERSCRIPT_SUB) {
1231
                    {
1231
                            baselineAdjust = -baselineAscent*0.5f;
1232
                        baselineValue = values.get(k);
1233
                        if (baselineValue instanceof Integer) {
1234
                            if (baselineValue == TextAttribute.SUPERSCRIPT_SUPER) {
1235
                                baselineAdjust += baselineAscent*0.5f;
1236
                            } else if (baselineValue==TextAttribute.SUPERSCRIPT_SUB) {
1237
                                baselineAdjust -= baselineAscent*0.5f;
1238
                            }
1239
                        } else if (baselineValue instanceof Float) {
1240
                            baselineAdjust += ((Float) baselineValue).floatValue();
1232
                        }
1241
                        }
1233
                    } else if (baseline instanceof Float) {
1234
                        baselineAdjust = ((Float) baseline).floatValue();
1235
                    }
1242
                    }
1236
                    if (vertical) {
1243
                    if (vertical) {
1237
                        ox = baselineAdjust;
1244
                        ox = baselineAdjust;

Return to bug 47359