A few months ago, I asked whether the “EB Garamond” font contains a short-arched version of the letter f
. I have now found out how to access this letter because it actually exists. Writing
\newcommand\fshort{\XeTeXglyph\the\XeTeXglyphindex "f.short" \relax}
makes it possible to access this letter by writing \fshort
.
Writing
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\myreplace}{m}
{
\tl_set:Nn \l__maxd_argument_tl { #1 }
\tl_replace_all:Nnn \l__maxd_argument_tl { f } { \fshort }
\tl_use:N \l__maxd_argument_tl
}
\tl_new:N \l__maxd_argument_tl
\ExplSyntaxOff
will result in the replacement of f
with the short-arched version of it when the text is encompassed by \myreplace{}
.
This, however, is not very convenient. I would like to globally replace every f
character with the short-arched f
.
I already tried using catcodes, but they do not work when it comes to (certain) ASCII characters. This answer which contains Cyrillic characters works perfectly fine:
\catcode`\Ё=\active
\defЁ{E}
\catcode`\ё=\active
\defё{e}
But writing something like
\catcode`\f=\active
\deff{\fshort}
or
\catcode`\f=\active
\def f{\fshort}
does not work. Also this question did not solve my problem.
David Carlisle’s solution works!
If you also want to use Q.short
in combination with f.short
, use the following code which has to be written in that order:
\newcommand\fshortgobble[1]{\XeTeXglyph\the\XeTeXglyphindex "f.short" \relax}
\newXeTeXintercharclass\fclass
\XeTeXcharclass `f =\fclass
\XeTeXinterchartoks 0 \fclass {\fshortgobble}
\XeTeXinterchartoks \fclass \fclass {\fshortgobble}
\XeTeXinterchartoks 4095 \fclass {\fshortgobble}
\newcommand\Qshortgobble[1]{\XeTeXglyph\the\XeTeXglyphindex "Q.short" \relax}
\newXeTeXintercharclass\Qclass
\XeTeXcharclass `Q =\Qclass
\XeTeXinterchartoks 0 \Qclass {\Qshortgobble}
\XeTeXinterchartoks \Qclass \Qclass {\Qshortgobble}
\XeTeXinterchartoks 4095 \Qclass {\Qshortgobble}
f.short
does not seem to be mapped properly in the current EB Garamond version. Therefore, I do not know the hex number forf.short
. But accessing it with\newcommand\fshort{\XeTeXglyph\the\XeTeXglyphindex "f.short" \relax}
works.