# Graphite features (Chinese Pinyin and low diacritics) on Gentium Plus

I'm trying to activate the Graphite features on Gentium Plus (Chinese Pinyin tone marks + low diacritics). This is my minimal example:

\documentclass[utf8,12pt,letterpaper]{article}
\usepackage{fontspec}
\begin{document}
\fontspec[Renderer=Graphite,RawFeature={1057=1},RawFeature={1054=1}]{Gentium Plus}

mā má mǎ mà

\end{document}


However, the features are not activated when I compile with XeLaTeX. On the contrary, I get this warning:

*************************************************
* fontspec warning: "only-luatex-feature"
*
* Ignored LuaTeX only feature: 'Renderer=Full/Basic'.
*************************************************


Although I didn't chose Full or Basic.

I have taken this into account: Using Graphite fonts on XeLaTeX

-
The warning you get is caused by a bug in fontspec-xetex.sty, but even fixing the bug doesn't seem to cause the font features to be activated, although I'm not sure why. –  Alan Munn Jan 4 '13 at 21:39
With some more investigation, Gentium has changed from numeric font features to alpha features (documentation contained in version 1.510), so the correct features should be lopr (old 1054) and chtn (old 1057). But this still doesn't work for me. I can't seem to get any of the features to work. –  Alan Munn Jan 4 '13 at 22:46
I should have made sure I was reading the new documentation. The alpha features don't work for me either though. –  Mårten Jan 4 '13 at 22:55
The bug in fontspec has been fixed, and will appear in the next update of the package. This will eliminate the "only-luatex" warning, and make the Graphite features theoretically available. But that doesn't solve the problem of why the features aren't recognized by the font. –  Alan Munn Jan 5 '13 at 19:20

After some more investigation, this seems to be a problem with two distinct sources. The first is a bug in fontspec, which causes the Graphite renderer to be inaccessible. This bug has been reported and fixed, and should show up in the next version of fontspec. As a temporary fix, you can add the following code to your document (a full sample document will follow):

\ExplSyntaxOn
\keys_define:nn {fontspec-preparse} {
Renderer .choice_code:n = {
\fontspec_update_fontid:n {+rend:\l_keys_choice_tl}
\int_compare:nTF {\l_keys_choice_int <= 3} {
\tl_set:Nv \l_fontspec_renderer_tl
{ g_fontspec_renderer_tag_ \l_keys_choice_tl }
}{
\fontspec_warning:nx {only-luatex-feature} {Renderer=Full/Basic}
}
}
,
Renderer .generate_choices:n = {AAT,ICU,Graphite,Full,Basic}
}
\ExplSyntaxOff


This is only half the problem, however. The most recent version of the Gentium Plus font has changed from numeric font features to alphabetic font features, so what used to be

RawFeature={1054=1}


should now be

RawFeature={lopr=1}


However, XeTeX does not seem to deal correctly with these new font feature designations, and assumes they are numeric values. This can be seen by the output of the aat-info.tex file adapted for Graphite:

Running this on version 1.504 of Gentium Plus yields the old numbering system, (image on the left) whereas running it on the latest version 1.510 of Gentium Plus reveals different numbers, instead of the expected alpha codes (image on the right):

The development version of XeTeX supports the alphanumeric IDs, but in the meantime, it's possible either to pass the "new" numeric values as RawFeatures, or as Khaled Hosny points out in the comments, use the full long names of the features as described in the Gentium Plus documentation. Here is a complete document, showing that the relevant features are now accessible with the different numbers or with the long form names. Be careful to match the names exactly: the ID names are case sensitive, as are the "True" and "False" (which must appear as shown.)

% !TEX TS-program = XeLaTeX

\documentclass[12pt,letterpaper]{article}
\usepackage{fontspec}
\ExplSyntaxOn
\keys_define:nn {fontspec-preparse} {
Renderer .choice_code:n = {
\fontspec_update_fontid:n {+rend:\l_keys_choice_tl}
\int_compare:nTF {\l_keys_choice_int <= 3} {
\tl_set:Nv \l_fontspec_renderer_tl
{ g_fontspec_renderer_tag_ \l_keys_choice_tl }
}{
\fontspec_warning:nx {only-luatex-feature} {Renderer=Full/Basic}
}
}
,
Renderer .generate_choices:n = {AAT,ICU,Graphite,Full,Basic}
}
\ExplSyntaxOff
\begin{document}
\newfontfamily\lowfull[Renderer=Graphite,RawFeature={Low-profile diacritics=True}]{Gentium Plus}
\newfontfamily\lownumeric[Renderer=Graphite,RawFeature={1819242610=1}]{Gentium Plus}
\newfontfamily\high[Renderer=Graphite,RawFeature={Low-profile diacritics=False}]{Gentium Plus}

{\lowfull mā má mǎ mà \qquad (Low profile)}

{\lownumeric  mā má mǎ mà \qquad (Low profile)}

{\high  mā má mǎ mà \qquad (Regular profile)}

\end{document}


-
Thanks a million! –  Mårten Jan 5 '13 at 22:23
You're welcome. I've brought the issue up on the XeTeX mailing list to see if there's some more permanent solution to be found. –  Alan Munn Jan 5 '13 at 22:31
You can access Graphite features by their labels in XeTeX, e.g. \font\test="Gentium Plus/GR:Small Caps;Literacy alternates=1" should work –  Khaled Hosny Jan 6 '13 at 9:54
@KhaledHosny Thanks for the comments and replies on the XeTeX list. I've updated the answer with the long form names, which is a more user friendly option. –  Alan Munn Jan 6 '13 at 22:18