svg text is not split by newlines

Asked by Evan

I have an svg file where several lines of text, in a list format essentially, do not get split at the end of each line. Each line is placed into the same text box, one on top of the other. When I view the text with the Text and Font tool, the string is a concatenation of all lines. When I manually enter line breaks into the string where they should be, the list comes out correctly.

The string:
'CMULines_IDTypeSymbolNotesRuleIDOverride'

should look like:
CMULines_ID
Type
Symbol
Notes
RuleID
Override

But instead it's as if all lines are anchored to the same coordinates as the first line, but they are not each separate elements.

Thanks for your help!
Evan

Question information

Language:
English Edit question
Status:
Answered
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
su_v (suv-lp) said :
#1

> I have an svg file where several lines of text, in a list format
> essentially do not get split at the end of each line

Did you write that SVG file yourself, using a plain text editor? If so, please read the SVG specification about the <text> object and handling of white-space in SVG text elements (else I suggest to contact the author of the file): newlines are always removed (as well as tabs, leading spaces, multiple space characters) by default; with the attribute 'xml-space="preserve"' all newline and tab characters will still be converted into space characters, but leading and multiple spaces not collapsed into a single space.
<http://www.w3.org/TR/SVG11/text.html#WhiteSpace>

For multiline text you can place the lines either inside separate <text> elements or inside separate <tspan> elements within the <text> element. As far as I understand, in both cases you have to take care of the vertical (relative) positioning (<http://www.w3.org/TR/SVG11/text.html#CurrentTextPosition>).

Alternatively rely on Inkscape and paste the list from the clipboard into a regular text object.

> When I manually enter line breaks into the string where they
> should be, the list comes out correctly.

If you edit the text inside Inkscape, the multiline text is split into correctly positioned <tspan>'s for each line (you can verify the change in Inkscape with 'Edit > XML Editor'.

Revision history for this message
Evan (evan-thoms) said :
#2

suv,
Thanks very much for your quick reply.
I did not write the file. At first, I assumed it was an Inkscape issue
because the text does look right when I view the file in Firefox and Visio.
But I just tried it in OpenOffice Draw and got a similar result, so I
suppose the author of the svg generation software I am getting this from,
may need to do some tinkering.

Just for clarity, see the attached files

On Tue, Nov 2, 2010 at 1:49 PM, ~suv <email address hidden>
wrote:
> Your question #132281 on Inkscape changed:
> https://answers.launchpad.net/inkscape/+question/132281
>
> Status: Open => Answered
>
> ~suv proposed the following answer:
>> I have an svg file where several lines of text, in a list format
>> essentially do not get split at the end of each line
>
> Did you write that SVG file yourself, using a plain text editor? If so,
please read the SVG specification about the <text> object and handling of
white-space in SVG text elements (else I suggest to contact the author of
the file): newlines are always removed (as well as tabs, leading spaces,
multiple space characters) by default; with the attribute
'xml-space="preserve"' all newline and tab characters will still be
converted into space characters, but leading and multiple spaces not
collapsed into a single space.
> <http://www.w3.org/TR/SVG11/text.html#WhiteSpace>
>
> For multiline text you can place the lines either inside separate <text>
> elements or inside separate <tspan> elements within the <text> element.
> As far as I understand, in both cases you have to take care of the
> vertical (relative) positioning
> (<http://www.w3.org/TR/SVG11/text.html#CurrentTextPosition>).
>
> Alternatively rely on Inkscape and paste the list from the clipboard
> into a regular text object.
>
>> When I manually enter line breaks into the string where they
>> should be, the list comes out correctly.
>
> If you edit the text inside Inkscape, the multiline text is split into
> correctly positioned <tspan>'s for each line (you can verify the change
> in Inkscape with 'Edit > XML Editor'.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
>
https://answers.launchpad.net/inkscape/+question/132281/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/inkscape/+question/132281
>
> You received this question notification because you are a direct
> subscriber of the question.
>

Revision history for this message
su_v (suv-lp) said :
#3

> because the text does look right when I view the file in Firefox

That's odd - when I viewed the test file I created following your description, in Firefox or Safari, it didn't render the newlines either :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.1"
   width="400"
   height="400"
   id="svg3975">
<text x="0" y="40" >
CMULines_ID
Type
Symbol
Notes
RuleID
Override</text>
</svg>

Can you paste the relevant snippet here? Or make the SVG file available (e.h. using the free image hosting service <http://imgh.us/> which accepts and serves SVG)?

Revision history for this message
Evan (evan-thoms) said :
#4

Example file is here:

http://imgh.us/ThomsExample.svg

It would appear that the unit identifier "em" in the dy attribute value is
not getting recognized. I tried others and they work. By inference does this
mean that a relative font-size is not being set or set incorrectly?

On Tue, Nov 2, 2010 at 7:31 PM, ~suv
<email address hidden>wrote:

> Your question #132281 on Inkscape changed:
> https://answers.launchpad.net/inkscape/+question/132281
>
> Status: Open => Answered
>
> ~suv proposed the following answer:
> > because the text does look right when I view the file in Firefox
>
> That's odd - when I viewed the test file I created following your
> description, in Firefox or Safari, it didn't render the newlines either
> :
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <svg
> xmlns:svg="http://www.w3.org/2000/svg"
> xmlns="http://www.w3.org/2000/svg"
> version="1.1"
> width="400"
> height="400"
> id="svg3975">
> <text x="0" y="40" >
> CMULines_ID
> Type
> Symbol
> Notes
> RuleID
> Override</text>
> </svg>
>
>
> Can you paste the relevant snippet here? Or make the SVG file available
> (e.h. using the free image hosting service <http://imgh.us/> which accepts
> and serves SVG)?
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
>
> https://answers.launchpad.net/inkscape/+question/132281/+confirm?answer_id=2
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/inkscape/+question/132281
>
> You received this question notification because you are a direct
> subscriber of the question.
>

Revision history for this message
su_v (suv-lp) said :
#5

Could be the same issue as reported in

Bug #168845 “<text> position attributes should handle relative units”:
<https://bugs.launchpad.net/inkscape/+bug/168845>

Revision history for this message
su_v (suv-lp) said :
#6

or precisely this one:

Bug #262528 “Problem with <tspan> element and attribute dy”
<https://bugs.launchpad.net/inkscape/+bug/262528>

Can you help with this problem?

Provide an answer of your own, or ask Evan for more information if necessary.

To post a message you must log in.