OSDN Git Service

more use of newtokenlib
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 9 May 2015 08:21:53 +0000 (17:21 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 9 May 2015 08:21:53 +0000 (17:21 +0900)
src/addons/luatexja-ruby.sty
src/ltj-direction.lua
src/ltj-kinsoku_make.tex
src/ltj-stack.lua
src/luatexja-compat.sty
src/luatexja-core.sty
test/test51-vtest.pdf
test/test51-vtest.tex

index 1f73ea1..2106a14 100644 (file)
 %% 引数:ルビ全角を単位とした実数
 %% この文字への pre-, post-intrusion の許容量
 \define@key[ltj]{japaram}{rubypreintrusion}{%
-  \expandafter\ltj@@set@stack@real#1:{RIPRE}{0}{0x7FFFFFFF}}
+  \ltj@@set@stack@real{RIPRE}{0}{0x7FFFFFFF}#1 }
 \define@key[ltj]{japaram}{rubypostintrusion}{%
-  \expandafter\ltj@@set@stack@real#1:{RIPOST}{0}{0x7FFFFFFF}}
-\def\ltj@@set@stack@real#1,#2:#3#4#5{%
-  \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#3,
-    \ltj@safe@num@or\ltj@defnum{#1},\ltj@safe@real{#2},#4,#5)}}
+  \ltj@@set@stack@real{RIPOST}{0}{0x7FFFFFFF}#1 }
+\def\ltj@@set@stack@real#1#2#3{%
+  \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#1,
+    #2, #3, luatexja.token.scan_word)}}
 
 % ルビ用のキー設定
 \def\ltj@@rkeydef#1{
index c05d0ed..b334ed4 100644 (file)
@@ -761,6 +761,8 @@ do
    luatexja.direction.get_box_dim = get_box_dim
 
    -- return value: (changed dimen of box itself?)
+   local scan_dimen, scan_int = luatexja.token.scan_dimen, luatexja.token.scan_int
+   local scan_keyword = luatexja.token.scan_keyword
    local function set_box_dim_common(key, s, l_dir)
       local s_dir, wh = get_box_dir(s, dir_yoko)
       s_dir = s_dir%dir_math_mod
@@ -781,10 +783,10 @@ do
             setfield(db, 'next', dnh)
             setfield(wh, 'value',to_node(db))
          end
-         setfield(db, key, tex.getdimen('ltj@tempdima'))
+         setfield(db, key, scan_dimen())
         return false
       else
-         setfield(s, key, tex.getdimen('ltj@tempdima'))
+         setfield(s, key, scan_dimen())
         if wh then
            -- change dimension of dir_nodes which are created "automatically"
               local bw, bh, bd
@@ -803,8 +805,7 @@ do
       end
    end
    local function set_box_dim(key)
-      local n = tex_getcount('ltj@tempcnta')
-      local s = getbox(n)
+      local s = getbox(scan_int()); scan_keyword('=')
       if s then
         local l_dir = (get_dir_count())%dir_math_mod
         s = to_direct(s)
@@ -813,7 +814,7 @@ do
             set_box_dim_common(key, s, l_dir)
         elseif b_dir%dir_math_mod == l_dir then
            -- s is dir_node
-           setfield(s, key, tex.getdimen('ltj@tempdima'))
+           setfield(s, key, scan_dimen())
            if b_dir<dir_node_manual then
               set_attr(s, attr_dir, b_dir%dir_node_auto + dir_node_manual)
            end
index 14ee0a1..acd3b6e 100644 (file)
@@ -1,8 +1,8 @@
 %#!luatex ltj-kinsoku_make.tex
+%\tracingall
 \input luatexja.sty
 
 \catcode`\@=11
-
 \ltj@tempcnta="0%"
 \loop\ifnum\ltj@tempcnta<"100%"
   \ltjsetparameter{alxspmode={\ltj@tempcnta,0}}%
  table.tofile('ltj-kinsoku.lua', s, 'return', false, true, false)
 }
 
-\bye
\ No newline at end of file
+\bye
index ef7a369..72e8b82 100644 (file)
@@ -20,6 +20,7 @@ local sid_user = node.subtype('user_defined')
 local STCK = luatexja.userid_table.STCK
 local fastcopy = table.fastcopy
 local setcount = tex.setcount
+local scan_int, scan_keyword = luatexja.token.scan_int, luatexja.token.scan_keyword
 hmode = 0 -- dummy
 
 charprop_stack_table={};
@@ -62,8 +63,11 @@ end
 local set_stack_table = set_stack_table
 
 -- EXT
-function set_stack_perchar(m,c,p,lb,ub)
-   if type(p)~='number' or p<lb or p>ub then
+function set_stack_perchar(m,lb,ub, getter)
+   local c = scan_int()
+   scan_keyword(',')
+   local p = tonumber((getter or scan_int)())
+   if p<lb or p>ub then
       ltjb.package_error('luatexja',
                         "invalid code (".. tostring(p) .. ")",
                         "The code should in the range "..tostring(lb) .. '..' ..
index 687d395..d7acb33 100644 (file)
   \directlua{luatexja.compat.to_kansuji(luatexja.token.scan_int())}%
 }
 
-\define@key[ltj]{japaram}{kansujichar}{%
-  \expandafter\ltj@@set@stack#1:{KSJ}{0}{0x7FFFFFFF}}
+\define@key[ltj]{japaram}{kansujichar}{\ltj@@set@stack{KSJ}{0}{0x7FFFFFFF}#1 }
 
 \ltjsetparameter{kansujichar={0,`〇}}
 \ltjsetparameter{kansujichar={1,`一}}
index dd20eee..0be0ab1 100644 (file)
 \setbox\z@\box\voidb@x
 
 % prebreakpenalty = {<char_code>, <penalty>}
-\define@key[ltj]{japaram}{kcatcode}{%
-  \expandafter\ltj@@set@stack#1:{KCAT}{0}{0x7FFFFFFF}}
-\define@key[ltj]{japaram}{prebreakpenalty}{%
-  \expandafter\ltj@@set@stack#1:{PRE}{-10000}{10000}}
-\define@key[ltj]{japaram}{postbreakpenalty}{%
-  \expandafter\ltj@@set@stack#1:{POST}{-10000}{10000}}
-\def\ltj@@set@stack#1,#2:#3#4#5{%
-  \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#3,
-    \ltj@safe@num@or{nil}{#1},\ltj@safe@num@or{nil}{#2},#4,#5)}}
+\define@key[ltj]{japaram}{kcatcode}{\ltj@@set@stack{KCAT}{0}{0x7FFFFFFF}#1 }
+\define@key[ltj]{japaram}{prebreakpenalty}{\ltj@@set@stack{PRE}{-10000}{10000}#1}
+\define@key[ltj]{japaram}{postbreakpenalty}{\ltj@@set@stack{POST}{-10000}{10000}#1 }
+\def\ltj@@set@stack#1#2#3{%
+  \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#1,#2,#3)}}
+%\def\ltj@@set@stack#1,#2:#3#4#5{%
+%  \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#3,
+%    \ltj@safe@num@or{nil}{#1},\ltj@safe@num@or{nil}{#2},#4,#5)}}
 
 % jatextfont = {<char_code>, <font_cs>}
 % only horizontal font is supported
   \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
   \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
   \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
-  \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.XSP,
-    \ltj@safe@num@or{nil}{#1},
-    \ltj@safe@num@or{nil}{\ltj@temp},0,3)}}
-
+  \ltj@@set@stack{XSP}03#1 \ltj@temp}
 
 % alxspmode = {<char_code>, <mode>}
 % mode: inhibit, preonly, postonly, allow
 %    or       0        1         2      3
 \define@key[ltj]{japaram}{alxspmode}{%        \inhibitxspcode
-  \expandafter\ltj@set@alxspmode#1:\relax}
-\def\ltj@set@alxspmode#1,#2:{%
-  \lowercase{\edef\ltj@temp{#2}}%
-  \def\ltj@tempa{inhibit}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{0}\fi
-  \def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
-  \def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
-  \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
-  \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.XSP,
-    \ltj@safe@num@or{nil}{#1},
-    \ltj@safe@num@or{nil}{\ltj@temp},0,3)}}
+  \expandafter\ltj@set@jaxspmode#1:\relax}% same code as jaxspmode
 
 % autospacing = <bool> (default: true)
 \define@boolkey[ltj]{japaram}{autospacing}[true]{%
   \fi}
 
 % [x]]kanjiskip = <skip>
-  \define@key[ltj]{japaram}{kanjiskip}{\ltjsetkanjiskip #1}
-  \define@key[ltj]{japaram}{xkanjiskip}{\ltjsetxkanjiskip #1}
+  \define@key[ltj]{japaram}{kanjiskip}{\ltjsetkanjiskip#1}
+  \define@key[ltj]{japaram}{xkanjiskip}{\ltjsetxkanjiskip#1}
   \protected\def\ltjsetkanjiskip{%                  % SKIP
     \directlua{%
       local d = luatexja.token.scan_glue()
 
 % jcharwidowpenalty = <count>
 \define@key[ltj]{japaram}{jcharwidowpenalty}{%      %COUNT
-  \ltj@@set@stack0,#1:{JWP}{-10000}{10000}}
+  \ltj@@set@stack{JWP}{-10000}{10000}\z@#1 }
 
 % differentjfm = { large | small | average | pleft | pright | paverage | both}
 \define@choicekey*+[ltj]{japaram}{differentjfm}[\ltj@temp\ltj@tempr]%
     \csname ltj@kcat6\endcsname="7FFFFFFF }%"
 
 \protected\def\ltjjachar{\afterassignment\ltj@@jachar\ltj@tempcnta}
-\def\ltj@@jachar{{\directlua{tex.globaldefs = 0}\ltj@alljachar\ltj@@origchar\ltj@tempcnta}}
+\def\ltj@@jachar{{\directlua{tex.globaldefs=0}\ltj@alljachar\ltj@@origchar\ltj@tempcnta}}
 \protected\def\ltjalchar{\afterassignment\ltj@@alchar\ltj@tempcnta}
-\def\ltj@@alchar{{\directlua{tex.globaldefs = 0}\ltj@allalchar\ltj@@origchar\ltj@tempcnta}}
+\def\ltj@@alchar{{\directlua{tex.globaldefs=0}\ltj@allalchar\ltj@@origchar\ltj@tempcnta}}
 
 %%%%%%%% \ltjsetmathletter<number>, \ltjunsetmathletter<number>
 \protected\def\ltjsetmathletter#1{%
-  \ltj@tempcnta=#1
-  \directlua{luatexja.math.is_math_letters[\the\ltj@tempcnta]=true}%
+  \directlua{luatexja.math.is_math_letters[luatexja.token.scan_int()]=true}#1 %
 }
 \protected\def\ltjunsetmathletter#1{%
-  \ltj@tempcnta=#1
-  \directlua{luatexja.math.is_math_letters[\the\ltj@tempcnta]=false}%
+  \directlua{luatexja.math.is_math_letters[luatexja.token.scan_int()]=false}#1 %
 }
 
 %%%%%%%% \ltjdeclarealtfont<base_font_cs><alt_font_cs>{100-200,3000-,5000,...}
 \let\ltjgetwd=\ltj@@getwd\let\ltjgetht=\ltj@@getht\let\ltjgetdp=\ltj@@getdp
 
 %%%%%%%% \ltjsetwd<box_num>=<dimen> etc.
-\protected\def\ltjsetwd{\begingroup
-  \ltj@reset@globaldefs\afterassignment\ltj@@setwd@a\ltj@tempcnta}
-\def\ltj@@setwd@a{\afterassignment\ltj@@setwd@b\ltj@tempdima}
-\def\ltj@@setwd@b{%
-  \directlua{luatexja.direction.set_box_dim('width')}%
-  \ltj@restore@globaldefs\endgroup}
-\protected\def\ltjsetht{\begingroup
-  \ltj@reset@globaldefs\afterassignment\ltj@@setht@a\ltj@tempcnta}
-\def\ltj@@setht@a{\afterassignment\ltj@@setht@b\ltj@tempdima}
-\def\ltj@@setht@b{%
-  \directlua{luatexja.direction.set_box_dim('height')}%
-  \ltj@restore@globaldefs\endgroup}
-\protected\def\ltjsetdp{\begingroup
-  \ltj@reset@globaldefs\afterassignment\ltj@@setdp@a\ltj@tempcnta}
-\def\ltj@@setdp@a{\afterassignment\ltj@@setdp@b\ltj@tempdima}
-\def\ltj@@setdp@b{%
-  \directlua{luatexja.direction.set_box_dim('depth')}%
-  \ltj@restore@globaldefs\endgroup}
+\protected\def\ltjsetwd{\directlua{luatexja.direction.set_box_dim('width')}}
+\protected\def\ltjsetht{\directlua{luatexja.direction.set_box_dim('height')}}
+\protected\def\ltjsetdp{\directlua{luatexja.direction.set_box_dim('depth')}}
 
 %%------------------ Load module for the format
 
index 16a2c2f..ccbf190 100644 (file)
Binary files a/test/test51-vtest.pdf and b/test/test51-vtest.pdf differ
index f008752..e440988 100644 (file)
 \vfill\eject
 
 \vbox{\tate\hsize100mm
-\tfont\f=KozMinPr6N-Regular.otf:-vert;jfm=ujisv \f
+\tfont\f=KozMinPr6N-Regular.otf:jfm=ujisv \f
 
 \ltjsetparameter{yalbaselineshift=.25em}\baselineskip15pt\parindent\zw
 \LaTeX の特徴として、テキストファイルであるソースコードを入力として処理することでDVIや
@@ -248,18 +248,18 @@ PDFなどの表示形式を出力として得ることが挙げられる。
   \tate\ltjsetparameter{talbaselineshift=0pt}Htp}
 縦ボックス\hbox{\vrule\copy12288\vrule}寸法\quad
 \vbox{\hsize=80pt\yoko\noindent
-  WD: \the\ltjgetwd{12288}, \\HT: \the\ltjgetht{12288}, \\DP: \the\ltjgetdp{12288}%
+  WD: \the\ltjgetwd12288, \\HT: \the\ltjgetht12288, \\DP: \the\ltjgetdp12288%
 }
 \vbox{\hsize=80pt\tate\noindent
-  WD: \the\ltjgetwd{12288}, \\HT: \the\ltjgetht{12288}, \\DP: \the\ltjgetdp{12288}%
+  WD: \the\ltjgetwd12288, \\HT: \the\ltjgetht12288, \\DP: \the\ltjgetdp12288%
 }
 \ltjsetwd12288=100pt
 \setbox0=\hbox{\tate\ltjsetht12288=10pt}
 \vbox{\hsize=80pt\yoko\noindent
-  WD: \the\ltjgetwd{12288}, \\HT: \the\ltjgetht{12288}, \\DP: \the\ltjgetdp{12288}%
+  WD: \the\ltjgetwd12288, \\HT: \the\ltjgetht12288, \\DP: \the\ltjgetdp12288%
 }
 \vbox{\hsize=80pt\tate\noindent
-  WD: \the\ltjgetwd{12288}, \\HT: \the\ltjgetht{12288}, \\DP: \the\ltjgetdp{12288}%
+  WD: \the\ltjgetwd12288, \\HT: \the\ltjgetht12288, \\DP: \the\ltjgetdp12288%
 }
 
 
@@ -268,21 +268,21 @@ PDFなどの表示形式を出力として得ることが挙げられる。
   \yoko\ltjsetparameter{yalbaselineshift=0pt}Htp}
 横ボックス\hbox{\vrule\copy12288\vrule}寸法\quad
 \vbox{\hsize=80pt\yoko\noindent
-  WD: \the\ltjgetwd{12288}, \\HT: \the\ltjgetht{12288}, \\DP: \the\ltjgetdp{12288}%
+  WD: \the\ltjgetwd12288, \\HT: \the\ltjgetht12288, \\DP: \the\ltjgetdp12288%
 }
 \vbox{\hsize=80pt\tate\noindent
-  WD: \the\ltjgetwd{12288}, \\HT: \the\ltjgetht{12288}, \\DP: \the\ltjgetdp{12288}%
+  WD: \the\ltjgetwd12288, \\HT: \the\ltjgetht12288, \\DP: \the\ltjgetdp12288%
 }
 \ltjsetwd12288=100pt
 \setbox0=\hbox{\tate\ltjsetht12288=10pt}
 \vbox{\hsize=80pt\yoko\noindent
-  WD: \the\ltjgetwd{12288}, \\HT: \the\ltjgetht{12288}, \\DP: \the\ltjgetdp{12288}%
+  WD: \the\ltjgetwd12288, \\HT: \the\ltjgetht12288, \\DP: \the\ltjgetdp12288%
 }
 \vbox{\hsize=80pt\tate\noindent
-  WD: \the\ltjgetwd{12288}, \\HT: \the\ltjgetht{12288}, \\DP: \the\ltjgetdp{12288}%
+  WD: \the\ltjgetwd12288, \\HT: \the\ltjgetht12288, \\DP: \the\ltjgetdp12288%
 }
 
-dimexpr でも使えるかな?\the \dimexpr2\ltjgetwd{` }+\ltjgetwd{200}+1pt\relax
+dimexpr でも使えるかな?\the \dimexpr2\ltjgetwd` +\ltjgetwd200+1pt\relax
 
 \vfill\eject