OSDN Git Service

fix #37467 (Is it safe to write a whatsit in math mode?)
[luatex-ja/luatexja.git] / src / luatexja-core.sty
index 317820e..6a4a230 100644 (file)
@@ -65,7 +65,7 @@
   \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
     \csname iftrue\endcsname
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{luatexja-core}[2016/05/15 Core of LuaTeX-ja]
+  \ProvidesPackage{luatexja-core}[2017/05/05 Core of LuaTeX-ja]
 \fi                             %</LaTeX>
 
 %% Load prerequisite packages.
@@ -79,6 +79,8 @@
   \RequirePackage{pdftexcmds} [2011/11/29] % v0.20
   \RequirePackage{xkeyval}    [2012/10/14] % v2.6b
   \RequirePackage{atbegshi}
+  \RequirePackage{etoolbox}
+  \AtBeginShipoutInit
   \IfFileExists{everyhook.sty}{\RequirePackage{everyhook}\ltj@everyhook@availtrue}{}
 \else                           %<*!LaTeX>
   \input luatexbase.sty
 
 %%%%%%%% Load all sub-packages.
 \ifltj@in@latex                 %<*LaTeX>
-  \RequirePackage{ltj-base}   [2016/05/15]
+  \RequirePackage{ltj-base}
 \else                           %<*!LaTeX>
   \input ltj-base.sty %
 \fi                             %</LaTeX>
 \newluafunction\ltj@restore@globaldefs@inner
 \newluafunction\ltj@@ihb@inner
 \newluafunction\ltj@@fakeparbegin@inner
+\newluafunction\ltj@@fakeboxbdd@inner
 \directlua{
   local t = lua.get_functions_table()
   t[\the\ltj@reset@globaldefs@inner] 
      = function() tex.globaldefs = luatexja.global_temp end
   t[\the\ltj@@ihb@inner] = luatexja.jfmglue.create_inhibitglue_node
   t[\the\ltj@@fakeparbegin@inner] = luatexja.jfmglue.create_beginpar_node
+  t[\the\ltj@@fakeboxbdd@inner] = luatexja.jfmglue.create_boxbdd_node
 }
 \protected\def\ltj@reset@globaldefs{\luafunction\ltj@reset@globaldefs@inner}
 \protected\def\ltj@restore@globaldefs{\luafunction\ltj@restore@globaldefs@inner}
 \protected\def\inhibitglue{\ifhmode\relax\luafunction\ltj@@ihb@inner\fi}
 \protected\def\ltjfakeparbegin{\ifhmode\relax\luafunction\ltj@@fakeparbegin@inner\fi}
+\protected\def\ltjfakeboxbdd{\ifhmode\relax\luafunction\ltj@@fakeboxbdd@inner\fi}
 
 
 %%%%%%%% \ltjdefcharrange<name>{100-200,3000-,5000,...}
   }
   \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
 %%------------------ Load module for the format
 
 \ifltj@in@latex                 %<*LaTeX>
-  \RequirePackage{ltj-latex}[2016/05/15]
+  \RequirePackage{ltj-latex}
 \else\ifltj@in@plain            %<*plain>
   \input ltj-plain.sty %
 \fi\fi                          %</LaTeX|plain>