OSDN Git Service

Fix \raise, \lower, \moveleft, \moveright.
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 18 Jul 2014 05:56:32 +0000 (14:56 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Fri, 18 Jul 2014 05:56:32 +0000 (14:56 +0900)
doc/ltjclasses.pdf
doc/ltjltxdoc.pdf
doc/ltjsclasses.pdf
src/ltj-base.sty
src/ltj-direction.lua
src/ltj-stack.lua
src/luatexja-core.sty

index 8a9e32f..80a6e57 100644 (file)
Binary files a/doc/ltjclasses.pdf and b/doc/ltjclasses.pdf differ
index d0cb7fb..812258a 100644 (file)
Binary files a/doc/ltjltxdoc.pdf and b/doc/ltjltxdoc.pdf differ
index 24f1be4..01f0dc8 100644 (file)
Binary files a/doc/ltjsclasses.pdf and b/doc/ltjsclasses.pdf differ
index d30221e..b8b7855 100644 (file)
@@ -23,8 +23,8 @@
 \newcount\ltj@tempcntb
 \newcount\ltj@tempcntc
 \newdimen\ltj@tempdima
-\newskip\ltj@tempskipa
-\newtoks\ltj@temptoks
+% \newskip\ltj@tempskipa unused
+% \newtoks\ltj@temptoks unused
 
 \countdef\ltj@@count@zero=0 %
 \luatexattributedef\ltj@@attr@zero=0 %
@@ -512,6 +512,33 @@ luatexja.base._error_show(true)% and many spaces trail!
   \def#1{\ltj@package@debug{#2}}
 }
 
+%% \ltj@afterbox <token><box>
+%% -> \setbox\ltj@afbox<box><token>
+%% from Sonja Maus, ``Looking Ahead for a <box>'',
+%%      TUGBoat, 11, No. 4, 1990.
+\newbox\ltj@afbox
+\protected\def\ltj@afterbox#1{%
+  \def\ltj@afb@xarg{#1}%
+  \afterassignment\ltj@afb@x
+  \chardef\next`.}
+\def\ltj@afb@x{\futurelet\next\ltj@afb@xtest}
+\def\ltj@afb@xtest{%
+  \ifcase\ifx\next\hbox\tw@\fi
+         \ifx\next\vbox\tw@\fi
+         \ifx\next\vtop\tw@\fi
+         \ifx\next\box\@ne\fi
+         \ifx\next\copy\@ne\fi
+         \ifx\next\vsplit\@ne\fi
+         \ifx\next\lastbox\@ne\fi
+         0% ``A <box> was ...'' error will be causes by \setbox later anyway.
+  \or\afterassignment\ltj@afb@xarg
+  \or\afterassignment\ltj@afb@xagarg
+  \fi
+  \setbox\ltj@afbox
+}
+\def\ltj@afb@xagarg{\aftergroup\ltj@afb@xarg}
+
+
 %%------------------ all done
 \ltj@base@AtEnd
 \endinput
index 040ce92..936d85d 100644 (file)
@@ -438,22 +438,24 @@ do
    local function check_dir(reg_num)
       start_time_measure('box_primitive_hook')
       local list_dir = get_dir_count()
-      local b = tex.getbox(tex_getcount('ltj@tempcnta'))
+      local b = getbox(tex_getcount('ltj@tempcnta'))
       if b then
         local box_dir = get_box_dir(to_direct(b), dir_yoko)
-        if box_dir%dir_node_auto ~= list_dir%dir_node_auto then
-            print('NEST', tex_nest.ptr, tex_getcount('ltj@tempcnta'))
-           luatexja.ext_show_node_list(
-               (tex_nest.ptr==0) and tex.lists.page_head or tex_nest[tex_nest.ptr].head,
-               'LIST' .. tostring(list_dir) .. '> ', print)
-           luatexja.ext_show_node_list(b, 'BOX' .. tostring(box_dir) .. '> ', print)
+        if box_dir%dir_node_auto ~= list_dir then
+       --    print('NEST', tex_nest.ptr, tex_getcount('ltj@tempcnta'))
+       --    luatexja.ext_show_node_list(
+        --       (tex_nest.ptr==0) and tex.lists.page_head or tex_nest[tex_nest.ptr].head,
+        --       'LIST' .. tostring(list_dir) .. '> ', print)
+       --   luatexja.ext_show_node_list(b, 'BOX' .. tostring(box_dir) .. '> ', print)
            ltjb.package_error(
               'luatexja',
               "Incompatible direction list can't be unboxed",
               'I refuse to unbox a box in differrent direction.')
         end
       end
-      tex.globaldefs = luatexja.global_temp
+      if luatexja.global_temp and tex.globaldefs~=luatexja.global_temp then 
+        tex.globaldefs = luatexja.global_temp
+      end
       stop_time_measure('box_primitive_hook')
    end
    luatexja.direction.check_dir = check_dir
@@ -803,6 +805,30 @@ do
    luatexja.direction.get_register_dir = get_register_dir
 end
 
+-- raise, lower
+do
+   local getbox, setbox, copy_list = tex.getbox, tex.setbox, Dnode.copy_list
+   function luatexja.direction.raise_box()
+      start_time_measure('box_primitive_hook')
+      local list_dir = get_dir_count()
+      local s = getbox('ltj@afbox')
+      if s then
+        local sd = to_direct(s)
+        local box_dir = get_box_dir(sd, dir_yoko)
+        if box_dir%dir_node_auto ~= list_dir then
+           setbox(
+              'ltj@afbox', 
+              to_node(
+                 copy_list(make_dir_whatsit(sd, sd, list_dir, 'box_move'))
+                 -- without copy_list, we get a segfault
+              )
+           )
+        end
+      end
+      stop_time_measure('box_primitive_hook')
+   end
+end
+
 -- 縦書き用字形への変換テーブル
 local font_vert_table = {} -- key: fontnumber
 do
index 29243ad..e2dea10 100644 (file)
@@ -85,7 +85,7 @@ function set_stack_font(m,c,p)
    set_stack_table(m+c, p)
 end
 
--- EXT: store \ltj@tempskipa
+-- EXT: sp: glue_spec
 function set_stack_skip(m,sp)
   local i = get_stack_level()
   if not sp then return end
index f45b5ac..a6fee46 100644 (file)
   \directlua{luatexja.direction.check_adjust_direction()}%
 }
 
-%%%% hbox, vbox, vtop
+%%%% \hbox, \vbox, \vtop
 \everyhbox{%
   \directlua{luatexja.direction.set_list_direction()}%
   \aftergroup\ltj@@reset@badness
   }%
 }
 
+%%%% \raise, \lower, \moveleft, \moveright
+\let\ltj@@orig@raise=\raise
+\let\ltj@@orig@lower=\lower
+\protected\def\raise{\ltj@reset@globaldefs\afterassignment\ltj@@raise\ltj@tempdima}
+\protected\def\lower{\ltj@reset@globaldefs\afterassignment\ltj@@raise\ltj@tempdima-}
+\protected\def\ltj@@raise{%
+  \ltj@restore@globaldefs
+  \edef\ltj@@raise@a{%
+    \noexpand\directlua{luatexja.direction.raise_box()}%
+    \ltj@@orig@raise\the\ltj@tempdima\noexpand\box\ltj@afbox
+  }\ltj@afterbox\ltj@@raise@a}
+\let\ltj@@orig@moveleft=\moveleft
+\let\ltj@@orig@moveright=\moveright
+\protected\def\moveleft{\ltj@reset@globaldefs\afterassignment\ltj@@moveleft\ltj@tempdima}
+\protected\def\moveright{\ltj@reset@globaldefs\afterassignment\ltj@@moveleft\ltj@tempdima-}
+\protected\def\ltj@@moveleft{%
+  \ltj@restore@globaldefs
+  \edef\ltj@@moveleft@a{%
+    \noexpand\directlua{luatexja.direction.raise_box()}%
+    \ltj@@orig@moveleft\the\ltj@tempdima\noexpand\box\ltj@afbox
+  }\ltj@afterbox\ltj@@moveleft@a}
+
 
 %%%% unhbox and unvbox
 \let\ltj@@orig@unhbox=\unhbox