xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Kolesnikov ...@sundraw.ws>
Subject SVG font is not used when rendering to PNG
Date Fri, 14 Apr 2006 16:17:15 GMT
Phew... Have to give up for a moment.
Spend a whole day trying to get an SVG font used properly when rendering 
a PNG image. I searched the Nabble forum and saw that other people had a 
similar problem, but couldn't figure out what goes wrong in my case.

I am creating the document using DOM. Here is how the reference to the 
font is added:

ServletContext ctx  = getServletContext();

Element defs = doc.createElementNS(svgNS, "defs");
Element style = doc.createElementNS(svgNS, "style");
style.setAttributeNS(null, "type", "text/css");
CDATASection fontRef = doc.createCDATASection(
                "@font-face { font-family: 'ForgottenFuturist'; src: 
url(\"" +
                ctx.getRealPath("/ForgottenFuturist.svg") +
                "#ForgottenFuturist\") format(svg) }");
style.appendChild(fontRef);
defs.appendChild(style);

root.appendChild(defs);

...

greeting.setAttributeNS(null, "font-family", "ForgottenFuturist");

After something like a few hundreds of failed attempts I changed output 
from PNG to SVG, to see what happens in the document. This is what I found:

<defs>
 <style type="text/css" xml:space="preserve"><![CDATA[@font-face { 
font-family: 'ForgottenFuturist'; src: 
url("/Users/sundraw/Documents/workspace/SVGLifeGraph/ForgottenFuturist.svg#ForgottenFuturist")

format(svg) }]]></style>

<linearGradient x1="0%" xmlns:xlink="http://www.w3.org/1999/xlink"
                        y1="0%" x2="0%" y2="100%" xlink:type="simple"
                        xlink:actuate="onLoad" id="v_grad" 
xlink:show="other">
            <stop stop-color="darkred" offset="0%"/>
            <stop stop-color="#fff" offset="100%"/>
</linearGradient>
</defs>

What could be wrong here?

Cheers,

Alexander




Mime
View raw message