# fontspec for small caps and nocommon ligatures (actually, rawfeatures works, but not ligatures=NoCommon)

(This is a bit of a mess, so apologies. The final solution ended up being in a different place than I first expected. Ultimately, what was happening is a combination of a bug in Linux Libertine O, and that it appears to me that fontspec, with TTF fonts, will not respect Ligatures=Rare, etc, but will respect RawFeature=+hlig, and other equivalents. see below for fuller explanation and final working solution, though not explanation for why it worked.)

[original post] I am trying to typeset a document for someone who wants to use a handwritten font. However the font does not have bold, italic, or bold italic, so I have found 3 other appropriate fonts, and am using fontspec to switch between these. But, for small caps, he wants to use linux libertine O but vary the color. Lastly, and most importantly, it appears that LLO is using a ligature for Th, and I want to use a non-ligated version.

I can get the various colors to work, but I can't seem to apply the ligatures=NoCommon to the smallcaps font.

The code below is from lyx. The "ThStrictWurtziteFirefly"'s are there so I can see the ligatures.

OK, this is my best effort:

\fontspec{Linux Libertine O}

ThStrictWurtziteFirefly \textsc{ThStrictWurtziteFirefly}Th \textbf{Th}
\textit{Th }\textbf{\textit{Th}}\textsc{ Th }\textbf{\textsc{Th}}\textbf{\textit{
}}{\itshape {\scshape Th}}{\bfseries \itshape {\scshape Th}}

Th \textbf{Th} \textit{Th }\textbf{\textit{Th}}\textsc{ Th }\textbf{\textsc{Th}}\textbf{\textit{
}}{\itshape {\scshape Th}}{\bfseries \itshape {\scshape Th}}

Th \textbf{Th} \textit{Th }\textbf{\textit{Th}}\textsc{ Th }\textbf{\textsc{Th}}\textbf{\textit{
}}{\itshape {\scshape Th}}{\bfseries \itshape {\scshape Th}}

Th \textbf{Th} \textit{Th }\textbf{\textit{Th}}\textsc{ Th }\textbf{\textsc{Th}}\textbf{\textit{
}}{\itshape {\scshape Th}}{\bfseries \itshape {\scshape Th}}

----

\fontspec{Linux Libertine O}0 ThStrictWurtziteFirefly \textsc{ThStrictWurtziteFirefly}
Th \textbf{Th} \textit{Th }\textbf{\textit{Th}}\textsc{ Th }\textbf{\textsc{Th}}\textbf{\textit{
}}{\itshape {\scshape Th}}{\bfseries \itshape {\scshape Th}}

\addfontfeature{UprightFont={SNsanafonmaruP},UprightFeatures={SmallCapsFont={Linux Libertine Capitals O}, SmallCapsFeatures = {Ligatures={NoCommon},Color=1470CF}}}1
ThStrictWurtziteFirefly \textsc{ThStrictWurtziteFirefly} Th \textbf{Th}
\textit{Th }\textbf{\textit{Th}}\textsc{ Th }\textbf{\textsc{Th}}\textbf{\textit{
}}{\itshape {\scshape Th}}{\bfseries \itshape {\scshape Th}}

\addfontfeature{BoldFont={SNsanafonkakuP}, BoldFeatures={Color = 470CF1,SmallCapsFont={Linux Libertine Capitals O}, SmallCapsFeatures = {Ligatures={NoCommon}, Color=70CF14} }}2
ThStrictWurtziteFirefly \textsc{ThStrictWurtziteFirefly} Th \textbf{Th}
\textit{Th }\textbf{\textit{Th}}\textsc{ Th }\textbf{\textsc{Th}}\textbf{\textit{
}}{\itshape {\scshape Th}}{\bfseries \itshape {\scshape Th}}

\addfontfeature{ItalicFont={SNsanafonP}, ItalicFeatures={Color = 0CF147, SmallCapsFont={Linux Libertine Capitals O}, SmallCapsFeatures = {Ligatures={NoCommon},Color=CF1470}}}3
ThStrictWurtziteFirefly \textsc{ThStrictWurtziteFirefly} Th \textbf{Th}
\textit{Th }\textbf{\textit{Th}}\textsc{ Th }\textbf{\textsc{Th}}\textbf{\textit{
}}{\itshape {\scshape Th}}{\bfseries \itshape {\scshape Th}}

\addfontfeature{BoldItalicFont={nagurigaki}, BoldItalicFeatures={ Color = 888844, SmallCapsFont={Linux Libertine Capitals O}, SmallCapsFeatures = {Ligatures={NoCommon}, Color=444422}}}4
ThStrictWurtziteFirefly \textsc{ThStrictWurtziteFirefly} Th \textbf{Th}
\textit{Th }\textbf{\textit{Th}}\textsc{ Th }\textbf{\textsc{Th}}\textbf{\textit{
}}{\itshape {\scshape Th}}{\bfseries \itshape {\scshape Th}}

Th Upright {\scshape Th  Small Caps}\\
\itshape Th Italic {\scshape Th Italic Small Caps}\\
\upshape\bfseries Th Bold {\scshape Th Bold Small Caps}\\
\itshape Th Bold Italic {\scshape Th Bold Italic Small Caps}

Thx in advance for any help...

[update] I just [found out][1] that this is actually a bug in linux libertine o, due to "Automatically produced font substyles" that they are not going to fix and recommend using "Open Type Features". I am not sure what this means, but I will hit the books and figure it out. Shows to go ya...

see below for my final answer.

-
Instead of editing the question with an answer, may be it will be clearer if you make an answer your own question and accept it? –  Sveinung Jul 31 '12 at 9:30
Am I allowed/supposed to do that? Not quite sure why, but it feels weird, like cheating or something, to me. –  asllearner Jul 31 '12 at 22:56
Yes, you can do that, and it is not cheating. Look at tex.stackexchange.com/questions/12806/… where lockstep asks a question and earns 94 upvotes for a good question, and lockstep also answer the question and earns 92 upvotes for a good answer. –  Sveinung Jul 31 '12 at 23:03
Am I allowed/supposed to do that? Not quite sure why, but it feels weird, like cheating or something. The problem with questions and answers is that there really isn't an isomorphism between them, questions have parts, and answers have parts, (if this were SHREK, I'd say they were like onions) yet it is in the nature of things that one imposes a linear structure on them in forums (desirable, to make it easier to follow and use, certainly), when thought and discovery and conversation are more multi-pronged/faceted. At least mine are. Anyhoo, I will add an answer, once I find the final solution. –  asllearner Jul 31 '12 at 23:03
woah you answered that quickly. I didnt even have time to edit my original answer, which got cut short because I tried to type a carriage return. But anyway, great, I'll do it. –  asllearner Jul 31 '12 at 23:04

I was able to get this to work using RawFeature=+smcp even though Ligatures=NoCommon, Rare, etc don't work. Only using raw feature works. Go figure. I think -liga would also have worked. I wonder why this is happening. Perhaps that is a question for another time.

Final Solution:

\setmainfont[Mapping= tex-text,  %
SmallCapsFont={Linux Libertine O},   %
SmallCapsFeatures= {Color=111111, RawFeature={+smcp,+hlig,+dlig}},   %
BoldFont={SNsanafonmaruP},   %
BoldFeatures={Color = 470CF1,AutoFakeBold=4,FakeBold=4,SmallCapsFont={Linux Libertine Capitals O Bold},%
SmallCapsFeatures = { Color=70CF14,   RawFeature={+smcp,+hlig,+dlig}} },  %
ItalicFont={SNsanafonkakuP},   %
ItalicFeatures={Color = 0CF147,AutoFakeBold=2,FakeBold=1,SmallCapsFont={Linux Libertine Capitals O Italic}, %
SmallCapsFeatures = {Color=CF1470,RawFeature={+smcp,+hlig,+dlig}}},   BoldItalicFont={nagurigaki},   %
BoldItalicFeatures={ Color = F1470C,SmallCapsFont={Linux Libertine Capitals O Bold Italic},  %
SmallCapsFeatures = { Color=24680B,RawFeature={+smcp,+hlig,+dlig}}} ]{SNsanafonmaruP}
-