\def\ltj@defdimen{0}
%%%%%%%% Attributes for Japanese typesetting.
+\newluatexattribute\ltj@icflag % attribute for italic correction
\newluatexattribute\ltj@curjfnt % index for ``current Japanese font''
-\newluatexattribute\jfam % index for current jfam
-\newluatexattribute\ltj@uniqid % unique id of box/paragraph
+\newluatexattribute\ltj@origchar %
\newluatexattribute\ltj@charclass %
-\newluatexattribute\ltj@yablshift % attribute for \yabaselineshift
-\newluatexattribute\ltj@ykblshift % attribute for \ykbaselineshift
\newluatexattribute\ltj@autospc % attribute for autospacing
\newluatexattribute\ltj@autoxspc % attribute for autoxspacing
-\newluatexattribute\ltj@icflag % attribute for italic correction
+\newluatexattribute\ltj@yablshift % attribute for \yabaselineshift
+\newluatexattribute\ltj@ykblshift % attribute for \ykbaselineshift
+\newluatexattribute\jfam % index for current jfam
+\ltj@icflag=0\ltj@origchar=0
+
+%%%%%%%% Attributes for character ranges
+\newcount\ltj@tempcnta
+\ltj@tempcnta=0
+\loop\ifnum\ltj@tempcnta<7
+ \expandafter\newluatexattribute%
+ \csname ltj@kcat\the\ltj@tempcnta\endcsname
+ \csname ltj@kcat\the\ltj@tempcnta\endcsname=0
+ \advance\ltj@tempcnta by1
+\repeat
+
%%%%%%%% Loading luatexja.lua
%% Quark tokens needed in ltj-base
\fi %</LaTeX>
-%%%%%%%% Attributes for character ranges
-\ltj@tempcnta=0
-\loop\ifnum\ltj@tempcnta<7
- \expandafter\newluatexattribute%
- \csname ltj@kcat\the\ltj@tempcnta\endcsname
- \csname ltj@kcat\the\ltj@tempcnta\endcsname=0
- \advance\ltj@tempcnta by1
-\repeat
-
%%%%%%%% \asluastring
\def\asluastring#1{'\luaescapestring{\detokenize{#1}}'}
\protected\def\ltj@reset@globaldefs{%
\directlua{luatexja.global_temp = tex.globaldefs; tex.globaldefs = 0}}
\protected\def\ltj@restore@globaldefs{\directlua{tex.globaldefs = luatexja.global_temp}}
-\let\new@everypar=\everypar
\protected\def\inhibitglue{\ifhmode\ltj@@ihb\fi}
-\def\ltj@@ihb{\directlua{luatexja.jfmglue.create_inhibitglue_node()}}
+\def\ltj@@ihb{\relax\directlua{luatexja.jfmglue.create_inhibitglue_node()}}
%%%%%%%% \yoko, \tate, \ifydir, \iftdir
%% At this moment, tategaki mode is not implemented;
\expandafter\ltj@@set@stackfont#1:{mjscr}}
\define@key[ltj]{japaram}{jascriptscriptfont}{%
\expandafter\ltj@@set@stackfont#1:{mjss}}
-\def\ltj@@set@stackfont#1,#2:#3{%
+\protected\def\ltj@@set@stackfont#1,#2:#3{%
\ltj@reset@globaldefs
\ltj@tempcnta=\ltj@curjfnt\ltj@curjfnt=-1 #2%
\ifnum\ltj@curjfnt=-1
\define@key[ltj]{japaram}{jcharwidowpenalty}{% %COUNT
\ltj@@set@stack0,#1:{jwp}{-10000}{10000}}
-% differentjfm = { large | small | average | both }
+% differentjfm = { large | small | average | pleft | pright | paverage | both}
\define@choicekey*+[ltj]{japaram}{differentjfm}[\ltj@temp\ltj@tempr]%
- {large,small,average,both}{%
+ {large,small,average,pleft,pright,paverage,both}{%
\ifcase\ltj@tempr
\directlua{luatexja.jfmglue.diffmet_rule = math.max}\or
\directlua{luatexja.jfmglue.diffmet_rule = math.min}\or
\directlua{luatexja.jfmglue.diffmet_rule = math.two_average}\or
+ \directlua{luatexja.jfmglue.diffmet_rule = math.two_pleft}\or
+ \directlua{luatexja.jfmglue.diffmet_rule = math.two_pright}\or
+ \directlua{luatexja.jfmglue.diffmet_rule = math.two_paverage}\or
\directlua{luatexja.jfmglue.diffmet_rule = math.two_add}
\fi
}{\ltj@PackageError{luatexja}{invalid argument `#1' for `differentjfm'}{%
Argument for `differentjfm' must be one of `large', `small', `average',^^J%
- and `both'. }}
- % large, small, average, both
+ `pleft', `pright', 'paverage' or `both'. }}
+ % large, small, average, pleft, pright, paverage, both
% jacharrange = { +-<range_number> }
\fi\next
}
-\protected\def\ltjsetparameter#1{%
+\protected\def\ltj@setpar@global{%
\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}\else\directlua{luatexja.isglobal=''}\fi
- \setkeys[ltj]{japaram}{#1}\ignorespaces}
+}
+\protected\def\ltjsetparameter#1{%
+ \ltj@setpar@global\setkeys[ltj]{japaram}{#1}\ignorespaces}
\protected\def\ltjglobalsetparameter#1{%
\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}\else\directlua{luatexja.isglobal='global'}\fi
\setkeys[ltj]{japaram}{#1}\ignorespaces}