What is the difficulty in adding text decorations, especially underline?
There have been user requests for underline (a text decoration) going back years and years. Since it has not shown up I assume this means that some library Inkscape depends on cannot do this. I checked the most obvious suspects and did not find a definitive smoking gun:
1. Freetype does support underlining (both location and thickness). http://www.cs.sunysb.edu/documentation/freetype-2.1.9/docs/tutorial/step2.ht...
2. SVG supports it with "text-decoration:underline".
3 Pango supports it: https://developer.gnome.org/pango/stable/PangoMarkupFormat.html
4. Cairo - not sure. (Maybe this is the guilty party?)
So, is there a document somewhere which explains why Inkscape cannot underline? I looked for a while but all Google turned up were lots of threads about how Inkscape does not have underline, but not _why_ it does not.
Thanks,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech
On Wed, 2013-03-13 at 13:50 -0700, mathog wrote:
There have been user requests for underline (a text decoration) going back years and years. Since it has not shown up I assume this means that some library Inkscape depends on cannot do this. I checked the most obvious suspects and did not find a definitive smoking gun:
- Freetype does support underlining (both location and
thickness). http://www.cs.sunysb.edu/documentation/freetype-2.1.9/docs/tutorial/step2.ht...
- SVG supports it with "text-decoration:underline".
3 Pango supports it: https://developer.gnome.org/pango/stable/PangoMarkupFormat.html
- Cairo - not sure. (Maybe this is the guilty party?)
So, is there a document somewhere which explains why Inkscape cannot underline? I looked for a while but all Google turned up were lots of threads about how Inkscape does not have underline, but not _why_ it does not.
I looked at this a couple of years ago. I don't remember the details, but I seem to recall that the code isn't structured very well to add the underlining. There was a GSOC project last summer that would have made it easier to add new features to text but it wasn't successful. SVG text decoration isn't the simplest thing in the world, see the example in the spec:
http://www.w3.org/TR/SVG/text.html#TextDecorationProperties
I don't think it is a library problem. Freetype gives the position of the underline (but doesn't draw it). SVG gives the rules of how to fill and stroke an underline. We don't use Pango markup for rendering on the canvas (it is more for marking up text in widgets and it doesn't handle strokes). We probably need to draw the underlines ourselves.
Note, Firefox also doesn't support text decoration. Chrome does but with some stroke artifacts (where ever the styling on the main text changes). Only Batik seems to do it right.
Tav
PS. Patches welcomed.
On 13-Mar-2013 14:22, Tavmjong Bah wrote:
We probably need to draw the underlines ourselves.
If you can tell me more or less where in the code the text is drawn to the screen I will have a look at it. Since drawing a line is never hard my guess is that the text decoration information is stripped earlier in the call stack, so that the difficulty comes in modifying the code to pass the information further down the stack to where it can be used - without breaking anything else.
Note, Firefox also doesn't support text decoration. Chrome does but with some stroke artifacts (where ever the styling on the main text changes). Only Batik seems to do it right.
Opera did underline, overline, and strike-through in the test case I tried. Not blink of course, but blink is asking a bit much for a browser.
Thanks,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech
participants (2)
-
mathog
-
Tavmjong Bah