OSDN Git Service

Releases 20150518.0
[luatex-ja/luatexja.git] / src / luatexja-core.sty
index fc645d6..dd20eee 100644 (file)
@@ -65,7 +65,7 @@
   \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
     \csname iftrue\endcsname
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{luatexja-core}[2015/02/22 Core of LuaTeX-ja]
+  \ProvidesPackage{luatexja-core}[2015/05/03 Core of LuaTeX-ja]
 \fi                             %</LaTeX>
 
 %% Load prerequisite packages.
 \protected\def\ltj@@q@escapenum{\ltj@@q@escapenum@}
 
 \directlua{%
-  luatexja = {}
+  luatexja = {};
+  luatexja.lang_ja = \the\ltj@@japanese;
   dofile(assert(kpse.find_file('luatexja.lua', 'tex'),
       "File `luatexja.lua' not found"))
 }
 
-
-%%% true if we can use [new]token.scan_int and co.
-\newif\ifltj@token@avail@scan
-\directlua{%
-  local bs = string.char(92)
-  if luatexja.token  then tex.sprint(bs .. 'ltj@token@avail@scantrue') end
-  print (luatexja.token)
-}
-
-
 %% \RequireLuaTeXjaSubmodule{name}[date]
 % A TeX version of luatexja.load_module(name)
 % The second optional argument [date] is simply ignored.
 \fi                             %</LaTeX>
 
 %%%%%%%% \asluastring
-\def\asluastring#1{'\luaescapestring{\detokenize{#1}}'}
+\def\asluastring#1{'\luatexluaescapestring{\detokenize{#1}}'}
 
 %%%%%%%% Redefine \/
 \protected\def\/{\relax\directlua{luatexja.jfont.append_italic()}}
 
 %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
-\protected\def\jfont{%
-  \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko')}}
-\protected\def\globaljfont{%
-  \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true,  'yoko')}}
+\protected\def\jfont#1{%
+  \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko','\luatexluaescapestring{\noexpand#1}')}}
+\protected\def\globaljfont#1{%
+  \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true,  'yoko','\luatexluaescapestring{\noexpand#1}')}}
 \def\ltj@@jfont{\directlua{luatexja.jfont.jfontdefY()}}
 
 %%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont
-\protected\def\tfont{%
-  \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(false, 'tate')}}
-\protected\def\globaltfont{%
-  \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(true,  'tate')}}
+\protected\def\tfont#1{%
+  \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(false, 'tate','\luatexluaescapestring{\noexpand#1}')}}
+\protected\def\globaltfont#1{%
+  \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(true,  'tate','\luatexluaescapestring{\noexpand#1}')}}
 \def\ltj@@tfont{\directlua{luatexja.jfont.jfontdefY()}}
 
 %%%%%%%% \zw, \zh
   \ltj@restore@globaldefs
   }
 
-\ifltj@token@avail@scan %%%%%%%%%%%%%%%%%%%%%%%% new tokenlib
 % {y,t}{ja,al}baselineshift = <dimen>
 % yjabaselineshift = <dimen>
 \define@key[ltj]{japaram}{yalbaselineshift}{%
 \define@key[ltj]{japaram}{tjabaselineshift}{%
   \directlua{tex.setattribute(luatexja.isglobal,
     luatexbase.attributes['ltj@tkblshift'], luatexja.token.scan_dimen())}#1}
-\else %%%%%%%%%%%%%%%%%%%%%%%% old tokenlib
-% yalbaselineshift = <dimen>
-% yjabaselineshift = <dimen>
-\define@key[ltj]{japaram}{yalbaselineshift}{%
-  \directlua{tex.setattribute(luatexja.isglobal,
-    luatexbase.attributes['ltj@yablshift'],
-    \ltj@safe@dimen@or\ltj@defdimen{#1})}}
-\define@key[ltj]{japaram}{yjabaselineshift}{%
-  \directlua{tex.setattribute(luatexja.isglobal,
-    luatexbase.attributes['ltj@ykblshift'],
-    \ltj@safe@dimen@or\ltj@defdimen{#1})}}
-% talbaselineshift = <dimen>
-% tjabaselineshift = <dimen>
-\define@key[ltj]{japaram}{talbaselineshift}{%
-  \directlua{tex.setattribute(luatexja.isglobal,
-    luatexbase.attributes['ltj@tablshift'],
-    \ltj@safe@dimen@or\ltj@defdimen{#1})}}
-\define@key[ltj]{japaram}{tjabaselineshift}{%
-  \directlua{tex.setattribute(luatexja.isglobal,
-    luatexbase.attributes['ltj@tkblshift'],
-    \ltj@safe@dimen@or\ltj@defdimen{#1})}}
-\fi %%%%%%%%%%%%%%%%%%%%%%%%
 
 % jaxspmode = {<char_code>, <mode>}
 % mode: inhibit, preonly, postonly, allow
   \fi}
 
 % [x]]kanjiskip = <skip>
-\ifltj@token@avail@scan %%%%%%%%%%%%%%%%%%%%%%%% new tokenlib
   \define@key[ltj]{japaram}{kanjiskip}{\ltjsetkanjiskip #1}
   \define@key[ltj]{japaram}{xkanjiskip}{\ltjsetxkanjiskip #1}
   \protected\def\ltjsetkanjiskip{%                  % SKIP
       local d = luatexja.token.scan_glue()
       luatexja.stack.set_stack_skip(luatexja.stack_table_index.XSK, d); node.free(d)
   }}
-\else %%%%%%%%%%%%%%%%%%%%%%%% old tokenlib
-  \define@key[ltj]{japaram}{kanjiskip}{\ltjsetkanjiskip{#1}}
-  \define@key[ltj]{japaram}{xkanjiskip}{\ltjsetxkanjiskip{#1}}
-  \protected\def\ltjsetkanjiskip#1{%                  % SKIP
-    \directlua{%
-      local d = \ltj@safe@glue{#1}
-      luatexja.stack.set_stack_skip(luatexja.stack_table_index.KSK, d); node.free(d)
-  }\ignorespaces}
-  \protected\def\ltjsetxkanjiskip#1{%                  % SKIP
-    \directlua{%
-      local d = \ltj@safe@glue{#1}
-      luatexja.stack.set_stack_skip(luatexja.stack_table_index.XSK, d); node.free(d)
-  }\ignorespaces}
-\else
-\fi %%%%%%%%%%%%%%%%%%%%%%%%
-
 
 % jcharwidowpenalty = <count>
 \define@key[ltj]{japaram}{jcharwidowpenalty}{%      %COUNT
 }
 
 %%%%%%%% \ltjgetwd<box_num> etc.
-\ifltj@token@avail@scan %%%%%%%%%%%%%%%%%%%%%%%% new tokenlib
 \def\ltj@@getwd{%
   \directlua{luatexja.direction.get_box_dim('width', luatexja.token.scan_int())}}
 \def\ltj@@getht{%
   \directlua{luatexja.direction.get_box_dim('height', luatexja.token.scan_int())}}
 \def\ltj@@getdp{%
   \directlua{luatexja.direction.get_box_dim('depth', luatexja.token.scan_int())}}
-\else %%%%%%%%%%%%%%%%%%%%%%%% old tokenlib
-\def\ltj@@getwd#1{%
-  \directlua{luatexja.direction.get_box_dim('width', \the\numexpr#1\relax)}}
-\def\ltj@@getht#1{%
-  \directlua{luatexja.direction.get_box_dim('height', \the\numexpr#1\relax)}}
-\def\ltj@@getdp#1{%
-  \directlua{luatexja.direction.get_box_dim('depth', \the\numexpr#1\relax)}}
-\fi %%%%%%%%%%%%%%%%%%%%%%%%
 \let\ltjgetwd=\ltj@@getwd\let\ltjgetht=\ltj@@getht\let\ltjgetdp=\ltj@@getdp
 
 %%%%%%%% \ltjsetwd<box_num>=<dimen> etc.