summaryrefslogtreecommitdiff
path: root/language/japanese/zxjafbfont/zxjafbfont.sty
blob: 762a0d5ec58e90691c12dc6b0399f6b54c9231df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
%
% zxjafbfont.sty
%

%% package declaration
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{zxjafbfont}[2011/02/20 v0.2]

%% preparations
\def\zxjx@pkgname{zxjafbfont}
\def\zxjx@error{\PackageError\zxjx@pkgname}
%
\RequirePackage{xeCJK}

%%------ User interface

%%<*> \setCJKfallbackfamily{<CJK_family_name>}
\newcommand*\setCJKfallbackfamily[1]{%
  \let\CJKsymbol\zxjx@CJKsymbol
  \edef\zxjx@fb@family{#1}}

%%<*> \unsetCJKfallbackfamily
\newcommand*\unsetCJKfallbackfamily{%
  \let\CJKsymbol\zxjx@org@CJKsymbol
  \let\zxjx@fb@family\relax}

%% \zxjx@fb@family
\let\zxjx@fb@family\relax

%%------ Patch to xeCJK procedures

%% \zxjx@enter@local
\def\zxjx@enter@local{%
  \bgroup \let\zxjx@maybe@egroup\egroup
  \zxjx@revoke@ingress}
\let\zxjx@maybe@egroup\@empty
\def\zxjx@preto@ictoks#1#2#3{%
  \chardef\zxjx@x=#1\chardef\zxjx@y=#2\relax
  \XeTeXinterchartoks\zxjx@x\zxjx@y\expandafter{%
    \expandafter#3\the\XeTeXinterchartoks\zxjx@x\zxjx@y}}
\@for\zxjx@a:=1,2,3\do{%
  \@for\zxjx@b:=0,1,2,3,4,5,6,255\do{%
    \zxjx@preto@ictoks\zxjx@a\zxjx@b{\zxjx@maybe@egroup}}}
\def\zxjx@revoke@ingress{%
  % Segfaults would occur unless \relax is there... (why?)
  \XeTeXinterchartoks 255 1{\relax}%
  \XeTeXinterchartoks 255 2{\relax}%
  \XeTeXinterchartoks 255 3{\relax}}
\chardef\zxjx@geta="3013

%% \zxjx@CJKsymbol
\def\zxjx@CJKsymbol#1{%
  \zxjx@enter@local
  \chardef\zxjx@uc=`#1\relax
  \unless\iffontchar\font\zxjx@uc
    \CJKfamily\zxjx@fb@family \xeCJK@setfont
  \fi
  \zxjx@uc}
\let\zxjx@org@CJKsymbol\CJKsymbol

%%------ all done
\endinput
%% EOF