# Xetex support for .otf features

In the .otf fonts where they are present, the Contextual Alternate (calt) and Localized Forms (locl) functions work fine in LibreOffice.

Experiment: I create a quoteright.fr glyph with a large bearing and impose a calt because quoteright glyph in Italian and in French is replaced by quoteright.fr glyph.

With LibreOffice the difference is evident: for the first line I set the Italian language, for the second line the English language (without bearing):

Instead with Xetex I can not enable these functions.

If I do not specify anything in the font features, the contextual substitution rule does not work.

If I enter Contextuals = Alternate I receive the message:

Package fontspec Warning: OpenType feature 'Contextuals = Alternate' (calt) not
(fontspec) available for font 'GaramondPremPro' with script
(fontspec) 'Latin' and language 'Default'.


and again the contextual replacement rule does not work.

Here is Xetex (first line in Italian, second in English

with the following code:

\documentclass {article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX,Numbers=OldStyle]{Garamond Premier Pro}
\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{italian}
\setotherlanguages{english}

\begin{document}

I'I N'P

\begin{english}I'I N'P\end{english}
\end {document}


What can you depend on? Is there an error or a lack in my code?

Thank you

PS

otfinfo -f recognizes only system-wide features, and not localized ones (neither calt nor locl), that are also present in the font if I check it with FontLab or FontForge:

samiel@darkstar:~/work\$ otfinfo --features font.otf

aalt    Access All Alternates
c2sc    Small Capitals From Capitals
cpsp    Capital Spacing
dnom    Denominators
frac    Fractions
kern    Kerning
liga    Standard Ligatures
lnum    Lining Figures
numr    Numerators
onum    Oldstyle Figures
pnum    Proportional Figures
smcp    Small Capitals
sups    Superscript
tnum    Tabular Figures
zero    Slashed Zero


PS2

I tried various possibilities. The following one:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX,Numbers=OldStyle,Language=Italian,RawFeature={+calt}]{Garamond Premier Pro}
\usepackage{polyglossia}
%\setmainlanguage[babelshorthands=true]{italian}
\setotherlanguages{english}

\begin{document}

I'I N'P

\begin{english}I'I N'P\end{english}

\end{document}


produces the calt all over the document, not only for Italian and French languages (as in the font localized calt rule).

If I set

\setmainfont[Ligatures=TeX,Numbers=OldStyle,RawFeature={+calt}]{Garamond Premier Pro}
\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{italian}


the replacement is never produced

I tried various possibilities. The following one:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX,Numbers=OldStyle,Language=Italian,RawFeature={+calt}]{Garamond Premier Pro}
\usepackage{polyglossia}
%\setmainlanguage[babelshorthands=true]{italian}
\setotherlanguages{english}

\begin{document}

I'I N'P

\begin{english}I'I N'P\end{english}

\end{document}


produces the calt all over the document, not only for Italian and Frenc (as inthe font cal rule.

If I set

\setmainfont[Ligatures=TeX,Numbers=OldStyle,RawFeature={+calt}]{Garamond Premier Pro}
\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{italian}


the replacement is never produced

• did you try to change the language? \setmainfont[Ligatures=TeX,Numbers=OldStyle,Language=Italian]{GaramondPremPro}? Dec 30, 2018 at 19:50
• Yes, but nothing chages. It takes general font settings and not calt Dec 30, 2018 at 20:04
• Well without the font it is difficult to test. If your feature needs locl you could activate it with the RawFeature key. Dec 30, 2018 at 20:13
• I happens with all other otf I tried Dec 30, 2018 at 20:21
• If you know a free font which can be used for tests, add the info to the question. Dec 30, 2018 at 20:36

The font in your comment works fine for me:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Language=Italian]{SamielPro.otf}
\setsansfont[]{SamielPro.otf}

\begin{document}

I'I N'P

\sffamily
I'I N'P

\end{document}


With lualatex it doesn't work, there one need to add the calc-feature explicitly:

\setmainfont[Language=Italian,RawFeature=+calt]{SamielPro.otf}


A language depending call could be setup with babel and \babelfont:

\documentclass{article}
\usepackage{fontspec}
\usepackage[english,italian]{babel}
\babelfont{rm}[Ligatures=TeX]{SamielPro.otf}

% for luatex:
%\babelfont[italian]{rm}[RawFeature=+calt,Ligatures=TeX]{SamielPro.otf}

\begin{document}

I'I N'P

\selectlanguage{english}
I'I N'P

\end{document}

• sorry, I don't understand your usage of \sfamily Dec 30, 2018 at 21:19
• I simply wanted the two variant under different commands. Dec 30, 2018 at 21:20
• but if I've an Italian or French text and an English one? Why specifying the languages as in my exemples above it doesn't work? It's not a sans but a serif font.... I'm rather confused Dec 30, 2018 at 21:21
• Well the warning seems to be wrong, the numbers are oldstyle. Make a bug report at the fontspec site. Dec 30, 2018 at 23:30
• but I've no more smallcaps, no more oldstyle proportional numbers (only monospaced), no more lining numbers... Ok, I'll write to the fontspec site Dec 30, 2018 at 23:38