You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Hervé Girod <he...@club-internet.fr> on 2004/09/11 12:40:08 UTC

Problem in SVGFont class ?

Hello !

When using the svgen package to convert Java2D stuff to SVG, the default font-family declaration for each Node is always enclosed in the classic &apos constructions (for " ' "), for example :

<g ... font-family="&apos;Courier New&apos; ...

Althrough the corresponding SVG image can be opened without problem (because when a text Node is encountered, the actual font declaration coming with the text don't have this particularity), I found that this construction was a bit odd...

After browsing through the sources, I discovered that the class that is directly responsible for this &apos stuff is the SVGFont class in package svggen. In the static familyToSVG(Font font) method, we have this code :

    StringBuffer fontFamily = new StringBuffer("'");
    fontFamily.append(fontFamilyStr);
    fontFamily.append("'");

It is obvious that, when trying to write the corresponding SVG Document to a file, the XMLWriter will have to write a " ' " character, so it will transforms it to &apos;, which is perfectly normal.

What's the reason for this " ' " enclosing, is it a bug or is there a reason for that that I don't see yet ?

Re: Problem in SVGFont class ?

Posted by Hervé Girod <he...@club-internet.fr>.
Cameron McCormack wrote :

>> What's the reason for this " ' " enclosing, is it a bug or is there a
>> reason for that that I don't see yet ?
>
> It is because CSS needs values with spaces to be quoted, for example:
>
>   font-family: 'Times New Roman'
>
> I guess it just quotes everything to be safe, so it doesn't have to
> check.
>

OK, I didn't know that thing about CSS...

However, although not necessary, I think the result could be "prettier", if
the DOMUtility / XMLWriter classes check if Strings are enclosed in two " '
", and keep the two enclosing quotes like that instead of converting it to
"&apos;". Of course, this would not be really useful, as the current
behaviour have no consequence, except on the "human readability" of the XML
text output.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org


Re: Problem in SVGFont class ?

Posted by Cameron McCormack <ca...@aka.mcc.id.au>.
Hi Herv.

Herv Girod:
> What's the reason for this " ' " enclosing, is it a bug or is there a
> reason for that that I don't see yet ?

It is because CSS needs values with spaces to be quoted, for example:

  font-family: 'Times New Roman'

I guess it just quotes everything to be safe, so it doesn't have to
check.

Cameron

-- 
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org