1

I'm trying to access superscript Cyrillic letter in Ladoga Pro Opentype font. I do not get them with \addfontfeature{VerticalPosition=Superior}. As far as I can see, they are not included in sups lookup table. But their names in the font are the names of the original glyphs suffixed with .sup (Cyrillic "м" = afii10078 -> afii10078.sup).

So how can I write a macro that gets the name of its character argument in the font, adds .sup and prints the resulting glyph with \XeTeXglyph\XeTeXglyphindex "name.sup" ?

Thank you in advance

3

Before trying to emulate this, first try VerticalPosition=ScientificSuperior. I have seen quite some fonts not providing "normal", but providing "scientific" superiors. This would explain why the characters are present but not accessuble through the lookup.

Also if you bought a font providing these characters but there is no lookup table for them, I would complain at the font vendor.

Anyway, while I do not recommend it, it is possible to write a macro as you described. This works in multiple steps:

  1. The macro receives a character argument, we have to get the codepoint. This is easy, TeX provides the codepoint through a backtick. But then we have to translate this into a font specific glyph slot before applying XeTeX's font commands, so we need \XeTeXcharglyph. For example, the glyph code of the forst argument can be queried with (Later we will not use \the because we work with TeX commands reading a number)
\the\XeTeXcharglyph`#1
  1. Now we need the glyphname. Luckily, XeTeX provides the \XeTeXglyphname primitive to access the glyphname of a glyph slot in a specific font. Here \font represents the current font, so we can expand the example above and get
\XeTeXglyphname\font\XeTeXcharglyph`#1
  1. Of course appending .sup is easy, here we will use .superior instead because this works with Linux Libertine. Then we have to get the glyph index of the new glyph: The \XeTeXglyphindex primitive comes to our rescue: Given a glyph name, it provides us with the index:
\XeTeXglyphindex"\XeTeXglyphname\font\XeTeXcharglyph`#1.superior"\relax
  1. Now we know the index of the required glyph, so we can insert it with \XeTeXglyph:
\XeTeXglyph\XeTeXglyphindex"\XeTeXglyphname\font\XeTeXcharglyph`#1.superior"\relax

Together, we get

% WARNING: This is a purely academic example, if you actually want to use
% superiors with Linux Libertine, just activate the `sups` feature instead,
% e.g. with `\addfontfeature{VerticalPosition=Superior}`
\documentclass{article}
\usepackage{fontspec}
\setmainfont{LinLibertine_R.otf}
\begin{document}
\newcommand\mysup[1]{%
  \XeTeXglyph
    \XeTeXglyphindex"\XeTeXglyphname\font\XeTeXcharglyph`#1.superior"
}
abc\mysup a\mysup b\mysup 9XXX
\end{document}

enter image description here

  • Thank you, Marcel, this completely solves my problem. (ScientificInferior does not work, and I'm not sure that the font vendor will make these changes for me. Actually, I've got beta version of this font with huge number of alternates for Old Slavonic letters for my project from them, it was not released, AFIAK.) – Vadim Radionov Feb 15 '19 at 12:01
  • ScientificSuperior, of course – Vadim Radionov Feb 15 '19 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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