OSDN Git Service

ltj-direction.lua: fixed a bug that \inhibitglue\tate causes an error.
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 14 Aug 2014 03:38:27 +0000 (12:38 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 14 Aug 2014 03:38:27 +0000 (12:38 +0900)
src/ltj-direction.lua
test/test51-vtest.pdf
test/test51-vtest.tex
test/test52-vtest-ins.pdf
test/test52-vtest-ins.tex

index 259f51c..c6a244f 100644 (file)
@@ -49,7 +49,6 @@ local tex_set_attr = tex.setattribute
 local PROCESSED    = luatexja.icflag_table.PROCESSED
 local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
 local PACKED       = luatexja.icflag_table.PACKED
-local STCK = luatexja.userid_table.STCK
 local DIR  = luatexja.userid_table.DIR
 local dir_tate = luatexja.dir_table.dir_tate
 local dir_yoko = luatexja.dir_table.dir_yoko
@@ -120,8 +119,41 @@ end
 do
    local node_next = node.next
    local node_set_attr = node.set_attribute
+   local node_traverse = node.traverse
+   local STCK = luatexja.userid_table.STCK
+   local IHB = luatexja.userid_table.IHB
+
+   local function test_list(h, lv)
+      if not h then 
+        return 2 -- need to create dir_whatsit
+      else
+        local flag = 2 -- need to create dir_whatsit
+        local w
+        for p in node_traverse(h) do
+           if p.id==id_whatsit then
+              if p.subtype==sid_user then
+                 local uid= p.user_id
+                 if uid==DIR then
+                    flag = 1; w = w or p -- found
+                 elseif not(uid==IHB or uid==STCK) then
+                    flag = 0; break -- error
+                 end
+              else
+                 flag = 0; break
+              end
+           else
+              flag = 0; break
+           end
+        end
+        if flag==1 then -- move dir_whatsit w
+           return 1,w -- TODO
+        else 
+           return flag
+        end
+      end
+   end
    local function set_list_direction(v, name)
-      local lv, w = tex_nest.ptr, tex.lists.page_head
+      local lv = tex_nest.ptr
       if not v then 
          v,name  = get_dir_count(), nil
         if lv>=1 and abs(tex_nest[lv-1].mode) == ltjs.mmode and v == dir_tate then
@@ -137,13 +169,10 @@ do
                 "To change direction in an align, \n"
                    .. "you shold use \\hbox or \\vbox.")
       else
-        local w = (lv==0) and tex.lists.page_head or tex_nest[lv].head.next
-        if w then
-           if (not w.next) and 
-              w.id==id_whatsit and w.subtype==sid_user and w.user_id==DIR then
-              node_set_attr(w, attr_dir, v)
-               if lv==0 then page_direction = v end
-           elseif lv==0 and not page_direction then
+        local h = (lv==0) and tex.lists.page_head or tex_nest[lv].head.next
+        local flag,w = test_list(h,lv)
+        if flag==0 then
+           if lv==0 and not page_direction then
               page_direction = v -- for first call of \yoko (in luatexja-core.sty)
            else
               ltjb.package_error(
@@ -152,6 +181,9 @@ do
                  'Direction change command by LuaTeX-ja is available\n'
                    .. 'only when the current list is null.')
            end
+        elseif flag==1 then 
+           node_set_attr(w, attr_dir, v)
+           if lv==0 then page_direction = v end
         else
            local w = node_new(id_whatsit, sid_user)
            setfield(w, 'next', nil)
index ae671f4..7b7f4f5 100644 (file)
Binary files a/test/test51-vtest.pdf and b/test/test51-vtest.pdf differ
index 23e3f84..2a7eba0 100644 (file)
 \vfill\eject
 
 \vbox{\tate\hsize100mm
-\tfont\f=KozMinPr6N-Regular.otf:+vert;jfm=ujisv \f
+\tfont\f=KozMinPr6N-Regular.otf:-vert;jfm=ujisv \f
 
 \ltjsetparameter{yalbaselineshift=.25em}\baselineskip15pt\parindent\zw
 \LaTeX の特徴として、テキストファイルであるソースコードを入力として処理することでDVIや
@@ -237,6 +237,8 @@ PDFなどの表示形式を出力として得ることが挙げられる。
 よって、より効率的な文章作成が可能ともなる。またMapleやMathematicaなどでドキュメントを
 作成し、\TeX 形式で出力することも可能である。
 
+\null\hfill
+(Wikipediaの「\LaTeX」の記事より.8/13現在)
 }
 
 \message{^^Jget/set box dimension^^J}
@@ -420,4 +422,7 @@ $$
 \F{tate}
 \F{dtou}
 \F{utod}
+
+\hbox{\inhibitglue\tate}
+\hbox{\ltjsetparameter{kanjiskip=0pt}\tate}
 \end
index 63d22d7..dafa171 100644 (file)
Binary files a/test/test52-vtest-ins.pdf and b/test/test52-vtest-ins.pdf differ
index fd88273..4151044 100644 (file)
@@ -21,7 +21,7 @@
   }
 
 かきくけこ\typeout{HOGE}
-\vadjust{insertion HOGE\showdir}% OK
+\vadjust{insertion HOGEあいう\showdir}% OK
 \vadjust{\yoko insertion\showdir}% must be an error
 }