simplify file coding system option.
[chise/omega.git] / chise.sty
1 \NeedsTeXFormat{LaTeX2e}
2 \ProvidesPackage{chise}[2003/10/18 v.0.2 (Omega/CHISE Team)]
3 % based on mulambda and omega-japanese
4 \RequirePackage{omega}
5 \RequirePackage[UT1]{fontenc}
6
7 \DeclareOption{utf8mcs}{
8   \externalocp\OCPuniGB=Utf8mcsToUniGB {}
9   \ocplist\uniGB=
10     \addbeforeocplist 1 \OCPuniGB
11     \nullocplist
12   \externalocp\OCPuniCNS=Utf8mcsToUniCNS {}
13   \ocplist\uniCNS=
14     \addbeforeocplist 1 \OCPuniCNS
15     \nullocplist
16   \externalocp\OCPuniJIS=Utf8mcsToUniJIS {}
17   \ocplist\uniJIS=
18     \addbeforeocplist 1 \OCPuniJIS
19     \nullocplist
20   \externalocp\OCPuniKS=Utf8mcsToUniKS {}
21   \ocplist\uniKS=
22     \addbeforeocplist 1 \OCPuniKS
23     \nullocplist
24   \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
25   \ocplist\uniMulti=
26     \addbeforeocplist 1 \OCPuniMulti
27     \nullocplist
28 }
29 \DeclareOption{utf8gb}{
30   \externalocp\OCPuniGB=Utf8gbToUniGB {}
31   \ocplist\uniGB=
32     \addbeforeocplist 1 \OCPuniGB
33     \nullocplist
34   \externalocp\OCPuniCNS=Utf8gbToUniCNS {}
35   \ocplist\uniCNS=
36     \addbeforeocplist 1 \OCPuniCNS
37     \nullocplist
38   \externalocp\OCPuniJIS=Utf8gbToUniJIS {}
39   \ocplist\uniJIS=
40     \addbeforeocplist 1 \OCPuniJIS
41     \nullocplist
42   \externalocp\OCPuniKS=Utf8gbToUniKS {}
43   \ocplist\uniKS=
44     \addbeforeocplist 1 \OCPuniKS
45     \nullocplist
46   \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
47   \ocplist\uniMulti=
48     \addbeforeocplist 1 \OCPuniMulti
49     \nullocplist
50 }
51 \DeclareOption{utf8cns}{
52   \externalocp\OCPuniGB=Utf8cnsToUniGB {}
53   \ocplist\uniGB=
54     \addbeforeocplist 1 \OCPuniGB
55     \nullocplist
56   \externalocp\OCPuniCNS=Utf8cnsToUniCNS {}
57   \ocplist\uniCNS=
58     \addbeforeocplist 1 \OCPuniCNS
59     \nullocplist
60   \externalocp\OCPuniJIS=Utf8cnsToUniJIS {}
61   \ocplist\uniJIS=
62     \addbeforeocplist 1 \OCPuniJIS
63     \nullocplist
64   \externalocp\OCPuniKS=Utf8cnsToUniKS {}
65   \ocplist\uniKS=
66     \addbeforeocplist 1 \OCPuniKS
67     \nullocplist
68   \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
69   \ocplist\uniMulti=
70     \addbeforeocplist 1 \OCPuniMulti
71     \nullocplist
72 }
73 \DeclareOption{utf8jis}{
74   \externalocp\OCPuniGB=Utf8jisToUniGB {}
75   \ocplist\uniGB=
76     \addbeforeocplist 1 \OCPuniGB
77     \nullocplist
78   \externalocp\OCPuniCNS=Utf8jisToUniCNS {}
79   \ocplist\uniCNS=
80     \addbeforeocplist 1 \OCPuniCNS
81     \nullocplist
82   \externalocp\OCPuniJIS=Utf8jisToUniJIS {}
83   \ocplist\uniJIS=
84     \addbeforeocplist 1 \OCPuniJIS
85     \nullocplist
86   \externalocp\OCPuniKS=Utf8jisToUniKS {}
87   \ocplist\uniKS=
88     \addbeforeocplist 1 \OCPuniKS
89     \nullocplist
90   \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
91   \ocplist\uniMulti=
92     \addbeforeocplist 1 \OCPuniMulti
93     \nullocplist
94 }
95 \DeclareOption{utf8ks}{
96   \externalocp\OCPuniGB=Utf8ksToUniGB {}
97   \ocplist\uniGB=
98     \addbeforeocplist 1 \OCPuniGB
99     \nullocplist
100   \externalocp\OCPuniCNS=Utf8ksToUniCNS {}
101   \ocplist\uniCNS=
102     \addbeforeocplist 1 \OCPuniCNS
103     \nullocplist
104   \externalocp\OCPuniJIS=Utf8ksToUniJIS {}
105   \ocplist\uniJIS=
106     \addbeforeocplist 1 \OCPuniJIS
107     \nullocplist
108   \externalocp\OCPuniKS=Utf8ksToUniKS {}
109   \ocplist\uniKS=
110     \addbeforeocplist 1 \OCPuniKS
111     \nullocplist
112   \externalocp\OCPuniMulti=Utf8mcsToUniMulti {}
113   \ocplist\uniMulti=
114     \addbeforeocplist 1 \OCPuniMulti
115     \nullocplist
116 }
117
118 \DeclareOption{gbfont}{
119   \AtBeginDocument{
120     \GBfont
121   }
122 }
123 \DeclareOption{cnsfont}{
124   \AtBeginDocument{
125     \CNSfont
126   }
127 }
128 \DeclareOption{jisfont}{
129   \AtBeginDocument{
130     \JISfont
131   }
132 }
133 \DeclareOption{ksfont}{
134   \AtBeginDocument{
135     \KSfont
136   }
137 }
138 \DeclareOption{multifont}{
139   \AtBeginDocument{
140     \Multifont
141   }
142 }
143
144 \ocp\CJKbreak=cjkbreak
145 %% \ocplist\CJKadjust=
146 %%    \addbeforeocplist 1 \CJKbreak
147 %%    \nullocplist
148 \def\cjkglue{\hskip 0pt plus 1pt minus .5pt}
149
150 \ocp\OCPutf=inutf8
151 \ocplist\inutf
152   \addbeforeocplist 1 \OCPutf
153   \nullocplist
154 \AtBeginDocument{
155 %  \DefaultInputMode onebyte
156 %  \InputMode currentfile onebyte
157 %  \DefaultInputTranslation onebyte \OCPutf
158 %  \InputTranslation currentfile \OCPutf
159   \pushocplist\inutf
160 }
161
162 %%%%% to use KAGE server %%%%%
163 \externalocp\OCPmkfont=makefonts.pl {}
164 \ocplist\mkfontOCP=
165 \addbeforeocplist 1 \OCPmkfont
166 \nullocplist
167
168 \AtEndDocument{
169   \pushocplist\mkfontOCP
170 }
171
172 % Settings for CJK
173 \def\selectjisfont{\fontencoding{OT1}\fontfamily{omjis}\selectfont}
174 \def\selectgbsfont{\fontencoding{OT1}\fontfamily{omgbs}\selectfont}
175 \def\selectcnsfont{\fontencoding{OT1}\fontfamily{omcns}\selectfont}
176 \def\selectksxfont{\fontencoding{OT1}\fontfamily{omksx}\selectfont}
177 %\def\JIS{\pushocplist\CJKadjust\selectjisfont}
178 %\def\GB{\pushocplist\CJKadjust\selectgbsfont}
179 %\def\KS{\pushocplist\CJKadjust\selectksxfont}
180 %\def\CNS{\pushocplist\CJKadjust\selectcnsfont}
181
182 \newenvironment{JISfont}{\pushocplist\uniJIS\selectjisfont}{\pushocplist\inutf}
183 \newenvironment{GBfont}{\pushocplist\uniGB\selectgbsfont}{\pushocplist\inutf}
184 \newenvironment{KSfont}{\pushocplist\uniKS\selectksxfont}{\pushocplist\inutf}
185 \newenvironment{CNSfont}{\pushocplist\uniCNS\selectcnsfont}{\pushocplist\inutf}
186 \newenvironment{Multifont}{\pushocplist\uniMulti}{\pushocplist\inutf}
187
188 \newcommand{\jisfont}[1]{\begingroup%
189   \pushocplist\uniJIS\selectjisfont #1\endgroup}
190 \newcommand{\gbfont}[1]{\begingroup%
191   \pushocplist\uniGB\selectgbsfont #1\endgroup}
192 \newcommand{\ksfont}[1]{\begingroup%
193   \pushocplist\uniKS\selectksxfont #1\endgroup}
194 \newcommand{\cnsfont}[1]{\begingroup%
195   \pushocplist\uniCNS\selectcnsfont #1\endgroup}
196 \newcommand{\multifont}[1]{\begingroup%
197   \pushocplist\uniMulti #1\endgroup}
198 \newcommand{\noncjk}[1]{\begingroup%
199   \normalfont\pushocplist\inutf #1\endgroup}
200
201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202 % Font Declaration
203 % ----------------
204 %% omgbs
205 \DeclareFontFamily{OT1}{omgbs}{}
206 \DeclareFontShape{OT1}{omgbs}{m}{n}{
207    <->omgbs
208 }{}
209 \DeclareFontShape{OT1}{omgbs}{m}{sc}{
210    <-> ssub * omgbs/m/n
211 }{}
212 \DeclareFontShape{OT1}{omgbs}{m}{it}{
213    <->omgb
214 }{}
215 \DeclareFontShape{OT1}{omgbs}{m}{sl}{
216    <-> ssub * omgbs/m/it
217 }{}
218 \DeclareFontShape{OT1}{omgbs}{m}{itsc}{
219    <-> ssub * omgbs/m/it
220 }{}
221 \DeclareFontShape{OT1}{omgbs}{m}{slsc}{
222    <-> ssub * omgbs/m/it
223 }{}
224 \DeclareFontShape{OT1}{omgbs}{bx}{n}{
225    <->omgbsgt
226 }{}
227 \DeclareFontShape{OT1}{omgbs}{bx}{sc}{
228    <-> ssub * omgbs/bx/n
229 }{}
230 \DeclareFontShape{OT1}{omgbs}{bx}{it}{
231    <->omgbsgt
232 }{}
233 \DeclareFontShape{OT1}{omgbs}{bx}{itsc}{
234    <-> ssub * omgbs/bx/it
235 }{}
236 \DeclareFontShape{OT1}{omgbs}{bx}{sl}{
237    <-> ssub * omgbs/bx/it
238 }{}
239 \DeclareFontShape{OT1}{omgbs}{bx}{slsc}{
240    <-> ssub * omgbs/bx/it
241 }{}
242
243 %% omcns
244 \DeclareFontFamily{OT1}{omcns}{}
245 \DeclareFontShape{OT1}{omcns}{m}{n}{
246    <->omcns
247 }{}
248 \DeclareFontShape{OT1}{omcns}{m}{sc}{
249    <-> ssub * omcns/m/n
250 }{}
251 \DeclareFontShape{OT1}{omcns}{m}{it}{
252    <->omcns
253 }{}
254 \DeclareFontShape{OT1}{omcns}{m}{sl}{
255    <-> ssub * omcns/m/it
256 }{}
257 \DeclareFontShape{OT1}{omcns}{m}{itsc}{
258    <-> ssub * omcns/m/it
259 }{}
260 \DeclareFontShape{OT1}{omcns}{m}{slsc}{
261    <-> ssub * omcns/m/it
262 }{}
263 \DeclareFontShape{OT1}{omcns}{bx}{n}{
264    <->omcnsgt
265 }{}
266 \DeclareFontShape{OT1}{omcns}{bx}{sc}{
267    <-> ssub * omcns/bx/n
268 }{}
269 \DeclareFontShape{OT1}{omcns}{bx}{it}{
270    <->omcnsgt
271 }{}
272 \DeclareFontShape{OT1}{omcns}{bx}{itsc}{
273    <-> ssub * omcns/bx/it
274 }{}
275 \DeclareFontShape{OT1}{omcns}{bx}{sl}{
276    <-> ssub * omcns/bx/it
277 }{}
278 \DeclareFontShape{OT1}{omcns}{bx}{slsc}{
279    <-> ssub * omcns/bx/it
280 }{}
281
282 %%
283 \DeclareFontFamily{OT1}{omjis}{}
284 \DeclareFontShape{OT1}{omjis}{m}{n}{
285    <->omjis
286 }{}
287 \DeclareFontShape{OT1}{omjis}{m}{sc}{
288    <-> ssub * omjis/m/n
289 }{}
290 \DeclareFontShape{OT1}{omjis}{m}{it}{
291    <->omjis
292 }{}
293 \DeclareFontShape{OT1}{omjis}{m}{sl}{
294    <-> ssub * omjis/m/it
295 }{}
296 \DeclareFontShape{OT1}{omjis}{m}{itsc}{
297    <-> ssub * omjis/m/it
298 }{}
299 \DeclareFontShape{OT1}{omjis}{m}{slsc}{
300    <-> ssub * omjis/m/it
301 }{}
302 \DeclareFontShape{OT1}{omjis}{bx}{n}{
303    <->omjisgt
304 }{}
305 \DeclareFontShape{OT1}{omjis}{bx}{sc}{
306    <-> ssub * omjis/bx/n
307 }{}
308 \DeclareFontShape{OT1}{omjis}{bx}{it}{
309    <->omjisgt
310 }{}
311 \DeclareFontShape{OT1}{omjis}{bx}{itsc}{
312    <-> ssub * omjis/bx/it
313 }{}
314 \DeclareFontShape{OT1}{omjis}{bx}{sl}{
315    <-> ssub * omjis/bx/it
316 }{}
317 \DeclareFontShape{OT1}{omjis}{bx}{slsc}{
318    <-> ssub * omjis/bx/it
319 }{}
320
321 %% omksx
322 \DeclareFontFamily{OT1}{omksx}{}
323 \DeclareFontShape{OT1}{omksx}{m}{n}{
324    <->omksx
325 }{}
326 \DeclareFontShape{OT1}{omksx}{m}{sc}{
327    <-> ssub * omksx/m/n
328 }{}
329 \DeclareFontShape{OT1}{omksx}{m}{it}{
330    <->omksx
331 }{}
332 \DeclareFontShape{OT1}{omksx}{m}{sl}{
333    <-> ssub * omksx/m/it
334 }{}
335 \DeclareFontShape{OT1}{omksx}{m}{itsc}{
336    <-> ssub * omksx/m/it
337 }{}
338 \DeclareFontShape{OT1}{omksx}{m}{slsc}{
339    <-> ssub * omksx/m/it
340 }{}
341 \DeclareFontShape{OT1}{omksx}{bx}{n}{
342    <->omksxgt
343 }{}
344 \DeclareFontShape{OT1}{omksx}{bx}{sc}{
345    <-> ssub * omksx/bx/n
346 }{}
347 \DeclareFontShape{OT1}{omksx}{bx}{it}{
348    <->omksxgt
349 }{}
350 \DeclareFontShape{OT1}{omksx}{bx}{itsc}{
351    <-> ssub * omksx/bx/it
352 }{}
353 \DeclareFontShape{OT1}{omksx}{bx}{sl}{
354    <-> ssub * omksx/bx/it
355 }{}
356 \DeclareFontShape{OT1}{omksx}{bx}{slsc}{
357    <-> ssub * omksx/bx/it
358 }{}
359
360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
361 \DeclareFontFamily{OT1}{chise000}{}
362 \DeclareFontShape{OT1}{chise000}{m}{n}{
363    <-> [.96] chise000min
364 }{}
365 \DeclareFontShape{OT1}{chise000}{m}{sc}{
366    <-> [.96] ssub * chise000min/m/n
367 }{}
368 \DeclareFontShape{OT1}{chise000}{m}{it}{
369    <-> [.96] chise000min
370 }{}
371 \DeclareFontShape{OT1}{chise000}{m}{sl}{
372    <-> [.96] ssub * chise000min/m/it
373 }{}
374 \DeclareFontShape{OT1}{chise000}{m}{itsc}{
375    <-> [.96] ssub * chise000min/m/it
376 }{}
377 \DeclareFontShape{OT1}{chise000}{m}{slsc}{
378    <-> [.96] ssub * chise000min/m/it
379 }{}
380 \DeclareFontShape{OT1}{chise000}{bx}{n}{
381    <-> [.96] chise000got
382 }{}
383 \DeclareFontShape{OT1}{chise000}{bx}{sc}{
384    <-> [.96] ssub * chise000got/bx/n
385 }{}
386 \DeclareFontShape{OT1}{chise000}{bx}{it}{
387    <-> [.96] chise000got
388 }{}
389 \DeclareFontShape{OT1}{chise000}{bx}{itsc}{
390    <-> [.96] ssub * chise000got/bx/it
391 }{}
392 \DeclareFontShape{OT1}{chise000}{bx}{sl}{
393    <-> [.96] ssub * chise000got/bx/it
394 }{}
395 \DeclareFontShape{OT1}{chise000}{bx}{slsc}{
396    <-> [.96] ssub * chise000got/bx/it
397 }{}
398 %%% GT
399 \DeclareFontFamily{OT1}{gt01}{}
400 \DeclareFontShape{OT1}{gt01}{m}{n}{
401    <-> gt01
402 }{}
403 \DeclareFontFamily{OT1}{gt02}{}
404 \DeclareFontShape{OT1}{gt02}{m}{n}{
405    <-> gt02
406 }{}
407 \DeclareFontFamily{OT1}{gt03}{}
408 \DeclareFontShape{OT1}{gt03}{m}{n}{
409    <-> gt03
410 }{}
411 \DeclareFontFamily{OT1}{gt04}{}
412 \DeclareFontShape{OT1}{gt04}{m}{n}{
413    <-> gt04
414 }{}
415 \DeclareFontFamily{OT1}{gt05}{}
416 \DeclareFontShape{OT1}{gt05}{m}{n}{
417    <-> gt05
418 }{}
419 \DeclareFontFamily{OT1}{gt06}{}
420 \DeclareFontShape{OT1}{gt06}{m}{n}{
421    <-> gt06
422 }{}
423 \DeclareFontFamily{OT1}{gt07}{}
424 \DeclareFontShape{OT1}{gt07}{m}{n}{
425    <-> gt07
426 }{}
427 \DeclareFontFamily{OT1}{gt08}{}
428 \DeclareFontShape{OT1}{gt08}{m}{n}{
429    <-> gt08
430 }{}
431 \DeclareFontFamily{OT1}{gt09}{}
432 \DeclareFontShape{OT1}{gt09}{m}{n}{
433    <-> gt09
434 }{}
435 \DeclareFontFamily{OT1}{gt10}{}
436 \DeclareFontShape{OT1}{gt10}{m}{n}{
437    <-> gt10
438 }{}
439 \DeclareFontFamily{OT1}{gt11}{}
440 \DeclareFontShape{OT1}{gt11}{m}{n}{
441    <-> gt11
442 }{}
443
444 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
445 % line break, from omega-japanese.
446
447 \def\CJKunbreakablekernone{%
448   \nobreak
449   \hskip 0sp plus 2sp minus 2sp
450   \nobreak
451 }
452 \def\CJKunbreakablekerntwo{%
453   \penalty 500
454   \hskip 0sp plus 2sp minus 2sp
455   \penalty 500
456 }
457 \def\CJKunbreakablekernthree{%
458   \penalty 200
459   \hskip 0sp plus 2sp minus 2sp
460   \penalty 200
461 }
462 \def\CJKbreakablekern{\hskip 0sp plus 2pt minus 2sp}
463 % BUG: \rlap should preserve the current font
464 \def\CJKprotrude#1{%
465   \discretionary{\rlap{#1}}%
466                 {}%
467                 {#1}%
468 }
469 %% Hyphenation parameters
470   % If the badness does not exceed this, no hyphenation is
471   % attempted
472   \pretolerance=-1
473
474   % Maximal badness
475   \tolerance=200
476
477   % Penalty added for the first hyphenation
478   % in the current paragraph
479   \hyphenpenalty=0 % Was 50
480
481   % Penalty added for subsequent hyphenations
482   \exhyphenpenalty=0 % Was 50
483
484   % TeX tries to minimize the demerit of the lines:
485   % (\linepenalty^2 + badness^2) + penalty^2
486   \linepenalty=10
487
488   % If a tight line is followed by a loose one
489   % (or conversely), we add \adjdemerits 
490   % to the demerit
491   \adjdemerits=0 % Was 10000 % ???
492
493   % two hyphens on consecutive lines also add 
494   % to the demerit
495   \doublehyphendemerits=0 % Was 10000
496
497   % A hyphen on the last line also adds to
498   % the demerit.
499   \finalhyphendemerits=0 % Was 5000
500
501   % Minimum number of characters in the current word
502   % before or after a hyphenation point
503   \lefthyphenmin=2
504   \righthyphenmin=3
505
506 % line break definition ends.
507
508 \ProcessOptions
509 \endinput