Replies: 2 comments 2 replies
-
I did some tests, for instance I converted this shape: I cleaned up the Inkscape file with Scour since SVG-Cleaner isn't available for <?xml version="1.0" encoding="UTF-8"?>
<svg width="4mm" height="8mm" version="1.1" viewBox="0 0 4 8" xmlns="http://www.w3.org/2000/svg">
<path d="m0 0s2.0784-0.087653 2 4-2 4-2 4h4v-8z" fill="#f00"/>
</svg> I grabbed the relative part into the \enabletrackers[metapost.svg.result]
\startbuffer[svgtest]
<svg id="svg21" width="4mm" height="8mm" version="1.1" viewBox="0 0 4 8" xmlns="http://www.w3.org/2000/svg">
<g id="layer1">
<path id="path991" d="m0 0s2.0784-0.087653 2 4-2 4-2 4h4v-8z" fill="#f00"/>
</g>
</svg>
\stopbuffer
\starttext
\includesvgbuffer[svgtest]
\stoptext And in the output you can actually find the conversion: metapost > svg > result graphic:
draw image (
fill ((0,0)..controls(0,0)and(2.0784,0.087653)..(2,-4)..controls(1.9216,-8.087653)and(0,-8)..(0,-8)--(4,-8)--(4,0)&&cycle)
withcolor svggray(0.941)
;
clip currentpicture to (unitsquare xyscaled (4,-8));
) ; A little bit convoluted but it created a |
Beta Was this translation helpful? Give feedback.
-
The conversion from I was day-dreaming again... 😭 Scour SVG (cleaned)<?xml version="1.0" encoding="UTF-8"?>
<svg width="12mm" height="8mm" version="1.1" viewBox="0 0 12 8" >
<rect width="12" height="8" fill="#f00" stroke-linecap="round" />
<path d="m0 0v8c1.6569 0 3-1.3431 3-3v-2c0-1.6569-1.3431-3-3-3z" fill="#999" />
</svg> XML<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="/usr/share/speedata-publisher/schema/layoutschema-en.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="/usr/share/speedata-publisher/schema/layoutschema-en.xsd" type="application/xml" schematypens="http://http://www.w3.org/2001/XMLSchema"?>
<Layout xmlns="urn:speedata.de:2009/publisher/en" xmlns:sd="urn:speedata:2009/publisher/functions/en" xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- PAGE SETTINGS -->
<Trace grid="no" textformat="no" objects="no" />
<Pageformat width="80mm" height="80mm" />
<LoadFontfile name="Amaranth-BoldItalic" filename="Amaranth-BoldItalic.ttf" mode="harfbuzz" />
<LoadFontfile name="Oswald-Light" filename="Oswald-Light.ttf" mode="harfbuzz" features="+frac" />
<LoadFontfile name="Oswald-Bold" filename="Oswald-Bold.ttf" mode="harfbuzz" features="+frac" />
<DefineFontfamily fontsize="10" leading="12" name="title">
<Regular fontface="Oswald-Light" />
<Bold fontface="Oswald-Bold" />
</DefineFontfamily>
<DefineFontfamily fontsize="12" leading="10" name="new">
<Regular fontface="Amaranth-BoldItalic" />
</DefineFontfamily>
<DefineColor name="aglgray" model="RGB" r="153" g="153" b="153" />
<DefineGraphic name="title">
filldraw box withcolor colors.aglgray ;
clip currentpicture to roundedsquare(box.width + 10mm, box.height, 3mm);
</DefineGraphic>
<DefineGraphic name="svg2mp">
fill unitsquare xyscaled (12,8) shifted (0,-8) withcolor red;
fill (0,0) -- (0,-8) .. controls(1.6569,-8) and (3,-6.6569) .. (3,-5) -- (3,-3) .. controls (3,-1.3431) and (1.6569,0) .. (0,0) -- cycle withcolor colors.aglgray;
clip currentpicture to (unitsquare xyscaled (12,-8))
</DefineGraphic>
<!-- first start with a table -->
<Record element="data">
<!-- SVG TO MP -->
<PlaceObject>
<Table width="20cm" fontfamily="title">
<Tr minheight="8mm" align="left" valign="middle">
<Td graphic="title" padding-left="3.2mm" padding-top="1mm" padding-right="0.6mm">
<Paragraph>
<B>
<NoBreak reduce="fontfit">
<Value>TITLE TABLE+SVG>MP</Value>
</NoBreak>
</B>
</Paragraph>
</Td>
<Td graphic="svg2mp" align="left" padding-right="3mm" padding-left="4.8mm" padding-top="1.3mm">
<Paragraph color="white" fontfamily="new">
<Value>NEW</Value>
</Paragraph>
</Td>
</Tr>
</Table>
</PlaceObject>
</Record>
</Layout> |
Beta Was this translation helpful? Give feedback.
-
Hi @pgundlach
I am still dealing with
MetaPost
, I barely graspedPublisher
and learningMetaPost
to draw a background is driving me crazy... 🤯On stack TeX Stack Exchange I asked for any utility to convert from
SVG
toMP
and someone replied me this:https://tex.stackexchange.com/questions/731996/any-utility-to-convert-from-svg-pdf-ps-to-mp-metapost
Now I wonder if you believe it would be possible to create a filter for
Publisher
that usesConTeXt
(if installed) to convert aSVG
file into aMP
one, in a more human-friendly manner.Something like:
What do you think about it? 🙏
TIP
I know that SVG files created for instance with Inkscape are filled up with a lot of extra tags, to reduce dramatically the size and weight of SVG files I use this utility that does a really great job:
https://github.com/RazrFalcon/svgcleaner/releases
It is still available a version for MacOS too! 😉
Beta Was this translation helpful? Give feedback.
All reactions