# [XeTeX] bopomofo ruby characters

Jonathan Kew jonathan_kew at sil.org
Mon Apr 7 22:01:29 CEST 2008

On 7 Apr 2008, at 6:53 pm, Ján Zahornadský wrote:

> Hello everyone!
>
> First, thanks for being such a great community!
>
> Now I'm in a problem of attaching a bopomofo pronunciation hints into
> Chinese characters. I've found Wang fonts, which have these as a
> part of
> a glyph, but due to multiple readings of the characters it's necessary
> to switch between these fonts, often not having idea which fonts
> carries
> which reading.
>
> The second approach I tried is to write a command to attach those
> symbols to a character. As I'm pretty unskilled in (Xe)LaTeX, my
> code so
> far looks like this (for 綽/ㄔㄨㄛˋ character):
>
> \fontsize{36}{36}\ming\fbox{綽\kern 8pt\raise 28pt\hbox{%
> \fontsize{12}{12}%
> \fontspec[RawFeature={vertical:}]{Ming(for ISO10646)}%
> \rotatebox{270}{\raise 1pt\hbox{\makebox[32pt]{\hfil ㄔㄨㄛ
> {\kern-16pt\
> lower-7pt\hbox{ˋ}}\hfil}}}%
> }\kern -4pt}

I don't have the same fonts as you, but here's a version of an \annot
macro that seems to work OK for me; you can just change font names in
the test doc to match your setup. A couple of points to note here:

- I've used "em" rather than absolute "pt" units in the \annot macro
so that it will scale to whatever text size you're using. You can of
course adjust the various dimensions to fine-tune the results, but it
looks pretty reasonable to my (ignorant) eye.

- It's very inefficient to use \fontspec{....} repeatedly for a
typeface that you use frequently; better to use \newfontfamily to
declare it ahead of time.

- The use of \addfontfeature here is also inefficient, but was
simpler than using \newfontfamily to declare a vertical variant of
each font, so I took the easy way out.

For more Chinese support, Google for the zhspacing package. I've also
seen a reference to something called xeCJK, but don't know anything
about it (the pages I saw were in Chinese, which I don't understand
beyond a handful of words).

HTH,

JK

% - - - - - - - - - - - - - - - -

\documentclass[10pt]{report}
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{xunicode}
\setmainfont[Mapping=tex-text]{Gentium}

\newfontfamily\song{STSong}
\newfontfamily\kai{STKaiti}
\newfontfamily\hei{STHeiti}

\newcommand\annot[3]{#1%
\raise.85em\hbox{%
\rotatebox{270}%
{\raise.2em\hbox{\makebox[1em]{\fontsize{0.3em}{0.3em}%
\addfontfeature{Vertical=RotatedGlyphs}#2%
\kern-1.1em\raise.7em\hbox{#3}}}}\kern-.1em}}

\begin{document}

\fontsize{36}{36}

\song
\fbox{\annot{綽}{ㄔㄨㄛ}{ˋ}}

\kai
\fbox{\annot{綽}{ㄔㄨㄛ}{ˋ}}

\hei
\fbox{\annot{綽}{ㄔㄨㄛ}{ˋ}}

\end{document}

% - - - - - - - - - - - - - - - -



More information about the XeTeX mailing list