[NTG-context] SVG text alignment issue

Thangalin thangalin at gmail.com
Wed Jun 29 20:48:50 CEST 2022


Thanks for checking this. Unfortunately, introducing \hbox didn't work; the
text is still off-center with respect to the vertical line:

https://i.ibb.co/hYGfdgZ/text-align.png

For comparison, the SVG file loaded into Inkscape appears similar to:

https://i.ibb.co/KF3PBkw/inkscape-alignment.png

Note how the text is vertically centered above the vertical line.

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.

Here's the code:

% SOF
\pushoverloadmode \unprotect

\permanent\tolerant\protected\def\includesvgfile[#1]#*[#2]%
   {\hbox\bgroup % no \dontleavehmode
    \getdummyparameters[\c!offset=\zeropoint,#2]%
    \clf_includesvgfile{#1}\dimexpr\dummyparameter\c!offset\relax
    \egroup}

\permanent\tolerant\protected\def\includesvgbuffer[#1]#*[#2]%
   {\hbox\bgroup % no \dontleavehmode
    \getdummyparameters[\c!offset=\zeropoint,#2]%
    \clf_includesvgbuffer{#1}\dimexpr\dummyparameter\c!offset\relax
    \egroup}

\protect \popoverloadmode

\startbuffer[svg]
<svg
   width="25mm"
   height="70mm"
   viewBox="0 0 25 70"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <path
     d="m 12.500001,63.971412 v -12.4787"
     id="path2"
     style="fill:none;fill-opacity:1;stroke:#000000;stroke-opacity:1" />
  <text
     x="-48.831322"
     y="15.60547"
     id="text4933-8-6"
     transform="rotate(-90)"

 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12px;font-family:Roboto;-inkscape-font-specification:'Roboto,
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal"><tspan
       id="tspan159594-1"
       x="-48.831322"
       y="15.60547"

 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12px;font-family:Roboto;-inkscape-font-specification:'Roboto,
Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal">16p13.3</tspan></text>
</svg>
\stopbuffer

\starttext
   \placefigure[]{}{\includesvgbuffer[svg][conversion=mp]}
\stoptext
% EOF
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220629/e1738533/attachment.htm>


More information about the ntg-context mailing list