[XeTeX] Access of vertical CJK fonts preceeding with @

Mike "Pomax" Kamermans pomax at nihongoresources.com
Tue Dec 11 23:18:01 CET 2012


I use XeLaTeX with vertically typeset CJK, using some custom macros:

% ----------------------------------------------------------------
% ruby markup stuff
% ----------------------------------------------------------------

\usepackage{accsupp}

% ----------------------------------------------------------------
% ruby and rubystack for for use in tables.
% This needs extra spacing to ensure visually appealing alignment,
% but rather than using an extra argument, it figured it'd be more
% readable, and overall less space-taking to just copy the plain
% macro and rename it
% ----------------------------------------------------------------

\newcommand*{\rtrubystack}[2]{{\relscale{0.5}%
   \begin{tabular}[b]{@{}c@{}}%
     {#1}\\%
     {\textscale{2}{#2}}%
   \end{tabular}}%
}

\DeclareRobustCommand*{\rtruby}[2]{%
   \mbox{%
     \setlength{\parskip}{0ex}%
     \BeginAccSupp{method=pdfstringdef,ActualText={#1}}%
       \rtrubystack{\phantom{#2}}{#1}%
       \llap{%
         \rtrubystack{#2}{\phantom{#1}}%
       }%
     \EndAccSupp{}%
   }%
}

% --------------------------------------------------------------
% ruby and rubystack macro, effecting ghost furigana in the PDF
% --------------------------------------------------------------

\newcommand*{\rubystack}[2]{{\relscale{0.5}%
   \begin{tabular}[b]{@{}c@{}}%
     {#1}\\%
    {\textscale{2}{#2}}%
   \end{tabular}}%
}

\DeclareRobustCommand*{\ruby}[2]{%
   \mbox{%
     \setlength{\parskip}{0ex}%
%    \BeginAccSupp{method=pdfstringdef,ActualText={#1 (#2)}}%
     \BeginAccSupp{method=pdfstringdef,ActualText={#1}}%
       \rubystack{\phantom{#2}}{#1}%
       \llap{%
         \rubystack{#2}{\phantom{#1}}%
       }%
     \EndAccSupp{}%
   }%
}

% --------------------------------------------------------------------------
% helper macro: adds space between the text and the [T]op \hline in a table
% --------------------------------------------------------------------------

\newcommand\T{\rule{0pt}{2.5ex}}% zero width, 2.5ex vertical spacing, 
ensures a visually appealing vertical alignment

% --------------------------------------------------------------------------
% vertical typesetting for CJK
% --------------------------------------------------------------------------

\DeclareRobustCommand*{\vruby}[2]{%
\mbox{%
\setlength{\parskip}{0ex}%
\BeginAccSupp{method=pdfstringdef,ActualText={#1}}%
\rule{0pt}{1.7em}\rubystack{\phantom{#2}}{#1}%
\llap{%
\rule{0pt}{1.7em}\rubystack{\smaller #2}{\phantom{#1}}%
}%
\EndAccSupp{}%
}%
}

\newcommand{\vertical}[4]{%
\XeTeXinterchartokenstate = 0 %
\begin{center}%
\rotatebox{-90}{%
\begin{varwidth}{\textwidth}%
\fontsize{#2pt}{#2pt}
\fontspec[RawFeature=vertical, Script=CJK]{#1}#4
\vspace{#2pt}%
\vspace{#2pt}%    this padding should only exist if ruby is present, for 
visual offset
\vspace{#2pt}%
\end{varwidth}}%
\\
\vspace{12pt}
\XeTeXinterchartokenstate = 1 %
\fontsize{8pt}{10pt}#3
\end{center}%
\XeTeXinterchartokenstate = 1 %
}


I then use it as:

    \vertical{Kozuka Mincho Pro}{21}{The いろは poem, with classical 
kana transcription}{色は匂へど...}

so it has baked in font name, font size, "block title", and then the 
actual text to typeset. This typesets the text top-down, right to left.

- Mike "Pomax" Kamermans
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/xetex/attachments/20121211/900e4350/attachment.html>


More information about the XeTeX mailing list