Thanks.
I basically created a working patch (excluding end of string line
breaks
and probably spacing issues). The patch checks if the text in contained
in a text box is a child of <svg:text> instead of <svg:tspan> . If this
is true a <tspan> is inserted as a child of the <text> and the string is
transfered to become a child of the <tspan>.
That seems like a sensible approach.
This works but it fails for strange reasons. If the text box is
selected and the cursor is moved over with the keyboard and a line
break is inserted, inkscape crashes. I traced this back to a problem
occurring with the Glib::ustring::iterator s being used. In the
instances that the patch fails the iterator's values don't match up
to their expected value. The problem also occurs after a line break,
an undo, and a repeat of the line break.
To make manipulations of the original text possible, Layout objects
maintain pointers back to the objects from which they were generated.
These pointers are becoming invalidated by the first set of changes
that you are doing, so when the rest of the code goes and tries to
insert the line break it accesses stuff that it thinks ought to be
where it left it but isn't.
All the other functions get round this problem by dividing their
process into two distinct parts (although this may not be evident
from reading the code): they plan what they are going to do and read
all the necessary data, then they execute that plan without touching
the Layout object. You could also work around it by forcing a
re-layout of the text between the two phases of the transform and
calling Layout::validateIterator(), but a re-layout is time-consuming.
I have posted the code in question to the bug report.
I'm not exactly clear on where this snippet is supposed to go. Can you
please use unified diffs in the future.
With regard to the space at end problem, that'll be because the <text>
element lacks an xml:space="preserve" attribute. This is a continuing
problem with imported text objects because Inkscape is behaving
entirely according to the SVG spec, it's just extremely baffling to
the user when their characters don't appear.
R.