Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to change the stylistic set used for italic y in my document. I used Alan Munn's method, explained here: Use stylistic set variations only for certain glyphs.

It works properly, except that it interferes with the kerning. (I believe this problem may be related to Emerson's: Glyph alternates break hyphenation.)

Is there a fix?

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Arno Pro}
\begin{document}

\textit{y} -- \textit{y.} -- y. % Proper kerning.

\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\myalt
\XeTeXcharclass `y \myalt
\XeTeXinterchartoks 0 \myalt = {\begingroup\addfontfeature{Style=Alternate}}
\XeTeXinterchartoks \myalt 0 = {\endgroup}
\XeTeXinterchartoks 255 \myalt = {\begingroup\addfontfeature{Style=Alternate}}
\XeTeXinterchartoks \myalt 255 = {\endgroup}

\textit{y} -- \textit{y.} -- y. % No kerning (esp. after the upright y).
\end{document}

This example is shown here:

enter image description here

share|improve this question
1  
XeTeX can't apply kerning between characters in different fonts. –  egreg Jan 12 '13 at 13:51
    
But is there a way around this problem? For instance, could the interchar class apply only to the italicised character and not its upright counterpart? I would not mind losing kerning as far as the italic y is concerned (there is very little anyway), but it is upsetting otherwise. –  Luca B. Jan 12 '13 at 15:33

1 Answer 1

up vote 5 down vote accepted

If you need the "Alternate" style only for italics, you can do like this:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Arno Pro}

\makeatletter
\def\it@shape@string{it}
\def\check@italics{%
  \ifx\f@shape\it@shape@string\addfontfeatures{Style=Alternate}\fi}

\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\myalt
\XeTeXcharclass `y \myalt
\XeTeXinterchartoks 0 \myalt = {\begingroup\check@italics}
\XeTeXinterchartoks \myalt 0 = {\endgroup}
\XeTeXinterchartoks 255 \myalt = {\begingroup\check@italics}
\XeTeXinterchartoks \myalt 255 = {\endgroup}
\makeatletter

\begin{document}

\begingroup\XeTeXinterchartokenstate=0 % disable for testing

\textit{y} -- \textit{y.} -- y. % Proper kerning.

\endgroup

\textit{y} -- \textit{y.} -- y. % Kerning is good after Roman y

\end{document}

I haven't the Arno Pro font, so I tested it with another font (which hasn't different y's), but the kerning was proper.

Note that the "modern" way for enabling the standard TeX ligatures is

Ligatures=TeX
share|improve this answer
    
Thank you! It works like a charm! –  Luca B. Jan 12 '13 at 16:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.