5

Am using Adobe Garamond Pro and need the two characters ʾ and ʿ that do not exist in that font. I have solved this by rotating ˘ 90 degrees either direction and making these new unicode characters with newunicodechar. This way I can type ʿ and ʾ directly in the source code to get the right output. Now, these characters are quite odd and need some adjusted kerning. I want to do this with \XeTeXinterchartoks. The problem is that this does not work with the newly created characters. Why is that and is there a workaround?

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}
\setmainfont{Adobe Garamond Pro} %substitute as desired

% make new character
\newunicodechar{ʾ}{\rotatebox[origin=center]{90}{˘}\hspace{-1.2ex}}

% (absurly large) kerning
\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\dia
\XeTeXcharclass `\ʾ=\dia
\newXeTeXintercharclass\el
\XeTeXcharclass `\l=\el
\XeTeXinterchartoks \el \el {\kern 1em}
\XeTeXinterchartoks \dia \el {\kern 1em}


\begin{document}

\Huge
llʾllll
\end{document}

enter image description here

Bonus question: Is there a way to rotate only the glyph ˘ and not the space below it?

  • 1
    The \XeTeXinterchartoks feature works only with actual characters; with \newunicodechar{<char>}{<tokens>} XeTeX will never see <char> at the processing stage where the feature is applied, because <char> has been substituted by <tokens>. – egreg May 27 '14 at 9:47
  • I see. That answers my question but as a comment I can't accept it as an answer. – Andreas May 27 '14 at 10:22
5

When you do \newunicodechar{<char>}{<tokens>}, the effect is that <char> becomes like a macro and so it disappears before reaching the stage where the \XeTeXinterchartoks feature is applied.

You can however work around this by using an expansion for your character that ends with an unused character; here I set U+FEFF (ZERO WIDTH NO-BREAK SPACE):

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}
\setmainfont{Old Standard} %substitute as desired

\usepackage{graphicx}

% make new character
\newunicodechar{ʾ}{\rotatebox[origin=center]{90}{˘}\hspace{-1.2ex}^^^^feff}

% (absurly large) kerning
\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\dia
\XeTeXcharclass "FEFF=\dia
\newXeTeXintercharclass\el
\XeTeXcharclass `\l=\el
\XeTeXinterchartoks \el \el {\kern 1em}
\XeTeXinterchartoks \dia \el {\kern 1em}


\begin{document}

\Huge
llʾllll
\end{document}

The syntax ^^^^feff is equivalent to typing the character directly (in this case it's better because it shows it). The hexadecimal number "FEFF can be used for assigning the character to a class (notice that lowercase is required for the ^^^^ notation, while uppercase must be used for hexadecimal numbers).

enter image description here

4

This answers your bonus question only. In general, there is not an automated fix, since the location of the glyph will, in general, have asymmetrical space above and below it, which can't be formulaically known in advance. But with a little work, solution can be achieved (whether this was better than what the OP was doing is for you to decide).

To get the item of the same width, place it in a box of the original glyph's width. To get the horizontal kerning right, I provide \xrb[offset]{glyph} to see a boxed version of the rotated glyph, allowing you to determine the proper offset. Once the proper offset is determined, just use \rb[offset]{glyph} with that offset

\documentclass{article}
\usepackage{graphicx}
\usepackage{calc}
\fboxsep=-\fboxrule
\newcommand\xrb[2][0pt]{\fbox{\makebox[\widthof{#2}][r]{%
  \raisebox{#1}{\rotatebox{90}{\raisebox{-#1}{#2}}\kern-#1}}}}
\newcommand\rb[2][0pt]{\makebox[\widthof{#2}][r]{%
  \raisebox{#1}{\rotatebox{90}{\raisebox{-#1}{#2}}\kern-#1}}}
\begin{document}
\fbox{'} \xrb[0pt]{'} \xrb[1pt]{'} \xrb[2pt]{'} \xrb[3pt]{'} \xrb[4pt]{'}

Steve\rb[4pt]{'}s test
\end{document}

enter image description here

  • Thanks. That's a nice and systematic way to go about it it. – Andreas May 27 '14 at 9:28

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.