Failure to append spaces and insert newlines in <text> without <tspan>

Bug #167647 reported by Tovrstra
2
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
Medium
Richard Hughes

Bug Description

Hi,

When opening svg files created with matplotlib, I had
two problems with editing text strings that were
created by matplotlib:

1) It is not possible to append a space at the end of a
text string.

2) When pressing enter in the middle of a string, the
new line is put at the same height of the original line.

I have attached an example svg file created with
matplotlib. I think the problems are related to the
fact that matplotlib does not place the text fragments
inside a <tspan></tspan>:

<text style="font-size: 7.000000; font-family:
Bitstream Vera Serif; font-style: Roman; fill:
#000000;" x="67.000000" y="397.800000">0.0</text>

Is this a matplotlib or a inkscape problem?

Revision history for this message
Tovrstra (tovrstra) wrote : 0.44pre2: newlines in text problem
Revision history for this message
Vonhalenbach (vonhalenbach) wrote :

1) I don't know why this should be useful?

2) Confirmed. Inkscape Ignores Newlines in text.

I tested it with the appended file. It has nothing to do
with <tspan>.

Revision history for this message
Tovrstra (tovrstra) wrote :

It is usefull to add a space at the end of a text string
when it will be followed by another word. This problem
implies that one can not separate words with spaces, unless
you type all the words first and afterwards put spaces
between them.

Revision history for this message
Richard Hughes (cyreve) wrote :

1) Both matplotlib and Inkscape are doing exactly what they
are supposed to, according to the SVG spec. The problem is,
the spec's weird. http://www.w3.org/TR/SVG11/text.
html#WhiteSpace. There has been discussion about
automatically adding xml:space="preserve" as soon as the
user starts editing, but we don't like to change people's
documents in unexpected ways.

2) You'll need both a tspan and a sodipodi:role="line"
attribute on it. Inkscape's behaviour in this regard could
be improved, but it's not urgent so won't be in 0.44

Revision history for this message
Tovrstra (tovrstra) wrote :

cyreve: Thank you cor your comments. Now I understand what
is going on.

I first tought about this possible solution:

Add xml:space="preserve" temporarly while the user is
editing the text, and revert this setting to the original
setting when the text box loses its focus.

This is not a complete solution (e.g. newlines and double
spaces), but it would at least allow the user to add words
that are separated by a single space.

One could also add an inkscape preference option whether or
not to automatically convert a <text>...</text> to a
<text><tspan sodipodi:role="line">...</tspan></text> when
the user starts editing that text item. hardcore svg hackers
would probably turn off this option, but I believe that it
is not a bad idea to turn it on by default?

Revision history for this message
Richard Hughes (cyreve) wrote :

Yes, I might look at implementing that temporary preserve
solution. The other option is somehow to allow the cursor to
move within characters which aren't actually rendered, but
that's immensely difficult for internal architecture reasons
(although there is something like it for text on path, since
the spec says that characters off the end of the path
shouldn't be rendered).

As for the newlines, I wouldn't both with a preference. Lots
of very complicated things happen to add a newline, and this
isn't the worst of them. It's not worth complicating the
options dialog with.

Revision history for this message
Dotsig (dotsig) wrote :

Even if we don't alter the behavior of currently existing
<text> blocks, we should have the text tool include the
<tspan> tag to get newlines to work for new text boxes which
are created by inkscape.

vonHalenbach (lustik)
Changed in inkscape:
status: New → Confirmed
su_v (suv-lp)
tags: added: text
Revision history for this message
su_v (suv-lp) wrote :

The second issue (newlines in <text> without <tspan>) is tracked separately in:
* Bug #167904 “Incorrect handling of <text> without <tspan>”
  https://bugs.launchpad.net/inkscape/+bug/167904

summary: - 0.44pre2: newlines in text problem
+ Failure to appending spaces and insert newlines in <text> without
+ <tspan>
summary: - Failure to appending spaces and insert newlines in <text> without
- <tspan>
+ Failure to append spaces and insert newlines in <text> without <tspan>
Revision history for this message
Patrick Storz (ede123) wrote :
tags: added: bug-migration
Changed in inkscape:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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