[NTG-context] SVG text alignment issue
Aditya Mahajan
adityam at umich.edu
Wed Jun 29 04:35:01 CEST 2022
On Mon, 27 Jun 2022, Thangalin via ntg-context wrote:
> In the following example, the line and text should be aligned to the
> middle when LMTX converts the SVG figure using MP. (Note that you may have
> to install Roboto, but the font isn't the issue.)
>
> % SOF
> \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
This has nothing to do with SVG. Looking at the definition of \includesvgbuffer, here is a simpler example illustrating the issue:
\starttext
\startplacefigure[location=here, title={Test}]
\dontleavehmode\begingroup
\startMPcode
draw fullcircle scaled 2cm;
\stopMPcode\endgroup
\stopplacefigure
\stoptext
One way to "fix" the alignment is to wrap everything in an hbox:
\placefigure[]{}{\hbox{\includesvgbuffer[svg][conversion=mp]}}
Maybe there is a simple way to modify the definition of includesvgbuffer so that an \hbox is not needed.
Aditya
More information about the ntg-context
mailing list