[XeTeX] asterism

Jonathan Kew jfkthame at googlemail.com
Tue Jan 12 11:00:08 CET 2010


On 12 Jan 2010, at 09:28, Michiel Kamermans wrote:

> 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:

For a one-off symbol like this, I wouldn't go to the trouble of setting up a character class (note that if you have lots of classes, and if you can't guarantee they'll always have spaces or other non-character stuff adjacent to them, then you need to consider the transitions between *all* possible pairs, which can get pretty unwieldy).

Simpler to make the character \active, and just define it as a macro:

  \catcode"2042=\active
  \def^^^^2042{{\asterfont\char"2042}}

where \asterfont is defined suitably using \newfontfamily.

JK

> 
> \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
> 
> 
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
> http://tug.org/mailman/listinfo/xetex




More information about the XeTeX mailing list