Forum How do I...?

Accessing alternate glyphs in OpenType fonts

dauwhe
I'm trying to use some ornaments in an opentype font (Poetica).

I can access the ornaments with font-variant: prince-opentype(ornm), and then use the unicode base character for the ornaments in my HTML (unicode 2022, the "option-8 bullet" for us mac users).

This gives me the very first alternate from the font (GID 997), but I want GID 1006. Is there any way of getting this character?

Thanks,

Dave
mikeday
Do you know which feature it is accessed by? If it is "access all alternates" then you can add aalt(1) or aalt(2) etc. to the font-variant to access this glyph. As a last resort, you can use "content: prince-glyph-index(1006)", although it's not the preferred solution.
_savage
I think I have a similar challenge with a font I use. The Unicode for numbers 0..9 have the font glyphs for the lining figures matched, so that the generated PDF renders with those glyphs.

However, I would like to use the old style figures, in particular the descending numbers instead of the lining ones. These glyphs have no Unicode associated with them, and I'm not quite sure how to replace 0..9 in my XML with "glyph 854" .. "glyph 863" when rendered to PDF.

Similar goes with ligatures that the font provides which have no Unicode code points. The ligatures that do have Unicode code points are accessed easily by rewriting the original XML text on-the-fly using
prince-text-replace: "ffi" "\fb03" "fi" "\fb01" "ffl" "\fb04" "fl" "\fb02" "ff" "\fb00" /* "???" "\fb05" */ "st" "\fb06"; /* order is important! */

How would I do something similar with glyphs that are not accessible by Unicode?

Edited by _savage

mikeday
If the font supports the "onum" feature to access old-style figures, then you can use:
font-variant: prince-opentype(onum)

For ligatures, Prince will already apply the "liga" feature by default. But you could also try applying discretionary ligatures ("dlig") or historical ligatures ("hlig").
_savage
Thanks Mike, that sort-of works...

Are liga, dlig, and hlig mutually exclusive, or are they complementary? It seems odd that liga selects the "fi" (in "first") ligature correctly but misses "ff" (in "off"), whereas dlig misses "fi" but selects "ff." The hlig selects none.

Having said that, there seems to be a dependency on the order here:
body {
  font-variant: prince-opentype(liga);
  font-variant: prince-opentype(onum);
}
enables the old style numbers and no ligatures, swapping the two enables ligatures but no old style numbers. When I put both into a single line
body {
  font-variant: prince-opentype(onum) prince-opentype(liga);
}
then, no matter what order, only ligatures work.

What am I missing here? (Using .ttf files, not sure if that matters.)

Edited by _savage

mikeday
The "liga" feature is for ligatures that should always be applied, unconditionally. The "dlig" feature is for discretionary ligatures, which the author may or may not want to apply.

You can apply multiple features like this:
font-variant: prince-opentype(onum, liga)

There have been CSS proposals for easier ways to select different alternate glyphs, and these will probably show up in Prince at some point.
_savage
Moving the ligature discussion over into this thread, which seems more appropriate.