From 1f72a8c996bedad62f754f509516f15e4137889f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 11 Oct 2020 21:37:50 +0000 Subject: luatexja git-svn-id: svn://tug.org/texlive/trunk@56639 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/luatex/luatexja/addons/luatexja-ruby.sty | 52 ++++++++++----- .../texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua | 17 +++-- .../texmf-dist/tex/luatex/luatexja/ltj-jfont.lua | 2 +- Master/texmf-dist/tex/luatex/luatexja/ltj-ruby.lua | 78 +++++++++++++++------- Master/texmf-dist/tex/luatex/luatexja/luatexja.sty | 4 +- .../tex/luatex/luatexja/patches/lltjdefs.sty | 4 +- .../tex/luatex/luatexja/patches/lltjfont.sty | 28 ++++---- 7 files changed, 123 insertions(+), 62 deletions(-) (limited to 'Master/texmf-dist/tex/luatex') diff --git a/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-ruby.sty b/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-ruby.sty index 518d6ec8bd8..7c1a939e6d5 100644 --- a/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-ruby.sty +++ b/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-ruby.sty @@ -4,7 +4,7 @@ % LaTeX only! \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{luatexja-ruby}[2017/09/26 v0.23a] +\ProvidesPackage{luatexja-ruby}[2020-10-05 v0.3] \RequirePackage{luatexja} %%------------------ @@ -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@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} } %%% @@ -186,17 +196,27 @@ \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}} @@ -205,7 +225,7 @@ stretchruby={1}{2}{1}, stretch = {1}{2}{1}, 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 diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua index 0bbf7249e51..e3cae86534b 100644 --- a/Master/texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua +++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-jfmglue.lua @@ -3,7 +3,7 @@ -- luatexbase.provides_module({ name = 'luatexja.jfmglue', - date = '2020-07-30', + date = '2020-10-05', description = 'Insertion process of JFM glues, [x]kanjiskip and others', }) luatexja.jfmglue = luatexja.jfmglue or {} @@ -258,6 +258,8 @@ luatexbase.create_callback("luatexja.jfmglue.whatsit_getinfo", "data", end) luatexbase.create_callback("luatexja.jfmglue.whatsit_after", "data", function (stat, Nq, Np) return false end) +luatexbase.create_callback("luatexja.jfmglue.whatsit_last_minute", "data", + function (stat, Nq, Np) return false end) -- calc next Np local calc_np @@ -543,10 +545,13 @@ end function calc_np(last, lp) local k -- We assume lp = node_next(Np.last) + if Nq and Nq.id==id_pbox_w then + luatexbase.call_callback("luatexja.jfmglue.whatsit_last_minute", false, Nq, Np) + end Np, Nq, non_ihb_flag = Nq, Np, true -- We clear `predefined' entries of Np before pairs() loop, -- because using only pairs() loop is slower. - Np.post, Np.pre, Np.xspc = nil, nil, nil + Np.post, Np.pre, Np.xspc, Np.gk = nil, nil, nil, nil Np.first, Np.id, Np.last, Np.met, Np.class= nil, nil, nil, nil Np.auto_kspc, Np.auto_xspc, Np.char, Np.nuc = nil, nil, nil, nil -- auto_kspc, auto_xspc: normally true/false, @@ -751,6 +756,10 @@ local function real_insert(g) if g then head = insert_before(head, Np.first, g) Np.first = g + local ngk = Np.gk + if not ngk then Np.gk = g + elseif type(ngk)=="table" then ngk[#ngk+1]=g + else Np.gk = { ngk, g } end end end @@ -1161,10 +1170,10 @@ do {}, {}, {first=nil}, { auto_kspc=nil, auto_xspc=nil, char=nil, class=nil, first=nil, id=nil, last=nil, met=nil, nuc=nil, - post=nil, pre=nil, xspc=nil, }, + post=nil, pre=nil, xspc=nil, gk=nil }, { auto_kspc=nil, auto_xspc=nil, char=nil, class=nil, first=nil, id=nil, last=nil, met=nil, nuc=nil, - post=nil, pre=nil, xspc=nil, }, + post=nil, pre=nil, xspc=nil, gk=nil }, } init_var = function (mode,dir) -- 1073741823: max_dimen diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua index 6b7667a0d16..ed40e86821f 100644 --- a/Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua +++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua @@ -3,7 +3,7 @@ -- luatexbase.provides_module({ name = 'luatexja.jfont', - date = '2020-09-16', + date = '2020-10-05', description = 'Loader for Japanese fonts', }) diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-ruby.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-ruby.lua index 865e301f30b..e2cb40d925b 100644 --- a/Master/texmf-dist/tex/luatex/luatexja/ltj-ruby.lua +++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-ruby.lua @@ -3,7 +3,7 @@ -- luatexbase.provides_module({ name = 'luatexja.ruby', - date = '2020-07-30', + date = '2020-10-05', description = 'Ruby annotation', }) luatexja.ruby = {} @@ -50,6 +50,7 @@ local attr_ruby_stretch = luatexbase.attributes['ltj@kcat2'] local attr_ruby_mode = luatexbase.attributes['ltj@kcat3'] local attr_ruby_id = luatexbase.attributes['ltj@kcat4'] -- uniq id local attr_ruby_intergap = luatexbase.attributes['ltj@kcat5'] +local attr_ruby_baseheight= luatexbase.attributes['ltj@kcat6'] local attr_ruby = luatexbase.attributes['ltj@rubyattr'] -- ルビ内部処理用,以下のようにノードによって使われ方が異なる -- * (whatsit) では JAglue 処理時に, @@ -128,6 +129,9 @@ function luatexja.ruby.read_old_break_info() local real_file = kpse.find_file(fname) if real_file then dofile(real_file) end cache_handle = io.open(fname, 'w') + if cache_handle then + cache_handle:write('local lrob=luatexja.ruby.old_break_info\n') + end end end local make_uniq_id @@ -142,12 +146,12 @@ end -- concatenation of boxes: reusing nodes -- ルビ組版が行われている段落/hboxでの設定が使われる. -- ルビ文字を格納しているボックスでの設定ではない! +local function get_attr_icflag(p) + return (has_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG +end local concat do local node_prev = node.direct.getprev - local function get_attr_icflag(p) - return (has_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG - end function concat(f, b) if f then if b then @@ -264,6 +268,7 @@ local function texiface_low(rst, rtlr, rtlp) set_attr(wv, attr_ruby_maxprep, rst.pre) set_attr(wv, attr_ruby_maxpostp, rst.post) set_attr(wv, attr_ruby_intergap, rst.intergap) + set_attr(wv, attr_ruby_baseheight, rst.baseheight) set_attr(wv, attr_ruby_stretch, rst.stretch) set_attr(wv, attr_ruby_mode, rst.mode) local n = wv @@ -309,11 +314,13 @@ end ---------------------------------------------------------------- -- r, p の中身のノードは再利用される -local function enlarge_parent(r, p, ppre, pmid, ppost, mapre, mapost, intmode) +local function enlarge_parent(r, p, tmp_tbl, intmode) -- r: ルビ部分の格納された box,p: 同,親文字 local rwidth = getfield(r, 'width') local sumprot = rwidth - getfield(p, 'width') -- >0 local pre_intrusion, post_intrusion + local ppre, pmid, ppost = tmp_tbl.ppre, tmp_tbl.pmid, tmp_tbl.ppost + local mapre, mapost = tmp_tbl.mapre, tmp_tbl.mapost if intmode == 0 then -- とりあえず組んでから決める p = enlarge(p, rwidth, ppre, pmid, ppost, 0, 0) pre_intrusion = min(mapre, round(ppre*getfield(p, 'glue_set')*65536)) @@ -349,17 +356,19 @@ end -- ルビボックスの生成(単一グループ) -- returned value: , , local max_margin -local function new_ruby_box(r, p, ppre, pmid, ppost, - mapre, mapost, imode, rgap) +local function new_ruby_box(r, p, tmp_tbl) local post_intrusion = 0 - local intmode = imode%4 + local imode + local ppre, pmid, ppost = tmp_tbl.ppre, tmp_tbl.pmid, tmp_tbl.ppost + local mapre, mapost = tmp_tbl.mapre, tmp_tbl.mapost local rpre, rmid, rpost, rsmash - imode = floor(imode/262144); rsmash = (imode%2 ==1) + imode = floor(tmp_tbl.imode/0x100000); rsmash = (imode%2 ==1) imode = floor(imode/2); rpost = imode%8; imode = (imode-rpost)/8; rmid = imode%8; imode = (imode-rmid)/8; rpre = imode%8 if getfield(r, 'width') > getfield(p, 'width') then -- change the width of p - r, p, post_intrusion = enlarge_parent(r, p, ppre, pmid, ppost, mapre, mapost, intmode) + r, p, post_intrusion = enlarge_parent(r, p, tmp_tbl, + floor(tmp_tbl.imode/4)%4) elseif getfield(r, 'width') < getfield(p, 'width') then -- change the width of r r = enlarge(r, getfield(p, 'width'), rpre, rmid, rpost, 0, 0) post_intrusion = 0 @@ -383,9 +392,10 @@ local function new_ruby_box(r, p, ppre, pmid, ppost, end local a, k = node_new(id_rule), node_new(id_kern, 1) setfield(a, 'width', 0); setfield(a, 'height', 0) - setfield(a, 'depth', 0); setfield(k, 'kern', rgap) + setfield(a, 'depth', 0); setfield(k, 'kern', tmp_tbl.rgap) insert_after(r, r, a); insert_after(r, a, k); insert_after(r, k, p); setfield(p, 'next', nil) + if tmp_tbl.bheight >= 0 then setfield(p, 'height', tmp_tbl.bheight) end a = node.direct.vpack(r); setfield(a, 'shift', 0) set_attr(a, attr_ruby, post_intrusion) if rsmash or getfield(a, 'height')0 and cache_handle then cache_handle:write( - 'luatexja.ruby.old_break_info[' - .. tostring(id) .. ']=' .. num - .. '\n') + 'lrob[' .. tostring(id) .. ']=' .. num .. '\n') end end @@ -736,6 +752,11 @@ do insert_before(Nq.nuc, Np.first, last_glue) Np.first = last_glue next_cluster_array[Nq.nuc] = last_glue -- ルビ処理用のグルー +-- if Nq.gk then +-- if type(Nq.gk)=="table" then +-- for _,v in ipairs(Nq.gk) do luatexja.ext_show_node(node.direct.tonode(v), 'BBt> ', print) end +-- else luatexja.ext_show_node(node.direct.tonode(Nq.gk), 'BBB> ', print) end +-- end end local nqnv = getfield(Nq.nuc, 'value') local x = node_next(node_next(nqnv)) @@ -779,4 +800,15 @@ do luatexbase.add_to_callback("luatexja.jfmglue.whatsit_after", whatsit_after_callback, "luatexja.ruby.np_info_after", 1) end +if false then -- いまは off + local function w (s, Nq, Np) + if Np.gk then + if type(Np.gk)=="table" then + for _,v in ipairs(Np.gk) do luatexja.ext_show_node(node.direct.tonode(v), 'AAt> ', print) end + else luatexja.ext_show_node(node.direct.tonode(Np.gk), 'AAA> ', print) end + end + end + luatexbase.add_to_callback("luatexja.jfmglue.whatsit_last_minute", w, + "luatexja.ruby.np_info_last_minute", 1) +end diff --git a/Master/texmf-dist/tex/luatex/luatexja/luatexja.sty b/Master/texmf-dist/tex/luatex/luatexja/luatexja.sty index cfee092e30b..74df9c779c4 100644 --- a/Master/texmf-dist/tex/luatex/luatexja/luatexja.sty +++ b/Master/texmf-dist/tex/luatex/luatexja/luatexja.sty @@ -35,13 +35,13 @@ \expandafter\let\csname ifltj@in@latex\expandafter\endcsname \csname iftrue\endcsname \NeedsTeXFormat{LaTeX2e} - \ProvidesPackage{luatexja}[2020-09-19 Japanese Typesetting with Lua(La)TeX] + \ProvidesPackage{luatexja}[2020-10-05 Japanese Typesetting with Lua(La)TeX] \DeclareOption{disablejfam}{\ltj@disablejfamtrue} \DeclareOption*{} \ProcessOptions\relax \fi % %%%% VERSION -\def\LuaTeXjaversion{20201001.0} +\def\LuaTeXjaversion{20201005.0} \directlua{require('ltj-unicode-ccfix.lua')}% catcode of ideographs diff --git a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjdefs.sty b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjdefs.sty index 03366c258f0..754a9122f84 100644 --- a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjdefs.sty +++ b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjdefs.sty @@ -3,7 +3,7 @@ % \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{lltjdefs}[2020-09-30 Default font settings of LuaTeX-ja] +\ProvidesPackage{lltjdefs}[2020-10-05 Default font settings of LuaTeX-ja] \ifdefined\ltj@stdmcfont\else\def\ltj@stdmcfont{file:HaranoAjiMincho-Regular.otf}\fi \ifdefined\ltj@stdgtfont\else\def\ltj@stdgtfont{file:HaranoAjiGothic-Medium.otf}\fi @@ -95,7 +95,7 @@ \@ltj@match@familyfalse \def\verbatim@font{\normalfont\ttfamily\kanjifamily\jttdefault\selectfont} -\def\@ltj@hook@family#1#2{ % #1: csname #2: contents +\def\@ltj@hook@family#1#2{% #1: csname #2: contents \ifltj@ltfilehook@avail % LaTeX 2020-10-01 \AddToHook{#1}{#2}% \else\ifcsname @#1hook\endcsname % LaTeX 2020-02-02 diff --git a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty index 564a1b6c159..bad7e6c7bcd 100644 --- a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty +++ b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty @@ -3,7 +3,7 @@ % \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{lltjfont}[2020-09-30 Patch to NFSS2 for LuaTeX-ja] +\ProvidesPackage{lltjfont}[2020-10-05 Patch to NFSS2 for LuaTeX-ja] %% patching \DeclareTextComposite \def\ltj@chardef@text@cmd#1{% @@ -639,7 +639,7 @@ \ifx\@forced@seriestrue\@undefined % 2020-02-02 pl0--2 \@latex@error {Please update LaTeX2e!^^J\space\space - At least LaTeX2e 2020-02-02 patch level 3 is required} + At least LaTeX2e 2020-02-02 patch level 3 is required}% {LaTeX2e 2020-02-02 patch level 2 (and 4) has a bug.} \else \ltj@@latex@plv=300 @@ -834,29 +834,29 @@ \patchcmd\update@series@target@value@kanji{\f@series}{\k@series}{}{} \def\@meta@family@list@kanji{\@elt{mc}\@elt{gt}\@elt{jtt}} -\def\@ltj@hook@series@default#1#2#3{ +\def\@ltj@hook@series@default#1#2#3{% \ifltj@ltfilehook@avail % 2020-10-01 \AddToHook{#1/defaults}{#2}% \else\ifcsname @set#1defaultshook\endcsname %after 2020-04-07 \expandafter\g@addto@macro\csname @set#1defaultshook\endcsname{#2}% \else % 2020-02-02 - \expandafter\patchcmd\csname #1 \endcsname{#3}{#3#2}{}{} + \expandafter\patchcmd\csname #1 \endcsname{#3}{#3#2}{}{}% \fi\fi } -\@ltj@hook@series@default{bfseries}{ +\@ltj@hook@series@default{bfseries}{% \let\bfseries@mc\bfdef@ult \let\bfseries@gt\bfdef@ult \let\bfseries@jtt\bfdef@ult -}{ +}{% \let\bfseries@rm\bfdef@ult \let\bfseries@sf\bfdef@ult \let\bfseries@tt\bfdef@ult } -\@ltj@hook@series@default{mdseries}{ +\@ltj@hook@series@default{mdseries}{% \let\mdseries@mc\mddef@ult \let\mdseries@gt\mddef@ult \let\mdseries@jtt\mddef@ult -}{ +}{% \let\mdseries@rm\mddef@ult \let\mdseries@sf\mddef@ult \let\mdseries@tt\mddef@ult @@ -890,11 +890,11 @@ \fi\fi\fi }{}{} -\def\@ltj@hook@series#1#2{ +\def\@ltj@hook@series#1#2{% \ifltj@ltfilehook@avail % 2020-10-01 \AddToHook{#1}{#2}% \else % 2020-02-02 - \expandafter\patchcmd\csname #1 \endcsname{\selectfont}{#2\selectfont}{}{} + \expandafter\patchcmd\csname #1 \endcsname{\selectfont}{#2\selectfont}{}{}% \fi } \@ltj@hook@series{bfseries}{% @@ -913,7 +913,7 @@ } \let\@ltj@hook@series\@undefined -\def\@ltj@hook@efd#1#2{ +\def\@ltj@hook@efd#1#2{% \ifltj@ltfilehook@avail % 2020-10-01 \AddToHook{expand@font@defaults}{#1}% \else\ifdefined\@expandfontdefaultshook %after 2020-04-07 @@ -930,7 +930,7 @@ \let\@ltj@hook@efd\@undefined \ifltj@ltfilehook@avail % 2020-10-01 - \appto\init@series@setup{ + \appto\init@series@setup{% \ifx\kanjiseriesdefault\kanjiseriesdefault@kernel \mdseries \let\kanjiseriesdefault\k@series @@ -945,13 +945,13 @@ } \fi -\def\@ltj@hook@dfh#1{ +\def\@ltj@hook@dfh#1{% \ifltj@ltfilehook@avail % 2020-10-01 \AddToHook{normalfont}{#1}% \else\ifdefined\@defaultfamilyhook \g@addto@macro\@defaultfamilyhook{#1}% \else % 2020-02-02 - \expandafter\patchcmd\csname normalfont \endcsname{\selectfont}{#1\selectfont}{}{} + \expandafter\patchcmd\csname normalfont \endcsname{\selectfont}{#1\selectfont}{}{}% \let\reset@font\normalfont \fi\fi } -- cgit v1.2.3