\newcount\ltj@tempcntc
\newdimen\ltj@tempdima
\newskip\ltj@tempskipa
+\newtoks\ltj@temptoks
-\newdimen\zw
-\newdimen\zh
+\newdimen\ltj@zw
+\newdimen\ltj@zh
\newdimen\jQ \jQ=0.25mm
-\newdimen\jH \jH=0.25mm
+\let\jH=\jQ
%%%%%%%% error message
\def\ltj@defnum{0}
\advance\ltj@tempcnta by1
\repeat
+
%%%%%%%% \asluastring
\def\asluastring#1{'\luaescapestring{\detokenize{#1}}'}
%%%%%%%% Redefine \/
-%\let\ltj@ic=\/ \protected\def\/{{\ltj@icflag=1\ltj@ic}}
-\protected\def\/{\directlua{luatexja.jfont.append_italic()}}
+\protected\def\/{\relax\directlua{luatexja.jfont.append_italic()}}
%%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
\protected\def\jfont{\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false)}}
\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true)}}
\def\ltj@@jfont{\directlua{luatexja.jfont.jfontdefY()}}
+%%%%%%%% \zw, \zh
+\def\zw{\directlua{luatexja.jfont.load_zw()}\ltj@zw}
+\def\zh{\directlua{luatexja.jfont.load_zh()}\ltj@zh}
+
%%%%%%%% \inhibitglue
-\protected\def\inhibitglue{\directlua{luatexja.jfmglue.create_inhibitglue_node()}}
+\let\new@everypar=\everypar
+\protected\def\inhibitglue{\relax%
+ \ifvmode
+ \directlua{ltj.global_temp = tex.globaldefs; tex.globaldefs = 0}% trick
+ \xdef\@@tempa{\the\everypar}%
+ \xdef\@@tempb{\everypar={\@@tempa}\@@tempa\noexpand\ltj@@ihb}%
+ \everypar\expandafter{\@@tempb}%
+ \directlua{tex.globaldefs = ltj.global_temp}% trick
+ \else\ifhmode\ltj@@ihb\fi\fi}
+\def\ltj@@ihb{\directlua{luatexja.jfmglue.create_inhibitglue_node()}}
+
+%%%%%%%% \yoko, \tate, \ifydir, \iftdir
+%% At this moment, tategaki mode is not implemented;
+%% there is only yokogaki mode now.
+\let\yoko\relax
+\let\tate\relax
+\newif\ifydir\ydirtrue
+\newif\iftdir\tdirfalse
%%%%%%%% \ltjdefcharrange<name>{100-200,3000-,5000,...}
\protected\def\ltjdefcharrange#1#2{%
- \ltj@tempcntc=#1 \expandafter\ltj@@dcrange#2,,\ignorespaces}
+ {\ltj@tempcntc=#1 \expandafter\ltj@@dcrange#2,,}\ignorespaces}
\def\ltj@@dcrange#1,{\def\ltj@temp{#1}%
\ifx\ltj@temp\empty\let\@next=\relax\else
\ltj@@dcrangeA{#1}\let\@next=\ltj@@dcrange\fi\@next}
\ltj@tempcnta=#1 \ltj@tempcntb=\ltj@tempcnta
\else
\def\ltj@temp{#1}%
- \ifx\ltj@temp\empty\ltj@tempcnta='200 \else\ltj@tempcnta=#1 \fi
+ \ifx\ltj@temp\empty\ltj@tempcnta='200\else\ltj@tempcnta=#1\fi\relax
\def\ltj@temp{#2}%
- \ifx\ltj@temp\empty\ltj@tempcntb="10FFFF \else\ltj@tempcntb=#2 \fi%"
+ \ifx\ltj@temp\empty\ltj@tempcntb="10FFFF\else\ltj@tempcntb=#2\fi\relax%"
\fi
\directlua{luatexja.charrange.add_char_range(\the\ltj@tempcnta,\the\ltj@tempcntb,
\the\ltj@tempcntc)}%
\define@key[ltj]{japaram}{jascriptscriptfont}{%
\expandafter\ltj@@set@stackfont#1:{mjss}}
\def\ltj@@set@stackfont#1,#2:#3{%
- {\ltj@tempcntb=\ltj@curjfnt\ltj@curjfnt=-1 #2%
- \global\ltj@tempcnta=\ltj@curjfnt\global\ltj@curjfnt=\ltj@tempcntb}%
- \ifnum\ltj@tempcnta=-1
+ \directlua{%
+ ltj.global_temp = tex.globaldefs;
+ tex.globaldefs = 0}%
+ \ltj@tempcnta=\ltj@curjfnt\ltj@curjfnt=-1 #2%
+ \ifnum\ltj@curjfnt=-1
\@PackageError{luatexja-core}%
{\string#2 is not a control sequence that represents \MessageBreak
a Japanese font}{}%
\else
\directlua{luatexja.stack.set_stack_font(ltj.isglobal, \asluastring{#3},
- \ltj@safe@num@or\ltj@defnum{#1}, \the\ltj@tempcnta)}%
- \fi}
+ \ltj@safe@num@or\ltj@defnum{#1}, \the\ltj@curjfnt)}%
+ \fi
+ \ltj@curjfnt=\ltj@tempcnta
+ \directlua{tex.globaldefs = ltj.global_temp}%
+ }
% yalbaselineshift = <dimen>
% yjabaselineshift = <dimen>
% jaxspmode = {<char_code>, <mode>}
% mode: inhibit, preonly, postonly, allow
-% or 0 2 1 3
+% or 0 1 2 3
\define@key[ltj]{japaram}{jaxspmode}{% \inhibitxspcode
\expandafter\ltj@set@jaxspmode#1:\relax}
\def\ltj@set@jaxspmode#1,#2:{%
\lowercase{\edef\ltj@temp{#2}}%
\def\ltj@tempa{inhibit}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{0}\fi
- \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
- \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
+ \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
+ \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
\def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
\directlua{luatexja.stack.set_stack_table(ltj.isglobal, 'xsp',
\ltj@safe@num@or\ltj@defnum{#1},
\fi\next
}
-\protected\def\ltjsetparameter#1{\directlua{ltj.isglobal=''}%
+\protected\def\ltjsetparameter#1{%
+ \ifnum\globaldefs>0\directlua{ltj.isglobal='global'}\else\directlua{ltj.isglobal=''}\fi
\setkeys[ltj]{japaram}{#1}\ignorespaces}
-\protected\def\ltjglobalsetparameter#1{\directlua{ltj.isglobal='global'}%
+\protected\def\ltjglobalsetparameter#1{%
+ \ifnum\globaldefs<0\directlua{ltj.isglobal=''}\else\directlua{ltj.isglobal='global'}\fi
\setkeys[ltj]{japaram}{#1}\ignorespaces}
-%%%%%%%%
+%%%%%%%% \ltjgetparameter
\def\ltj@@decl@array@param#1{%
\expandafter\let\csname ltj@@array@param/#1\endcsname=t%
}
\directlua{ltj.ext_get_parameter_binary('#1', \ltj@safe@num{#2})}%
}
+%%%%%%%% \ltjalchar<number>, \ltjjachar<number>
+\let\ltj@@origchar=\char
+\protected\def\ltj@alljachar{\relax
+ \csname ltj@kcat0\endcsname=0
+ \csname ltj@kcat1\endcsname=0
+ \csname ltj@kcat2\endcsname=0
+ \csname ltj@kcat3\endcsname=0
+ \csname ltj@kcat4\endcsname=0
+ \csname ltj@kcat5\endcsname=0
+ \csname ltj@kcat6\endcsname=0 }
+\protected\def\ltj@allalchar{\relax
+ \csname ltj@kcat0\endcsname="7FFFFFFF %"
+ \csname ltj@kcat1\endcsname="7FFFFFFF %"
+ \csname ltj@kcat2\endcsname="7FFFFFFF %"
+ \csname ltj@kcat3\endcsname="7FFFFFFF %"
+ \csname ltj@kcat4\endcsname="7FFFFFFF %"
+ \csname ltj@kcat5\endcsname="7FFFFFFF %"
+ \csname ltj@kcat6\endcsname="7FFFFFFF }%"
+\protected\def\ltj@backup@kcat{\edef\ltj@restore@kcat{%
+ \csname ltj@kcat0\endcsname=\expandafter\the\csname ltj@kcat0\endcsname\relax
+ \csname ltj@kcat1\endcsname=\expandafter\the\csname ltj@kcat1\endcsname\relax
+ \csname ltj@kcat2\endcsname=\expandafter\the\csname ltj@kcat2\endcsname\relax
+ \csname ltj@kcat3\endcsname=\expandafter\the\csname ltj@kcat3\endcsname\relax
+ \csname ltj@kcat4\endcsname=\expandafter\the\csname ltj@kcat4\endcsname\relax
+ \csname ltj@kcat5\endcsname=\expandafter\the\csname ltj@kcat5\endcsname\relax
+ \csname ltj@kcat6\endcsname=\expandafter\the\csname ltj@kcat6\endcsname\relax}}
+\let\ltj@restore@kcat=\relax
+
+\protected\def\ltjjachar{\afterassignment\ltj@@kchar\ltj@tempcnta}
+\def\ltj@@kchar{{\directlua{tex.globaldefs = 0}\ltj@alljachar\ltj@@origchar\ltj@tempcnta}}
+\protected\def\ltjalchar{\afterassignment\ltj@@achar\ltj@tempcnta}
+\def\ltj@@achar{{\directlua{tex.globaldefs = 0}\ltj@allalchar\ltj@@origchar\ltj@tempcnta}}
-%\def\ltj@temp{plain}
-%\ifx\fmtname\ltj@temp
-% \message{plain format: loading luatexja-plain.tex}
-%\fi
-%\input luatexja-plain.tex
-%\catcode`\@=12
-%\endinput
-%! ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
%%------------------ Load module for the format