I am trying to generate PNG text icons from SVG in Cocoon. I just want a PNG with no extra
space around the text.

I use the following match in my sitemap and generate the appropriate text icon by calling

        1) .../nav2.png?icon-text=abc
2) .../nav2.png?icon- text=Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogoch
        3) ...

<map:match pattern="nav2.png">
        <map:generate src="resources/svg/nav2.svg" type="file" />
        <map:transform src="resources/svg/nav2.xslt">
                <map:parameter name="icon-text" value="{request-param:icon-text}" 
/>
        </map:transform>
        <map:serialize type="svg2png" />
</map:match>





The generated icon should contain the text and nothing else. The following is the template I
use (see <map:generate> above).


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:svg="http://www.w3.org/2000/svg";
   xmlns="http://www.w3.org/2000/svg";>
  <text />
</svg>




And this is the transformation (see <map:transform> above).


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0" xmlns:svg="http://www.w3.org/2000/svg"; xmlns="http://www.w3.org/2000/ svg">

        <xsl:param name="icon-text" />

        <xsl:template match="/svg:svg/svg:text">
                <text
style="font-size:15px;font-style:normal;font-variant:normal;font- weight:normal;font-stretch:normal;writing-mode:lr-tb;fill:black;fill- opacity:1;font-family:VAG Rounded Std Thin"
                        x="0"
                        y="15px"
                        id="icon-text">
                        <xsl:value-of select="$icon-text" />
                </text>
        </xsl:template>

        <xsl:template match="svg:*">
                <xsl:copy>
                        <xsl:apply-templates select="*|@*|text()" />
                </xsl:copy>
        </xsl:template>

        <xsl:template match="@*">
                <xsl:copy-of select="." />
        </xsl:template>
        
</xsl:stylesheet>



This all works in principle but the PNGs generated have non- predictable widths (with a variance in height in occasional cases). It is as though the text is being padded with blanks to the right. I can't pass a parameter "height" to the SVG serializer because I don't
know how long the rendered text is.

Can anyone point to my error? How can I specify that I want to generate a text icon whose
width is defined by the rendered length of the text?


Steve

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to