OSDN Git Service

add \ltj@zw and \ltj@zh
[luatex-ja/luatexja.git] / src / luatexja-core.sty
index 6a4a230..a6bc90b 100644 (file)
@@ -65,7 +65,7 @@
   \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
     \csname iftrue\endcsname
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{luatexja-core}[2017/05/05 Core of LuaTeX-ja]
+  \ProvidesPackage{luatexja-core}[2017/11/12 Core of LuaTeX-ja]
 \fi                             %</LaTeX>
 
 %% Load prerequisite packages.
 \expandafter\endinput\fi\relax
 
 %% Check LuaTeX version.
-\ifnum\luatexversion<85
+\ifnum\luatexversion<100
   \@PackageError{luatexja-core}
     {This LuaTeX engine is too old for this package;\MessageBreak
-     at least beta-0.85.0 is needed}
+     at least 1.0.0 is needed}
     {Package loading is aborted now.\MessageBreak}
 \expandafter\endinput\fi\relax
 
 \newattribute\ltj@icflag    % attribute for italic correction
 \newattribute\ltj@curjfnt   % index for ``current horizontal Japanese font''
 \newattribute\ltj@curtfnt   % index for ``current vertical Japanese font''
-\newattribute\ltj@origchar  %
 \newattribute\ltj@charclass %
 \newattribute\ltj@charcode %
 \newattribute\ltj@autospc   % attribute for autospacing
 \newattribute\ltj@tablshift % attribute for talbaselineshift
 \newattribute\ltj@tkblshift % attribute for tjabaselineshift
 \newattribute\jfam          % index for current jfam
+\newattribute\ltj@vert@ori  % <=0: UAX#50, >0: always upright
 
 \newattribute\ltj@dir
 \newlanguage\ltj@@japanese
 \ltj@dir\z@
 \ltj@icflag\z@
-\ltj@origchar\z@
 \ltj@charclass\z@
 \ltj@curjfnt\m@ne
 \ltj@curtfnt\m@ne
   t[\the\ltj@zw@inner] = function() setdimen('ltj@zw', ltjf.get_zw()) end
   t[\the\ltj@zh@inner] = function() setdimen('ltj@zh', ltjf.get_zh()) end
 }
-\protected\def\zw{\luafunction\ltj@zw@inner\ltj@zw}
-\protected\def\zh{\luafunction\ltj@zh@inner\ltj@zh}
+\protected\def\ltj@zw{\luafunction\ltj@zw@inner\ltj@zw}
+\protected\def\ltj@zh{\luafunction\ltj@zh@inner\ltj@zh}
+\let\zw=\ltj@zw
+\let\zh=\ltj@zh
 
 %%%%%%%% \inhibitglue
 \newluafunction\ltj@reset@globaldefs@inner
 \define@key[ltj]{japaram}{jacharrange}{\expandafter\ltj@@scrange#1,,}
 \def\ltj@@scrange#1,{%
   \edef\ltj@temp{#1}%
-  \ifx\ltj@temp\empty\let\next=\relax\else\let\next=\ltj@@scrange
+  \ifx\ltj@temp\empty\let\ltj@@next=\relax\else\let\ltj@@next=\ltj@@scrange
     \directlua{luatexja.charrange.toggle_char_range(%
       luatexja.is_global,\ltj@safe@num@or{nil}{#1})}%
-  \fi\next
+  \fi\ltj@@next
 }
 
 \protected\def\ltj@setpar@global{%
 
 %%%%%%%% \ltjalchar<number>, \ltjjachar<number>
 \let\ltj@@origchar=\char
-\protected\def\ltj@alljachar{\relax
-    \csname ltj@kcat0\endcsname\z@
-    \csname ltj@kcat1\endcsname\z@
-    \csname ltj@kcat2\endcsname\z@
-    \csname ltj@kcat3\endcsname\z@
-    \csname ltj@kcat4\endcsname\z@
-    \csname ltj@kcat5\endcsname\z@
-    \csname ltj@kcat6\endcsname\z@}
+\newluafunction\ltj@alljachar@inner
+\directlua{
+  local t, set_attr = lua.get_functions_table(), tex.setattribute
+  local get_attr, floor = tex.getattribute, math.floor
+  local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
+  local lang_ja = luatexja.lang_ja
+  t[\the\ltj@alljachar@inner] = function()
+    font.current(get_attr(attr_curjfnt)); tex.language=lang_ja;
+    for i=0,6 do
+      set_attr(luatexbase.attributes['ltj@kcat' .. floor(i)],0)
+    end
+  end
+}
+\protected\def\ltj@alljachar{\luafunction\ltj@alljachar@inner}
 \protected\def\ltj@allalchar{\relax
     \csname ltj@kcat0\endcsname="7FFFFFFF %"
     \csname ltj@kcat1\endcsname="7FFFFFFF %"
 \let\orig@insert=\insert
 \protected\def\insert{\begingroup\afterassignment\ltj@@insert@A\ltj@tempcnta}
 \protected\def\ltj@@insert@A{\orig@insert\ltj@tempcnta\bgroup
-  \aftergroup\ltj@@insert@B\let\next}
+  \aftergroup\ltj@@insert@B\let\ltj@@next}
 \protected\def\ltj@@insert@B{\directlua{luatexja.direction.populate_insertion_dir_whatsit()}\endgroup}
 
 %%%% vadjust
 \protected\def\vadjust{%
   \ltj@@orig@vadjust\bgroup
   \directlua{luatexja.direction.set_list_direction_hook('adj')}%
-  \aftergroup\ltj@@vadjust@check@dir\let\next}
+  \aftergroup\ltj@@vadjust@check@dir\let\ltj@@next}
 \protected\def\ltj@@vadjust@check@dir{%
   \directlua{luatexja.direction.check_adjust_direction()}%
 }
   }
   \PushPreHook{hbox}{\luafunction\ltj@@box@dirhook\aftergroup\ltj@@reset@badness}
   \PushPreHook{vbox}{\luafunction\ltj@@box@dirhook\aftergroup\ltj@@reset@badness}
-  \PushPreHook{math}{\luafunction\ltj@@box@dirhook}
-  \PushPreHook{display}{\luafunction\ltj@@box@dirhook}
 \else
   \let\ltj@@everyhbox=\everyhbox\let\ltj@@everyvbox=\everyvbox
   \newtoks\ltj@@i@everyhbox\newtoks\ltj@@i@everyvbox
     \aftergroup\ltj@@reset@badness\the\ltj@@i@everyhbox}
   \ltj@@everyvbox{\luafunction\ltj@@box@dirhook
     \aftergroup\ltj@@reset@badness\the\ltj@@i@everyvbox}
-  %% math
-  \ifltj@in@latex
-    \frozen@everymath{\luafunction\ltj@@box@dirhook\check@mathfonts\the\everymath}
-  \else
-    \let\ltj@@everymath=\everymath\newtoks\ltj@@i@everymath\let\everymath=\ltj@@i@everymath
-    \ltj@@everymath{\luafunction\ltj@@box@dirhook\the\ltj@@i@everymath}
-  \fi
-  %% display
-  \ifltj@in@latex
-    \frozen@everydisplay{\luafunction\ltj@@box@dirhook\check@mathfonts\the\everydisplay}
-  \else
-    \let\ltj@@everydisplay=\everydisplay\newtoks\ltj@@i@everydisplay\let\everydisplay=\ltj@@i@everydisplay
-    \ltj@@everydisplay{\luafunction\ltj@@box@dirhook\the\ltj@@i@everydisplay}
-  \fi
 \fi
 
 \newluafunction\ltj@@reset@badness@inner