I think he's got code like this:
Document doc = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
SVGGraphics2D graphics = new SVGGraphics2D(doc);
graphics.setFont(Font.decode("SansSerif-PLAIN-30"));
graphics.drawString("Hello, World!", 100, 100);
// More graphics commands here...
graphics.stream(new OutputStreamWriter(System.out));
Which produces output like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
          'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
<svg color-interpolation="auto" color-rendering="auto" fill="black"
fill-opacity="1" font-family="&apos;Dialog&apos;" font-size="12"

font-style="normal" font-weight="normal" image-rendering="auto"
shape-rendering="auto" stroke="black" stroke-dasharray="none"
stroke-dashoffset="0"

stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="10"
stroke-opacity="1" stroke-width="1" text-rendering="auto"

xmlns="http://www.w3.org/2000/svg"; xmlns:xlink="http://www.w3.org/1999/xlink";
><!--Generated by the Batik Graphics2D SVG Generator--><defs id="genericDefs"
  /><g
  ><g font-family="sans-serif" font-size="30"
    ><text stroke="none" x="100" xml:space="preserve" y="100"
      >Hello, World!</text
    ></g
  ></g
></svg
>
Note the <g> element with font-size="30" which should (I think) be
30pt, since the font size in java's Font.decode is always specifed in
points.
Maybe a bug in Batik? I have a feeling this has come up before.

Pete


On Tue, Jan 18, 2011 at 9:26 AM, Martin Jacobson
<jacobson.mar...@gmail.com> wrote:
> Hi Detlief,
>
> Assuming that describing me as a 'titan' was a compliment, I thank you for
> it! :)
>
> However, I confess I don't know how you are creating SVG, either ---
> clearly, with Batik, there's more than one way to 'crack a nut'!
> I do understand XML, SVG, and CSS, which is why I posted.
>
> Best of luck,
> Martin
>
> On 17 January 2011 23:59, detlef.amb...@gmx.de <detlef.amb...@gmx.de> wrote:
>>
>> Hi Martin,
>>
>> I can not operate on your titan level. I have no clue what you mean.
>>
>> Never constructed a SAX Parser or did a Velocity template merge or
>> grabbed out an element of a DOM-type document.
>>
>> I'm a bloody old fashioned C-Programmer who just wants to draw some data
>> to a *.svg document and get the textsize right.
>>
>> So I'll go back to the books and get me some basics (or rather go to the
>> kitchen and get me some beer).
>>
>> Thanks for the help
>> Cheers
>> Detlef
>>
>> Am 16.01.2011 10:10, schrieb Martin Jacobson:
>> > I have never tried doing it like that! I create a text stream
>> > containig SVG that is piped into a SAX parser, like this
>> >
>> > SAXSVGDocumentFactory fac = new SAXSVGDocumentFactory(prs);
>> > SVGDocument doc=fac.createSVGDocument(uri.toString(), r);
>> >
>> > The text stream comes from the output of a Velocity template merge.
>> > This way, I can keep the SVG template external to the
>> > application. But, in any case, the outcome is that I have a DOM-type
>> > document (doc) that I can then do with as I please: for example,
>> > if I have an element el, I can write:
>> >
>> > el.setAttribute("style", "font-family: Times; font-size:30pt;");
>> >
>> > Can you not work on the DOM object?
>> >
>> > Martin
>> >
>> > On 15 January 2011 23:38, detlef.amb...@gmx.de <detlef.amb...@gmx.de>
>> > wrote:
>> >> Hi Martin,
>> >>
>> >>>>>>>
>> >> How do you generate the SVG?
>> >> <<<<<
>> >>
>> >> I'm not sure what you mean.
>> >>
>> >> I create a SVG Generator like this and plot the graphics to it:
>> >>>>>>>>>>>
>> >> // Create an instance of the SVG Generator.
>> >> SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
>> >> ggg.run(svgGenerator);
>> >> <<<<<<<<<<
>> >>
>> >> For setting the font-size I use
>> >> g.setFont(new Font("Times New Roman", Font.PLAIN, 30));
>> >> on 'Graphics g'
>> >>
>> >> Hope that clarifies.
>> >>
>> >> THX
>> >> Detlef
>> >>
>> >> Am 15.01.2011 10:15, schrieb Martin Jacobson:
>> >>> Firefox is correct, but 'picky': CSS size attributes are supposed to
>> >>> have a unit - only the value 0 derogates from this.
>> >>> OTOH, surely adding the text 'pt' is trivial? How do you generate the
>> >>> SVG?
>> >>> Martin
>> >>>
>> >>> On 14 January 2011 22:23, detlef.amb...@gmx.de <detlef.amb...@gmx.de>
>> >>> wrote:
>> >>>> Hi,
>> >>>>
>> >>>> I generate a .svg file. In this file the font size is tailored:
>> >>>>
>> >>>>> <g style="font-family:&apos;Times New Roman&apos;; font-size:30;"
>> >>>>
>> >>>> The browser (firefox, chrome works ok)ignores the fontsize.
>> >>>>
>> >>>> It exspects
>> >>>>> <g style="font-family:&apos;Times New Roman&apos;; font-size:30px;"
>> >>>> i.e appending a pt or px to the fontsize.
>> >>>>
>> >>>> How can I achieve this?
>> >>>> I now use
>> >>>> g.setFont(new Font("Times New Roman", Font.PLAIN, 30));
>> >>>>
>> >>>> JDK 1.6.0_18, jre6, Windows
>> >>>>
>> >>>> Thank you.
>> >>>> Cheers
>> >>>> Detlef
>> >>>>
>> >>>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail:
>> >>>> batik-users-unsubscr...@xmlgraphics.apache.org
>> >>>> For additional commands, e-mail:
>> >>>> batik-users-h...@xmlgraphics.apache.org
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
>> >> For additional commands, e-mail:
>> >> batik-users-h...@xmlgraphics.apache.org
>> >>
>> >>
>> >
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
>>
>
>
>
> --
> From my MacBook Pro
>

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org

Reply via email to