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 Craig Ringer <cr...@postnewspapers.com.au> on 2011/12/05 13:37:52 UTC

Condensed fonts

Hi all

As part of some work I'm doing with fop (1.0) at the moment I need to 
select a condensed face for a font. This is proving harder than expected 
and I thought I'd seek some advice here.

This is /not/ a question about the creation of "fake condensed" faces to 
support the font-stretch property. That's not what I'm after. I have a 
full set of condensed and regular faces and don't need to fake a 
condensed face.

The problem is that fop appears to be misclassifying the font faces I 
have, and that there's no apparent way to tell fop "I want a condensed 
face" even if they were classified correctly.

I'm loading the fonts by having fop scan the directory they're in using 
the <fonts><directory> config param and it's finding them fine. However, 
Fop doesn't seem to be able to tell the difference between the condensed 
and non-condensed faces of these fonts. It also seems to think they all 
have the same weight (400) as per the log excerpts below.

So:

- Any idea why fop might think all the fonts its examining have the same 
weight and slant?
- If I have both condensed and non-condensed variants of a font, how can 
I select which face to use? The font-stretch property is what I'd expect 
to be able to use, but fop doesn't seem to be aware of font stretch. Is 
there any way I can do this?

Here's an excerpt of the log output from fop where it detects the fonts. 
The full log is at http://pastebin.com/91u9bW10 . You can see that it 
seems unable to distinguish the weights or how condensed they are:

Registering: HelveticaNeueLT Std Cn,normal,400 under F17
HelveticaNeueLT Std Cn,normal,400: Replacing HelveticaNeueLTStd-BdCn 
(priority=23) by HelveticaNeueLTStd-Cn (priority=21)
Registering: HelveticaNeueLTStd-BlkCn,normal,400 under F18
Registering: Helvetica Neue LT Std,normal,400 under F18
Helvetica Neue LT Std,normal,400: Not replacing HelveticaNeueLTStd-Cn 
(priority=21) by HelveticaNeueLTStd-BlkCn (priority=24)
Registering: HelveticaNeueLT Std Blk Cn,normal,400 under F18

By contrast, fontconfig identifies them as I'd expect:

$ fc-list | grep Neue
Helvetica Neue LT Std:style=55 Roman,Regular
Helvetica Neue LT Std,HelveticaNeueLT Std Cn:style=57 Condensed,Regular
Helvetica Neue LT Std,HelveticaNeueLT Std Blk Cn:style=97 Black 
Condensed,Regular
Helvetica Neue LT Std,HelveticaNeueLT Std Cn:style=77 Bold Condensed,Bold

These were originally OpenType fonts with CFF outlines; they were 
converted to TrueType using FontForge. They behave as expected with 
other tools including FontConfig and can be used normally in apps.

Ideas?

Will I have to manually register these fonts via the Java API 
one-by-one, coming up with a fake family name for the condensed variants 
so I can select them by family name?

--
Craig Ringer



POST Newspapers
276 Onslow Rd, Shenton Park
Ph: 08 9381 3088     Fax: 08 9388 2258
ABN: 50 008 917 717
http://www.postnewspapers.com.au/

Re: Condensed fonts

Posted by Craig Ringer <cr...@postnewspapers.com.au>.
On 12/05/2011 08:37 PM, Craig Ringer wrote:
> Hi all
>
> As part of some work I'm doing with fop (1.0) at the moment I need to 
> select a condensed face for a font. This is proving harder than 
> expected and I thought I'd seek some advice here.
Just by way of a follow-up, it appears that the issue can be worked 
around - albeit clumsily - by registering each font manually in the 
config file, specifying a different family name for condensed and 
non-condensed variants. I can then select the condensed face by asking 
for "Helvetica Neue LT Condensed" as the family. It's clunky and clumsy 
to set up, but it does work. See the generated config file snippet below 
for an example.

I recently stopped using Fop's Java API to configure my embedded fop 
instance; now I generate a temporary config file and have fop read that 
in. It's verbose and roundabout, but gives access to features like the 
<fonts><directory> directive and now the <fonts><font> directive that 
aren't exposed via the Java API. Given that, it's not too hard to 
generate these font-info directives and clone them for both renderers, 
it's just going to be a real hassle to maintain the font list.

Any idea how big a job it'd be to get fop to recognise condensed and 
expanded fonts, track that info alongside the weight and slant, and use 
font-stretch to select fonts based on it? I'm not asking someone to do 
the work for me, I'm just looking for an idea of what sort of scale the 
job would be. Major restructure throughout fop? Changes flowing 
throughout fop but not particularly complex ones except for the font 
classifier enhancements? Relatively trivial?

Here's the config file snippet I'm using to get my fonts to work in the 
mean time. In reality there are plenty more fonts, but here's how it works:

<fonts>
<font 
embed-url="file:/opt/jboss/classads/fonts/HelveticaNeueLTStd-Roman.ttf">
<font-triplet name="Helvetica Neue LT" style="normal" weight="400"/>
</font>
<font embed-url="file:/opt/jboss/classads/fonts/HelveticaNeueLTStd-Cn.ttf">
<font-triplet name="Helvetica Neue LT Condensed" style="normal" 
weight="400"/>
</font>
<font 
embed-url="file:/opt/jboss/classads/fonts/HelveticaNeueLTStd-BdCn.ttf">
<font-triplet name="Helvetica Neue LT Condensed" style="normal" 
weight="700"/>
</font>
<font 
embed-url="file:/opt/jboss/classads/fonts/HelveticaNeueLTStd-BlkCn.ttf">
<font-triplet name="Helvetica Neue LT Condensed" style="normal" 
weight="900"/>
</font>
</fonts>

--
Craig Ringer


POST Newspapers
276 Onslow Rd, Shenton Park
Ph: 08 9381 3088     Fax: 08 9388 2258
ABN: 50 008 917 717
http://www.postnewspapers.com.au/