[NTG-context] SVG text alignment issue

Thangalin thangalin at gmail.com
Thu Jun 30 04:49:16 CEST 2022


Here's the formal rule:

https://www.w3.org/TR/SVG11/coords.html#TransformAttribute

rotate(<rotate-angle> [<cx> <cy>]), which specifies a rotation by
<rotate-angle> degrees about a given point. If optional parameters <cx> and
<cy> are not supplied, the rotation is about the origin of the current user
coordinate system. The operation corresponds to the matrix [cos(a) sin(a)
-sin(a) cos(a) 0 0]. If optional parameters <cx> and <cy> are supplied, the
rotation is about the point (cx, cy). The operation represents the
equivalent of the following specification: translate(<cx>, <cy>)
rotate(<rotate-angle>) translate(-<cx>, -<cy>).

It looks like cx/cy, if not present, mean to rotate the text about its
origin, which I would take to be width/2 and height/2. They define the
rotation matrix as [cos(a) sin(a) -sin(a) cos(a) 0 0], where a is the angle:

https://www.w3.org/TR/SVG11/coords.html#RotationDefined

It appears as though LMTX is rotating around the baseline, rather than the
central point of the text's bounding box. (I thought that (cap height +
descender height) / 2 was the middle, but I suppose that wouldn't account
for diacritics.)

Thanks for looking into this!

On Wed, Jun 29, 2022 at 2:24 PM Hans Hagen via ntg-context <
ntg-context at ntg.nl> wrote:

> On 6/29/2022 8:48 PM, Thangalin wrote:
>
> > To me, it looks like the text, after a rotational transform, is being
> > written to the baseline rather than (cap height + descender height) / 2,
> > which seems to be a MetaPost conversion issue? There's another, possibly
> > related issue, which I'll provide in a separate thread.
> Where is that rediculous (rather font version sensitive) rule defined?
> In all test i did so far baseline works ok.
>
> Btw, it is sort of baffling what applications spit out when it comes to
> svg (and exp text). The cod being meant for machines "eyes" only is not
> really an excuse.
>
> Hans
>
>
> -----------------------------------------------------------------
>                                            Hans Hagen | PRAGMA ADE
>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>         tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context at ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
>
> ___________________________________________________________________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220629/ce1d4ba0/attachment.htm>


More information about the ntg-context mailing list