I would like to get the variant option from fontspec working under Linux. Unfortunately, this option which works with the AAT font system is not compatible with the OpenType font mechanism used under Linux.

However, I dumped one of the Mac OS X fonts which contains such variant glyphs and I found that these variant glyphs can be easily got by using their name. Indeed their name are composed like this: "<name of the standard glyph>.<variant number>". For instance to get the second variant of a "d", just use the: \XeTeXglyph\XeTeXglyphindex "d.2". For a "é", it would be: \XeTeXglyph\XeTeXglyphindex "eacute.2" etc.

Thus I developed a little command to get the corresponding variant if present or use the default one otherwise:

  \@tempcnta=\XeTeXglyphindex "#1.#2"\relax

Right now I would like to construct a command which takes two arguments: the first one would be the variant number and the second one the sentence to write by using that variant. Unfortunately I don't know exactly how can I parse character by character the second argument and call the \variantChar command.

Last but not least, I would be interested by knowing a way to get the name of a glyph in order to take into account complexe glyphs name like "eacute" or ligature glyphs like "ft" etc. Is there a such command which takes as argument the glyph and returns the glyph name?

Otherwise do you know an other way to use variant glyphs available in MacOS X fonts under Linux?

  • Welcome to tex.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting.
    – Seamus
    Commented Mar 11, 2011 at 13:16

1 Answer 1


I once implemented a similar thing using TeX's tail recursion. Adapted to your situation, my macro definition would look like this:


The macro \@@varianttext just iterates over the input and applies \variantchar to each character.

Edit: I updated the solution to handle spaces correctly.

  • Thank you very much for your code! I used the "|" character which is not often used for test. It works pretty well. The only problem is that it eats space characters.. I guess it is a bug in my \variantChar command.. I will investigate.
    – Adesuray
    Commented Mar 11, 2011 at 14:21
  • It's not a bug in \variantChar command.. The space character is really eaten. Does someone have an idea to get it back? Thank you in advance.
    – Adesuray
    Commented Mar 11, 2011 at 14:31
  • It seems that TeX discards the spaces when it scans arguments. For example, if you define \def\test#1#2{#1,#2}, then \test ab gives the same result as \test a b. Commented Mar 11, 2011 at 14:38
  • I really don't know how to preserve the space.. I tried to play with the catcodes but it seems that it doesn't work... :(
    – Adesuray
    Commented Mar 11, 2011 at 15:34
  • 1
    @Michael: because otherwise the macro parameters are read before \obeyspaces is processed. Commented Mar 11, 2011 at 17:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .