hi all. when i want to put some SVGs in my document the svg does not render properly here is the code: \starttext \startMPcode draw lmt_svg [ filename = "smile.svg"] \stopMPcode \stoptext also when i look at evenmore manual at page15, for font Abelone-FREE the gradients has rendered properly is there difference between rendering such fonts and rendering SVGs? if its a font feature how i can use this font features for my svg?
Hi ! Did you have a look at this : https://wiki.contextgarden.net/SVG Le 12/03/2024 à 14:36, seyal.zavira@gmail.com a écrit :
hi all.
when i want to put some SVGs in my document the svg does not render properly here is the code:
\starttext \startMPcode draw lmt_svg [ filename = "smile.svg"] \stopMPcode \stoptext
also when i look at evenmore manual at page15, for font Abelone-FREE the gradients has rendered properly is there difference between rendering such fonts and rendering SVGs?
if its a font feature how i can use this font features for my svg? ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
thanks for your reply
yes but i don't have problem with regular svgs but when svgs has gradient
color it does not produce any color in output.
you can see my svg in attachment.
On Tue, Mar 12, 2024 at 9:43 AM Jean-Pierre Delange
Hi !
Did you have a look at this :
https://wiki.contextgarden.net/SVG
hi all.
when i want to put some SVGs in my document the svg does not render
Le 12/03/2024 à 14:36, seyal.zavira@gmail.com a écrit : properly here is the code:
\starttext \startMPcode draw lmt_svg [ filename = "smile.svg"] \stopMPcode \stoptext
also when i look at evenmore manual at page15, for font Abelone-FREE the
gradients has rendered properly is there difference between rendering such fonts and rendering SVGs?
if its a font feature how i can use this font features for my svg?
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
Am 12.03.24 um 14:53 schrieb seyal zavira:
> when i want to put some SVGs in my document the svg does not render properly here is the code: > > \starttext > \startMPcode > draw lmt_svg [ > filename = "smile.svg"] > \stopMPcode > \stoptext
I can confirm the problem also with the regular image call \externalfigure[smile.svg][conversion=mp] Hraban
Yes, the code given by Seyal gives only the circle vith eyes and mouth without colors (on my computer). But, It seems that one have to deal with a more complex lines of code. If I'm not mistaken, MetaPost alone natively supports only the 3 colours red, green and blue. To support CMYK colour gradients, MetaPost needs to work with Metafun (see here : https://wiki.contextgarden.net/Color_in_MetaPost). Perhaps an image in *.png format is required. But I can't give any advice, as I'm not an experienced MetaPost/Metafun user. see this code below and the result as attached file : \starttext \input tufte \externalfigure[smile.svg][conversion=mp] \stoptext Best//JP Le 12/03/2024 à 15:01, Henning Hraban Ramm a écrit :
Am 12.03.24 um 14:53 schrieb seyal zavira:
> when i want to put some SVGs in my document the svg does not render properly here is the code: > > \starttext > \startMPcode > draw lmt_svg [ > filename = "smile.svg"] > \stopMPcode > \stoptext
I can confirm the problem also with the regular image call
\externalfigure[smile.svg][conversion=mp]
Hraban ___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
On 3/12/2024 2:53 PM, seyal zavira wrote:
thanks for your reply
yes but i don't have problem with regular svgs but when svgs has gradient color it does not produce any color in output.
you can see my svg in attachment. svg gets worse and worse (esp the inheritance model) ... anyway, i can sort of get the gradient but no stepwise gradient opacity (in pdf and i'm not going to emulate something) (it's not the most interesting stuff to work on unpaid)
but ... i don't know if fixing this breaks something else 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 -----------------------------------------------------------------
Thanks. I appreciate your work
You are correct. when i convert this svg to pdf via inkscape it works like
a charm.
But what is standard way of including an svg file with context if we want
to inkscape render the images?
On Tue, 12 Mar 2024, 21:51 Hans Hagen,
On 3/12/2024 2:53 PM, seyal zavira wrote:
thanks for your reply
yes but i don't have problem with regular svgs but when svgs has gradient color it does not produce any color in output.
you can see my svg in attachment. svg gets worse and worse (esp the inheritance model) ... anyway, i can sort of get the gradient but no stepwise gradient opacity (in pdf and i'm not going to emulate something) (it's not the most interesting stuff to work on unpaid)
but ... i don't know if fixing this breaks something else
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 / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
Am 12.03.24 um 23:59 schrieb seyal zavira:
You are correct. when i convert this svg to pdf via inkscape it works like a charm.
But what is standard way of including an svg file with context if we want to inkscape render the images?
\externalfigure[smile] without any other settings, but inkscape must be callable on the command line (which doesn’t work for me on MacOS any more, must investigate…). Hraban
Hi Hraban & Seyal I can confirm that converting the *.svg file into a *.pdf file displays the colour shades correctly ... (I used Gimp to export the smile.svg file to a smile03.pdf file). The MWE below works correctly, even if you have to make finer adjustments to place the figure in a precise position on the page. As I'm in the process of enriching and clarifying a few pages of the ConTeXt wiki and the French wikibook, I'm interested in the details concerning the position of figures, images and photos etc. So please let me know (in private mail) how you make your documents (a MWE will do). \starttext \input tufte \externalfigure[smile03.pdf][conversion=mp] \stoptext It seems to me that Pablo has been struggling with the fine graining of PDF files in recent months, but I think it was more about the information contained in the PDF output than the processing of PDF images in *.tex file output. JP Le 13/03/2024 à 09:16, Henning Hraban Ramm a écrit :
Am 12.03.24 um 23:59 schrieb seyal zavira:
You are correct. when i convert this svg to pdf via inkscape it works like a charm.
But what is standard way of including an svg file with context if we want to inkscape render the images?
\externalfigure[smile]
without any other settings, but inkscape must be callable on the command line (which doesn’t work for me on MacOS any more, must investigate…).
Hraban ___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
Am 13.03.24 um 13:14 schrieb Jean-Pierre Delange:
Hi Hraban & Seyal
I can confirm that converting the *.svg file into a *.pdf file displays the colour shades correctly ... (I used Gimp to export the smile.svg file to a smile03.pdf file).
Gimp is a really bad choice in this case, since it converts vectors into pixels. And if you place a PDF, no further conversion is needed. If you have problems with SVGs, use Inkscape (or some commercial alternative like Affinity Designer or Adobe Illustrator) for PDF conversion.
The MWE below works correctly, even if you have to make finer adjustments to place the figure in a precise position on the page. As I'm in the process of enriching and clarifying a few pages of the ConTeXt wiki and the French wikibook, I'm interested in the details concerning the position of figures, images and photos etc. So please let me know (in private mail) how you make your documents (a MWE will do).
Position options: * relative placement as floats, i.e. \placefigure * absolute placement on layers, i.e. \setlayer * relative corrections with \offset (also within floats) Hraban
Hraban, Thank a lot for these clarifications ! Jean-Pierre
Le 13 mars 2024 à 13:41, Henning Hraban Ramm
a écrit : Am 13.03.24 um 13:14 schrieb Jean-Pierre Delange:
Hi Hraban & Seyal I can confirm that converting the *.svg file into a *.pdf file displays the colour shades correctly ... (I used Gimp to export the smile.svg file to a smile03.pdf file).
Gimp is a really bad choice in this case, since it converts vectors into pixels. And if you place a PDF, no further conversion is needed.
If you have problems with SVGs, use Inkscape (or some commercial alternative like Affinity Designer or Adobe Illustrator) for PDF conversion.
The MWE below works correctly, even if you have to make finer adjustments to place the figure in a precise position on the page. As I'm in the process of enriching and clarifying a few pages of the ConTeXt wiki and the French wikibook, I'm interested in the details concerning the position of figures, images and photos etc. So please let me know (in private mail) how you make your documents (a MWE will do).
Position options: * relative placement as floats, i.e. \placefigure * absolute placement on layers, i.e. \setlayer * relative corrections with \offset (also within floats)
Hraban ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
On 3/13/2024 9:16 AM, Henning Hraban Ramm wrote:
Am 12.03.24 um 23:59 schrieb seyal zavira:
You are correct. when i convert this svg to pdf via inkscape it works like a charm.
But what is standard way of including an svg file with context if we want to inkscape render the images?
\externalfigure[smile]
without any other settings, but inkscape must be callable on the command line (which doesn’t work for me on MacOS any more, must investigate…). \startMPcode draw lmt_svg [ filename = "smile.svg"] \stopMPcode
Now gives the attached but it took me a while to figure out what works. An inkscape export adds for instance something (globally applied) that is not in the svg file (which actually derived from tiger.svg as mentioned in the file). To be honest this is a horrible file and a good example of making things more complex than needed (probably common in wysiwyg applications), although we already had the machinery in the mp/pdf converter. The biggest issue here is that one has to put some constrants in place order to make it work in e.g. sumatra (mypdf) and acrobat (which here actually does weird erratic things when I play with another test). As with much complex svg, browsers also differ in interpretation o fsome features so it's hard to figure out what to do when there are conflicting demands. (Pointing to something that works tomorrow doesn't mean it worked when we tried to implement something yesterday.) For Hraben - who mentioned it - i also added support for group opacity and transformed shades. In the process I tried a few inkscape options (pdf export) but some produce faulty files (with missing stuff) so i guess we have a complex situation in general. That said, as long as one sticks to reliable and clean code (plain svg) it should mostly work out. Text is another matter because svg dropped glyph support so now everything has to go through font features which in turn means that if one uses svg as output format one has to specify every character with possible abuse of a substitution feature that accesses it. So that is no longer a real interesting option, unless of course one exports all text as curves, just to be sure. (I will extend general text suport but it will always be suboptimal but then, svg is not a long term archival format anyway.) No upload yet as i also want to do some cleanup, ps. For metapost lovers, here is some of the trickery used: \startMPpage[offset=1ts] draw image ( fill (unitsquare xscaled 10cm yscaled 4cm) withcolor svgcolor(0.5,0,0) ; registerluminositygroup ("test") ( fill (unitsquare scaled 2cm) shifted (1cm,1cm) withshademethod "circular" withshadecolors (.6,.1) ) ; applyluminositygroup ("test") ( fill (unitsquare scaled 2cm) shifted (1cm,1cm) withshademethod "circular" ) ; draw luminositygroup ( fill (unitsquare scaled 2cm) shifted (4cm,1cm) withshademethod "circular" withshadecolors (.6,.1) ) ( fill (unitsquare scaled 2cm) shifted (4cm,1cm) withshademethod "circular" ) ; draw luminosityshade ( (unitsquare scaled 2cm) shifted (7cm,1cm) ) ( withshademethod "circular" withshadecolors (.6,.1) ) ( withshademethod "circular" ) ; ) ; \stopMPpage Not that intuitive and a bit ugly deep down but it works (there was no need to extend mp btw as we already have graphic grouping in the engine). 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 -----------------------------------------------------------------
Thanks you and harban for all your thorough explanation.
On Fri, 15 Mar 2024, 23:11 Hans Hagen via ntg-context,
On 3/13/2024 9:16 AM, Henning Hraban Ramm wrote:
Am 12.03.24 um 23:59 schrieb seyal zavira:
You are correct. when i convert this svg to pdf via inkscape it works like a charm.
But what is standard way of including an svg file with context if we want to inkscape render the images?
\externalfigure[smile]
without any other settings, but inkscape must be callable on the command line (which doesn’t work for me on MacOS any more, must investigate…). \startMPcode draw lmt_svg [ filename = "smile.svg"] \stopMPcode
Now gives the attached but it took me a while to figure out what works. An inkscape export adds for instance something (globally applied) that is not in the svg file (which actually derived from tiger.svg as mentioned in the file).
To be honest this is a horrible file and a good example of making things more complex than needed (probably common in wysiwyg applications), although we already had the machinery in the mp/pdf converter.
The biggest issue here is that one has to put some constrants in place order to make it work in e.g. sumatra (mypdf) and acrobat (which here actually does weird erratic things when I play with another test).
As with much complex svg, browsers also differ in interpretation o fsome features so it's hard to figure out what to do when there are conflicting demands. (Pointing to something that works tomorrow doesn't mean it worked when we tried to implement something yesterday.)
For Hraben - who mentioned it - i also added support for group opacity and transformed shades.
In the process I tried a few inkscape options (pdf export) but some produce faulty files (with missing stuff) so i guess we have a complex situation in general. That said, as long as one sticks to reliable and clean code (plain svg) it should mostly work out.
Text is another matter because svg dropped glyph support so now everything has to go through font features which in turn means that if one uses svg as output format one has to specify every character with possible abuse of a substitution feature that accesses it. So that is no longer a real interesting option, unless of course one exports all text as curves, just to be sure.
(I will extend general text suport but it will always be suboptimal but then, svg is not a long term archival format anyway.)
No upload yet as i also want to do some cleanup,
ps. For metapost lovers, here is some of the trickery used:
\startMPpage[offset=1ts]
draw image ( fill (unitsquare xscaled 10cm yscaled 4cm) withcolor svgcolor(0.5,0,0) ;
registerluminositygroup ("test") ( fill (unitsquare scaled 2cm) shifted (1cm,1cm) withshademethod "circular" withshadecolors (.6,.1) ) ;
applyluminositygroup ("test") ( fill (unitsquare scaled 2cm) shifted (1cm,1cm) withshademethod "circular" ) ;
draw luminositygroup ( fill (unitsquare scaled 2cm) shifted (4cm,1cm) withshademethod "circular" withshadecolors (.6,.1) ) ( fill (unitsquare scaled 2cm) shifted (4cm,1cm) withshademethod "circular" ) ;
draw luminosityshade ( (unitsquare scaled 2cm) shifted (7cm,1cm) ) ( withshademethod "circular" withshadecolors (.6,.1) ) ( withshademethod "circular" ) ; ) ;
\stopMPpage
Not that intuitive and a bit ugly deep down but it works (there was no need to extend mp btw as we already have graphic grouping in the engine).
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 / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
Dear CTX wizards, The commands given by Hans don't work properly in my case (with CTX on Windows 11). I am probably ignorant of how to implement \startMPpage. I'm not a "MetaPost lover", but I'd like to understand something; especially as I know how to make simple frames to include summaries. In any case, the MWE below correctly displays the "smile" images (in *.pdf format) and incorrectly displays the smile.svg image). On the other hand, the \startMPpage script given by Hans only produces a white square. The *.log is attached. The MWE : \starttext \startchapter[title={MetaPost}] First : a draw sample with a simple command %\externalfigure \externalfigure[smile.pdf] % Hans comments on Metapost Now gives the attached but it took me a while to figure out what works. An inkscape export adds for instance something (globally applied) that is not in the svg file (which actually derived from tiger.svg as mentioned in the file). To be honest this is a horrible file and a good example of making things more complex than needed (probably common in wysiwyg applications), although we already had the machinery in the mp/pdf converter. The biggest issue here is that one has to put some constrants in place order to make it work in e.g. sumatra (mypdf) and acrobat (which here actually does weird erratic things when I play with another test). As with much complex svg, browsers also differ in interpretation o fsome features so it's hard to figure out what to do when there are conflicting demands. (Pointing to something that works tomorrow doesn't mean it worked when we tried to implement something yesterday.) For Hraban - who mentioned it - i also added support for group opacity and transformed shades. Hans Hagen % If we use another call to the same smile drawing (but in *.svg format) % the svg file is given by Inkscape (as the smile.pdf, exported through Inkscape) \startMPcode draw lmt_svg [ filename = "smile.svg"] \stopMPcode \stopchapter \startchapter[title={Hans tricky drawing}] Now, see the results of Hans has given to \quote{metapost lovers}, here is some of the trickery used : \startMPpage[offset=1ts] draw image ( fill (unitsquare xscaled 10cm yscaled 4cm) withcolor svgcolor(0.5,0,0) ; registerluminositygroup ("test") ( fill (unitsquare scaled 2cm) shifted (1cm,1cm) withshademethod "circular" withshadecolors (.6,.1) ) ; applyluminositygroup ("test") ( fill (unitsquare scaled 2cm) shifted (1cm,1cm) withshademethod "circular" ) ; draw luminositygroup ( fill (unitsquare scaled 2cm) shifted (4cm,1cm) withshademethod "circular" withshadecolors (.6,.1) ) ( fill (unitsquare scaled 2cm) shifted (4cm,1cm) withshademethod "circular" ) ; draw luminosityshade ( (unitsquare scaled 2cm) shifted (7cm,1cm) ) ( withshademethod "circular" withshadecolors (.6,.1) ) ( withshademethod "circular" ) ; ) ; \stopMPpage \stopchapter \stoptext Le 15/03/2024 à 20:39, Hans Hagen via ntg-context a écrit :
On 3/13/2024 9:16 AM, Henning Hraban Ramm wrote:
Am 12.03.24 um 23:59 schrieb seyal zavira:
You are correct. when i convert this svg to pdf via inkscape it works like a charm.
But what is standard way of including an svg file with context if we want to inkscape render the images?
\externalfigure[smile]
without any other settings, but inkscape must be callable on the command line (which doesn’t work for me on MacOS any more, must investigate…). \startMPcode draw lmt_svg [ filename = "smile.svg"] \stopMPcode
Now gives the attached but it took me a while to figure out what works. An inkscape export adds for instance something (globally applied) that is not in the svg file (which actually derived from tiger.svg as mentioned in the file).
To be honest this is a horrible file and a good example of making things more complex than needed (probably common in wysiwyg applications), although we already had the machinery in the mp/pdf converter.
The biggest issue here is that one has to put some constrants in place order to make it work in e.g. sumatra (mypdf) and acrobat (which here actually does weird erratic things when I play with another test).
As with much complex svg, browsers also differ in interpretation o fsome features so it's hard to figure out what to do when there are conflicting demands. (Pointing to something that works tomorrow doesn't mean it worked when we tried to implement something yesterday.)
For Hraben - who mentioned it - i also added support for group opacity and transformed shades.
In the process I tried a few inkscape options (pdf export) but some produce faulty files (with missing stuff) so i guess we have a complex situation in general. That said, as long as one sticks to reliable and clean code (plain svg) it should mostly work out.
Text is another matter because svg dropped glyph support so now everything has to go through font features which in turn means that if one uses svg as output format one has to specify every character with possible abuse of a substitution feature that accesses it. So that is no longer a real interesting option, unless of course one exports all text as curves, just to be sure.
(I will extend general text suport but it will always be suboptimal but then, svg is not a long term archival format anyway.)
No upload yet as i also want to do some cleanup,
ps. For metapost lovers, here is some of the trickery used:
\startMPpage[offset=1ts]
draw image ( fill (unitsquare xscaled 10cm yscaled 4cm) withcolor svgcolor(0.5,0,0) ;
registerluminositygroup ("test") ( fill (unitsquare scaled 2cm) shifted (1cm,1cm) withshademethod "circular" withshadecolors (.6,.1) ) ;
applyluminositygroup ("test") ( fill (unitsquare scaled 2cm) shifted (1cm,1cm) withshademethod "circular" ) ;
draw luminositygroup ( fill (unitsquare scaled 2cm) shifted (4cm,1cm) withshademethod "circular" withshadecolors (.6,.1) ) ( fill (unitsquare scaled 2cm) shifted (4cm,1cm) withshademethod "circular" ) ;
draw luminosityshade ( (unitsquare scaled 2cm) shifted (7cm,1cm) ) ( withshademethod "circular" withshadecolors (.6,.1) ) ( withshademethod "circular" ) ; ) ;
\stopMPpage
Not that intuitive and a bit ugly deep down but it works (there was no need to extend mp btw as we already have graphic grouping in the engine).
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 /https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage :https://www.pragma-ade.nl /https://context.aanhet.net (mirror) archive :https://github.com/contextgarden/context wiki :https://wiki.contextgarden.net ___________________________________________________________________________________
participants (6)
-
Hans Hagen
-
Hans Hagen
-
Henning Hraban Ramm
-
Jean-Pierre Delange
-
seyal zavira
-
seyal.zavira@gmail.com