You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Oleg Tkachenko <ol...@multiconn.com> on 2002/04/01 16:02:17 UTC

font-family and font names list

Hello there!

I'm trying the following object in fop 0.20.3:

<fo:inline font-style="italic" font-family="Arial, Helvetica, Geneva" 
font-size="11.0pt">Tuesday, Mar. 5, 2002 12:33</fo:inline>

And got error message:
[ERROR]: unknown font Arial, Helvetica, Geneva,normal,normal so 
defaulted font to any
[ERROR]: defaulted font to any,normal,normal

Is it a bug/unsupported feature or am I wrong with something here ?

-- 
Oleg Tkachenko
Multiconn International, Israel


Re: font-family and font names list

Posted by Chuck Paussa <Ch...@systems.dhl.com>.
Oleg,

You are right. The CSS method of defining font family lists is not 
supported by FOP (Mainly because they haven't figured out a good way to 
parse the list.) You can only say font-family="Arial" or 
font-family="TimesNewRoman" not both.

Chuck Paussa

Oleg Tkachenko wrote:

> Hello !
>
> Yes, I do define fonts in userconfig.xml, the problem is in using list 
> of font names in font-family trait, like this one:
> font-family="Arial TimesNewRoman", it seems that doesn't work.
>
> Togan Muftuoglu wrote:
>
>> * Oleg Tkachenko; <ol...@multiconn.com> on 01 Apr, 2002 wrote:
>>
>>> Wayne Elliott wrote:
>>> [ERROR]: unknown font sans-serif, Arial, Helvetica, 
>>> Geneva,italic,normal so defaulted font to any
>>>
>>>> then try
>>>> ... font-family=" sans-serif" 
>>>
>>>
>>> no error, it works.
>>>
>>> Well, it seems to me Mr. J.Pietschmann is right, fop gets it as 
>>> string so font list is unsupported feature.
>>>
>>
>> Sorry I may have missed the thread but if you use a onfiguration file
>> and define the fonts and their names in it you can use these fonts,
>> currently I am using truetype fonts by this method here is --
>> Togan Muftuoglu
>>
>> snipped from userconfig.xml
>>
>> <!--
>> ************************************************************************
>>  Add fonts here
>> ************************************************************************
>> -->
>> <font metrics-file="ttfarial.xml" kerning="yes" embed-file="arial.ttf">
>>    <font-triplet name="Arial" style="normal" weight="normal"/>
>>    <font-triplet name="ArialMT" style="normal" weight="normal"/>
>> </font>
>> <font metrics-file="ttfarialbd.xml" kerning="yes" 
>> embed-file="arialbd.ttf">
>>    <font-triplet name="Arial" style="normal" weight="bold"/>
>>    <font-triplet name="ArialMT" style="normal" weight="bold"/>
>> </font>
>> <font metrics-file="ttfariali.xml" kerning="yes" 
>> embed-file="ariali.ttf">
>>    <font-triplet name="Arial" style="italic" weight="normal"/>
>>    <font-triplet name="ArialMT" style="italic" weight="normal"/>
>> </font>
>> <font metrics-file="ttfarialbi.xml" kerning="yes" 
>> embed-file="arialbi.ttf">
>>    <font-triplet name="Arial" style="italic" weight="bold"/>
>>    <font-triplet name="ArialMT" style="italic" weight="bold"/>
>> </font>
>>
>> <font metrics-file="times.xml" kerning="yes" embed-file="times.ttf">
>>     <font-triplet name="TimesNewRoman" style="normal" weight="normal"/>
>>     <font-triplet name="Times Roman"  style="normal" weight="normal"/>
>> </font>
>>
>> <font metrics-file="timesi.xml" kerning="yes" embed-file="timesi.ttf">
>>     <font-triplet name="TimesNewRoman" style="italic" weight="normal"/>
>>     <font-triplet name="Times Roman"  style="italic" weight="normal"/>
>> </font>
>> <font metrics-file="timesbd.xml" kerning="yes" embed-file="timesbd.ttf">
>>     <font-triplet name="TimesNewRoman" style="normal" weight="bold"/>
>>     <font-triplet name="Times Roman"  style="normal" weight="bold"/>
>> </font>
>> <font metrics-file="timesbi.xml" kerning="yes" embed-file="timesbi.ttf">
>>     <font-triplet name="TimesNewRoman" style="italic" weight="bold"/>
>>     <font-triplet name="Times Roman"  style="italic" weight="bold"/>
>> </font>
>>
>> </configuration>
>
>
>




Re: font-family and font names list

Posted by Oleg Tkachenko <ol...@multiconn.com>.
Hello !

Yes, I do define fonts in userconfig.xml, the problem is in using list 
of font names in font-family trait, like this one:
font-family="Arial TimesNewRoman", it seems that doesn't work.

Togan Muftuoglu wrote:
> * Oleg Tkachenko; <ol...@multiconn.com> on 01 Apr, 2002 wrote:
> 
>> Wayne Elliott wrote:
>> [ERROR]: unknown font sans-serif, Arial, Helvetica, 
>> Geneva,italic,normal so defaulted font to any
>>
>>> then try
>>> ... font-family=" sans-serif" 
>>
>> no error, it works.
>>
>> Well, it seems to me Mr. J.Pietschmann is right, fop gets it as string 
>> so font list is unsupported feature.
>>
> 
> Sorry I may have missed the thread but if you use a onfiguration file
> and define the fonts and their names in it you can use these fonts,
> currently I am using truetype fonts by this method here is --
> Togan Muftuoglu
> 
> snipped from userconfig.xml
> 
> <!--
> ************************************************************************
>  Add fonts here
> ************************************************************************
> -->
> <font metrics-file="ttfarial.xml" kerning="yes" embed-file="arial.ttf">
>    <font-triplet name="Arial" style="normal" weight="normal"/>
>    <font-triplet name="ArialMT" style="normal" weight="normal"/>
> </font>
> <font metrics-file="ttfarialbd.xml" kerning="yes" embed-file="arialbd.ttf">
>    <font-triplet name="Arial" style="normal" weight="bold"/>
>    <font-triplet name="ArialMT" style="normal" weight="bold"/>
> </font>
> <font metrics-file="ttfariali.xml" kerning="yes" embed-file="ariali.ttf">
>    <font-triplet name="Arial" style="italic" weight="normal"/>
>    <font-triplet name="ArialMT" style="italic" weight="normal"/>
> </font>
> <font metrics-file="ttfarialbi.xml" kerning="yes" embed-file="arialbi.ttf">
>    <font-triplet name="Arial" style="italic" weight="bold"/>
>    <font-triplet name="ArialMT" style="italic" weight="bold"/>
> </font>
> 
> <font metrics-file="times.xml" kerning="yes" embed-file="times.ttf">
>     <font-triplet name="TimesNewRoman" style="normal" weight="normal"/>
>     <font-triplet name="Times Roman"  style="normal" weight="normal"/>
> </font>
> 
> <font metrics-file="timesi.xml" kerning="yes" embed-file="timesi.ttf">
>     <font-triplet name="TimesNewRoman" style="italic" weight="normal"/>
>     <font-triplet name="Times Roman"  style="italic" weight="normal"/>
> </font>
> <font metrics-file="timesbd.xml" kerning="yes" embed-file="timesbd.ttf">
>     <font-triplet name="TimesNewRoman" style="normal" weight="bold"/>
>     <font-triplet name="Times Roman"  style="normal" weight="bold"/>
> </font>
> <font metrics-file="timesbi.xml" kerning="yes" embed-file="timesbi.ttf">
>     <font-triplet name="TimesNewRoman" style="italic" weight="bold"/>
>     <font-triplet name="Times Roman"  style="italic" weight="bold"/>
> </font>
> 
> </configuration>


-- 
Oleg Tkachenko
Multiconn International, Israel


Re: font-family and font names list

Posted by Togan Muftuoglu <to...@users.sourceforge.net>.
* Oleg Tkachenko; <ol...@multiconn.com> on 01 Apr, 2002 wrote:
>Wayne Elliott wrote:
>[ERROR]: unknown font sans-serif, Arial, Helvetica, Geneva,italic,normal 
>so defaulted font to any
>
>>then try
>>... font-family=" sans-serif" 
>no error, it works.
>
>Well, it seems to me Mr. J.Pietschmann is right, fop gets it as string 
>so font list is unsupported feature.
>

Sorry I may have missed the thread but if you use a onfiguration file
and define the fonts and their names in it you can use these fonts,
currently I am using truetype fonts by this method here is 
--
Togan Muftuoglu

snipped from userconfig.xml

<!--
************************************************************************
  Add fonts here
************************************************************************
-->
<font metrics-file="ttfarial.xml" kerning="yes" embed-file="arial.ttf">
    <font-triplet name="Arial" style="normal" weight="normal"/>
    <font-triplet name="ArialMT" style="normal" weight="normal"/>
 </font>
 <font metrics-file="ttfarialbd.xml" kerning="yes" embed-file="arialbd.ttf">
    <font-triplet name="Arial" style="normal" weight="bold"/>
    <font-triplet name="ArialMT" style="normal" weight="bold"/>
 </font>
 <font metrics-file="ttfariali.xml" kerning="yes" embed-file="ariali.ttf">
    <font-triplet name="Arial" style="italic" weight="normal"/>
    <font-triplet name="ArialMT" style="italic" weight="normal"/>
 </font>
 <font metrics-file="ttfarialbi.xml" kerning="yes" embed-file="arialbi.ttf">
    <font-triplet name="Arial" style="italic" weight="bold"/>
    <font-triplet name="ArialMT" style="italic" weight="bold"/>
 </font>

<font metrics-file="times.xml" kerning="yes" embed-file="times.ttf">
	<font-triplet name="TimesNewRoman" style="normal" weight="normal"/>
	<font-triplet name="Times Roman"  style="normal" weight="normal"/>
</font>

<font metrics-file="timesi.xml" kerning="yes" embed-file="timesi.ttf">
	<font-triplet name="TimesNewRoman" style="italic" weight="normal"/>
	<font-triplet name="Times Roman"  style="italic" weight="normal"/>
</font>
<font metrics-file="timesbd.xml" kerning="yes" embed-file="timesbd.ttf">
	<font-triplet name="TimesNewRoman" style="normal" weight="bold"/>
	<font-triplet name="Times Roman"  style="normal" weight="bold"/>
</font>
<font metrics-file="timesbi.xml" kerning="yes" embed-file="timesbi.ttf">
	<font-triplet name="TimesNewRoman" style="italic" weight="bold"/>
	<font-triplet name="Times Roman"  style="italic" weight="bold"/>
</font>

</configuration>






-- 




Re: font-family and font names list

Posted by Oleg Tkachenko <ol...@multiconn.com>.
Wayne Elliott wrote:

> Try putting sans-serif at the end
> 
> ... font-family="Arial, Helvetica, Geneva, sans-serif" 

[ERROR]: unknown font Arial, Helvetica, Geneva, sans-serif,italic,normal 
so defaulted font to any


> 
> then try putting it at the beginning
> 
> ... font-family=" sans-serif, Arial, Helvetica, Geneva" 

[ERROR]: unknown font sans-serif, Arial, Helvetica, Geneva,italic,normal 
so defaulted font to any

> 
> then try
> 
> ... font-family=" sans-serif" 
no error, it works.

Well, it seems to me Mr. J.Pietschmann is right, fop gets it as string 
so font list is unsupported feature.

-- 
Oleg Tkachenko
Multiconn International, Israel


Re: font-family and font names list

Posted by Wayne Elliott <wp...@iinet.net.au>.
Oleg 

My understanding is that the list of fonts are iterated through until
an existing font is found. Preferred fonts are put first. 

I don't know how FOP locates fonts or if it can be given some clues.

Try putting sans-serif at the end

... font-family="Arial, Helvetica, Geneva, sans-serif" 

then try putting it at the beginning

... font-family=" sans-serif, Arial, Helvetica, Geneva" 

then try

... font-family=" sans-serif" 

I'd be interested in the results you get.

WPE

----- Original Message ----- 
From: "Oleg Tkachenko" <ol...@multiconn.com>
To: <fo...@xml.apache.org>
Sent: Monday, April 01, 2002 10:02 PM
Subject: font-family and font names list


> Hello there!
> 
> I'm trying the following object in fop 0.20.3:
> 
> <fo:inline font-style="italic" font-family="Arial, Helvetica, Geneva" 
> font-size="11.0pt">Tuesday, Mar. 5, 2002 12:33</fo:inline>
> 
> And got error message:
> [ERROR]: unknown font Arial, Helvetica, Geneva,normal,normal so 
> defaulted font to any
> [ERROR]: defaulted font to any,normal,normal
> 
> Is it a bug/unsupported feature or am I wrong with something here ?
> 
> -- 
> Oleg Tkachenko
> Multiconn International, Israel
> 
> 

Re: POLITICAL: font-family and font names list

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Christopher R. Maden wrote:
>>I *hate* CSS for the havoc it wrecked on
>>other otherwise quite sensible standards.
> Sorry - responsibility for this lies squarely with the XSL WG.

Well, i should have said "I hate CSS syntax".
IMHO it would have been better to abandon the
current syntax and develop an XMLified form,
which would have fitted much better into XHTML,
SVG and XSLFO. The CSS WG is responsiible for
missing this great chance.
Bad luck.

Regards
J.Pietschmann


POLITICAL: font-family and font names list

Posted by "Christopher R. Maden" <cr...@maden.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 06:42 1/4/02, J.Pietschmann wrote:
>I remember a post which basically said that font lists
>are a last minute addendum to XSLFO imposed for CSS
>compatibility. I *hate* CSS for the havoc it wrecked on
>other otherwise quite sensible standards.

Sorry - responsibility for this lies squarely with the XSL WG.

Compatibility with CSS was a goal: that is, given a CSS stylesheet for an 
XML document type, it should be possible to programmatically generate an 
equivalent XSL stylesheet.  That did not require that CSS properties or 
syntax be adopted wholesale, but that was done anyway.  I can't really tell 
you why - I was there, and it's a bit of a mystery to me.

~Chris
- -- 
Christopher R. Maden, Principal Consultant, crism consulting
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA
-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Privacy 6.5.8

iQA/AwUBPKkOKKxS+CWv7FjaEQJfmwCfVVse71h1Ry5tbWyh6ffG/LkI4uMAoNiX
dYUGLaCvjttPeE4VBQTAbBpU
=/iMc
-----END PGP SIGNATURE-----


Re: font-family and font names list

Posted by "Peter B. West" <pb...@powerup.com.au>.
  Joerg,

I share your opinion about the detrimental effects of CSS on the spec, 
or rather, as Chris points out, of the manner in which CSS compatibility 
was introduced

"font-family" is especially nasty, not only because it can have a 
comma-separated list of (family-name|generic-family) items, but also 
(vale Dudley Moore) because the family-name elements can contain spaces.

The existing code defines a Property class and ListProperty that extends 
it.  parseProperty() prepares a ListProperty and starts the parsing by 
calling parseAdditiveExpr(), which returns a Property.  If TOK_EOF is 
pending, check the ListProperty.  If it is null, the just-generated 
Property is returned, else the Property is appended to the ListProperty, 
and the ListProperty is returned.

If TOK_EOF is not pending, there is more of the expression to parse,  so 
add the Property to the ListProperty and loop on the call to 
parseAdditiveExpr() to parse the next value.  On the face of it, this 
parser cannot deal with a comma-separated list at all, except as a list 
of args to a function call.  The looping behaviour is for 
space-separated values.   I am at a bit of a loss to explain the error, 
though.  I would expect to see a "syntax error" PropertyException. 
 Maybe I missed something in the parser.  Maybe all that follows is 
redundant.

My approach is to define a PropertyValue interface, implemented by each 
of the property value types, and PropertyValueList which extends 
LinkedList and implements PropertyValue.  The elements of the LinkedList 
are PropertyValues.   (This is close to the existing arrangement, where 
ListProperty extends Property, and the elements of ListProperty are 
instances of Property.)

Modify PropertyParser.parse() to return a PropertyValue, and change the 
basic parse loop.   Like the existing code, prepare a PropertyValueList 
and start the parsing, receiving a PropertyValue.  If EOF is pending 
after the call to parseAdditiveExpr(), and the PropertyValueList is 
empty, return the PropertyValue, else add the PropertyValue to the 
PropertyValueList and return that.

However, when EOF is not pending, check for COMMA pending.  If so, we 
are parsing a comma-separated list, presumably.  Discard the comma, add 
the PropertyValue to the PropertyValueList, and loop on the call to 
parseAdditiveExpr().  If COMMA is not pending, we are parsing a 
space-separated list, so call parseSublist(Property) with the 
just-returned Property as the argument which will become the first 
element of the sublist.  The parseSublist() call returns a 
PropertyValueList when the expression is exhausted, or when a comma 
separator is encountered.  This sublist is appended to the parent 
PropertyValueList.

This allows two types of list in the expression to be distinguished.  A 
PropertyValueList returned by the parser contains, at the top level, 
comma-separated elements.  If any of these elements, including the only 
element, are themselves PropertyValueLists, they contain space-separated 
lists of elements.  The syntax of the expressions only requires, as far 
as I can see, these two levels.  In the case of a font-family expression 
like, say,
"Times New Roman, New Century Schoolbook, serif",
the returned PropertyListValue would contain three elements: 
PropertyValueList, PropertyValueList, NCName, where the NCName string 
value is "serif".  The PropertyValueList elements would each contain 
three elements: NCName, NCName, NCName.  I.e., "Times" "New" "Roman" and 
"New" "Century" "Schoolbook".  Presented with such a PropertyValueList, 
the font-family property can re-construct the font-family names.

The spec explicitly allows such behaviour.  "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." (7.8.2 "font-family")

The existing code can readily be modified in the same way.  The parser 
currently returns a Property, which may be an instance of ListProperty. 
 As mentioned above, the elements of a ListProperty are Property 
instances, therefore possibly ListProperty instances.  What to do about 
the code generation, something which I am keen to remove, is beyond my 
ken, but I'm sure Karen or Keiron will find a way.

Peter

J.Pietschmann wrote:

> Oleg Tkachenko wrote:
>
>> I'm trying the following object in fop 0.20.3:
>>
>> <fo:inline font-style="italic" font-family="Arial, Helvetica, Geneva" 
>> font-size="11.0pt">Tuesday, Mar. 5, 2002 12:33</fo:inline>
>>
>> And got error message:
>> [ERROR]: unknown font Arial, Helvetica, Geneva,normal,normal so 
>> defaulted font to any
>> [ERROR]: defaulted font to any,normal,normal
>
>
> I remember a post which basically said that font lists
> are a last minute addendum to XSLFO imposed for CSS
> compatibility. I *hate* CSS for the havoc it wrecked on
> other otherwise quite sensible standards. The font list
> attribute introduces another language with a rather
> nontrivial grammar, which is incidentally incompatible
> with the expression language used for other properties.
> The parser in fop/expr doesn't obviously handle it, and
> i didn't find evidence that the font-family attribute is
> handled by another parser, the foproperties.xml declares this:
>   <property>
>     <name>font-family</name>
>     <inherited>true</inherited>
>     <datatype>String</datatype>
>     <default>sans-serif</default>
>   </property>
> So my guess is the feature is not implemented. :-(




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


Re: font-family and font names list

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Oleg Tkachenko wrote:
> Hello there!
> 
> I'm trying the following object in fop 0.20.3:
> 
> <fo:inline font-style="italic" font-family="Arial, Helvetica, Geneva" 
> font-size="11.0pt">Tuesday, Mar. 5, 2002 12:33</fo:inline>
> 
> And got error message:
> [ERROR]: unknown font Arial, Helvetica, Geneva,normal,normal so 
> defaulted font to any
> [ERROR]: defaulted font to any,normal,normal
> 
> Is it a bug/unsupported feature or am I wrong with something here ?
> 

I remember a post which basically said that font lists
are a last minute addendum to XSLFO imposed for CSS
compatibility. I *hate* CSS for the havoc it wrecked on
other otherwise quite sensible standards. The font list
attribute introduces another language with a rather
nontrivial grammar, which is incidentally incompatible
with the expression language used for other properties.
The parser in fop/expr doesn't obviously handle it, and
i didn't find evidence that the font-family attribute is
handled by another parser, the foproperties.xml declares this:
   <property>
     <name>font-family</name>
     <inherited>true</inherited>
     <datatype>String</datatype>
     <default>sans-serif</default>
   </property>
So my guess is the feature is not implemented. :-(

J.Pietschmann