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}[2015/05/03 Core of LuaTeX-ja]
71 %% Load prerequisite packages.
73 \newif\ifltj@everyhook@avail\ltj@everyhook@availfalse
74 %! 外部パッケージは普通の \endlinechar で読まないと危険.
75 \ifltj@in@latex %<*LaTeX>
76 \RequirePackage{luaotfload} [2013/12/31] % v2.3
77 \RequirePackage{ltxcmds} [2011/11/09] % v1.22
78 \RequirePackage{pdftexcmds} [2011/11/29] % v0.20
79 \RequirePackage{xkeyval} [2012/10/14] % v2.6b
80 \RequirePackage{atbegshi}
81 \IfFileExists{everyhook.sty}{\RequirePackage{everyhook}\ltj@everyhook@availtrue}{}
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<74
101 \@PackageError{luatexja-core}
102 {This LuaTeX engine is too old for this package;\MessageBreak
103 at least beta-0.74.0 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 %! この中に master の luatexja-core.sty の内容を挿入する
119 % LuaTeX-ja core TeX source
123 \def\ltj@loaded{hoge}
127 \newdimen\jQ \jQ=0.25mm
130 %%%%%%%% error message
134 %%%%%%%% Attributes for Japanese typesetting.
135 \newluatexattribute\ltj@icflag % attribute for italic correction
136 \newluatexattribute\ltj@curjfnt % index for ``current horizontal Japanese font''
137 \newluatexattribute\ltj@curtfnt % index for ``current vertical Japanese font''
138 \newluatexattribute\ltj@origchar %
139 \newluatexattribute\ltj@charclass %
140 \newluatexattribute\ltj@charcode %
141 \newluatexattribute\ltj@autospc % attribute for autospacing
142 \newluatexattribute\ltj@autoxspc % attribute for autoxspacing
143 \newluatexattribute\ltj@yablshift % attribute for yalbaselineshift
144 \newluatexattribute\ltj@ykblshift % attribute for yjabaselineshift
145 \newluatexattribute\ltj@tablshift % attribute for talbaselineshift
146 \newluatexattribute\ltj@tkblshift % attribute for tjabaselineshift
147 \newluatexattribute\jfam % index for current jfam
149 \newluatexattribute\ltj@dir
150 \newlanguage\ltj@@japanese
158 %%%%%%%% Attributes for character ranges
159 \newcount\ltj@tempcnta
161 \loop\ifnum\ltj@tempcnta<7
162 \expandafter\newluatexattribute%
163 \csname ltj@kcat\the\ltj@tempcnta\endcsname
164 \csname ltj@kcat\the\ltj@tempcnta\endcsname=0
165 \advance\ltj@tempcnta\@ne
169 %%%%%%%% Loading luatexja.lua
170 %% Quark tokens needed in ltj-base
171 \protected\def\ltj@@q@escape{\ltj@@q@escape@}
172 \protected\def\ltj@@q@escapenum{\ltj@@q@escapenum@}
176 luatexja.lang_ja = \the\ltj@@japanese;
177 dofile(assert(kpse.find_file('luatexja.lua', 'tex'),
178 "File `luatexja.lua' not found"))
181 %% \RequireLuaTeXjaSubmodule{name}[date]
182 % A TeX version of luatexja.load_module(name)
183 % The second optional argument [date] is simply ignored.
184 \def\RequireLuaTeXjaSubmodule#1{%
185 \@ifnextchar[{\ltj@requirelua@submod{#1}}{\ltj@requirelua@submod{#1}[]}}
186 \def\ltj@requirelua@submod#1[#2]{%
187 \directlua{luatexja.load_module(
188 "\luatexluaescapestring{#1}")}}
191 %%%%%%%% Load all sub-packages.
192 \ifltj@in@latex %<*LaTeX>
193 \RequirePackage{ltj-base} [2013/05/14]
195 \input ltj-base.sty %
198 %%%%%%%% \asluastring
199 \def\asluastring#1{'\luatexluaescapestring{\detokenize{#1}}'}
202 \protected\def\/{\relax\directlua{luatexja.jfont.append_italic()}}
204 %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
205 \protected\def\jfont#1{%
206 \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko','\luatexluaescapestring{\noexpand#1}')}}
207 \protected\def\globaljfont#1{%
208 \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'yoko','\luatexluaescapestring{\noexpand#1}')}}
209 \def\ltj@@jfont{\directlua{luatexja.jfont.jfontdefY()}}
211 %%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont
212 \protected\def\tfont#1{%
213 \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(false, 'tate','\luatexluaescapestring{\noexpand#1}')}}
214 \protected\def\globaltfont#1{%
215 \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(true, 'tate','\luatexluaescapestring{\noexpand#1}')}}
216 \def\ltj@@tfont{\directlua{luatexja.jfont.jfontdefY()}}
219 \protected\def\zw{\directlua{tex.setdimen('ltj@zw', luatexja.jfont.get_zw())}\ltj@zw}
220 \protected\def\zh{\directlua{tex.setdimen('ltj@zh', luatexja.jfont.get_zh())}\ltj@zh}
222 %%%%%%%% \inhibitglue
223 \protected\def\ltj@reset@globaldefs{%
224 \directlua{luatexja.global_temp = tex.globaldefs; tex.globaldefs = 0}}
225 \protected\def\ltj@restore@globaldefs{\directlua{tex.globaldefs = luatexja.global_temp}\relax}
226 \protected\def\inhibitglue{\ifhmode\ltj@@ihb\fi}
227 \def\ltj@@ihb{\relax\directlua{luatexja.jfmglue.create_inhibitglue_node()}}
229 %%%%%%%% \ltjdefcharrange<name>{100-200,3000-,5000,...}
230 \protected\def\ltjdefcharrange#1#2{%
231 {\ltj@tempcntc=#1 \expandafter\ltj@@dcrange#2,,}\ignorespaces}
232 \def\ltj@@dcrange#1,{\def\ltj@temp{#1}%
233 \ifx\ltj@temp\empty\let\@next=\relax\else
234 \ltj@@dcrangeA{#1}\let\@next=\ltj@@dcrange\fi\@next}
235 \def\ltj@@dcrangeA#1{\ltj@@dcrangeB#1--\@nil}
236 \def\ltj@@dcrangeB#1-#2-#3\@nil{\def\ltj@temp{#3}%
238 \ltj@tempcnta=#1 \ltj@tempcntb=\ltj@tempcnta
241 \ifx\ltj@temp\empty\ltj@tempcnta='200\else\ltj@tempcnta=#1\fi\relax
243 \ifx\ltj@temp\empty\ltj@tempcntb="10FFFF\else\ltj@tempcntb=#2\fi\relax%"
245 \directlua{luatexja.charrange.add_char_range(\the\ltj@tempcnta,\the\ltj@tempcntb,
249 %%%%%%%% \ltjsetparameter
250 \newcount\ltj@@stack \newcount\ltj@@group@level
251 \ltj@@group@level\z@\ltj@@stack\z@
254 \directlua{% This value depends on the version of LuaTeX.
255 luatexja.stack.hmode = -tex.nest[tex.nest.ptr].mode
259 \directlua{% This value depends on the version of LuaTeX.
260 luatexja.stack.vmode = -tex.nest[tex.nest.ptr].mode
263 \setbox\z@\box\voidb@x
265 % prebreakpenalty = {<char_code>, <penalty>}
266 \define@key[ltj]{japaram}{kcatcode}{\ltj@@set@stack{KCAT}{0}{0x7FFFFFFF}#1\relax}
267 \define@key[ltj]{japaram}{prebreakpenalty}{\ltj@@set@stack{PRE}{-10000}{10000}#1\relax}
268 \define@key[ltj]{japaram}{postbreakpenalty}{\ltj@@set@stack{POST}{-10000}{10000}#1\relax}
269 \def\ltj@@set@stack#1#2#3{%
270 \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#1,#2,#3)}}
271 %\def\ltj@@set@stack#1,#2:#3#4#5{%
272 % \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#3,
273 % \ltj@safe@num@or{nil}{#1},\ltj@safe@num@or{nil}{#2},#4,#5)}}
275 % jatextfont = {<char_code>, <font_cs>}
276 % only horizontal font is supported
277 \define@key[ltj]{japaram}{jatextfont}{%
278 \expandafter\ltj@@set@stackfont#1:{MJT}}
279 \define@key[ltj]{japaram}{jascriptfont}{%
280 \expandafter\ltj@@set@stackfont#1:{MJS}}
281 \define@key[ltj]{japaram}{jascriptscriptfont}{%
282 \expandafter\ltj@@set@stackfont#1:{MJSS}}
283 \protected\def\ltj@@set@stackfont#1,#2:#3{%
284 \ltj@reset@globaldefs
285 \ltj@tempcnta=\ltj@curjfnt\ltj@curjfnt\m@ne#2%
286 \ifnum\ltj@curjfnt=\m@ne
287 \@PackageError{luatexja-core}%
288 {\string#2 is not a control sequence that represents \MessageBreak
291 \directlua{luatexja.stack.set_stack_font(luatexja.stack_table_index.#3,
292 \ltj@safe@num@or{nil}{#1}, \the\ltj@curjfnt)}%
294 \ltj@curjfnt=\ltj@tempcnta
295 \ltj@restore@globaldefs
298 % {y,t}{ja,al}baselineshift = <dimen>
299 % yjabaselineshift = <dimen>
300 \define@key[ltj]{japaram}{yalbaselineshift}{%
301 \directlua{tex.setattribute(luatexja.isglobal,
302 luatexbase.attributes['ltj@yablshift'], luatexja.token.scan_dimen())}#1\relax}
303 \define@key[ltj]{japaram}{yjabaselineshift}{%
304 \directlua{tex.setattribute(luatexja.isglobal,
305 luatexbase.attributes['ltj@ykblshift'], luatexja.token.scan_dimen())}#1\relax}
306 \define@key[ltj]{japaram}{talbaselineshift}{%
307 \directlua{tex.setattribute(luatexja.isglobal,
308 luatexbase.attributes['ltj@tablshift'], luatexja.token.scan_dimen())}#1\relax}
309 \define@key[ltj]{japaram}{tjabaselineshift}{%
310 \directlua{tex.setattribute(luatexja.isglobal,
311 luatexbase.attributes['ltj@tkblshift'], luatexja.token.scan_dimen())}#1\relax}
313 % jaxspmode = {<char_code>, <mode>}
314 % mode: inhibit, preonly, postonly, allow
316 \define@key[ltj]{japaram}{jaxspmode}{% \inhibitxspcode
317 \expandafter\ltj@set@jaxspmode#1:\relax}
318 \def\ltj@set@jaxspmode#1,#2:{%
319 \lowercase{\edef\ltj@temp{#2}}%
320 \def\ltj@tempa{inhibit}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{0}\fi
321 \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
322 \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
323 \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
324 \ltj@@set@stack{XSP}03#1 \ltj@temp}
326 % alxspmode = {<char_code>, <mode>}
327 % mode: inhibit, preonly, postonly, allow
329 \define@key[ltj]{japaram}{alxspmode}{% \inhibitxspcode
330 \expandafter\ltj@set@jaxspmode#1:\relax}% same code as jaxspmode
332 % autospacing = <bool> (default: true)
333 \define@boolkey[ltj]{japaram}{autospacing}[true]{%
334 \ifltj@japaram@autospacing
335 \directlua{luatexja.ext_print_global()}\ltj@autospc\@ne
337 \directlua{luatexja.ext_print_global()}\ltj@autospc\z@
340 % autoxspacing = <bool> (default: true)
341 \define@boolkey[ltj]{japaram}{autoxspacing}[true]{%
342 \ifltj@japaram@autoxspacing
343 \directlua{luatexja.ext_print_global()}\ltj@autoxspc\@ne
345 \directlua{luatexja.ext_print_global()}\ltj@autoxspc\z@
348 % [x]]kanjiskip = <skip>
349 \define@key[ltj]{japaram}{kanjiskip}{\ltjsetkanjiskip#1}
350 \define@key[ltj]{japaram}{xkanjiskip}{\ltjsetxkanjiskip#1}
351 \protected\def\ltjsetkanjiskip{% % SKIP
353 local d = luatexja.token.scan_glue()
354 luatexja.stack.set_stack_skip(luatexja.stack_table_index.KSK, d); node.free(d)
356 \protected\def\ltjsetxkanjiskip{% % SKIP
358 local d = luatexja.token.scan_glue()
359 luatexja.stack.set_stack_skip(luatexja.stack_table_index.XSK, d); node.free(d)
362 % jcharwidowpenalty = <count>
363 \define@key[ltj]{japaram}{jcharwidowpenalty}{% %COUNT
364 \ltj@@set@stack{JWP}{-10000}{10000}\z@#1 }
366 % differentjfm = { large | small | average | pleft | pright | paverage | both}
367 \define@choicekey*+[ltj]{japaram}{differentjfm}[\ltj@temp\ltj@tempr]%
368 {large,small,average,pleft,pright,paverage,both}{%
370 \directlua{luatexja.jfmglue.diffmet_rule = math.max}\or
371 \directlua{luatexja.jfmglue.diffmet_rule = math.min}\or
372 \directlua{luatexja.jfmglue.diffmet_rule = math.two_average}\or
373 \directlua{luatexja.jfmglue.diffmet_rule = math.two_pleft}\or
374 \directlua{luatexja.jfmglue.diffmet_rule = math.two_pright}\or
375 \directlua{luatexja.jfmglue.diffmet_rule = math.two_paverage}\or
376 \directlua{luatexja.jfmglue.diffmet_rule = math.two_add}
378 }{\ltj@PackageError{luatexja}{invalid argument `#1' for `differentjfm'}{%
379 Argument for `differentjfm' must be one of `large', `small', `average',^^J%
380 `pleft', `pright', 'paverage' or `both'. }}
381 % large, small, average, pleft, pright, paverage, both
384 % jacharrange = { +-<range_number> }
385 \define@key[ltj]{japaram}{jacharrange}{\expandafter\ltj@@scrange#1,,}
386 \def\ltj@@scrange#1,{%
388 \ifx\ltj@temp\empty\let\next=\relax\else\let\next=\ltj@@scrange
389 \directlua{luatexja.charrange.toggle_char_range(%
390 luatexja.is_global,\ltj@safe@num@or{nil}{#1})}%
394 \protected\def\ltj@setpar@global{%
395 \relax\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}%
396 \else\directlua{luatexja.isglobal=''}\fi
398 \protected\def\ltjsetparameter#1{%
399 \directlua{luatexja.base.start_time_measure('set_par')}%
400 \ltj@setpar@global\setkeys[ltj]{japaram}{#1}%
401 \directlua{luatexja.base.stop_time_measure('set_par')}%
403 \protected\def\ltjglobalsetparameter#1{%
404 \relax\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}%
405 \else\directlua{luatexja.isglobal='global'}\fi%
406 \directlua{luatexja.base.start_time_measure('set_par')}%
407 \setkeys[ltj]{japaram}{#1}%
408 \directlua{luatexja.base.stop_time_measure('set_par')}%
411 %%%%%%%% \ltjgetparameter
412 \def\ltj@@decl@array@param#1{%
413 \expandafter\let\csname ltj@@array@param/#1\endcsname=t%
415 \ltj@@decl@array@param{prebreakpenalty}
416 \ltj@@decl@array@param{postbreakpenalty}
417 \ltj@@decl@array@param{jaxspmode}
418 \ltj@@decl@array@param{alxspmode}
419 \ltj@@decl@array@param{kcatcode}
420 \ltj@@decl@array@param{jacharrange}
421 \ltj@@decl@array@param{chartorange}
422 \ltj@@decl@array@param{boxdir}
423 \def\ltjgetparameter#1{%
424 \directlua{luatexja.base.start_time_measure('get_par')}%
425 % stop call is moved in luatexja.lua
426 \ifcsname ltj@@array@param/#1\endcsname
427 \expandafter\ltx@firstoftwo
429 \expandafter\ltx@secondoftwo
431 {\ltj@@getparam@two{#1}}%
432 {\ltj@@getparam@one{#1}}%
434 \def\ltj@@getparam@one#1{%
435 \directlua{luatexja.ext_get_parameter_unary('#1')}%
437 \def\ltj@@getparam@two#1#2{%
438 \directlua{luatexja.ext_get_parameter_binary('#1', \ltj@safe@num@or{nil}{#2})}%
441 %%%%%%%% \ltjalchar<number>, \ltjjachar<number>
442 \let\ltj@@origchar=\char
443 \protected\def\ltj@alljachar{\relax
444 \csname ltj@kcat0\endcsname\z@
445 \csname ltj@kcat1\endcsname\z@
446 \csname ltj@kcat2\endcsname\z@
447 \csname ltj@kcat3\endcsname\z@
448 \csname ltj@kcat4\endcsname\z@
449 \csname ltj@kcat5\endcsname\z@
450 \csname ltj@kcat6\endcsname\z@}
451 \protected\def\ltj@allalchar{\relax
452 \csname ltj@kcat0\endcsname="7FFFFFFF %"
453 \csname ltj@kcat1\endcsname="7FFFFFFF %"
454 \csname ltj@kcat2\endcsname="7FFFFFFF %"
455 \csname ltj@kcat3\endcsname="7FFFFFFF %"
456 \csname ltj@kcat4\endcsname="7FFFFFFF %"
457 \csname ltj@kcat5\endcsname="7FFFFFFF %"
458 \csname ltj@kcat6\endcsname="7FFFFFFF }%"
460 \protected\def\ltjjachar{\afterassignment\ltj@@jachar\ltj@tempcnta}
461 \def\ltj@@jachar{{\directlua{tex.globaldefs=0}\ltj@alljachar\ltj@@origchar\ltj@tempcnta}}
462 \protected\def\ltjalchar{\afterassignment\ltj@@alchar\ltj@tempcnta}
463 \def\ltj@@alchar{{\directlua{tex.globaldefs=0}\ltj@allalchar\ltj@@origchar\ltj@tempcnta}}
465 %%%%%%%% \ltjsetmathletter<number>, \ltjunsetmathletter<number>
466 \protected\def\ltjsetmathletter#1{%
467 \directlua{luatexja.math.is_math_letters[luatexja.token.scan_int()]=true}#1\relax
469 \protected\def\ltjunsetmathletter#1{%
470 \directlua{luatexja.math.is_math_letters[luatexja.token.scan_int()]=false}#1\relax
473 %%%%%%%% \ltjdeclarealtfont<base_font_cs><alt_font_cs>{100-200,3000-,5000,...}
474 % <base_font_cs> の 第 3 引数の文字達は <alt_font_cs> で組む
476 \def\ltj@@getjfontnumber#1{% result in \ltj@tempcntc
477 \ltj@reset@globaldefs
478 \begingroup\ltj@curjfnt\m@ne\ltj@curtfnt\m@ne\relax
479 #1\directlua{luatexja.__temp = -(\the\ltj@curjfnt)*(\the\ltj@curtfnt)}\endgroup
480 \ltj@tempcntc=\directlua{tex.sprint(luatexja.__temp)}\relax
481 \ifnum\ltj@tempcntc=\m@ne
482 \@PackageError{luatexja-core}%
483 {\string#1 is not a control sequence that represents \MessageBreak
484 a Japanese font}{I'll use the current horizontal Japanese font instead.^^J}%
485 \ltj@tempcntc=\ltj@curjfnt
486 \fi\ltj@restore@globaldefs}
488 \protected\def\ltjdeclarealtfont#1#2#3{%
489 {\ltj@@getjfontnumber#1\@tempcnta=\ltj@tempcntc% \@tempcnta: 基底フォント
490 \ltj@@getjfontnumber#2%
491 \expandafter\ltj@@altfont#3,,}\ignorespaces}
492 \def\ltj@@altfont#1,{\def\ltj@temp{#1}%
493 \ifx\ltj@temp\empty\let\@next=\relax\else
494 \ltj@@altfontA{#1}\let\@next=\ltj@@altfont\fi\@next}
495 \def\ltj@@altfontA#1{\ltj@@altfontB#1--\@nil}
496 \def\ltj@@altfontB#1-#2-#3\@nil{\def\ltj@temp{#3}%
498 \ltj@tempcnta=#1 \ltj@tempcntb=\ltj@tempcnta
501 \ifx\ltj@temp\empty\ltj@tempcnta='200\else\ltj@tempcnta=#1\fi\relax
503 \ifx\ltj@temp\empty\ltj@tempcntb="10FFFF\else\ltj@tempcntb=#2\fi\relax%"
505 \directlua{luatexja.jfont.set_alt_font(
506 \the\ltj@tempcnta,\the\ltj@tempcntb,
507 \the\ltj@tempcntc, \the\@tempcnta)}%
510 %%%%%%%% \ltjclearaltfont<font_cs>
511 % <font_cs> の文字は全部 <font_cs> 本来の文字で組む
512 \protected\def\ltjclearaltfont#1{%
513 {\ltj@@getjfontnumber#1%
514 \directlua{luatexja.jfont.clear_alt_font(\the\ltj@tempcntc)}}\ignorespaces}
517 %%%%%%%% \yoko, \tate,\dtou
518 \protected\def\tate{%
519 \directlua{luatexja.direction.set_list_direction(3, 'tate')}%
521 \protected\def\yoko{%
522 \directlua{luatexja.direction.set_list_direction(4, 'yoko')}%
524 \protected\def\dtou{%
525 \directlua{luatexja.direction.set_list_direction(1, 'dtou')}%
527 \protected\def\utod{% 「縦数式ディレクション」
528 \directlua{luatexja.direction.set_list_direction(11, 'utod')}%
530 \define@key[ltj]{japaram}{direction}{%% always local
531 \directlua{luatexja.direction.set_list_direction(1, 'ltjsetparameter')}%
537 \let\orig@insert=\insert
538 \protected\def\insert{\begingroup\afterassignment\ltj@@insert@A\ltj@tempcnta}
539 \protected\def\ltj@@insert@A{\orig@insert\ltj@tempcnta\bgroup
540 \aftergroup\ltj@@insert@B\let\next}
541 \protected\def\ltj@@insert@B{\directlua{luatexja.direction.populate_insertion_dir_whatsit()}\endgroup}
544 \let\ltj@@orig@vadjust=\vadjust
545 \protected\def\vadjust{%
546 \ltj@@orig@vadjust\bgroup
547 \directlua{luatexja.direction.set_list_direction_hook('adj')}%
548 \aftergroup\ltj@@vadjust@check@dir\let\next}
549 \protected\def\ltj@@vadjust@check@dir{%
550 \directlua{luatexja.direction.check_adjust_direction()}%
553 %%%% \hbox, \vbox, \vtop
555 $\directlua{% This value depends on the version of LuaTeX.
556 luatexja.stack.mmode = -tex.nest[tex.nest.ptr].mode
559 \setbox\z@\box\voidb@x
560 \ifltj@everyhook@avail% using everyhook package
562 \directlua{luatexja.direction.set_list_direction_hook()}%
563 \aftergroup\ltj@@reset@badness
566 \directlua{luatexja.direction.set_list_direction_hook()}%
567 \aftergroup\ltj@@reset@badness
570 \let\ltj@@everyhbox=\everyhbox\let\ltj@@everyvbox=\everyvbox
571 \newtoks\ltj@@i@everyhbox\newtoks\ltj@@i@everyvbox
572 \let\everyhbox=\ltj@@i@everyhbox\let\everyvbox=\ltj@@i@everyvbox
574 \directlua{luatexja.direction.set_list_direction_hook()}%
575 \aftergroup\ltj@@reset@badness
576 \the\ltj@@i@everyhbox}
578 \directlua{luatexja.direction.set_list_direction_hook()}%
579 \aftergroup\ltj@@reset@badness
580 \the\ltj@@i@everyvbox}
583 \protected\def\ltj@@reset@badness{%
585 if luatexja.global_temp then
586 tex.hbadness= tex.hbadness or luatexja.hbadness_temp
587 tex.vbadness= tex.vbadness or luatexja.vbadness_temp
588 tex.globaldefs= luatexja.global_temp or tex.globaldefs
592 \AtBeginShipout{\directlua{luatexja.direction.finalize()}}
594 %%%% \raise, \lower, \moveleft, \moveright
595 \let\ltj@@orig@raise=\raise
596 \let\ltj@@orig@lower=\lower
597 \protected\def\raise{\ltj@reset@globaldefs\afterassignment\ltj@@raise\ltj@tempdima}
598 \protected\def\lower{\ltj@reset@globaldefs\afterassignment\ltj@@raise\ltj@tempdima-}
599 \protected\def\ltj@@raise{%
600 \ltj@restore@globaldefs
602 \noexpand\directlua{luatexja.direction.raise_box()}%
603 \ltj@@orig@raise\the\ltj@tempdima\noexpand\box\ltj@afbox
604 }\ltj@afterbox\ltj@@raise@a}
605 \let\ltj@@orig@moveleft=\moveleft
606 \let\ltj@@orig@moveright=\moveright
607 \protected\def\moveleft{\ltj@reset@globaldefs\afterassignment\ltj@@moveleft\ltj@tempdima}
608 \protected\def\moveright{\ltj@reset@globaldefs\afterassignment\ltj@@moveleft\ltj@tempdima-}
609 \protected\def\ltj@@moveleft{%
610 \ltj@restore@globaldefs
611 \edef\ltj@@moveleft@a{%
612 \noexpand\directlua{luatexja.direction.raise_box()}%
613 \ltj@@orig@moveleft\the\ltj@tempdima\noexpand\box\ltj@afbox
614 }\ltj@afterbox\ltj@@moveleft@a}
617 \let\ltj@@orig@vcenter=\vcenter
618 \protected\def\vcenter{\ltj@afterbox\ltj@@vcenter\vbox}
619 \protected\def\ltj@@vcenter{%
620 \directlua{luatexja.direction.raise_box()}%
621 \ltj@@orig@vcenter{\box\ltj@afbox}%
624 %%%% \unhbox and \unvbox
625 \long\def \@gobbletwo #1#2{}
626 \let\ltj@@orig@unhbox=\unhbox
627 \let\ltj@@orig@unvbox=\unvbox
628 \protected\def\unhbox{\ltj@reset@globaldefs\afterassignment\ltj@@unhbox\ltj@tempcnta}
629 \protected\def\unvbox{\ltj@reset@globaldefs\afterassignment\ltj@@unvbox\ltj@tempcnta}
630 \protected\def\ltj@@unhbox{%
631 \directlua{luatexja.direction.unbox_check_dir()}%
632 \ltj@@orig@unhbox\ltj@tempcnta}
633 \protected\def\ltj@@unvbox{%
634 \directlua{luatexja.direction.unbox_check_dir()}%
635 \ltj@@orig@unvbox\ltj@tempcnta}
636 \let\ltj@@orig@unhcopy=\unhcopy
637 \let\ltj@@orig@unvcopy=\unvcopy
638 \protected\def\unhcopy{\ltj@reset@globaldefs\afterassignment\ltj@@unhcopy\ltj@tempcnta}
639 \protected\def\unvcopy{\ltj@reset@globaldefs\afterassignment\ltj@@unvcopy\ltj@tempcnta}
640 \protected\def\ltj@@unhcopy{%
641 \directlua{luatexja.direction.unbox_check_dir(true)}%
642 \ltj@@orig@unhcopy\ltj@tempcnta
643 \directlua{luatexja.direction.uncopy_restore_whatsit()}}
644 \protected\def\ltj@@unvcopy{%
645 \directlua{luatexja.direction.unbox_check_dir(true)}%
646 \ltj@@orig@unvcopy\ltj@tempcnta
647 \directlua{luatexja.direction.uncopy_restore_whatsit()}}
650 \let\ltj@@orig@lastbox=\lastbox
651 \protected\def\lastbox{%
652 \directlua{luatexja.direction.lastbox_hook()}\ltj@@orig@lastbox
655 %%%%%%%% \ltjgetwd<box_num> etc.
657 \directlua{luatexja.direction.get_box_dim('width', luatexja.token.scan_int())}}
659 \directlua{luatexja.direction.get_box_dim('height', luatexja.token.scan_int())}}
661 \directlua{luatexja.direction.get_box_dim('depth', luatexja.token.scan_int())}}
662 \let\ltjgetwd=\ltj@@getwd\let\ltjgetht=\ltj@@getht\let\ltjgetdp=\ltj@@getdp
664 %%%%%%%% \ltjsetwd<box_num>=<dimen> etc.
665 \protected\def\ltjsetwd{\directlua{luatexja.direction.set_box_dim('width')}}
666 \protected\def\ltjsetht{\directlua{luatexja.direction.set_box_dim('height')}}
667 \protected\def\ltjsetdp{\directlua{luatexja.direction.set_box_dim('depth')}}
669 %%------------------ Load module for the format
671 \ifltj@in@latex %<*LaTeX>
672 \RequirePackage{ltj-latex}[2013/05/14]
673 \else\ifltj@in@plain %<*plain>
674 \input ltj-plain.sty %
675 \fi\fi %</LaTeX|plain>
677 \newluatexcatcodetable\ltj@temp@cctb
678 \def\ltj@overwrite@catcodetable#1{%
679 \setluatexcatcodetable\ltj@temp@cctb{\luatexcatcodetable#1}%
680 \setluatexcatcodetable#1{\luatexcatcodetable\ltj@temp@cctb\catcode"FFFFF=14}%"
682 \ltj@overwrite@catcodetable\CatcodeTableLaTeX
683 \ltj@overwrite@catcodetable\CatcodeTableLaTeXAtLetter
684 \ltj@overwrite@catcodetable\CatcodeTableExpl
687 %%------------------ all done