6 %% Avoid multiple loading.
7 \csname\if11luatexjacoreLoaded\fi\endcsname
9 \catcode32=\the\catcode32%
10 \catcode33=\the\catcode33%
11 \catcode35=\the\catcode35%
12 \catcode40=\the\catcode40%
13 \catcode41=\the\catcode41%
14 \catcode42=\the\catcode42%
15 \catcode43=\the\catcode43%
16 \catcode44=\the\catcode44%
17 \catcode45=\the\catcode45%
18 \catcode46=\the\catcode46%
19 \catcode58=\the\catcode58%
20 \catcode59=\the\catcode59%
21 \catcode60=\the\catcode60%
22 \catcode61=\the\catcode61%
23 \catcode62=\the\catcode62%
24 \catcode64=\the\catcode64%
25 \catcode91=\the\catcode91%
26 \catcode93=\the\catcode93%
27 \catcode94=\the\catcode94%
28 \catcode95=\the\catcode95%
29 \catcode126=\the\catcode126%
30 \endlinechar=\the\endlinechar
54 %! なお, 上のcatcode設定はcoreとcompatで同一にしておく.
55 \edef\ltj@core@AtEnd{\x
56 \noexpand\let\noexpand\ltj@core@AtEnd\relax}
57 \def\luatexjacoreLoaded{\endinput}
59 %% Check if LaTeX is used.
60 \begingroup\expandafter\expandafter\expandafter\endgroup
61 \expandafter\ifx\csname RequirePackage\endcsname\relax %<*!LaTeX>
62 \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
63 \csname iffalse\endcsname
65 \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
66 \csname iftrue\endcsname
67 \NeedsTeXFormat{LaTeX2e}
68 \ProvidesPackage{luatexja-core}[2011/04/01 v0.1]
71 %% Load prerequisite packages.
72 %! 参考: W32TeX の LuaTeX
73 %! 2010/11/27 v0.65.0 r3988 (LuaTeX-ja の最低要件)
74 %! 2010/07/10 v0.60.2 r3735 (TL2010 とほぼ同じ)
76 %! 外部パッケージは普通の \endlinechar で読まないと危険.
77 \ifltj@in@latex %<*LaTeX>
78 \RequirePackage{luaotfload} [2010/11/11] % v1.21
79 \RequirePackage{infwarerr} [2010/04/08] % v1.3
80 \RequirePackage{ltxcmds} [2010/04/26] % v1.7
81 \RequirePackage{pdftexcmds} [2010/04/01] % v0.9
82 \RequirePackage{xkeyval} [2008/08/13] % v2.6a
92 %% Check if LuaTeX is used
93 \ltx@LocalExpandAfter\ifx\csname directlua\endcsname\relax
94 % Loading is silently aborted, since the notice of the wrong
95 % engine is aldready shown in otfluaload.
97 \expandafter\endinput\fi\relax
99 %% Check LuaTeX version.
100 \ifnum\luatexversion<65
101 \@PackageError{luatexja-core}
102 {This LuaTeX engine is too old for this package;\MessageBreak
103 at least v0.65 is needed}
104 {Package loading is aborted now.\MessageBreak}
105 \expandafter\endinput\fi\relax
107 %! なお、luatexbase-compat の説明に従うと、LuaTeX 拡張プリミティブは
108 %! plain/LaTeX の両方で \luatex 付の名前(\directlua はそのまま)
111 %% \LuaTeXjaAvailable
113 \let\LuaTeXjaAvailable=t %
117 %% Load all sub-packages.
118 \ifltj@in@latex %<*LaTeX>
119 \RequirePackage{luatexja-cctbreg}[2011/04/01]
120 \RequirePackage{luatexja-base}[2011/04/01]
122 \input luatexja-cctbreg.sty %
123 \input luatexja-base.sty %
128 %! この中に master の luatexja-core.sty の内容を挿入する
130 % LuaTeX-ja core TeX source
134 \def\ltj@loaded{hoge}
136 \newcount\ltj@tempcnta
137 \newcount\ltj@tempcntb
138 \newcount\ltj@tempcntc
139 \newdimen\ltj@tempdima
140 \newskip\ltj@tempskipa
144 \newdimen\jQ \jQ=0.25mm
145 \newdimen\jH \jH=0.25mm
147 %%%%%%%% Attributes for Japanese typesetting.
148 \newluatexattribute\ltj@curjfnt % index for ``current Japanese font''
149 \newluatexattribute\ltj@charclass %
150 \newluatexattribute\ltj@yablshift % attribute for \yabaselineshift
151 \newluatexattribute\ltj@ykblshift % attribute for \ykbaselineshift
152 \newluatexattribute\ltj@autospc % attribute for autospacing
153 \newluatexattribute\ltj@autoxspc % attribute for autoxspacing
154 \newluatexattribute\ltj@icflag % attribute for italic correction
155 \newlanguage\ltj@japanese
157 %%%%%%%% Loading lua files
161 function ltj.loadlua(file)
162 local path = assert(kpse.find_file(file, 'tex'),
163 "File '"..file.."' not found")
164 texio.write_nl("("..path..")")
168 ltj.loadlua('luatexja-rmlgbm.lua')
169 % For Ryumin-Light and GothicBBB-Medium.
170 ltj.loadlua('luatexja-jfont.lua')
171 ltj.loadlua('luatexja-core.lua')
172 ltj.loadlua('luatexja-jfmglue.lua')
173 ltj.loadlua('luatexja-xkanji.lua')
177 %%%%%%%% Attributes for character ranges
179 \loop\ifnum\ltj@tempcnta<7
180 \expandafter\newluatexattribute%
181 \csname ltj@kcat\the\ltj@tempcnta\endcsname
182 \csname ltj@kcat\the\ltj@tempcnta\endcsname=0
183 \advance\ltj@tempcnta by1
186 %%%%%%%% \asluastring
187 \def\asluastring#1{'\luaescapestring{\detokenize{#1}}'}
190 %\let\ltj@ic=\/ \protected\def\/{{\ltj@icflag=1\ltj@ic}}
191 \protected\def\/{\directlua{ltj.ext_append_italic()}}
193 %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
194 \protected\def\jfont{\afterassignment\ltj@@jfont\directlua{ltj.ext_jfontdefX(false)}}
195 \protected\def\globaljfont{%
196 \afterassignment\ltj@@jfont\directlua{ltj.ext_jfontdefX(true)}}
197 \def\ltj@@jfont{\directlua{ltj.ext_jfontdefY()}}
199 %%%%%%%% \inhibitglue
200 \protected\def\inhibitglue{\directlua{ltj.ext_create_inhibitglue_node()}}
202 %%%%%%%% \ltjdefcharrange<name>{100-200,3000-,5000,...}
203 \protected\def\ltjdefcharrange#1#2{%
204 \ltj@tempcntc=#1 \expandafter\ltj@@dcrange#2,,\ignorespaces}
205 \def\ltj@@dcrange#1,{\def\ltj@temp{#1}%
206 \ifx\ltj@temp\empty\let\@next=\relax\else
207 \ltj@@dcrangeA{#1}\let\@next=\ltj@@dcrange\fi\@next}
208 \def\ltj@@dcrangeA#1{\ltj@@dcrangeB#1--\@nil}
209 \def\ltj@@dcrangeB#1-#2-#3\@nil{\def\ltj@temp{#3}%
211 \ltj@tempcnta=#1 \ltj@tempcntb=\ltj@tempcnta
214 \ifx\ltj@temp\empty\ltj@tempcnta='200 \else\ltj@tempcnta=#1 \fi
216 \ifx\ltj@temp\empty\ltj@tempcntb="10FFFF \else\ltj@tempcntb=#2 \fi%"
218 \directlua{ltj.ext_add_char_range(\the\ltj@tempcnta,\the\ltj@tempcntb,
222 %%%%%%%% \ltjsetparameter
223 \newcount\ltj@@stack \newcount\ltj@@group@level
224 \ltj@@group@level=0 \ltj@@stack=0
226 % prebreakpenalty = {<char_code>, <penalty>}
227 \define@key[ltj]{japaram}{kcatcode}{%
228 \expandafter\ltj@@set@stack#1:{kcat}{0}{0x7FFFFFFF}}
229 \define@key[ltj]{japaram}{prebreakpenalty}{%
230 \expandafter\ltj@@set@stack#1:{pre}{-10000}{10000}}
231 \define@key[ltj]{japaram}{postbreakpenalty}{%
232 \expandafter\ltj@@set@stack#1:{post}{-10000}{10000}}
233 \def\ltj@@set@stack#1,#2:#3#4#5{%
234 \ltj@tempcnta=#1\relax \ltj@tempcntb=#2\relax
235 \directlua{ltj.ext_set_stack_table(ltj.isglobal, \asluastring{#3},
236 \the\ltj@tempcnta,tex.getcount('ltj@tempcntb'),#4,#5)}}
238 % yalbaselineshift = <dimen>
239 % yjabaselineshift = <dimen>
240 \define@key[ltj]{japaram}{yalbaselineshift}{%
241 \ltj@tempdima=#1\relax%
242 \directlua{tex.setattribute(ltj.isglobal,
243 luatexbase.attributes['ltj@yablshift'],
244 tex.getdimen('ltj@tempdima'))}}
245 \define@key[ltj]{japaram}{yjabaselineshift}{%
246 \ltj@tempdima=#1\relax%
247 \directlua{tex.setattribute(ltj.isglobal,
248 luatexbase.attributes['ltj@ykblshift'],
249 tex.getdimen('ltj@tempdima'))}}
251 % jaxspmode = {<char_code>, <mode>}
252 % mode: inhibit, preonly, postonly, allow
254 \define@key[ltj]{japaram}{jaxspmode}{% \inhibitxspcode
255 \expandafter\ltj@set@jaxspmode#1:\relax}
256 \def\ltj@set@jaxspmode#1,#2:{%
257 \lowercase{\edef\ltj@temp{#2}}%
258 \def\ltj@tempa{inhibit}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{0}\fi
259 \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
260 \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
261 \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
262 \ltj@tempcnta=#1\relax\ltj@tempcntb=\ltj@temp\relax
263 \directlua{ltj.ext_set_stack_table(ltj.isglobal, 'xsp', \the\ltj@tempcnta,
264 \the\ltj@tempcntb,0,3)}}
266 % alxspmode = {<char_code>, <mode>}
267 % mode: inhibit, preonly, postonly, allow
269 \define@key[ltj]{japaram}{alxspmode}{% \inhibitxspcode
270 \expandafter\ltj@set@alxspmode#1:\relax}
271 \def\ltj@set@alxspmode#1,#2:{%
272 \lowercase{\edef\ltj@temp{#2}}%
273 \def\ltj@tempa{inhibit}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{0}\fi
274 \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
275 \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
276 \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
277 \ltj@tempcnta=#1\relax\ltj@tempcntb=\ltj@temp\relax
278 \directlua{ltj.ext_set_stack_table(ltj.isglobal, 'xsp', \the\ltj@tempcnta,
279 \the\ltj@tempcntb,0,3)}}
281 % autospacing = <bool> (default: true)
282 \define@boolkey[ltj]{japaram}{autospacing}[true]{%
283 \ifltj@japaram@autospacing
284 \directlua{ltj.ext_print_global()}\ltj@autospc=1
286 \directlua{ltj.ext_print_global()}\ltj@autospc=0
289 % autoxspacing = <bool> (default: true)
290 \define@boolkey[ltj]{japaram}{autoxspacing}[true]{%
291 \ifltj@japaram@autoxspacing
292 \directlua{ltj.ext_print_global()}\ltj@autoxspc=1
294 \directlua{ltj.ext_print_global()}\ltj@autoxspc=0
297 \define@key[ltj]{japaram}{kanjiskip}{% % SKIP
298 \ltj@tempskipa=#1\relax
299 \directlua{ltj.ext_set_stack_skip(ltj.isglobal, 'kanjiskip')}}
300 \define@key[ltj]{japaram}{xkanjiskip}{% % SKIP
301 \ltj@tempskipa=#1\relax
302 \directlua{ltj.ext_set_stack_skip(ltj.isglobal, 'xkanjiskip')}}
303 \define@key[ltj]{japaram}{jcharwidowpenalty}{% %COUNT
305 \directlua{ltj.ext_set_stack_table(ltj.isglobal, 'jwp', 0,
306 \the\ltj@tempcnta, -10000, 10000)}}
308 % differentjfm = { large | small | average | both }
309 \define@choicekey*+[ltj]{japaram}{differentjfm}[\ltj@temp\ltj@tempr]%
310 {large,small,average,both}{%
312 \directlua{ltj.ja_diffmet_rule = math.max}\or
313 \directlua{ltj.ja_diffmet_rule = math.min}\or
314 \directlua{ltj.ja_diffmet_rule = math.two_average}\or
315 \directlua{ltj.ja_diffmet_rule = math.two_add}
317 }{\@PackageWarning{luatexja}{ignored invalid argument '#1' for 'differentjfm'}}
318 % large, small, average, both
321 % jacharrange = { +-<range_number> }
322 \define@key[ltj]{japaram}{jacharrange}{\expandafter\ltj@@scrange#1,,}
323 \def\ltj@@scrange#1,{%
325 \ifx\ltj@temp\empty\let\next=\relax\else\let\next=\ltj@@scrange
326 \ltj@tempcnta=#1 \directlua{ltj.ext_toggle_char_range(%
327 ltj.is_global,\the\ltj@tempcnta)}%
331 \protected\def\ltjsetparameter#1{\directlua{ltj.isglobal=''}%
332 \setkeys[ltj]{japaram}{#1}\ignorespaces}
333 \protected\def\ltjglobalsetparameter#1{\directlua{ltj.isglobal='global'}%
334 \setkeys[ltj]{japaram}{#1}\ignorespaces}
337 \def\ltj@@decl@array@param#1{%
338 \expandafter\let\csname ltj@@array@param/#1\endcsname=t%
340 \ltj@@decl@array@param{prebreakpenalty}
341 \ltj@@decl@array@param{postbreakpenalty}
342 \ltj@@decl@array@param{jaxspmode}
343 \ltj@@decl@array@param{alxspmode}
344 \ltj@@decl@array@param{kcatcode}
345 \ltj@@decl@array@param{jacharrange}
346 \ltj@@decl@array@param{chartorange}
347 \def\ltjgetparameter#1{%
348 \ifcsname ltj@@array@param/#1\endcsname
349 \expandafter\ltx@firstoftwo
351 \expandafter\ltx@secondoftwo
353 {\ltj@@getparam@two{#1}}%
354 {\ltj@@getparam@one{#1}}%
356 \def\ltj@@getparam@one#1{%
357 \directlua{ltj.ext_get_parameter_unary('#1')}}%
358 \def\ltj@@getparam@two#1#2{\ltj@tempcnta=#2
359 \directlua{ltj.ext_get_parameter_binary('#1', \the\ltj@tempcnta)}%
364 %\def\ltj@temp{plain}
365 %\ifx\fmtname\ltj@temp
366 % \message{plain format: loading luatexja-plain.tex}
368 %\input luatexja-plain.tex
373 %%------------------ Load module for the format
375 \ifltj@in@latex %<*LaTeX>
376 \RequirePackage{luatexja-latex}[2011/04/01]
377 \else\ifltj@in@plain %<*plain>
378 \input luatexja-plain.sty %
379 \fi\fi %</LaTeX|plain>
381 %%------------------ all done