[XeTeX] On cross-language font selection

Yin Dian yindian at gmail.com
Fri Feb 16 04:56:21 CET 2007

Hi jjgod,

   I came up with an inspiration yesterday night on the macro implementation
of font selection and space skipping. It is based on the thought of explicit
switch via the active tilde. After an hour's hack I've finished the
primitive part. Further development requires a judge for math mode and
parameterized commands, so the change of behavior of backslash and braces is

  Following is a test case encoded in UTF-8. Compiled successfully on my
XeTeX 2.2-0.996.

\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
\input xfwpunct.sty
\FWPsetcompactlig  % if you have xfwpunct.sty to judge the full-width
punctuation kerning
\font\zhfont="SimSun" at 12pt
\font\enfont="Times New Roman" at 12pt
\newskip\toggleskip % skip when toggling font
\toggleskip=0.3ex plus 0.6ex
\long\def\xchin#1{\xchinese #1\endxchinese}
  \xchinese at savespecials
  \let\xchinese at savespecials\relax % no further save needed
  \xchinese at makespecials
  \xchinese at iterate
\def\xchinese at savespecials{%
  \let\xchinese at oldtilde~
  \let\xchinese at oldtildecmd\~
\gdef\xchinese at makespecials{%
  \let<\xchinese at bgroup
  \let~\xchinese at tilde
  \let\~\xchinese at oldtilde
  \let\tild\xchinese at oldtildecmd
\def\xchinese at restorespecials{%
  \let~\xchinese at oldtilde
  \let\~\xchinese at oldtildecmd
\long\def\xchinese at tilde#1~{%
  \xchinese at restorespecials
  \hskip\toggleskip #1\hskip\toggleskip
  \xchinese at iterate
\long\gdef\xchinese at bgroup#1>{%
  \xchinese at iterate
\long\def\xchinese at iterate#1{%
  \ifx #1\endxchinese
    \let\xchinese at iterate@next\xchinese at iterate
    \ifx #1\xchinese at tilde
      \let\xchinese at iterate@next\xchinese at tilde
      \ifx #1\xchinese at bgroup
        \let\xchinese at iterate@next\xchinese at bgroup
        \xchinese at restorespecials
        #1\xchinese at makespecials
    \expandafter\xchinese at iterate@next


\def\frac#1#2{\bgroup #1\over #2\egroup}


u(t) = K_P e(t) + T_i \int_0^t e(\tau)d\tau + T_d \frac{de(t)}{dt}




2007/2/14, Jjgod Jiang <gzjjgod at gmail.com>:
> Hi Peter and Bruno,
> 2007/2/14, Peter Dyballa <Peter_Dyballa at web.de>:
> > Font switching is not all, there should also happen a switch to a
> > different language with other typographic rules. Something like
> > Babel's \selectlanguage{} might be the right thing: switching the
> > text's language, switching the font and its script and language (like
> > fontspec offers), plus some internals like writing direction, glue ...
> I can understand your points now. Indeed, we guys using XeTeX
> to typeset Chinese are not very satified with glue between CJK
> characters and Latin characters. So the questions is, can we solve
> this problem at TeX macro level? If not, we still need low level
> mechanism provided by some XeTeX primitives.
> - jjgod.
> _______________________________________________
> XeTeX mailing list
> postmaster at tug.org
> http://tug.org/mailman/listinfo/xetex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/xetex/attachments/20070216/e774c484/attachment.html 

More information about the XeTeX mailing list