Text edit mishandles span of just colored spaces

Bug #1181326 reported by David Mathog
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Medium
David Mathog

Bug Description

This came up in the context of adding SVG text decoration support. Text decorations need to be visible over spaces

http://www.w3.org/TR/SVG/text.html#TextDecorationProperties

and in the CSS2 and default CSS3 modes they take their color from the color of the spaces. (Even though nothing is drawn for the space glyph itself.) However differently colored spaces cannot exist in Inkscape at present. Here is how to demonstrate that:

1. Open a text box and enter "word" with black letters.
2. Insert two spaces between "r" and "d".
3. Select those spaces and change their color to something other than black.

Result: the spaces shift to the end of the "word" and become part of the original span.

Alternate method:

1. (as above)
2. Insert "1 2" between "r" and "d".
3. Select "1 2" and color it something other than black.
4. Delete "1". (works)
5. Delete "2".

Result: the spaces shift to the end of the "word" and become part of the original span.

I suspect that this happens, at least in part, in Layout-TNG-Output.cpp, where there is a section where glyphs are added to a display list. Only the visible glyphs are added. Because space is not visible, it is not added. The end result is a tspan with no visible glyphs in it. If it isn't there, then there is likely an equivalent operation in nr-style.cpp.

Tags: color text

Related branches

Revision history for this message
David Mathog (mathog) wrote :

One other point, the bounding box that is drawn around the text after the spaces shift to the end is off by 1 space (inwards). If there are N spaces on the end, the box is drawn at the right boundary of the N-1th space.

That is the case even if the text is just typed in directly as "word ".

Revision history for this message
David Mathog (mathog) wrote :

The small change below takes care of the issue with formatted spaces shifting to the end as in the first message. (I still have not located the "one white space left off the end of bounding box" issue from message #1).

--- src/text-editing.cpp 2013-03-16 19:42:47 +0000
+++ src/text-editing.cpp 2013-05-21 20:59:08 +0000
@@ -1871,7 +1871,7 @@
             if (next_string == NULL) {
                 return false; // an empty paragraph
             }
- next_string->string += str;
+ next_string->string = str + next_string->string;
             break;
         }
     }

Revision history for this message
jazzynico (jazzynico) wrote :

Reproduced on Windows XP, Inkscape 0.48.4 and trunk revision 12387.

tags: added: color text
Changed in inkscape:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
David Mathog (mathog) wrote :

Fixes for these issues are in branch lp988601. That branch is 99.99% the same as trunk, it just has some extra graphics drivers and implements SVG text decoration. These text formatting changes are not in those sections, so diff lp988601 against. trunk (I do not know how to do that) and look in text-editing.cpp and related. Note that the final fix was much more involved than in (2) above, because there were sections of the code that were "merging" two points of an editing tree, where each node held only the changes in edits at that point, which dropped all of the format specifiers the two points had in common. It was necessary to trace back to the first common node above the two edit points to retrieve that information. Only then could all of the "editing spaces" issues be resolved.

Kris (kris-degussem)
Changed in inkscape:
status: Triaged → In Progress
assignee: nobody → David Mathog (mathog)
Revision history for this message
su_v (suv-lp) wrote :
Changed in inkscape:
milestone: none → 0.49
status: In Progress → Fix Committed
Bryce Harrington (bryce)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.