[XeTeX] asterism
Michiel Kamermans
pomax at nihongoresources.com
Tue Jan 12 10:28:40 CET 2010
teginch at bluewin.ch wrote:
> Pete, Stephen,
>
> Thanks for your input. I had something along the lines of Peter Flynn's solution in my mind which would allow to use the same font. Worked great for me.
Note that this is of course very much not an asterism, but a creative
way to construct something that looks like an asterism. As a
consequence, people will not be able to do a search for an asterism in
your document, even though reasonably speaking PDF files should be
searchable. An alternative to the creative "making your own asterism
rather than using the real unicode codepoint glyph" is to use XeLaTeX's
character classes and define a new class for the asterism, and then
setting up some simple rules to swap fonts only for characters from this
class:
\documentclass{article}
\usepackage{xltxtra} % automatically loads xunicode and fontspec
\newfontfamily{\extrafont}{FontThatContainsAsterism} % fontspec command
that binds a fontswap to \extrafont
\newfontfamily{\rmfont}{MyFavouriteFont} % same for \rmfont
\setmainfont{MyFavouriteFont} % set up document's default font
\XeTeXinterchartokenstate = 1 % arguably the most distinguished xetex
feature
\newXeTeXintercharclass\fontextras % request a new character class
\XeTeXcharclass `\⁂ \fontextras % assign your character this new class
\XeTeXinterchartoks 0 \fontextras = {\extrafont} % what to do when going
from latin to any character in your class
\XeTeXinterchartoks 255 \fontextras = {\extrafont} % what to do when
going from boundary to any character in your class
\XeTeXinterchartoks \fontextras 0 = {\rmfont} % what to do when going
from any character in your class to latin
\XeTeXinterchartoks \fontextras 255 = {\rmfont}% what to do when going
from any character in your class to boundary
\begin{document}
This text will render using the font bound to rmfont, but the ⁂ symbol
will use the font bound to extrafont. This is done without us having to
issue any kind of command in the text itself, so that we don't have to
bother with \textbackslash asterism\textbackslash\ calls every time we
want an asterism.
\end{document}
- Mike "Pomax" Kamermans
nihongoresources.com
More information about the XeTeX
mailing list