You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Linus-Lin <LL...@OfficeDepot.com> on 2001/02/05 18:32:12 UTC
FW: painting from components with SVGGenerator Class
> -----Original Message-----
> From: Linus-Lin
> Sent: Monday, February 05, 2001 11:31 AM
> To: 'batik-dev@xml.apache.org'
> Subject: painting from components with SVGGenerator Class
>
> Hello,
> I've been using FOP for the past nine months and have able to
> produce good PDF docs.
> However, they still don't have non-Latin font support as of now and
> support only a small subset of
> Unicode. So I've decide to use SVG to paint, scale and clip individual
> fonts after I've created them
> with Batik classes, primarily SVGGenerator.
>
> So far...
>
> I've been able to produce hebrew font onto a TextArea component after
> setting the font.properties file
> and importing the correct True-Type with the following code:
>
> public static void main(String[] args) {
>
> JFrame f = new JFrame("");
>
> JTextArea area = new JTextArea();
> JScrollPane jsp = new JScrollPane(area);
>
> area.setFont(new Font("David",Font.PLAIN,24));
> area.append("\u05F0");
> f.getContentPane().add(jsp);
>
> f.addWindowListener(new WindowAdapter() {
> public void windowClosing(WindowEvent e) {
> System.exit(0);
> }
> });
>
> f.setSize(1000,100);
> f.setVisible(true);
> }
>
> However this code
>
> public static void main(String [] args) throws IOException {
>
> DOMImplementation domImpl =
> GenericDOMImplementation.getDOMImplementation();
>
> Document document = domImpl.createDocument(null, "svg",
> null);
>
> SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
>
> TestSVGGen test = new TestSVGGen();
>
> JFrame f = new JFrame("");
>
> JTextArea area = new JTextArea();
> JScrollPane jsp = new JScrollPane(area);
>
> area.setFont(new Font("David",Font.PLAIN,24));
> area.append("\u05F0");
>
> area.paint(svgGenerator);
>
> boolean useCSS = true; // we want to use CSS style attribute
> Writer out = new OutputStreamWriter(System.out, "UTF-8");
> svgGenerator.stream(out, useCSS);
> }
>
> produces the following SVG:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20001102//EN'
> 'http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd'>
> <svg style="fill-opacity:1; font-weight:normal; color-rendering:auto;
> stroke-miterlimit:10; stroke-linejoin:miter; fill:black;
> stroke-linecap:square; image-rendering:auto; stroke-opacity:1;
> stroke-dashoffset:0; font-size:12pt; stroke:black; text-rendering:auto;
> stroke-dasharray:none; font-family:'sansserif';
> color-interpolation:sRGB; shape-rendering:auto; stroke-width:1;
> font-style:normal;" width="2147483647" height="2147483647">
> <!--Generated by the Java 2D API Graphics2D SVG Generator, Sun
> Microsystems Inc.-->
> <defs id="genericDefs" />
> <g />
> </svg>
>
> -------------
> Any opinions or answers?
>
> Linus