Hi,
I've implemented the CSS 3 'text-orientation' property which controls how glyphs are rendered in vertical text. This property replaces the 'glyph-orientation-vertical' property which Inkscape never implemented and is deprecated in SVG 2. While doing this work I also corrected some other layout issues with vertical text and with multi-line text. As this work is rather invasive I've pushed my changes to a new branch which can be checked out via:
bzr branch lp:~inkscape.dev/inkscape/writing_modes
Please test this branch!
Here is a list of the most important changes:
* Latin characters in vertical text will be drawn by default sideways. This is the default direction in both SVG 1.1 and in CSS 3 Writing Modes. Currently Inkscape draws the glyphs upright.
* Punctuation characters in CJK vertical text will be orientated correctly.
* The Text Toolbar can be used to set 'text-orientation' which controls how characters are orientated in vertical text (it has no effect on horizontal text). The three choices are 'mixed' where the glyphs are drawn in their Unicode defined natural orientation, 'upright' where all glyphs are drawn upright, and 'sideways' where all glyphs are drawn sideways.
* The new CSS 3 values for 'writing-mode' will be recognized. The values written out are still the SVG 1.1 values except for the new 'vertical-lr' value which has no equivalent SVG 1.1 value (and is required for Mongolian). A new button appears on the Text Toolbar to select this value. (The SVG 1.1 values are deprecated but must still be recognized by SVG renderers.)
* Fonts without vertical metrics will have a vertical advance of 1em. The CSS specification explicitly does not define what advance to use but the SVG 1.1 spec suggests 1em and the W3C Japanese text document specified an advance of 1em.
* In laying out multi-line text, any 'leading' value from the font is ignored. CSS dictates that the font-size corresponds to the em height of a font which is defined as 'ascent' + 'descent'. The change to ignore the "internal" font 'leading' may make small visual changes in how multi-line text appears.
* In flowed text, Inkscape has been using a "scaled" value of 'ascent' to position the first line. This has been changed to follow the correct CSS prescription of using the value of 'half-leading' + normal 'ascent' for horizontal text (to find the alphabetic baseline) and 'half -leading' + half em width for vertical text (to find the center baseline). (The 'leading' in this case is the extra space needed between lines as dictated by the 'line-height' property. It is not the 'internal' font 'leading'.)
Tav
Hi Tav,
You can make a merge request if you'd like comments on the branch to be kept together. It's useful even if you don't need the peer check.
I do have a question about text. I'd like a "by width" sizing option for flow text, I can't find anything but I'm pretty sure it's not something that would/should be in the svg3 spec anyway. The option sizes all lines to fit by increasing or decreasing the line's individual font size and turns off word-wrap and font size selection.
Any advice on how you'd make this feature given you've just been through the text code?
Best Regards, Martin Owens
On Wed, 2015-10-28 at 15:41 +0100, Tavmjong Bah wrote:
Hi,
I've implemented the CSS 3 'text-orientation' property which controls how glyphs are rendered in vertical text. This property replaces the 'glyph-orientation-vertical' property which Inkscape never implemented and is deprecated in SVG 2. While doing this work I also corrected some other layout issues with vertical text and with multi-line text. As this work is rather invasive I've pushed my changes to a new branch which can be checked out via:
bzr branch lp:~inkscape.dev/inkscape/writing_modes
Please test this branch!
Here is a list of the most important changes:
- Latin characters in vertical text will be drawn by default sideways.
This is the default direction in both SVG 1.1 and in CSS 3 Writing Modes. Currently Inkscape draws the glyphs upright.
- Punctuation characters in CJK vertical text will be orientated
correctly.
- The Text Toolbar can be used to set 'text-orientation' which controls
how characters are orientated in vertical text (it has no effect on horizontal text). The three choices are 'mixed' where the glyphs are drawn in their Unicode defined natural orientation, 'upright' where all glyphs are drawn upright, and 'sideways' where all glyphs are drawn sideways.
- The new CSS 3 values for 'writing-mode' will be recognized. The
values written out are still the SVG 1.1 values except for the new 'vertical-lr' value which has no equivalent SVG 1.1 value (and is required for Mongolian). A new button appears on the Text Toolbar to select this value. (The SVG 1.1 values are deprecated but must still be recognized by SVG renderers.)
- Fonts without vertical metrics will have a vertical advance of 1em.
The CSS specification explicitly does not define what advance to use but the SVG 1.1 spec suggests 1em and the W3C Japanese text document specified an advance of 1em.
- In laying out multi-line text, any 'leading' value from the font is
ignored. CSS dictates that the font-size corresponds to the em height of a font which is defined as 'ascent' + 'descent'. The change to ignore the "internal" font 'leading' may make small visual changes in how multi-line text appears.
- In flowed text, Inkscape has been using a "scaled" value of 'ascent'
to position the first line. This has been changed to follow the correct CSS prescription of using the value of 'half-leading' + normal 'ascent' for horizontal text (to find the alphabetic baseline) and 'half -leading' + half em width for vertical text (to find the center baseline). (The 'leading' in this case is the extra space needed between lines as dictated by the 'line-height' property. It is not the 'internal' font 'leading'.)
Tav
On Wed, 2015-10-28 at 11:01 -0400, Martin Owens wrote:
Hi Tav,
You can make a merge request if you'd like comments on the branch to be kept together. It's useful even if you don't need the peer check.
Done
I do have a question about text. I'd like a "by width" sizing option for flow text, I can't find anything but I'm pretty sure it's not something that would/should be in the svg3 spec anyway. The option sizes all lines to fit by increasing or decreasing the line's individual font size and turns off word-wrap and font size selection.
Any advice on how you'd make this feature given you've just been through the text code?
One could hack this into the code using Inkscape's existing multi-line text mode where each line is a separate <tspan>. In principle, you can set the 'text-length' attribute on each <tspan> element but I don't know the status of browser support. It's not an easy thing to implement as it can get quite complicated with nested <tspan>s.
Best Regards, Martin Owens
On Wed, 2015-10-28 at 15:41 +0100, Tavmjong Bah wrote:
Hi,
I've implemented the CSS 3 'text-orientation' property which controls how glyphs are rendered in vertical text. This property replaces the 'glyph-orientation-vertical' property which Inkscape never implemented and is deprecated in SVG 2. While doing this work I also corrected some other layout issues with vertical text and with multi-line text. As this work is rather invasive I've pushed my changes to a new branch which can be checked out via:
bzr branch lp:~inkscape.dev/inkscape/writing_modes
Please test this branch!
Here is a list of the most important changes:
- Latin characters in vertical text will be drawn by default
sideways. This is the default direction in both SVG 1.1 and in CSS 3 Writing Modes. Currently Inkscape draws the glyphs upright.
- Punctuation characters in CJK vertical text will be orientated
correctly.
- The Text Toolbar can be used to set 'text-orientation' which
controls how characters are orientated in vertical text (it has no effect on horizontal text). The three choices are 'mixed' where the glyphs are drawn in their Unicode defined natural orientation, 'upright' where all glyphs are drawn upright, and 'sideways' where all glyphs are drawn sideways.
- The new CSS 3 values for 'writing-mode' will be recognized. The
values written out are still the SVG 1.1 values except for the new 'vertical-lr' value which has no equivalent SVG 1.1 value (and is required for Mongolian). A new button appears on the Text Toolbar to select this value. (The SVG 1.1 values are deprecated but must still be recognized by SVG renderers.)
- Fonts without vertical metrics will have a vertical advance of
1em. The CSS specification explicitly does not define what advance to use but the SVG 1.1 spec suggests 1em and the W3C Japanese text document specified an advance of 1em.
- In laying out multi-line text, any 'leading' value from the font
is ignored. CSS dictates that the font-size corresponds to the em height of a font which is defined as 'ascent' + 'descent'. The change to ignore the "internal" font 'leading' may make small visual changes in how multi-line text appears.
- In flowed text, Inkscape has been using a "scaled" value of
'ascent' to position the first line. This has been changed to follow the correct CSS prescription of using the value of 'half-leading' + normal 'ascent' for horizontal text (to find the alphabetic baseline) and 'half -leading' + half em width for vertical text (to find the center baseline). (The 'leading' in this case is the extra space needed between lines as dictated by the 'line-height' property. It is not the 'internal' font 'leading'.)
Tav
On Wed, 2015-10-28 at 21:50 +0100, Tavmjong Bah wrote:
One could hack this into the code using Inkscape's existing multi-line text mode where each line is a separate <tspan>. In principle, you can set the 'text-length' attribute on each <tspan> element but I don't know the status of browser support. It's not an easy thing to implement as it can get quite complicated with nested <tspan>s.
Thanks for your help tav,
Our text fallback support for text isn't complete afaik, so browser support need not be an issue. What's the status of our text fallback options?
http://www.w3.org/TR/SVG/text.html#TextElementTextLengthAttribute
According to this, textLength would either space text out or stretch it across to space horizontally. So it wouldn't quite resize the tspan to the right font size. Is this interpretation right?
Best Regards, Martin Owens
On 28-Oct-2015 07:41, Tavmjong Bah wrote:
- Latin characters in vertical text will be drawn by default sideways.
This is the default direction in both SVG 1.1 and in CSS 3 Writing Modes. Currently Inkscape draws the glyphs upright.
For Latin characters how does that differ from rotated horizontal text? Isn't vertical text for Latin characters to be used in those situations where the glyphs are to be drawn "head to toe", as it were, as on the neon name sign on a theater? Like this:
http://www.fwembassytheatre.org/upcoming_pic1b.jpg
Regards,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech
On Wed, 2015-10-28 at 11:48 -0700, mathog wrote:
On 28-Oct-2015 07:41, Tavmjong Bah wrote:
- Latin characters in vertical text will be drawn by default
sideways. This is the default direction in both SVG 1.1 and in CSS 3 Writing Modes. Currently Inkscape draws the glyphs upright.
For Latin characters how does that differ from rotated horizontal text?
If the text only consists of Latin characters, it doesn't. However, the most common use of vertical text is for CJK layout where CJK punctuation (brackets, dashes, etc.) and Latin characters are rotated.
Isn't vertical text for Latin characters to be used in those situations where the glyphs are to be drawn "head to toe", as it were, as on the neon name sign on a theater? Like this:
That can be done by using the 'text-orientation' value 'upright'.
Regards,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
A few more changes have been checked in:
* x-height is taken from font if in the OS/2 font-metrics table otherwise it is measured with the 'x' glyph. At the moment, the value is only used in deriving baselines.
* The 'dominant-baseline' property is implemented (but w/o GUI). The position of the 'mathematical' and and 'hanging' baselines are determined from the font.
I cannot test the code changes work on Windows. It would be quite useful is someone that can compile Inkscape on Windows could at least see that the source compiles.
The source can be obtained via:
bzr branch lp:~inkscape.dev/inkscape/writing_modes
I will give people a couple of days to test before checking it into trunk
Tav
On Wed, 2015-10-28 at 15:41 +0100, Tavmjong Bah wrote:
Hi,
I've implemented the CSS 3 'text-orientation' property which controls how glyphs are rendered in vertical text. This property replaces the 'glyph-orientation-vertical' property which Inkscape never implemented and is deprecated in SVG 2. While doing this work I also corrected some other layout issues with vertical text and with multi-line text. As this work is rather invasive I've pushed my changes to a new branch which can be checked out via:
bzr branch lp:~inkscape.dev/inkscape/writing_modes
Please test this branch!
Here is a list of the most important changes:
- Latin characters in vertical text will be drawn by default sideways.
This is the default direction in both SVG 1.1 and in CSS 3 Writing Modes. Currently Inkscape draws the glyphs upright.
- Punctuation characters in CJK vertical text will be orientated
correctly.
- The Text Toolbar can be used to set 'text-orientation' which controls
how characters are orientated in vertical text (it has no effect on horizontal text). The three choices are 'mixed' where the glyphs are drawn in their Unicode defined natural orientation, 'upright' where all glyphs are drawn upright, and 'sideways' where all glyphs are drawn sideways.
- The new CSS 3 values for 'writing-mode' will be recognized. The
values written out are still the SVG 1.1 values except for the new 'vertical-lr' value which has no equivalent SVG 1.1 value (and is required for Mongolian). A new button appears on the Text Toolbar to select this value. (The SVG 1.1 values are deprecated but must still be recognized by SVG renderers.)
- Fonts without vertical metrics will have a vertical advance of 1em.
The CSS specification explicitly does not define what advance to use but the SVG 1.1 spec suggests 1em and the W3C Japanese text document specified an advance of 1em.
- In laying out multi-line text, any 'leading' value from the font is
ignored. CSS dictates that the font-size corresponds to the em height of a font which is defined as 'ascent' + 'descent'. The change to ignore the "internal" font 'leading' may make small visual changes in how multi-line text appears.
- In flowed text, Inkscape has been using a "scaled" value of 'ascent'
to position the first line. This has been changed to follow the correct CSS prescription of using the value of 'half-leading' + normal 'ascent' for horizontal text (to find the alphabetic baseline) and 'half -leading' + half em width for vertical text (to find the center baseline). (The 'leading' in this case is the extra space needed between lines as dictated by the 'line-height' property. It is not the 'internal' font 'leading'.)
Tav
participants (3)
-
Martin Owens
-
mathog
-
Tavmjong Bah