Proposal for restructuring how Inkscape handles text.
This is a work in progress...
Inkscape currently handles all text layout using code written for the never-adopted "flowed-text" SVG1.2 spec. There are several problems with this code:
- The code does not handle normal SVG text well.
- It is extremely complex. It mixes up line-breaking with layout code.
- Inkscape's "flowed-text" is not recognized by any other SVG renderer.
The major goal is to reorganize the code to treat all text as normal SVG text. Three special cases would be indicated by inkscape namespace tags giving a total of four types of text:
Normal SVG text
Standard SVG text with all properties ("x", "y", "letter-spacing, etc.).
The only special text manipulating provided by Inkscape would be that a carriage return would create a new <tspan> starting directly below the first "y" value of the <text> object and a distance of "line-spacing" below the <text> or <tspan> just before the carriage return (this should work for both right-to-left text and left-to-right text).
One problem with the current Inkscape implementation is that text in a <text> object is automatically moved to a <tspan>. This can cause problems with animated SVG's.
A block of text should be contained in one <text> element. Multiple lines should be handled in <tspan>s. This allows multi-line text selection (for example, you may want to change an attribute on a string of text that spans parts of two lines).
Normal Inkscape text
Normal SVG text with the added property that lines are handled by Inkscape, allowing insertion of new lines in the middle This is equivalent to the current Inkscape manipulation of text.
- inkscape:text-property="manage_lines" : Indicates type
- inkscape:text-role="line" : Marks start of each new line (replaces sodipodi:role="line").
One routine would be responsible for manipulation of lines, outputting normal SVG which would then be rendered by the normal SVG text routines.
Inkscape flowed text
Text where line-breaking would be handled by Inkscape to fit in a rectangle box, equivalent to the current Inkscape flowed:text. "letter-spacing" and "word-spacing" could be used to justify the text.
Hyphenation, indentation, etc. could be added here.
- inkscape:text-box=href(#xxx) or <inkscape:flowregion>
One routine would be responsible for line-breaking, outputting normal SVG which would then be rendered by the normal SVG text routines. Line spacing is controlled only by the "line-spacing" property.. This routine would be responsible for verifying new lines fit in the box.
Inkscape flowed into shape text
A more generalized case of normal Inkscape flowed text.
Switching between the four modes would be possible, preserving the rendering of the text as much as possible.
- Write new routines to handle plain SVG text. Check that it works for all imported text.
- Switch "normal" Inkscape text (with lines handled by Inkscape) to use the new code.
- Rewrite line-breaking code to output standard SVG.