W3C home > Mailing lists > Public > www-svg@w3.org > August 2001

Re: Does a font family with a period in it need apos around it?

From: Randall Parker <randall@nls.net>
Date: Tue, 21 Aug 2001 15:33:08 -0700
Message-Id: <200108212233.SAA10163@tux.w3.org>
To: "www-svg@w3.org" <www-svg@w3.org>, "Chris Lilley" <chris@w3.org>
Chris,

A comment of my own about all this: I've been doing a lot of experiments with Java on my 
system to see which font families it labels each of various java.awt.Font objects I create 
with different arguments to the constructor. I think I understand why it is that Batik is 
creating a font family (sansserif.italic) that seems odd. I need to describe a little bit of Java 
to you and I think it is relevant to understand because it points out something that perhaps 
some standards document ought to state as being bad thing to do.

In Java if I instantiate a java.awt.Font with the name "sansserif" and the style argument as 
Font.ITALIC then Java creates an object whose fontFamily is sansserif.italic and whose 
style is PLAIN. I can also instantiate a java.awt.Font with argument of "sansserif.italic" and 
Font.PLAIN and it will create a Font that again has fontFamily of sansserif.italic and againg 
has a plain style. 

But here's the twist: I can not instantiate a java.awt.Font with font argument as 
"sansserif.italic" and style of Font.ITALIC. If I do that Java says basically "I don't know what 
this is" and hence it defaults to creating an Arial font object (fontFamily, fontName, and 
PSName are all Arial). In Java (or in some TTF file? I don't know) there is a font family 
"sansserif.italic" that has plain style and that does NOT have an italics style. Visually 
"sansserif.italic" plain style is really italic in appearance. 

This seems to be an abuse. This is the sort of thing that, IMO, standards writers would tell 
people not to do it if only occurred to the standards writers that people might do such a 
thing in the first place. It causes unexpected behaviors. It is a reason why different tools are 
going to generate different output from the same document. I also think it explains why 
Batik, which is written in Java after all, is generating a font-face tag with font-family of 
sansserif.italic.

I'd like to convince the Batik developers not to emit font-family names that end in .italic, 
.bold, or .bolditalic. Better to move that part of it over to the font-style where it belongs. But 
my guess is they are going to claim they are not doing anything that violates a standard. 

Enough of my own rant.

I thought you might like to see responses I received elsewhere. First of all, I think the  David 
Woolley <david@djwhome.demon.co.uk> response is from a message I posted on Yahoo 
SVG Developers list (not sure since it came in private e-mail):


	It's an error in Batik, and it is a violation of CSS2 rather 
	than specifically SVG.

	See appendix D of the CSS2 specification:

	amongst other things, attribute values may be strings or
	idents.  Strings are between matchedd 's or "s and may not
	contain an unescaped instance of the corresponding quote.

	idents are a name start character followed by:
[a-z0-9-]|{nonascii}|{escape}

	[DJW:]  which doesn't permit unescaped .s.

	Note that sans-serif, with a hyphen, is a reserved name
	and this attribute is a family name, so should not normally 
	include modifiers like italic or bold (CSS2 14.4.6).



Then from the Batik list Stephane Hillion <shillion@ilog.fr> responded arguing that it is not a 
Batik bug. I think Stephane may be a Batik developer:

On Thursday 16 August 2001 16:32, Randall Parker wrote:
> Stephane,
>
> Are you a Batik committer? Is any Batik committer reading this message?
>
> I posted elsewhere and got this response that argues it is a bug in Batik.
> In fact, it is two separate bugs since it is an illegal family name as
> well. This response came from David Woolley <david@djwhome.demon.co.uk>
>
> 	It's an error in Batik, and it is a violation of CSS2 rather
> 	than specifically SVG.
>
> 	See appendix D of the CSS2 specification:
>
> 	amongst other things, attribute values may be strings or
> 	idents.  Strings are between matchedd 's or "s and may not
> 	contain an unescaped instance of the corresponding quote.

This is not what the grammar describe. A property value can be a list of what 
you want separated by any operator including white-spaces. So for example:

  font-family: Times New Roman, serif;

is a well-formed property declaration.

And according to the CSS2 spec, the unquoted name Times New Roman is valid:

<family-name>
The name of a font family of choice. In the previous example, "Baskerville", 
"Heisi Mincho W3", and "Symbol" are font families. Font family names 
containing whitespace should be quoted. If quoting is omitted, any whitespace 
characters before and after the font name are ignored and any sequence of 
whitespace characters inside the font name is converted to a single space.


>
> 	idents are a name start character followed by:
> [a-z0-9-]|{nonascii}|{escape}
>
> 	[DJW:]  which doesn't permit unescaped .s.
>
> 	Note that sans-serif, with a hyphen, is a reserved name
> 	and this attribute is a family name, so should not normally
> 	include modifiers like italic or bold (CSS2 14.4.6).

It is right, but sansserif.italic is a valid family name, equivalent to 
"sansserif.italic" since there is no rule to says that a system font name 
can't contain a dot or one of the CSS reserved keywords.
And it is not an error to refer to an unavailable font.


On Sat, 18 Aug 2001 11:46:13 +0200, Chris Lilley wrote:

>
>
>Randall Parker wrote:
>> 
>> I'm trying to figure out whether Adobe SVGViewer or Apache Batik has a
>> bug with
>> the handling of font family names. I'm hoping someone here can say
>> whether
>> a font family name with a period in it (eg sansserif.italic) should be
>> 
>> quoted by apostrophes.
>
>Firstly, quoting is never wrong.
>
>Secondly, there is perhaps the potential for confusion as sans-serif is
>a reserved name for a generic font family and is thus never quoted.
>However, I would expect the hyphen to be sufficient disambiguation
>there. *Unless* the implementation tries to compact strings by making
>them all the same case, removing spaces or other punctuation, removing
>vowels, etc (there was an SVG implementation which did this, no longer
>in widespread use).
>
>
>> I have an SVG file output by Batik that the Batik Viewer can view but
>> that the Adobe SVG Viewer can't view.
>> 
>> It appeas that Adobe's SVGViewer considers this line to be bad because
>> of the .italic as part of the font family name:
>> 
>> <font-face ascent="100.52667" descent="21.970367" units-per-em="100"
>> style="font-family:sansserif.italic; font-style:italic;
>> font-weight:normal;" />
>> 
>> Changing to
>> font-family:sansserif;
>> removes the bad CSS error that SVGViewer reports as an IE plug-in:
>> bad CSS property or descriptor declaration
>
>OK but does it make it use that font, or just stop complaining about its
>syntax?
>
>> 
>> I noticed something else too. There were three occurrences of
>> sansserif.italic. The later 2 were in text tags:
>> 
>> <text x="227.9677734375" y="254.92665100097656" style="font-size:12;
>> font-family:&apos;sansserif.italic&apos;; font-style:italic;
>> stroke:none;">
>> 
>> Note that they have the ampersand apostrophes around them. So then I
>> changed the font-face font-family attribute to have the ampersand
>> apostrophe
>
>That makes no difference. These predefined entities like &amp; &lt; etc
>get converted to & < etc during parsing. You could just as easily put  '
>instead of &apos; - clearly though, you can't nest " inside ".
>
>> 
>> <font-face ascent="100.52667" descent="21.970367" units-per-em="100"
>> style="font-family:
>> &apos;sansserif.italic&apos;; font-style:italic; font-weight:normal;"
>> />
>> 
>> Now SVGViewer no longer generates an error message about this SVG
>> file.
>
>That is worrying. It implies a string match on the unparsed string.
>
>> So is it a bug in Batik for the font-face font-family to not put the
>> apos chars around a font family that has a dot in the middle of it? 
>
>No. But I would suggest that font family names always be quoted. It does
>no harm, and is never wrong. When used inside an xml attribute value, if
>the attribute value is delimited by " use ' and if it is delimited by '
>use ".
>
>> Or is it a bug in Adobe SVG Viewer?
>
>Possibly, needs more testing. But your two questions (is it a bug in
>batik not to insert &apos; is it a bug in adobe) do not coverr all the
>possibilities.
> 
>> Some relevant links to the specs. They don't say precisely enough what
>> are legal
>> font family names and when the font family names have to be quoted.
>> They talk about white space. But since period is not white space then
>> is the apos not needed?
>
>Good catch, I will review this section. If it is ambiguous them the CSS
>WG can discuss an appropriate clarification for the eratta.
>
>
>-- 
>Chris
>
>
Received on Tuesday, 21 August 2001 18:33:03 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:20 GMT