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}[2014/06/22 Core of LuaTeX-ja]
71 %% Load prerequisite packages.
73 %! 外部パッケージは普通の \endlinechar で読まないと危険.
74 \ifltj@in@latex %<*LaTeX>
75 \RequirePackage{luaotfload} [2013/05/10] % v2.2
76 \RequirePackage{infwarerr} [2010/04/08] % v1.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}
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@autospc % attribute for autospacing
141 \newluatexattribute\ltj@autoxspc % attribute for autoxspacing
142 \newluatexattribute\ltj@yablshift % attribute for yalbaselineshift
143 \newluatexattribute\ltj@ykblshift % attribute for yjabaselineshift
144 \newluatexattribute\ltj@tablshift % attribute for talbaselineshift
145 \newluatexattribute\ltj@tkblshift % attribute for tjabaselineshift
146 \newluatexattribute\jfam % index for current jfam
148 \newluatexattribute\ltj@dir
157 %%%%%%%% Attributes for character ranges
158 \newcount\ltj@tempcnta
160 \loop\ifnum\ltj@tempcnta<7
161 \expandafter\newluatexattribute%
162 \csname ltj@kcat\the\ltj@tempcnta\endcsname
163 \csname ltj@kcat\the\ltj@tempcnta\endcsname=0
164 \advance\ltj@tempcnta by1
168 %%%%%%%% Loading luatexja.lua
169 %% Quark tokens needed in ltj-base
170 \protected\def\ltj@@q@escape{\ltj@@q@escape@}
171 \protected\def\ltj@@q@escapenum{\ltj@@q@escapenum@}
175 dofile(assert(kpse.find_file('luatexja.lua', 'tex'),
176 "File `luatexja.lua' not found"))
179 %% \RequireLuaTeXjaSubmodule{name}[date]
180 % A TeX version of luatexja.load_module(name)
181 % The second optional argument [date] is simply ignored.
182 \def\RequireLuaTeXjaSubmodule#1{%
183 \@ifnextchar[{\ltj@requirelua@submod{#1}}{\ltj@requirelua@submod{#1}[]}}
184 \def\ltj@requirelua@submod#1[#2]{%
185 \directlua{luatexja.load_module(
186 "\luatexluaescapestring{#1}")}}
189 %%%%%%%% Load all sub-packages.
190 \ifltj@in@latex %<*LaTeX>
191 \RequirePackage{ltj-base} [2013/05/14]
193 \input ltj-base.sty %
196 %%%%%%%% \asluastring
197 \def\asluastring#1{'\luaescapestring{\detokenize{#1}}'}
200 \protected\def\/{\relax\directlua{luatexja.jfont.append_italic()}}
202 %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
203 \protected\def\jfont{%
204 \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false)}}
205 \protected\def\globaljfont{%
206 \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true)}}
207 \def\ltj@@jfont{\directlua{luatexja.jfont.jfontdefY('yoko')}}
209 %%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont
210 \protected\def\tfont{\afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(false)}}
211 \protected\def\globaltfont{%
212 \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(true)}}
213 \def\ltj@@tfont{\directlua{luatexja.jfont.jfontdefY('tate')}}
217 \protected\def\zw{\directlua{tex.setdimen('ltj@zw', luatexja.jfont.get_zw())}\ltj@zw}
218 \protected\def\zh{\directlua{tex.setdimen('ltj@zh', luatexja.jfont.get_zh())}\ltj@zh}
220 %%%%%%%% \inhibitglue
221 \protected\def\ltj@reset@globaldefs{%
222 \directlua{luatexja.global_temp = tex.globaldefs; tex.globaldefs = 0}}
223 \protected\def\ltj@restore@globaldefs{\directlua{tex.globaldefs = luatexja.global_temp}\relax}
224 \protected\def\inhibitglue{\ifhmode\ltj@@ihb\fi}
225 \def\ltj@@ihb{\relax\directlua{luatexja.jfmglue.create_inhibitglue_node()}}
227 %%%%%%%% \ltjdefcharrange<name>{100-200,3000-,5000,...}
228 \protected\def\ltjdefcharrange#1#2{%
229 {\ltj@tempcntc=#1 \expandafter\ltj@@dcrange#2,,}\ignorespaces}
230 \def\ltj@@dcrange#1,{\def\ltj@temp{#1}%
231 \ifx\ltj@temp\empty\let\@next=\relax\else
232 \ltj@@dcrangeA{#1}\let\@next=\ltj@@dcrange\fi\@next}
233 \def\ltj@@dcrangeA#1{\ltj@@dcrangeB#1--\@nil}
234 \def\ltj@@dcrangeB#1-#2-#3\@nil{\def\ltj@temp{#3}%
236 \ltj@tempcnta=#1 \ltj@tempcntb=\ltj@tempcnta
239 \ifx\ltj@temp\empty\ltj@tempcnta='200\else\ltj@tempcnta=#1\fi\relax
241 \ifx\ltj@temp\empty\ltj@tempcntb="10FFFF\else\ltj@tempcntb=#2\fi\relax%"
243 \directlua{luatexja.charrange.add_char_range(\the\ltj@tempcnta,\the\ltj@tempcntb,
247 %%%%%%%% \ltjsetparameter
248 \newcount\ltj@@stack \newcount\ltj@@group@level
249 \ltj@@group@level=0 \ltj@@stack=0
252 \directlua{% This value depends on the version of LuaTeX.
253 luatexja.stack.hmode = -tex.nest[tex.nest.ptr].mode
257 \directlua{% This value depends on the version of LuaTeX.
258 luatexja.stack.vmode = -tex.nest[tex.nest.ptr].mode
262 % prebreakpenalty = {<char_code>, <penalty>}
263 \define@key[ltj]{japaram}{kcatcode}{%
264 \expandafter\ltj@@set@stack#1:{KCAT}{0}{0x7FFFFFFF}}
265 \define@key[ltj]{japaram}{prebreakpenalty}{%
266 \expandafter\ltj@@set@stack#1:{PRE}{-10000}{10000}}
267 \define@key[ltj]{japaram}{postbreakpenalty}{%
268 \expandafter\ltj@@set@stack#1:{POST}{-10000}{10000}}
269 \def\ltj@@set@stack#1,#2:#3#4#5{%
270 \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#3,
271 \ltj@safe@num@or{nil}{#1},\ltj@safe@num@or{nil}{#2},#4,#5)}}
273 % jatextfont = {<char_code>, <font_cs>}
274 % only horizontal font is supported
275 \define@key[ltj]{japaram}{jatextfont}{%
276 \expandafter\ltj@@set@stackfont#1:{MJT}}
277 \define@key[ltj]{japaram}{jascriptfont}{%
278 \expandafter\ltj@@set@stackfont#1:{MJS}}
279 \define@key[ltj]{japaram}{jascriptscriptfont}{%
280 \expandafter\ltj@@set@stackfont#1:{MJSS}}
281 \protected\def\ltj@@set@stackfont#1,#2:#3{%
282 \ltj@reset@globaldefs
283 \ltj@tempcnta=\ltj@curjfnt\ltj@curjfnt=-1 #2%
284 \ifnum\ltj@curjfnt=-1
285 \@PackageError{luatexja-core}%
286 {\string#2 is not a control sequence that represents \MessageBreak
289 \directlua{luatexja.stack.set_stack_font(luatexja.stack_table_index.#3,
290 \ltj@safe@num@or{nil}{#1}, \the\ltj@curjfnt)}%
292 \ltj@curjfnt=\ltj@tempcnta
293 \ltj@restore@globaldefs
296 % yalbaselineshift = <dimen>
297 % yjabaselineshift = <dimen>
298 \define@key[ltj]{japaram}{yalbaselineshift}{%
299 \directlua{tex.setattribute(luatexja.isglobal,
300 luatexbase.attributes['ltj@yablshift'],
301 \ltj@safe@dimen@or\ltj@defdimen{#1})}}
302 \define@key[ltj]{japaram}{yjabaselineshift}{%
303 \directlua{tex.setattribute(luatexja.isglobal,
304 luatexbase.attributes['ltj@ykblshift'],
305 \ltj@safe@dimen@or\ltj@defdimen{#1})}}
306 % talbaselineshift = <dimen>
307 % tjabaselineshift = <dimen>
308 \define@key[ltj]{japaram}{talbaselineshift}{%
309 \directlua{tex.setattribute(luatexja.isglobal,
310 luatexbase.attributes['ltj@tablshift'],
311 \ltj@safe@dimen@or\ltj@defdimen{#1})}}
312 \define@key[ltj]{japaram}{tjabaselineshift}{%
313 \directlua{tex.setattribute(luatexja.isglobal,
314 luatexbase.attributes['ltj@tkblshift'],
315 \ltj@safe@dimen@or\ltj@defdimen{#1})}}
317 % jaxspmode = {<char_code>, <mode>}
318 % mode: inhibit, preonly, postonly, allow
320 \define@key[ltj]{japaram}{jaxspmode}{% \inhibitxspcode
321 \expandafter\ltj@set@jaxspmode#1:\relax}
322 \def\ltj@set@jaxspmode#1,#2:{%
323 \lowercase{\edef\ltj@temp{#2}}%
324 \def\ltj@tempa{inhibit}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{0}\fi
325 \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
326 \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
327 \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
328 \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.XSP,
329 \ltj@safe@num@or{nil}{#1},
330 \ltj@safe@num@or{nil}{\ltj@temp},0,3)}}
332 % alxspmode = {<char_code>, <mode>}
333 % mode: inhibit, preonly, postonly, allow
335 \define@key[ltj]{japaram}{alxspmode}{% \inhibitxspcode
336 \expandafter\ltj@set@alxspmode#1:\relax}
337 \def\ltj@set@alxspmode#1,#2:{%
338 \lowercase{\edef\ltj@temp{#2}}%
339 \def\ltj@tempa{inhibit}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{0}\fi
340 \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
341 \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
342 \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
343 \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.XSP,
344 \ltj@safe@num@or{nil}{#1},
345 \ltj@safe@num@or{nil}{\ltj@temp},0,3)}}
347 % autospacing = <bool> (default: true)
348 \define@boolkey[ltj]{japaram}{autospacing}[true]{%
349 \ifltj@japaram@autospacing
350 \directlua{luatexja.ext_print_global()}\ltj@autospc=1
352 \directlua{luatexja.ext_print_global()}\ltj@autospc=0
355 % autoxspacing = <bool> (default: true)
356 \define@boolkey[ltj]{japaram}{autoxspacing}[true]{%
357 \ifltj@japaram@autoxspacing
358 \directlua{luatexja.ext_print_global()}\ltj@autoxspc=1
360 \directlua{luatexja.ext_print_global()}\ltj@autoxspc=0
363 % [x]]kanjiskip = <dimen>
364 \define@key[ltj]{japaram}{kanjiskip}{\ltjsetkanjiskip{#1}}
365 \define@key[ltj]{japaram}{xkanjiskip}{\ltjsetxkanjiskip{#1}}
366 \protected\def\ltjsetkanjiskip#1{% % SKIP
368 local d = \ltj@safe@glue{#1}
369 luatexja.stack.set_stack_skip(luatexja.stack_table_index.KSK, d); node.free(d)
371 \protected\def\ltjsetxkanjiskip#1{% % SKIP
373 local d = \ltj@safe@glue{#1}
374 luatexja.stack.set_stack_skip(luatexja.stack_table_index.XSK, d); node.free(d)
378 % jcharwidowpenalty = <count>
379 \define@key[ltj]{japaram}{jcharwidowpenalty}{% %COUNT
380 \ltj@@set@stack0,#1:{JWP}{-10000}{10000}}
382 % differentjfm = { large | small | average | pleft | pright | paverage | both}
383 \define@choicekey*+[ltj]{japaram}{differentjfm}[\ltj@temp\ltj@tempr]%
384 {large,small,average,pleft,pright,paverage,both}{%
386 \directlua{luatexja.jfmglue.diffmet_rule = math.max}\or
387 \directlua{luatexja.jfmglue.diffmet_rule = math.min}\or
388 \directlua{luatexja.jfmglue.diffmet_rule = math.two_average}\or
389 \directlua{luatexja.jfmglue.diffmet_rule = math.two_pleft}\or
390 \directlua{luatexja.jfmglue.diffmet_rule = math.two_pright}\or
391 \directlua{luatexja.jfmglue.diffmet_rule = math.two_paverage}\or
392 \directlua{luatexja.jfmglue.diffmet_rule = math.two_add}
394 }{\ltj@PackageError{luatexja}{invalid argument `#1' for `differentjfm'}{%
395 Argument for `differentjfm' must be one of `large', `small', `average',^^J%
396 `pleft', `pright', 'paverage' or `both'. }}
397 % large, small, average, pleft, pright, paverage, both
400 % jacharrange = { +-<range_number> }
401 \define@key[ltj]{japaram}{jacharrange}{\expandafter\ltj@@scrange#1,,}
402 \def\ltj@@scrange#1,{%
404 \ifx\ltj@temp\empty\let\next=\relax\else\let\next=\ltj@@scrange
405 \directlua{luatexja.charrange.toggle_char_range(%
406 luatexja.is_global,\ltj@safe@num@or{nil}{#1})}%
410 \protected\def\ltj@setpar@global{%
411 \relax\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}%
412 \else\directlua{luatexja.isglobal=''}\fi
414 \protected\def\ltjsetparameter#1{%
415 \directlua{luatexja.base.start_time_measure('set_par')}%
416 \ltj@setpar@global\setkeys[ltj]{japaram}{#1}%
417 \directlua{luatexja.base.stop_time_measure('set_par')}%
419 \protected\def\ltjglobalsetparameter#1{%
420 \relax\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}%
421 \else\directlua{luatexja.isglobal='global'}\fi%
422 \directlua{luatexja.base.start_time_measure('set_par')}%
423 \setkeys[ltj]{japaram}{#1}%
424 \directlua{luatexja.base.stop_time_measure('set_par')}%
427 %%%%%%%% \ltjgetparameter
428 \def\ltj@@decl@array@param#1{%
429 \expandafter\let\csname ltj@@array@param/#1\endcsname=t%
431 \ltj@@decl@array@param{prebreakpenalty}
432 \ltj@@decl@array@param{postbreakpenalty}
433 \ltj@@decl@array@param{jaxspmode}
434 \ltj@@decl@array@param{alxspmode}
435 \ltj@@decl@array@param{kcatcode}
436 \ltj@@decl@array@param{jacharrange}
437 \ltj@@decl@array@param{chartorange}
438 \ltj@@decl@array@param{boxdir}
439 \def\ltjgetparameter#1{%
440 \directlua{luatexja.base.start_time_measure('get_par')}%
441 \ifcsname ltj@@array@param/#1\endcsname
442 \expandafter\ltx@firstoftwo
444 \expandafter\ltx@secondoftwo
446 {\ltj@@getparam@two{#1}}%
447 {\ltj@@getparam@one{#1}}%
449 \def\ltj@@getparam@one#1{%
450 \directlua{luatexja.ext_get_parameter_unary('#1')}%
451 \directlua{luatexja.base.stop_time_measure('get_par')}%
453 \def\ltj@@getparam@two#1#2{%
454 \directlua{luatexja.ext_get_parameter_binary('#1', \ltj@safe@num@or{nil}{#2})}%
455 \directlua{luatexja.base.stop_time_measure('get_par')}%
458 %%%%%%%% \ltjalchar<number>, \ltjjachar<number>
459 \let\ltj@@origchar=\char
460 \protected\def\ltj@alljachar{\relax
461 \csname ltj@kcat0\endcsname=0
462 \csname ltj@kcat1\endcsname=0
463 \csname ltj@kcat2\endcsname=0
464 \csname ltj@kcat3\endcsname=0
465 \csname ltj@kcat4\endcsname=0
466 \csname ltj@kcat5\endcsname=0
467 \csname ltj@kcat6\endcsname=0 }
468 \protected\def\ltj@allalchar{\relax
469 \csname ltj@kcat0\endcsname="7FFFFFFF %"
470 \csname ltj@kcat1\endcsname="7FFFFFFF %"
471 \csname ltj@kcat2\endcsname="7FFFFFFF %"
472 \csname ltj@kcat3\endcsname="7FFFFFFF %"
473 \csname ltj@kcat4\endcsname="7FFFFFFF %"
474 \csname ltj@kcat5\endcsname="7FFFFFFF %"
475 \csname ltj@kcat6\endcsname="7FFFFFFF }%"
477 \protected\def\ltjjachar{\afterassignment\ltj@@jachar\ltj@tempcnta}
478 \def\ltj@@jachar{{\directlua{tex.globaldefs = 0}\ltj@alljachar\ltj@@origchar\ltj@tempcnta}}
479 \protected\def\ltjalchar{\afterassignment\ltj@@alchar\ltj@tempcnta}
480 \def\ltj@@alchar{{\directlua{tex.globaldefs = 0}\ltj@allalchar\ltj@@origchar\ltj@tempcnta}}
482 %%%%%%%% \ltjsetmathletter<number>, \ltjunsetmathletter<number>
483 \protected\def\ltjsetmathletter#1{%
485 \directlua{luatexja.math.is_math_letters[\the\ltj@tempcnta]=true}%
487 \protected\def\ltjunsetmathletter#1{%
489 \directlua{luatexja.math.is_math_letters[\the\ltj@tempcnta]=false}%
492 %%%%%%%% \ltjdeclarealtfont<base_font_cs><alt_font_cs>{100-200,3000-,5000,...}
493 % <base_font_cs> の 第 3 引数の文字達は <alt_font_cs> で組む
495 \def\ltj@@getjfontnumber#1{% result in \ltj@tempcntc
496 \ltj@reset@globaldefs
497 \begingroup\ltj@curjfnt=-1 \ltj@curtfnt=-1\relax
498 #1\directlua{luatexja.__temp = -(\the\ltj@curjfnt)*(\the\ltj@curtfnt)}\endgroup
499 \ltj@tempcntc=\directlua{tex.sprint(luatexja.__temp)}\relax
500 \ifnum\ltj@tempcntc=-1
501 \@PackageError{luatexja-core}%
502 {\string#1 is not a control sequence that represents \MessageBreak
503 a Japanese font}{I'll use the current horizontal Japanese font instead.^^J}%
504 \ltj@tempcntc=\ltj@curjfnt
505 \fi\ltj@restore@globaldefs}
507 \protected\def\ltjdeclarealtfont#1#2#3{%
508 {\ltj@@getjfontnumber#1\@tempcnta=\ltj@tempcntc% \@tempcnta: 基底フォント
509 \ltj@@getjfontnumber#2%
510 \expandafter\ltj@@altfont#3,,}\ignorespaces}
511 \def\ltj@@altfont#1,{\def\ltj@temp{#1}%
512 \ifx\ltj@temp\empty\let\@next=\relax\else
513 \ltj@@altfontA{#1}\let\@next=\ltj@@altfont\fi\@next}
514 \def\ltj@@altfontA#1{\ltj@@altfontB#1--\@nil}
515 \def\ltj@@altfontB#1-#2-#3\@nil{\def\ltj@temp{#3}%
517 \ltj@tempcnta=#1 \ltj@tempcntb=\ltj@tempcnta
520 \ifx\ltj@temp\empty\ltj@tempcnta='200\else\ltj@tempcnta=#1\fi\relax
522 \ifx\ltj@temp\empty\ltj@tempcntb="10FFFF\else\ltj@tempcntb=#2\fi\relax%"
524 \directlua{luatexja.jfont.set_alt_font(
525 \the\ltj@tempcnta,\the\ltj@tempcntb,
526 \the\ltj@tempcntc, \the\@tempcnta)}%
529 %%%%%%%% \ltjclearaltfont<font_cs>
530 % <font_cs> の文字は全部 <font_cs> 本来の文字で組む
531 \protected\def\ltjclearaltfont#1{%
532 {\ltj@@getjfontnumber#1%
533 \directlua{luatexja.jfont.clear_alt_font(\the\ltj@tempcntc)}}\ignorespaces}
536 %%%%%%%% \yoko, \tate,\dtou
537 \protected\def\tate{%
538 \directlua{luatexja.direction.set_list_direction(3, 'tate')}%
540 \protected\def\yoko{%
541 \directlua{luatexja.direction.set_list_direction(4, 'yoko')}%
543 \protected\def\dtou{%
544 \directlua{luatexja.direction.set_list_direction(1, 'dtou')}%
546 \protected\def\utod{% 「縦数式ディレクション」
547 \directlua{luatexja.direction.set_list_direction(11, 'utod')}%
549 \define@key[ltj]{japaram}{direction}{%% always local
550 \directlua{luatexja.direction.set_list_direction(1, 'ltjsetparameter')}%
556 %\let\orig@insert=\insert
557 %\protected\def\insert{\begingroup\afterassignment\ltj@@insert@A\ltj@tempcnta}
558 %\protected\def\ltj@@insert@A{\orig@insert\ltj@tempcnta\bgroup\aftergroup\endgroup\let\next}
560 \let\ltj@@orig@vadjust=\vadjust
561 \protected\def\vadjust{%
562 \ltj@@orig@vadjust\bgroup
563 \directlua{luatexja.direction.set_list_direction('adj')}%
564 \aftergroup\ltj@@vadjust@check@dir\let\next}
565 \protected\def\ltj@@vadjust@check@dir{%
566 \directlua{luatexja.direction.check_adjust_direction()}%
569 %%%% \hbox, \vbox, \vtop
571 \directlua{luatexja.direction.set_list_direction()}%
572 \aftergroup\ltj@@reset@badness
575 \directlua{luatexja.direction.set_list_direction()}%
576 \aftergroup\ltj@@reset@badness
578 \protected\def\ltj@@reset@badness{%
580 if luatexja.global_temp then
581 tex.hbadness= tex.hbadness or luatexja.hbadness_temp
582 tex.vbadness= tex.vbadness or luatexja.vbadness_temp
583 tex.globaldefs= luatexja.global_temp or tex.globaldefs
588 $\directlua{% This value depends on the version of LuaTeX.
589 luatexja.stack.mmode = -tex.nest[tex.nest.ptr].mode
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()}}
651 \let\ltj@@orig@lastbox=\lastbox
652 \protected\def\lastbox{%
653 \directlua{luatexja.direction.lastbox_hook()}\ltj@@orig@lastbox
656 %%%%%%%% \ltjgetwd<box_num> etc.
658 \directlua{luatexja.direction.get_box_dim('width', \the\numexpr#1\relax)}%
662 \directlua{luatexja.direction.get_box_dim('height', \the\numexpr#1\relax)}%
666 \directlua{luatexja.direction.get_box_dim('depth', \the\numexpr#1\relax)}%
669 \let\ltjgetwd=\ltj@@getwd\let\ltjgetht=\ltj@@getht\let\ltjgetdp=\ltj@@getdp
671 %%%%%%%% \ltjsetwd<box_num>=<dimen> etc.
672 \protected\def\ltjsetwd{\begingroup
673 \ltj@reset@globaldefs\afterassignment\ltj@@setwd@a\ltj@tempcnta}
674 \def\ltj@@setwd@a{\afterassignment\ltj@@setwd@b\ltj@tempdima}
676 \directlua{luatexja.direction.set_box_dim('width')}%
677 \ltj@restore@globaldefs\endgroup}
678 \protected\def\ltjsetht{\begingroup
679 \ltj@reset@globaldefs\afterassignment\ltj@@setht@a\ltj@tempcnta}
680 \def\ltj@@setht@a{\afterassignment\ltj@@setht@b\ltj@tempdima}
682 \directlua{luatexja.direction.set_box_dim('height')}%
683 \ltj@restore@globaldefs\endgroup}
684 \protected\def\ltjsetdp{\begingroup
685 \ltj@reset@globaldefs\afterassignment\ltj@@setdp@a\ltj@tempcnta}
686 \def\ltj@@setdp@a{\afterassignment\ltj@@setdp@b\ltj@tempdima}
688 \directlua{luatexja.direction.set_box_dim('depth')}%
689 \ltj@restore@globaldefs\endgroup}
692 %%------------------ Load module for the format
694 \ifltj@in@latex %<*LaTeX>
695 \RequirePackage{ltj-latex}[2013/05/14]
696 \else\ifltj@in@plain %<*plain>
697 \input ltj-plain.sty %
698 \fi\fi %</LaTeX|plain>
700 \newluatexcatcodetable\ltj@temp@cctb
701 \def\ltj@overwrite@catcodetable#1{%
702 \setluatexcatcodetable\ltj@temp@cctb{\luatexcatcodetable#1}%
703 \setluatexcatcodetable#1{\luatexcatcodetable\ltj@temp@cctb\catcode"FFFFF=14}%"
705 \ltj@overwrite@catcodetable\CatcodeTableLaTeX
706 \ltj@overwrite@catcodetable\CatcodeTableLaTeXAtLetter
707 \ltj@overwrite@catcodetable\CatcodeTableExpl
710 %%------------------ all done