-------------------- hlist 内の文字の検索
local first_char, last_char, find_first_char
-------------------- hlist 内の文字の検索
local first_char, last_char, find_first_char
local function check_box(box_ptr, box_end)
local p = box_ptr; local found_visible_node = false
local function check_box(box_ptr, box_end)
local p = box_ptr; local found_visible_node = false
else
if getfield(p, 'shift')==0 then
if check_box(getlist(p), nil) then found_visible_node = true end
else
if getfield(p, 'shift')==0 then
if check_box(getlist(p), nil) then found_visible_node = true end
function check_box_high(Nx, box_ptr, box_end)
first_char = nil; last_char = nil; find_first_char = true
function check_box_high(Nx, box_ptr, box_end)
first_char = nil; last_char = nil; find_first_char = true
set_np_xspc_jachar(Nx, first_char)
else
set_np_xspc_alchar(Nx, getchar(first_char),first_char, 1)
set_np_xspc_jachar(Nx, first_char)
else
set_np_xspc_alchar(Nx, getchar(first_char),first_char, 1)
-luatexbase.create_callback("luatexja.jfmglue.whatsit_getinfo", "data",
- function (Np, lp, Nq)
- if Np.nuc then return Np
- else
+luatexbase.create_callback("luatexja.jfmglue.whatsit_getinfo", "data",
+ function (Np, lp, Nq)
+ if Np.nuc then return Np
+ else
function (stat, Nq, Np) return false end)
-- calc next Np
do
local function set_attr_icflag_processed(p)
function (stat, Nq, Np) return false end)
-- calc next Np
do
local function set_attr_icflag_processed(p)
- if get_attr_icflag(p)<= ITALIC then
- set_attr(p, attr_icflag, PROCESSED)
+ if get_attr_icflag(p)<= ITALIC then
+ set_attr(p, attr_icflag, PROCESSED)
if lp and getid(lp) == id_kern and ITALIC == get_attr_icflag(lp) then
set_attr(lp, attr_icflag, IC_PROCESSED)
Np.last = lp; return node_next(lp)
if lp and getid(lp) == id_kern and ITALIC == get_attr_icflag(lp) then
set_attr(lp, attr_icflag, IC_PROCESSED)
Np.last = lp; return node_next(lp)
local calc_np_auxtable = {
[id_glyph] = function (lp)
Np.first, Np.nuc = (Np.first or lp), lp;
local calc_np_auxtable = {
[id_glyph] = function (lp)
Np.first, Np.nuc = (Np.first or lp), lp;
local op, flag
head, lp, op, flag = ltjd_make_dir_node(head, lp, list_dir, 'jfm hlist')
local op, flag
head, lp, op, flag = ltjd_make_dir_node(head, lp, list_dir, 'jfm hlist')
Np.id = (flag or getfield(op, 'shift')~=0) and id_box_like or id_hlist
return true, lp
end,
[id_vlist] = function(lp)
local op
head, lp, op = ltjd_make_dir_node(head, lp, list_dir, 'jfm:' .. getid(lp))
Np.id = (flag or getfield(op, 'shift')~=0) and id_box_like or id_hlist
return true, lp
end,
[id_vlist] = function(lp)
local op
head, lp, op = ltjd_make_dir_node(head, lp, list_dir, 'jfm:' .. getid(lp))
set_attr(lp, attr_icflag, PROCESSED)
return false, node_next(lp)
end,
set_attr(lp, attr_icflag, PROCESSED)
return false, node_next(lp)
end,
local lps = getsubtype(lp)
if lps==sid_user then
if getfield(lp, 'user_id')==luatexja.userid_table.IHB then
local lps = getsubtype(lp)
if lps==sid_user then
if getfield(lp, 'user_id')==luatexja.userid_table.IHB then
head = node_remove(head, lp); node_free(lp); ihb_flag = true
return false, lq;
else
set_attr(lp, attr_icflag, PROCESSED)
luatexbase.call_callback("luatexja.jfmglue.whatsit_getinfo",
Np, lp, Nq)
head = node_remove(head, lp); node_free(lp); ihb_flag = true
return false, lq;
else
set_attr(lp, attr_icflag, PROCESSED)
luatexbase.call_callback("luatexja.jfmglue.whatsit_getinfo",
Np, lp, Nq)
return true, node_next(lp)
else
return false, node_next(lp)
return true, node_next(lp)
else
return false, node_next(lp)
else
-- we do special treatment for these whatsit nodes.
if lps == sid_start_link or lps == sid_start_thread then
else
-- we do special treatment for these whatsit nodes.
if lps == sid_start_link or lps == sid_start_thread then
elseif lps == sid_end_link or lps == sid_end_thread then
Np.first, Nq.last = nil, lp;
end
elseif lps == sid_end_link or lps == sid_end_thread then
Np.first, Nq.last = nil, lp;
end
set_attr(lp, attr_icflag, PROCESSED)
Np.last, Np.id = lp, id_math;
set_attr(lp, attr_icflag, PROCESSED)
Np.last, Np.id = lp, id_math;
- Np.first, Np.nuc, Np.last = (Np.first or lp), lp, lp;
+ Np.first, Np.nuc, Np.last = (Np.first or lp), lp, lp;
Np.id = getid(lp); set_attr(lp, attr_icflag, PROCESSED)
return true, node_next(lp)
end,
Np.id = getid(lp); set_attr(lp, attr_icflag, PROCESSED)
return true, node_next(lp)
end,
Np.first = Np.first or lp
if getsubtype(lp)==2 then
set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
Np.first = Np.first or lp
if getsubtype(lp)==2 then
set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
set_attr(lp, attr_icflag, PROCESSED); Np.nuc = lp
Np.id = (getfont(lp) == (has_attr(lp, attr_curjfnt) or -1)) and id_jglyph or id_glyph
set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
set_attr(lp, attr_icflag, PROCESSED); Np.nuc = lp
Np.id = (getfont(lp) == (has_attr(lp, attr_curjfnt) or -1)) and id_jglyph or id_glyph
else
Np.id = id_kern; set_attr(lp, attr_icflag, PROCESSED)
Np.last = lp; return true, node_next(lp)
else
Np.id = id_kern; set_attr(lp, attr_icflag, PROCESSED)
Np.last = lp; return true, node_next(lp)
head = node_remove(head, lp); node_free(lp); lp = lq
else return calc_np_pbox(lp, last)
end -- id_pbox
head = node_remove(head, lp); node_free(lp); lp = lq
else return calc_np_pbox(lp, last)
end -- id_pbox
else
cls, c = slow_find_char_class(has_attr(x, attr_orig_char), m, getchar(x))
end
else
cls, c = slow_find_char_class(has_attr(x, attr_orig_char), m, getchar(x))
end
if cls~=0 then set_attr(x, attr_jchar_class, cls) end
Nx.pre = table_current_stack[PRE + c] or 0
Nx.post = table_current_stack[POST + c] or 0
Nx.xspc = table_current_stack[XSP + c] or 3
Nx.kcat = table_current_stack[KCAT + c] or 0
Nx.auto_kspc, Nx.auto_xspc = (has_attr(x, attr_autospc)==1), (has_attr(x, attr_autoxspc)==1)
if cls~=0 then set_attr(x, attr_jchar_class, cls) end
Nx.pre = table_current_stack[PRE + c] or 0
Nx.post = table_current_stack[POST + c] or 0
Nx.xspc = table_current_stack[XSP + c] or 3
Nx.kcat = table_current_stack[KCAT + c] or 0
Nx.auto_kspc, Nx.auto_xspc = (has_attr(x, attr_autospc)==1), (has_attr(x, attr_autoxspc)==1)
-- change the information for the next loop
-- (will be done if Nx is an alphabetic character or a hlist)
after_hlist = function (Nx)
local s = Nx.last_char
if s then
if getid(s)==id_glyph then
-- change the information for the next loop
-- (will be done if Nx is an alphabetic character or a hlist)
after_hlist = function (Nx)
local s = Nx.last_char
if s then
if getid(s)==id_glyph then
set_np_xspc_jachar(Nx, s)
else
set_np_xspc_alchar(Nx, getchar(s), s, 2)
set_np_xspc_jachar(Nx, s)
else
set_np_xspc_alchar(Nx, getchar(s), s, 2)
after_alchar = function (Nx)
local x = Nx.nuc
return set_np_xspc_alchar(Nx, getchar(x), x, 2)
after_alchar = function (Nx)
local x = Nx.nuc
return set_np_xspc_alchar(Nx, getchar(x), x, 2)
if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
setfield(p, 'penalty', a)
head = insert_before(head, Np.first, p)
if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
setfield(p, 'penalty', a)
head = insert_before(head, Np.first, p)
set_attr(p, attr_icflag, KINSOKU)
end
else for _, v in pairs(Bp) do add_penalty(v,a) end
set_attr(p, attr_icflag, KINSOKU)
end
else for _, v in pairs(Bp) do add_penalty(v,a) end
local f = node_new(id_glue)
set_attr(f, attr_icflag, g[4])
setfield(f, 'spec', n)
local f = node_new(id_glue)
set_attr(f, attr_icflag, g[4])
setfield(f, 'spec', n)
calc_ja_ja_aux = function (gb,ga, db, da)
local rbb, rab = (1-db)/2, (1-da)/2 -- 「前の文字」由来のグルーの割合
local rba, raa = (1+db)/2, (1+da)/2 -- 「前の文字」由来のグルーの割合
calc_ja_ja_aux = function (gb,ga, db, da)
local rbb, rab = (1-db)/2, (1-da)/2 -- 「前の文字」由来のグルーの割合
local rba, raa = (1+db)/2, (1+da)/2 -- 「前の文字」由来のグルーの割合
and diffmet_rule ~= math.two_paverage then
rbb, rab, rba, raa = 1,0,0,1
end
and diffmet_rule ~= math.two_paverage then
rbb, rab, rba, raa = 1,0,0,1
end
local k = 2*getid(gb) - getid(ga)
if k == bg_ag then
local bs, as = getfield(gb, 'spec'), getfield(ga, 'spec')
local k = 2*getid(gb) - getid(ga)
if k == bg_ag then
local bs, as = getfield(gb, 'spec'), getfield(ga, 'spec')
setfield(gb, 'kern', round(diffmet_rule(rbb*bd + rba*ad, rab*bd + raa*ad)))
node_free(ga)
return gb
setfield(gb, 'kern', round(diffmet_rule(rbb*bd + rba*ad, rab*bd + raa*ad)))
node_free(ga)
return gb
local as = getfield(ga, 'spec')
-- gb: kern, ga: glue
local bd, ad = getfield(gb, 'kern'), getfield(as, 'width')
local as = getfield(ga, 'spec')
-- gb: kern, ga: glue
local bd, ad = getfield(gb, 'kern'), getfield(as, 'width')
local gb, db = new_jfm_glue(qm, Nq.class,
slow_find_char_class(has_attr(npn, attr_orig_char),
qm, getchar(npn)))
local gb, db = new_jfm_glue(qm, Nq.class,
slow_find_char_class(has_attr(npn, attr_orig_char),
qm, getchar(npn)))
- return calc_ja_ja_aux(gb, ga, db, da);
+ return calc_ja_ja_aux(gb, ga, db, da);
fast_find_char_class(((Nq.id == id_math and -1) or (type(Nq.char)=='string' and Nq.char or 'jcharbdd')), pm), Np.class)
else return nil
end
fast_find_char_class(((Nq.id == id_math and -1) or (type(Nq.char)=='string' and Nq.char or 'jcharbdd')), pm), Np.class)
else return nil
end
local g = calc_ja_ja_glue() or get_kanjiskip() -- M->K
handle_penalty_normal(Nq.post, Np.pre, g); real_insert(g)
elseif Nq.met then -- qid==id_hlist
local g = get_OA_skip() or get_kanjiskip() -- O_A->K
handle_penalty_normal(0, Np.pre, g); real_insert(g)
local g = calc_ja_ja_glue() or get_kanjiskip() -- M->K
handle_penalty_normal(Nq.post, Np.pre, g); real_insert(g)
elseif Nq.met then -- qid==id_hlist
local g = get_OA_skip() or get_kanjiskip() -- O_A->K
handle_penalty_normal(0, Np.pre, g); real_insert(g)
local g = get_OA_skip() or get_xkanjiskip(Np) -- O_A->X
handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g); real_insert(g)
else
local g = get_OA_skip() or get_xkanjiskip(Np) -- O_A->X
handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g); real_insert(g)
else
local g = get_OB_skip() or get_xkanjiskip(Nq) -- O_B->X
handle_penalty_normal(Nq.post, (Np.id==id_hlist and 0 or Np.pre), g); real_insert(g)
else
local g = get_OB_skip() or get_xkanjiskip(Nq) -- O_B->X
handle_penalty_normal(Nq.post, (Np.id==id_hlist and 0 or Np.pre), g); real_insert(g)
else
local g = get_OB_skip() or get_kanjiskip() -- O_B->K
handle_penalty_normal(Nq.post, 0, g); real_insert(g)
elseif Nq.met then -- Nq.id==id_hlist
local g = get_kanjiskip() -- K
handle_penalty_suppress(0, 0, g); real_insert(g)
local g = get_OB_skip() or get_kanjiskip() -- O_B->K
handle_penalty_normal(Nq.post, 0, g); real_insert(g)
elseif Nq.met then -- Nq.id==id_hlist
local g = get_kanjiskip() -- K
handle_penalty_suppress(0, 0, g); real_insert(g)
local g = get_xkanjiskip(Np) -- X
handle_penalty_suppress(0, 0, g); real_insert(g)
end
local g = get_xkanjiskip(Np) -- X
handle_penalty_suppress(0, 0, g); real_insert(g)
end
local g = get_xkanjiskip(Nq) -- X
handle_penalty_suppress(0, 0, g); real_insert(g)
end
local g = get_xkanjiskip(Nq) -- X
handle_penalty_suppress(0, 0, g); real_insert(g)
end
local x = Nq.nuc
return set_np_xspc_alchar(Nq, getchar(x),x, 2)
end, -- after_alchar(Nq)
[id_hlist] = function() after_hlist(Nq) end,
[id_pbox] = function() after_hlist(Nq) end,
[id_disc] = function() after_hlist(Nq) end,
local x = Nq.nuc
return set_np_xspc_alchar(Nq, getchar(x),x, 2)
end, -- after_alchar(Nq)
[id_hlist] = function() after_hlist(Nq) end,
[id_pbox] = function() after_hlist(Nq) end,
[id_disc] = function() after_hlist(Nq) end,
else
-- the current list is the contents of a hbox
local npi, pm = Np.id, Np.met
else
-- the current list is the contents of a hbox
local npi, pm = Np.id, Np.met
local g = new_jfm_glue(pm, Np.class, fast_find_char_class('boxbdd', pm))
if g then
set_attr(g, attr_icflag, BOXBDD)
local g = new_jfm_glue(pm, Np.class, fast_find_char_class('boxbdd', pm))
if g then
set_attr(g, attr_icflag, BOXBDD)
-- リスト先頭の処理
local function handle_list_head(par_indented)
local npi, pm = Np.id, Np.met
-- リスト先頭の処理
local function handle_list_head(par_indented)
local npi, pm = Np.id, Np.met
if not ihb_flag then
local g = new_jfm_glue(pm, fast_find_char_class(par_indented, pm), Np.class)
if g then
if not ihb_flag then
local g = new_jfm_glue(pm, fast_find_char_class(par_indented, pm), Np.class)
if g then
set_attr(kanji_skip, attr_icflag, KANJI_SKIP)
get_kanjiskip = (getfield(getfield(kanji_skip, 'spec'), 'width') == 1073741823)
and get_kanjiskip_jfm or get_kanjiskip_normal
set_attr(kanji_skip, attr_icflag, KANJI_SKIP)
get_kanjiskip = (getfield(getfield(kanji_skip, 'spec'), 'width') == 1073741823)
and get_kanjiskip_jfm or get_kanjiskip_normal
xkanji_skip = node_new(id_glue)
setfield(xkanji_skip, 'spec', skip_table_to_spec(XSK))
set_attr(xkanji_skip, attr_icflag, XKANJI_SKIP)
get_xkanjiskip = (getfield(getfield(xkanji_skip, 'spec'), 'width') == 1073741823)
and get_xkanjiskip_jfm or get_xkanjiskip_normal
xkanji_skip = node_new(id_glue)
setfield(xkanji_skip, 'spec', skip_table_to_spec(XSK))
set_attr(xkanji_skip, attr_icflag, XKANJI_SKIP)
get_xkanjiskip = (getfield(getfield(xkanji_skip, 'spec'), 'width') == 1073741823)
and get_xkanjiskip_jfm or get_xkanjiskip_normal
- 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,
+ 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,
- 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,
+ 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,
-- the current list is to be line-breaked:
-- hbox from \parindent is skipped.
local lp, par_indented, lpi, lps = head, 'boxbdd', getid(head), getsubtype(head)
-- the current list is to be line-breaked:
-- hbox from \parindent is skipped.
local lp, par_indented, lpi, lps = head, 'boxbdd', getid(head), getsubtype(head)
Np.char, par_indented = 'parbdd', 'parbdd'
Np.width = getfield(lp, 'width')
end
Np.char, par_indented = 'parbdd', 'parbdd'
Np.width = getfield(lp, 'width')
end
elseif Np and getfield(lp, 'user_id') == BPAR then
Np.first = lp; Np.nuc = lp; Np.last = lp
Np.char = 'parbdd'
elseif Np and getfield(lp, 'user_id') == BPAR then
Np.first = lp; Np.nuc = lp; Np.last = lp
Np.char = 'parbdd'