# how to set font feature file for a specific font file and not the whole font shape

I'm looking for having my document set with specific ligatures, such as 's' replaced by 'longs', 's t' by 'longs_t' etc. and using the Linux Libertine G font.

To do this, I'm writing my text normally with 's' and I'm using a font feature file together with the fontspec package and compiling with Lualatex.

This works properly. Here if the font feature file:

#font.fea
languagesystem DFLT dflt ;
languagesystem latn dflt ;

feature oplt {
@notf = [a b c d e g j k m n o p q r u v w x y z];
sub s' @notf by longs;
sub longs longs' by s; # words don't end with longs
sub f longs' by s;     # end with fs, not f_longs
} oplt;

feature oooo {
sub s s by longs_s;
sub s s by germandbls.alt;
sub s t by longs_t;
sub s h by longs_h;
sub s i by longs_i;
sub s l by longs_l;
sub s s i by longs_longs_i;
} oooo;


here is a piece of code compiled with Lualatex:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[FeatureFile=font.fea, RawFeature=+oplt,RawFeature=+oooo]{Linux Libertine G Regular}
\begin{document}
ssi
\textit{ssi}
\end{document}


The issue I have is, this will fail. Lualatex ends with

 !LuaTeX error (file C:/Windows/Fonts/linlibertineg_it.ttf): Invalid glyph index
(gid 2335)


My understanding is that the font feature file is applied to the whole font shapes (italic, bold, etc.), but the thing is some of the glyphs I put in the feature file are present in the regular file and not in the italic/bold shapes.

That is the case for the longs_longs_i ligature, which is defined in the regular shape of Linux Libertine Graphite and not in the Italic shape. I didn't clearly find the way to use fontspec to set-up my feature file only for the regular shape and not for the other shapes.

Is there any workaround, apart from embedding the features in the font file ?

-

I don’t have Linux Libertine Graphite, but the approach I’ve used with Linux Libertine O will probably work:

\documentclass{article}
\usepackage{filecontents,fontspec}
\begin{filecontents*}{font.fea}
languagesystem DFLT dflt ;
languagesystem latn dflt ;

feature oplt {
@notf = [a b c d e g j k m n o p q r u v w x y z];
sub s' @notf by longs;
sub longs longs' by s; # words don't end with longs
sub f longs' by s;     # end with fs, not f_longs
} oplt;

feature oooo {
sub s s by longs_s;
sub s s by germandbls.alt;
sub s t by longs_t;
sub s h by longs_h;
sub s i by longs_i;
sub s l by longs_l;
} oooo;

feature zzzz {
sub s s i by longs_longs_i;
} zzzz;
\end{filecontents*}
\setmainfont[FeatureFile=font.fea,RawFeature=+oplt,RawFeature=+oooo,UprightFeatures={RawFeature=+zzzz}]{Linux Libertine O}
\begin{document}
ssi
\textit{ssi}
\end{document}


See section 7.4 of the fontspec manual for explanations.

-