X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Faddons%2Fluatexja-ruby.sty;h=7c1a939e6d5f777bd37f97006989352d16160511;hb=1a26bd568b0b32af39051011d3d94e900ef463a2;hp=22c7ebf6e800a4231c204b20ea035f0935b40375;hpb=76c2f061a5f0d85e7c0e4a6bf433f0279e908fd7;p=luatex-ja%2Fluatexja.git diff --git a/src/addons/luatexja-ruby.sty b/src/addons/luatexja-ruby.sty index 22c7ebf..7c1a939 100644 --- a/src/addons/luatexja-ruby.sty +++ b/src/addons/luatexja-ruby.sty @@ -4,11 +4,11 @@ % LaTeX only! \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{luatexja-ruby}[2014/03/19 v0.2] +\ProvidesPackage{luatexja-ruby}[2020-10-05 v0.3] \RequirePackage{luatexja} %%------------------ -\newluatexattribute\ltj@rubyattr +\newattribute\ltj@rubyattr \ltj@rubyattr=0 \RequireLuaTeXjaSubmodule{ruby} @@ -18,12 +18,12 @@ %% 引数:ルビ全角を単位とした実数 %% この文字への 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, token.scan_word)}} % ルビ用のキー設定 \def\ltj@@rkeydef#1{ @@ -47,9 +47,9 @@ \ltj@@rkeydef{pre} \ltj@@rkeydef{post} %% 親文字伸長の際の比,{0}{1}{1} などと0--7 の数 3 つで指定 -%% attr_ruby_stretch (head left,middle,right)(end)(middle) 27-bits -\ltj@@rkeydef{stretchhead} % 行頭形 -\ltj@@rkeydef{stretchend} % 行末形 +%% attr_ruby_stretch (bol left,middle,right)(eol)(middle) 27-bits +\ltj@@rkeydef{stretchbol} % 行頭形 +\ltj@@rkeydef{stretcheol} % 行末形 \ltj@@rkeydef{stretch} % 行中形 %% ルビが伸長するときの比 {1}{2}{1} などと0--7 の数 3 つで指定 %% attr_ruby_mode 上位部分 @@ -67,6 +67,14 @@ \ltj@@rkeydef{fontcmd}%% フォント \define@boolkey[ltj]{ruby}{rubysmash}[true]{} +\ltj@@rkeydef{ybaseheight} % 縦組以外 (yoko, utod, dtou) +\ltj@@rkeydef{tbaseheight} % 縦組 +\define@key[ltj]{ruby}{baseheight}{% + \expandafter\def\csname ltj@@rubyip@ybaseheight\endcsname{#1}% + \expandafter\def\csname ltj@@rubyip@tbaseheight\endcsname{#1}% +} + +%% これらの値が正のとき,親文字の高さをこの値(\zh 単位)とみなす %%%%%%%% setkeys の別名 \protected\def\ltjsetruby{\setkeys[ltj]{ruby}} @@ -89,15 +97,17 @@ maxmargin = \ltj@safe@dimen{\ltj@@rubyip@maxmargin\zw}, pre = \ltj@safe@dimen{\ltj@@rubyip@pre#1}, post = \ltj@safe@dimen{\ltj@@rubyip@post#1}, - intergap = \ltj@safe@dimen{\ltj@@rubyip@intergap\zw}, + intergap = \ltj@safe@dimen{\ltj@@rubyip@intergap\zh}, stretch - = 262144 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchhead - + 512 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchend + = 262144 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchbol + + 512 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretcheol + \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretch, mode - = 2097152 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchruby + = (2097152 * \expandafter\ltj@@ruby@cts\ltj@@rubyip@stretchruby + \ltj@safe@num{\ltj@@rubyip@mode} - + 1048576 * \ifltj@ruby@rubysmash1\else0\fi + + 1048576 * \ifltj@ruby@rubysmash1\else0\fi), + baseheight = \ltj@safe@dimen{\ifnum\ltjgetparameter{direction}=3 + \ltj@@rubyip@tbaseheight\else\ltj@@rubyip@ybaseheight\fi\zh}, \string} } %%% @@ -146,10 +156,14 @@ %%%%%%%% TeX command \protected\def\ltjruby{\@ifnextchar[\ltj@@ruby{\ltj@@ruby[]}}%] -\AtBeginDocument{\ifdefined\ruby\else\let\ruby=\ltjruby\fi} +\AtBeginDocument{% + \ifdefined\ruby\else\let\ruby=\ltjruby\fi + \directlua{luatexja.ruby.read_old_break_info()}% +} \def\ltj@@ruby[#1]#2#3{{% #1: option #2: 親文字群,#3: ルビ文字列群,共に| 区切り \setkeys[ltj]{ruby}{#1}% - \directlua{ruby_tmplist_r = \string{\string}; ruby_tmplist_p = \string{\string}}% + \directlua{luatexja.ruby.ruby_tmplist_r = \string{\string}; + luatexja.ruby.ruby_tmplist_p = \string{\string}}% \leavevmode\dimen0=\f@size pt\dimen1=\ltj@@rubyip@size\dimen0% % 引数展開,テーブルにセット \pxrr@decompbar{#2}{\let\ltj@@ruby@mark\ltj@@ruby@sp\pxrr@res}% @@ -157,16 +171,16 @@ {\fontsize{\ltj@@rubyip@size\dimen0}\z@\selectfont\ltj@@rubyip@fontcmd\global\dimen1=\zw}% \directlua{% luatexja.ruby.texiface(\ltj@@ruby@create@table{\dimen1}, - ruby_tmplist_r, ruby_tmplist_p)}% + luatexja.ruby.ruby_tmplist_r, luatexja.ruby.ruby_tmplist_p)}% }} \def\ltj@@ruby@sr#1{% \setbox0=\hbox{\fontsize{\dimen1}\z@\ltj@@rubyip@fontcmd\selectfont#1}% - \directlua{table.insert(ruby_tmplist_r, luatexja.ruby.cpbox())}% + \directlua{table.insert(luatexja.ruby.ruby_tmplist_r, luatexja.ruby.cpbox())}% } \def\ltj@@ruby@sp#1{% \setbox0=\hbox{\selectfont#1}% - \directlua{table.insert(ruby_tmplist_p, luatexja.ruby.cpbox())}% + \directlua{table.insert(luatexja.ruby.ruby_tmplist_p, luatexja.ruby.cpbox())}% } \protected\def\ltjkenten{\@ifnextchar[\ltj@@kenten{\ltj@@kenten[]}}%] @@ -182,26 +196,36 @@ \ltjsetparameter{rubypreintrusion={\the\count@,1}, rubypostintrusion={\the\count@,1}} \advance\count@1\repeat -%% 「」 -\ltjsetparameter{rubypreintrusion={`「,1}, - rubypostintrusion={`」,1}} -%% ,、 -\ltjsetparameter{rubypreintrusion={`,,1}, - rubypostintrusion={`,,1}} -\ltjsetparameter{rubypreintrusion={`、,1}, - rubypostintrusion={`、,1}} -%% ・ -\ltjsetparameter{rubypreintrusion={`・,1}, - rubypostintrusion={`・,1}} +%% カタカナ +\count@="30A0\loop\relax\ifnum \count@<"3100 + \ltjsetparameter{rubypreintrusion={\the\count@,1}, + rubypostintrusion={\the\count@,1}} + \advance\count@1\repeat +%% Kana Supplement +\count@="1B000\loop\relax\ifnum \count@<"1B170 + \ltjsetparameter{rubypreintrusion={\the\count@,1}, + rubypostintrusion={\the\count@,1}} + \advance\count@1\repeat +%% 開き括弧・閉じ括弧 +\@for\@tmp:=`\‘,`\“,`\〈,`\《,`\「,`\『,`\【,`\〔,`\〖,`\〘,`\〝,`\(,`\[,`\{,`\⦅ \do + {\ltjsetparameter{rubypreintrusion={\@tmp,1}}} +\@for\@tmp:=`\’,`\”,`\〉,`\》,`\」,`\』,`\】,`\〕,`\〗,`\〙,`\〟,`\),`\],`\},`\⦆ \do + {\ltjsetparameter{rubypostintrusion={\@tmp,1}}} +%% 中点類 +\@for\@tmp:=`\・,`\:,`\;,`\―,`\‥,`\…,`〳,`\〴,`\〵,"2014 \do + {\ltjsetparameter{rubypreintrusion={\@tmp,1},rubypostintrusion={\@tmp,1}}} +%% 読点・句点 +\@for\@tmp:=`\、,`\,,`\。,`\. \do + {\ltjsetparameter{rubypostintrusion={\@tmp,1}}} %% 段落インデント部分 \ltjsetparameter{rubypreintrusion={-1,1}} \setkeys[ltj]{ruby}{ pre=-1, post=-1, mode=1, stretchruby={1}{2}{1}, stretch = {1}{2}{1}, - stretchhead={0}{1}{1}, stretchend={1}{1}{0}, + stretchbol={0}{1}{1}, stretcheol={1}{1}{0}, maxmargin=0.5, size=0.5, intergap=0, rubysmash=false, - kenten=\ltjalchar`•, fontcmd=\relax + kenten=\ltjalchar`•, fontcmd=\relax, ybaseheight=0.88, tbaseheight=0.5 } -\endinput \ No newline at end of file +\endinput