Bug 52290 - Fop offers no way to select between condensed and non-condensed font variants
Summary: Fop offers no way to select between condensed and non-condensed font variants
Status: CLOSED WONTFIX
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: fonts (show other bugs)
Version: 1.0
Hardware: PC Linux
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-06 03:35 UTC by Craig Ringer
Modified: 2012-04-30 00:17 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Ringer 2011-12-06 03:35:43 UTC
If one has a collection of faces for a font, some of which are condensed and some which are not, fop doesn't offer any way to select between them.

According to the XSL-FO standard it appears that the "font-stretch" property should be used to pick between condensed/expanded/regular faces of a font. font-stretch is documented as unimplemented in fop. The only questions about on the mailing list have referred to using font-stretch to artificially condense or expand a regular face, which is *not* what I need to do, and an idea that was rejected anyway.

It looks like Fop stores font info as (family, style, weight) triplets, where "style" here refers to oblique/regular. It doesn't seem to have to track any additional style attributes like small-caps or whether the face is a condensed or expanded face.

To support font-stretch, fop will need to:

- Identify whether a font face is condensed/expanded/regular when examining it
- Track additional font metadata, not just the basic font-triplet, treating 
  condensed and non-condensed faces as different fonts.
- Consider the value of font-stretch when matching fonts.

There are some free condensed fonts, including http://dejavu-fonts.org/ which has a variety of condensed faces, so this isn't something that requires commercial fonts (though it'll be mostly useful with them).
Comment 1 Craig Ringer 2011-12-06 03:37:55 UTC
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.

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>
Comment 2 Craig Ringer 2011-12-06 03:40:58 UTC
See also https://issues.apache.org/bugzilla/show_bug.cgi?id=52290, which
relates to misclassification of some condensed faces. Since fop seems to be
having trouble detecting the font weights too, this might not really be
related, but it's worth seeing.
Comment 3 Craig Ringer 2011-12-06 03:45:14 UTC
Whoops, that should've been https://issues.apache.org/bugzilla/show_bug.cgi?id=52289, re the inability to select between condensed and non-condensed faces.
Comment 4 Craig Ringer 2011-12-15 07:20:48 UTC
It turns out that the manual font definitions are not required. A regular directory scan for fonts will add the fully qualified face name as a fake family automatically, so if you have the font:

  MyriadPro-BlackCondIt.ttf

then presuming the file name is the same as the internal full face name, you can reference it in fop with:

  font-family="MyriadPro-BlackCondIt" font-weight="normal" font-style="normal"

Note the use of "normal" weight and slant, even though this is a black condensed oblique face. Fop appears to always register these fully-qualified font faces as normal/normal, so if you want to specify an exact face you need to give a normal weight and slant.

This is really only a workaround for the inability to properly use font-stretch, however it'll be useful for people who have small-capitals or other specialized font faces they want to be able to explicitly name.

If you're not sure what fop expects your font to be called, turn on trace logging in fop and search the log for "registering" (case insensitive) to find font names.
Comment 5 Craig Ringer 2011-12-15 07:25:44 UTC
Please flag as importance: Enhancement
Comment 6 Glenn Adams 2012-04-07 01:42:40 UTC
resetting P2 open bugs to P3 pending further review
Comment 7 Glenn Adams 2012-04-07 09:49:13 UTC
use explicit font configuration to specify distinct font family names; if a patch is provided that supports a more general solution, then it will be considered for application;
Comment 8 Glenn Adams 2012-04-30 00:14:41 UTC
batch transition resolved+wontfix to closed+wontfix
Comment 9 Glenn Adams 2012-04-30 00:17:13 UTC
batch transition resolved+wontfix to closed+wontfix; if you believe this remains a bug and can demonstrate it with appropriate input FO file and output PDF file (as applicable), then you may reopen