blob: 4d5b2baef31b9e493923baa38b3e3ca612a1f865 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
%%
%% This is file 'zxbase.sty'.
%%
%% Copyright (c) 2017 Takayuki YATO (aka. "ZR")
%% GitHub: https://github.com/zr-tex8r
%% Twitter: @zr_tex8r
%%
%% This package is distributed under the MIT License.
%%
%% package declaration
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{zxbase}[2017/05/29 v1.1]
\RequirePackage{ifxetex}
\RequireXeTeX
%% preparations
\RequirePackage{bxbase}
\def\zx@pkgname{zxbase}
%--------------------------------------- generic family detection
%%<+> \zxSpecFamily / \zxRMFamily / \zxSFFamily / \zxTTFamily
% The constants signifying each generic family.
% These values can be considered as fixed, so you can say i.e.
% "\ifnum\zxGFFlag<\zxSFFamily <non-sans> \else <sans> \fi"
\chardef\zxSpecFamily=0
\chardef\zxRMFamily=1
\chardef\zxSFFamily=2
\chardef\zxTTFamily=3
%% \zx@set@genfamflag
% A patch to be inserted to \selectfont. This makes \selectfont
% set a right \zx..Family constant to \zxGFFlag.
\def\zx@set@genfamflag{%
\zx@set@gff@get\zx@curfam\f@family
\let\zxGFFlag\zxSpecFamily
\zx@set@gff@match\ttdefault\zxTTFamily
\zx@set@gff@match\sfdefault\zxSFFamily
\zx@set@gff@match\rmdefault\zxRMFamily}
\def\zx@set@gff@get#1#2{%
\expandafter\let\expandafter#1\csname
zf@family@fontname#2\endcsname
\ifx#1\relax \edef#1{#2}\fi}
\def\zx@set@gff@match#1#2{%
\zx@set@gff@get\zx@genfam#1%
\ifx\zx@genfam\zx@curfam \let\zxGFFlag#2\fi}
%%<+> \zxBDHookGenFamFlag
\def\zxBDHookGenFamFlag{\zx@bdhook@genfamflag@do}
\@onlypreamble\zx@bdhook@genfamflag@do
\def\zx@bdhook@genfamflag@do{%
\expandafter\zx@bdhook@genfamflag@a\csname selectfont \endcsname
\let\zx@bdhook@genfamflag@do\relax}
\@onlypreamble\zx@bdhook@genfamflag@a
\def\zx@bdhook@genfamflag@a#1{%
\expandafter\def\expandafter#1\expandafter{%
\expandafter\zx@set@genfamflag#1}}
%--------------------------------------- forge pTeX primitives
% It is not totally safe, but is required so as to make
% the 'ajmacros' package work.
%%<+> \zxBDHookForgepTeXDir
\def\zxBDHookForgepTeXDir{\zx@bdhook@forgeptexdir@do}
\@onlypreamble\zx@bdhook@forgeptexdir@do
\def\zx@bdhook@forgeptexdir@do{%
\zx@letconstif{ydir}{true}\zx@letconstif{tdir}{false}%
\ifx\yoko\@undefined \let\yoko\relax \fi
\ifx\tate\@undefined \let\tate\relax \fi
}
\def\zx@letconstif#1#2{%
\ifcsname if#1\endcsname\else
\expandafter\let\csname if#1\expandafter\endcsname
\csname if#2\endcsname \fi}
%--------------------------------------- load pLaTeX packages
%%<+> switch 'zxPPInUTFEight'
\newif\ifzxPPInUTFEight
%% variables
\newif\ifzx@jisenc
%% errors
\def\zx@err@ukenc#1{\PackageError\zx@pkgname
{File '#1' is in unknown encoding}%
{The file must be encoded in ISO-2022-JP or UTF-8.}}
%%<+> \zxRequirepLaTeXPackage{<package>}
\@onlypreamble\zxRequirepLaTeXPackage
\def\zxRequirepLaTeXPackage#1{%
\ifzxPPInUTFEight \zx@jisencfalse
\else \zx@checkjisorutfeight{#1.\@pkgextension}%
\ifcase\zx@joru \zx@err@ukenc{#1.\@pkgextension}\or
\zx@jisenctrue \else \zx@jisencfalse \fi
\fi
\let\NeedsTeXFormat\zx@mute@NeedsTeXFormat
\ifzx@jisenc \XeTeXdefaultencoding ISO-2022-JP\relax \fi
\RequirePackage{#1}\relax
\ifzx@jisenc \XeTeXdefaultencoding auto\relax \fi
\let\NeedsTeXFormat\zx@org@NeedsTeXFormat
}
%% \zx@mute@NeedsTeXFormat
\def\zx@mute@NeedsTeXFormat#1{\@ifnextchar[{\zx@mute@ntf@a}{\relax}}
\def\zx@mute@ntf@a[#1]{\relax}
\let\zx@org@NeedsTeXFormat\NeedsTeXFormat
%% \zx@checkjisorutfeight{<file>}
% Decides whether <file> is encoded in JIS or UTF-8 and sets to \zx@joru.
% 0:binary; 1:JIS; 2:UTF-8; 3:US-ASCII
\def\zx@checkjisorutfeight#1{%
\begingroup
\XeTeXdefaultencoding bytes\relax
\let\zx@c@ctl=f\def\zx@found@ctl{\let\zx@c@ctl=t}%
\let\zx@c@esc=f\def\zx@found@esc{\let\zx@c@esc=t}%
\let\zx@c@high=f\def\zx@found@high{\let\zx@c@high=t}%
\zx@make@activelet{0}{32}\zx@found@ctl
\zx@make@ignorable{32}{127}%
\zx@make@activelet{127}{128}\zx@found@ctl
\zx@make@activelet{128}{256}\zx@found@high
\zx@make@activelet{27}{28}\zx@found@esc
\catcode13=5 \catcode32=10 \catcode9=10 \catcode`\~=9
\@@input"#1"\relax
\if t\zx@c@ctl \global\chardef\zx@g@joru0
\else\if t\zx@c@esc \global\chardef\zx@g@joru1
\else\if t\zx@c@high \global\chardef\zx@g@joru2
\else \global\chardef\zx@g@joru3 \fi\fi\fi
\XeTeXdefaultencoding auto\relax
\endgroup
\let\zx@joru\zx@g@joru}
\def\zx@make@activelet#1#2#3{%
\catcode`\~=\active \let\zx@tmpx=#3\relax
\@tempcnta#1\relax\loop
\catcode\@tempcnta\active \lccode`\~=\@tempcnta
\lowercase{\let~\zx@tmpx}%
\advance\@tempcnta\@ne \ifnum\@tempcnta<#2 \repeat}
\def\zx@make@ignorable#1#2{%
\@tempcnta#1\relax\loop \catcode\@tempcnta9
\advance\@tempcnta\@ne \ifnum\@tempcnta<#2 \repeat}
%%<*> \platexpackagesinunicode
\@onlypreamble\platexpackagesinunicode
\newcommand*\platexpackagesinunicode{\zxPPInUTFEighttrue}
%--------------------------------------- all done
\endinput
%% EOF
|