# How to add LineFinal (falt) or WordFinal (fina) features to Garamond Premier Pro on XeLaTeX?

I'm still familiarizing myself with XeLaTeX and the fontspec package. I would like to access the OpenType feature LineFinal or WordFinal with the Garamond Premier Pro font from Adobe.

For example, I would like to obtain the following when ending a line or a paragraph :

So I tried adding the Contextuals=WordFinal option to \setmainfont but instead I get the following :

and the console says this :

*************************************************
* fontspec warning: "icu-feature-not-exist-in-font"
*
* OpenType feature 'Contextuals=WordFinal' (+fina) not available for font
* 'Garamond Premier Pro/BI' with script 'Latin' and language 'Default'.
*************************************************


which usually does not bother me because the same warning appears for Historic, Rare or TeX Ligatures options and they do work fine.

Here's the MWE for testing :

\documentclass{book}
\usepackage[urw-garamond]{mathdesign}
\usepackage[francais]{babel}
\usepackage[no-math]{fontspec}
\usepackage{amsmath}
\setmainfont[Ligatures={Rare,TeX,Historic}, Contextuals=WordFinal]{Garamond Premier Pro}

\begin{document}
It's easy to be polite.\smallskip

Next paragraph starts here.
\end{document}


To obtain the "e.end" of the first pic, instead of writing polite I wrote polit\XeTeXglyph249 which works well. But it will become really tedious if I have to do this every time... Is there a simple solution?

EDIT 1

Seems that AGPPro doesn't feature the fina nor the falt features. Checked it using otfinfo -f on a terminal :

\$ otfinfo -f /Library/Fonts/Garamond\ Premier\ Pro/GaramondPremrPro.otf

aalt    Access All Alternates
c2sc    Small Capitals From Capitals
calt    Contextual Alternates
case    Case-Sensitive Forms
cpsp    Capital Spacing
dlig    Discretionary Ligatures
dnom    Denominators
frac    Fractions
hist    Historical Forms
kern    Kerning
liga    Standard Ligatures
lnum    Lining Figures
numr    Numerators
onum    Oldstyle Figures
ordn    Ordinals
ornm    Ornaments
pnum    Proportional Figures
salt    Stylistic Alternates
sinf    Scientific Inferiors
size    Optical Size
smcp    Small Capitals
ss01    Stylistic Set 1
ss02    Stylistic Set 2
ss03    Stylistic Set 3
ss04    Stylistic Set 4
subs    Subscript
sups    Superscript
tnum    Tabular Figures
zero    Slashed Zero


Any solutions?

I would settle if I could at least use the feature at the end of paragraphs (as they may be the only places where I actually use the feature).

-
@NilsL Good point... Why is this all so tricky?! Anyways what do you mean by RawFeature? –  jrojasqu Mar 25 '13 at 9:59
@NilsL Not again... I just switched from Lua to Xe because my font didn't work correctly when compiled with Lua (most of the features don't work). But maybe it's the sole solution here... –  jrojasqu Mar 25 '13 at 10:02
It's only tricky if you expect OpenType, in it's full range of features, to harmonize perfectly, out of the box, with a typesetting application designed decades before OpenType saw the light of day. InDesign users will find this not tricky at all, simply because the two were basically made for each other :) –  Nils L Mar 25 '13 at 10:02
Maybe it doesn't matter to you, but these sorts of 'stretched' letters were only used (sometimes) to fill out a line so that the line was properly justified, especially in manuscripts / early printings where the margins were narrow. It might look odd to drop them in at the end of any paragraph whatsoever. ... In other words, a 'manual' solution might be preferred since you will need to make an aesthetic judgment call in each case! –  jon Mar 26 '13 at 3:31
@jrojasqu -- a good place to browse is the 900 000+(!) digitalizations of manuscripts and incunabula editions at the Bavarian State Library. The website is mostly in German, though I tried to give a link for the English versions. –  jon Mar 26 '13 at 14:07

1. The tech specs or manual that come with the font should include a list of what features the font has and how to access them. This list here says there is, for example, no falt or fina feature in Garamond Premier Pro. This would explain why what you're doing has no effect. fontspec can't do more than what's available in the font.

2. The word-final forms you're looking for might a available via a different feature tag, though. Consider this example using Minion:

\documentclass{scrartcl}
\usepackage{fontspec}

\setmainfont[StylisticSet=2]{Minion Pro}

\begin{document}
politee
\end{document}


As you can see from Minion Pro's feature file, this is, however, not the smart kind of line-end substitution you want.

feature ss02 {
ignore sub @END_OFF' @WORD;
sub @END_OFF' by @END_ON;
} ss02;


3. Whenever fontspec is giving you trouble accessing a feature that should be available, RawFeature might help. In addition to the font's documentation, Eddie Kohler's otfinfo is a useful tool to check what features a font has and what their tags are.

4. With Lua, fontspec is able to use OpenType feature files. You can write your own to add custom substitution rules and other stuff.

5. Fancy things can be done using OpenType fonts. Not all of them can be done by all TeX engines. The fontspec manual provides information on what's possible in Xe and/or Lua respectively. When choosing an engine, other factors might be more important, though, than ease of access to line-end subs. Apart from that -- the more fancyness you want, the more likely it'll be that a system other than TeX will be a better choice, as fancyness isn't among the applications TeX was designed for IMHO.

-
You're right, I just checked what RawFeatures are available running mtxrun --script fonts --info --list --name --pattern="*GaramondPremrPro*" on a terminal. fina and falt are not there. Thanks anyways, I'll have to look for another solution though. –  jrojasqu Mar 25 '13 at 10:34

Following some comments, elements from another answers in this forum and a little research on typography, I found out that the features I wanted are only to be used in particular cases. These cases are not really abundant so the solution I propose can be used only when needed.

This solution involves the \XeTeXglyph function, which can be used to access a particular glyph that one can't specifically type with the keyboard. This means of course that a compilation using XeLaTeX is needed. (Or maybe I'm wrong?).

I added the following commands to the preamble :

\newcommand{\af}{\XeTeXglyph247}
\newcommand{\df}{\XeTeXglyph248}
\newcommand{\ef}{\XeTeXglyph249}
\newcommand{\hf}{\XeTeXglyph250}
\newcommand{\mf}{\XeTeXglyph251}
\newcommand{\nf}{\XeTeXglyph252}


and so on for every alternate glyph I wish to use. This way it is easier to call the alternate glyphs to "emulate" a WordFinal or LineFinal procedure simply calling \af, \df, \ef, etc, at the end of a word, sentence or paragraph :

NOTE

I did try to use the RawFeature options from the fontspec package to load the "Stylistic Sets".

For AGPPro these are the ones available :

ss01    Stylistic Set 1
ss02    Stylistic Set 2
ss03    Stylistic Set 3
ss04    Stylistic Set 4


But neither one of them had a WordFinal or LineFinal feature embedded.

-