SVG not rendering correctly with LMTX and conversion=mp
The following MWE fails to render the text in the attached SVG properly: \starttext \externalfigure[test.svg][conversion=mp] \stoptext The axis labels, tick labels, and title are all incorrect. This file was generated with Matplotlib.
Check that your Inkscape is working properly. That proble NOT appear on my machine... Best, L. Montgomery El lun., 18 de octubre de 2021 10:15, Jason Ross via ntg-context < ntg-context@ntg.nl> escribió:
The following MWE fails to render the text in the attached SVG properly:
\starttext \externalfigure[test.svg][conversion=mp] \stoptext
The axis labels, tick labels, and title are all incorrect. This file was generated with Matplotlib.
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@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
___________________________________________________________________________________
On 10/18/21 8:38 AM, Luis Montgomery wrote:
Check that your Inkscape is working properly.
That proble NOT appear on my machine...
Best,
L. Montgomery
(Sorry Luis, I forgot to cc mailing list) Per https://wiki.contextgarden.net/Command/externalfigure, in LMTX the conversion is done natively when "conversion=mp" is set. Inkscape is not used for the conversion.
In my tests, this conversion works internally with linux.
On windows it fails and stops at
l.63 \ registerctxluafile {data-bin} {}
% before data-tex
?
El lun, 18 oct 2021 a las 10:49, Jason Ross (
On 10/18/21 8:38 AM, Luis Montgomery wrote:
Check that your Inkscape is working properly.
That proble NOT appear on my machine...
Best,
L. Montgomery
(Sorry Luis, I forgot to cc mailing list) Per https://wiki.contextgarden.net/Command/externalfigure, in LMTX the conversion is done natively when "conversion=mp" is set. Inkscape is not used for the conversion.
Il 18/10/21 17:15, Jason Ross via ntg-context ha scritto:
The following MWE fails to render the text in the attached SVG properly:
\starttext \externalfigure[test.svg][conversion=mp] \stoptext
The axis labels, tick labels, and title are all incorrect. This file was generated with Matplotlib.
If you open test.svg with Inkscape, ungroup and then save, you get a SVG that is typeset right with LMTX. Looking at the differences between the two SVGs, I can see that Inkscape changes all the transform="translate(...)scale(...)" attributes into transform="matrix(...)". Now focus on the "y = sin(x)" text. In the attachment I modified the transform attributes of that text, from "translate(...)scale(...)" to "matrix(...)", taking the values from the version obtained from Inkscape. Use that SVG with your MWE and you'll see "y = sin(x)" appearing in the right place in the PDF. I would say the "translate(...)scale(...)" specification is not supported in LMTX (yet). Massi
On 10/18/2021 6:06 PM, mf via ntg-context wrote:
Il 18/10/21 17:15, Jason Ross via ntg-context ha scritto:
The following MWE fails to render the text in the attached SVG properly:
\starttext \externalfigure[test.svg][conversion=mp] \stoptext
The axis labels, tick labels, and title are all incorrect. This file was generated with Matplotlib.
If you open test.svg with Inkscape, ungroup and then save, you get a SVG that is typeset right with LMTX.
Looking at the differences between the two SVGs, I can see that Inkscape changes all the transform="translate(...)scale(...)" attributes into transform="matrix(...)".
Now focus on the "y = sin(x)" text. In the attachment I modified the transform attributes of that text, from "translate(...)scale(...)" to "matrix(...)", taking the values from the version obtained from Inkscape.
Use that SVG with your MWE and you'll see "y = sin(x)" appearing in the right place in the PDF.
I would say the "translate(...)scale(...)" specification is not supported in LMTX (yet). it is supported; i'll send you a snippet to test (as it was not really a minimal example)
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 -----------------------------------------------------------------
Here it's wrong. See attachment. Massimiliano Il 18/10/21 18:30, Hans Hagen via ntg-context ha scritto:
On 10/18/2021 6:06 PM, mf via ntg-context wrote:
Il 18/10/21 17:15, Jason Ross via ntg-context ha scritto:
The following MWE fails to render the text in the attached SVG properly:
\starttext \externalfigure[test.svg][conversion=mp] \stoptext
The axis labels, tick labels, and title are all incorrect. This file was generated with Matplotlib.
If you open test.svg with Inkscape, ungroup and then save, you get a SVG that is typeset right with LMTX.
Looking at the differences between the two SVGs, I can see that Inkscape changes all the transform="translate(...)scale(...)" attributes into transform="matrix(...)".
Now focus on the "y = sin(x)" text. In the attachment I modified the transform attributes of that text, from "translate(...)scale(...)" to "matrix(...)", taking the values from the version obtained from Inkscape.
Use that SVG with your MWE and you'll see "y = sin(x)" appearing in the right place in the PDF.
I would say the "translate(...)scale(...)" specification is not supported in LMTX (yet). it is supported; i'll send you a snippet to test (as it was not really a minimal example)
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@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 ___________________________________________________________________________________
Il 18/10/21 18:30, Hans Hagen via ntg-context ha scritto:
On 10/18/2021 6:06 PM, mf via ntg-context wrote:
Il 18/10/21 17:15, Jason Ross via ntg-context ha scritto:
The following MWE fails to render the text in the attached SVG properly:
\starttext \externalfigure[test.svg][conversion=mp] \stoptext
The axis labels, tick labels, and title are all incorrect. This file was generated with Matplotlib.
If you open test.svg with Inkscape, ungroup and then save, you get a SVG that is typeset right with LMTX.
Looking at the differences between the two SVGs, I can see that Inkscape changes all the transform="translate(...)scale(...)" attributes into transform="matrix(...)".
Now focus on the "y = sin(x)" text. In the attachment I modified the transform attributes of that text, from "translate(...)scale(...)" to "matrix(...)", taking the values from the version obtained from Inkscape.
Use that SVG with your MWE and you'll see "y = sin(x)" appearing in the right place in the PDF.
I would say the "translate(...)scale(...)" specification is not supported in LMTX (yet). it is supported; i'll send you a snippet to test (as it was not really a minimal example)
Coming soon... (see attachment) The problem was the order in which transformations are applied when multiple transformations are specified in the transform attribute, like in "translate(...)scale(...)...". testsvg.tex and test.svg are the MWE and the SVG file provided by Jason Ross in the first post of this thread. Massi
On 10/18/2021 6:06 PM, mf via ntg-context wrote:
Il 18/10/21 17:15, Jason Ross via ntg-context ha scritto:
The following MWE fails to render the text in the attached SVG properly:
\starttext \externalfigure[test.svg][conversion=mp] \stoptext
The axis labels, tick labels, and title are all incorrect. This file was generated with Matplotlib.
If you open test.svg with Inkscape, ungroup and then save, you get a SVG that is typeset right with LMTX.
Looking at the differences between the two SVGs, I can see that Inkscape changes all the transform="translate(...)scale(...)" attributes into transform="matrix(...)".
Now focus on the "y = sin(x)" text. In the attachment I modified the transform attributes of that text, from "translate(...)scale(...)" to "matrix(...)", taking the values from the version obtained from Inkscape.
Use that SVG with your MWE and you'll see "y = sin(x)" appearing in the right place in the PDF.
I would say the "translate(...)scale(...)" specification is not supported in LMTX (yet). does the spec say anywhere what teh order is?
<!-- g transform="translate (14.118498 132.66443) rotate (-90) scale (0.1 -0.1)" --> this looks better but <g transform="scale (0.1 -0.1) rotate (-90) translate (14.118498 132.66443) "> how about 10 scales and 15 rotations and 3 transforms in any order? 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 -----------------------------------------------------------------
On 10/18/2021 5:15 PM, Jason Ross via ntg-context wrote:
The following MWE fails to render the text in the attached SVG properly:
\starttext \externalfigure[test.svg][conversion=mp] \stoptext
The axis labels, tick labels, and title are all incorrect. This file was generated with Matplotlib. we actually can avoid that by using label remapping (i fixed a scanning buglet in the first example:)
\startTEXpage \startMPcode lmt_remaptext [ label = "here 1", where = "l", text = "\bfa let's try this one out" ] ; lmt_remaptext [ label = "here 2", where = "r", text = "let's try this one out too" ] ; lmt_remaptext [ label = "here 3", where = "l", text = "$e = mc^2$" ] ; lmt_remaptext [ label = "here 5", where = "m", text = "this a bit longer label" ] ; lmt_remaptext [ label = "here 4", where = "m", text = "!", dx = -1pt, dy = -30pt ] ; draw lmt_svg [ filename = "labels-003.svg", ] ; \stopMPcode \stopTEXpage one can also have the labels externally \startluacode table.save ( "labels-001.lua", { { label = "here 1", where = "l", text = "let's try this one out" }, { label = "here 2", where = "r", text = "let's try this one out too" }, { label = "here 3", where = "l", text = "$e = mc^2$" }, { label = "here 5", where = "m", text = "this a bit longer label" }, { label = "here 4", where = "m", text = "!" }, } ) \stopluacode \startMPpage draw lmt_svg [ filename = "labels-003.svg", labelfile = "labels-001.lua", ] ; \stopMPpage the idea is then that in an svg editor one uses symbolic names and when including those get property typeset (should work in in next upload; is independent of reported issue) 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 -----------------------------------------------------------------
Fixing your svg. View attachments. El lun, 18 oct 2021 a las 10:15, Jason Ross via ntg-context (< ntg-context@ntg.nl>) escribió:
The following MWE fails to render the text in the attached SVG properly:
\starttext \externalfigure[test.svg][conversion=mp] \stoptext
The axis labels, tick labels, and title are all incorrect. This file was generated with Matplotlib.
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@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
___________________________________________________________________________________
participants (4)
-
Hans Hagen
-
Jason Ross
-
Luis Montgomery
-
mf