Difference between revisions of "TextRework"

From Inkscape Wiki
Jump to navigation Jump to search
(what types of text is now)
Line 13: Line 13:


== Strategy ==
== Strategy ==
There are 3 types of text now: regular, flowed and linked-flowed text.


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:
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:

Revision as of 09:13, 27 June 2012

Proposal for restructuring how Inkscape handles text.

This is a work in progress...

Motivation

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.


Strategy

There are 3 types of text now: regular, flowed and linked-flowed text.

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.

New attributes:

  • 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. Note that SVG2 may add some CSS text properties that could be useful here.

New attributes:

  • inkscape:text-property="flowed_text"
  • inkscape:text-align="justify"
  • 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.

Note: SVG2 will include text flow into arbitrary shapes using CSS Regions and CSS Exlusions.

Implementation Steps

  1. Write new routines to handle plain SVG text. Check that it works for all imported text.
  2. Switch "normal" Inkscape text (with lines handled by Inkscape) to use the new code.
  3. Rewrite line-breaking code to output standard SVG.

Alignment Issues

Note that inkscape is not able to vertically align some text according to a given boundary (wether the text box or an explicitly selected shape) It would be usefull to get such alignment features. Apple Pages does it "the right way"