Re: Cannot change text rotation centre in SVGs

Hi Antonio,


First of all, I'd hint towards redirecting authoring and related questions
towards dedicated lists such as the popular SVG Developers [1] (which has a
very rich archive), as this is more targeted at "technical discussion on
SVG and its specifications" [2].


Currently, when you rotate text it rotates using the bottom left of
> the text as its centre. Would there ever be the possibility of
> allowing the text rotation centre to be either of the corners of the
> bounding box or the centre?
>

Well, there are several existing techniques, from which I'll pull a couple
from memory:
1. Adjusting the "text-anchor" [3] property, one is also able to set the
rotation point to the bottom center or bottom right. One may additionally
combined with "font-size" [4] and some math to determine the remaining
cases (upper left, upper center and upper right). This is feasible for
simple cases (single text node) but will likely become less useful as
textual content layout and complexity increase (nested "tspan" elements,
desired text alignments and/or combine with other transforms). I'm
attaching a simple example which covers this case.
2. Using the "getBBox" scripting method, the center can also be determined
but only in runtime, after the text is rendered (inserted into the
document, even if invisible, in order for the layout engine to be able to
determine dimensions). I believe that this is covered by D. Dailey's et.
al. excellent book [5].


Cheers,
 Helder


[1] http://tech.groups.yahoo.com/group/svg-developers/
[2] http://lists.w3.org/Archives/Public/www-svg/
[3] http://www.w3.org/TR/SVG/text.html#TextAnchorProperty
[4] http://www.w3.org/TR/SVG/text.html#FontSizeProperty
[5] http://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html

Received on Friday, 29 March 2013 18:29:31 UTC