[1] = { -- fw. opening punctuations
chars = {
- 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
+ 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
0x3018, 0x301D, 0xFF08, 0xFF3B, 0xFF5B, 0xFF5F
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- fw. closing/colon punctuations
chars = {
- 0x2019, 0x201D, 0x3001, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
+ 0x2019, 0x201D, 0x3001, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
0x3017, 0x3019, 0x301F, 0xFF09, 0xFF0C, 0xFF3D, 0xFF5D, 0xFF60,
- 0xFF1A, 0xFF1B
+ 0xFF1A, 0xFF1B
},
align = 'left', left = 0.0, down = 0.0,
width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
[1] = { -- fw. opening punctuations
chars = {
- 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
+ 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
0x3018, 0x301D, 0xFF08, 0xFF3B, 0xFF5B, 0xFF5F
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- fw. closing/colon/dot punctuations, except 4 & 7
chars = {
- 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
+ 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
0x3017, 0x3019, 0x301F, 0xFF09, 0xFF0C, 0xFF3D, 0xFF5D, 0xFF60,
0xFF0E, 0xFF1A, 0xFF1B, 0xFF01, 0xFF1F
},
[1] = { -- 開き括弧類
chars = {
- '‘', '“', '〈', '《', '「', '『', '【', '〔', '〖',
+ '‘', '“', '〈', '《', '「', '『', '【', '〔', '〖',
'〘', '〝', '(', '[', '{', '⦅'
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- 閉じ括弧類
chars = {
- '’', '”', '、', '〉', '》', '」', '』', '】', '〕',
+ '’', '”', '、', '〉', '》', '」', '』', '】', '〕',
'〗', '〙', '〟', ')', ',', ']', '}', '⦆'
},
align = 'left', left = 0.0, down = 0.0,
[1] = { -- fw. opening punctuations
chars = {
- 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
+ 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
0x3018, 0x301D, 0xFF08, 0xFF3B, 0xFF5B, 0xFF5F
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- fw. closing/colon/dot punctuations, except 4 & 7
chars = {
- 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
+ 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
0x3017, 0x3019, 0x301F, 0xFF09, 0xFF0C, 0xFF3D, 0xFF5D, 0xFF60,
- 0xFF0E, 0xFF1A, 0xFF1B
+ 0xFF0E, 0xFF1A, 0xFF1B
},
align = 'left', left = 0.0, down = 0.0,
width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
[3] = {
chars = {
'∴', '♀', '♂', '〃', '々', 'ぁ', 'ぃ', 'ぅ', 'ぇ', 'ぉ', 'っ', 'ゃ', 'ゅ ',
- 'ょ', 'ゎ', 'ゕ', 'ゖ', 'ゞ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ッ', 'ャ', 'ュ', 'ョ',
- 'ヮ', 'ヵ', 'ヶ', 'ㇰ', 'ㇱ', 'ㇲ', 'ㇳ', 'ㇴ', 'ㇵ', 'ㇶ', 'ㇷ', 'ㇸ', 'ㇹ', 'ㇺ',
+ 'ょ', 'ゎ', 'ゕ', 'ゖ', 'ゞ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ッ', 'ャ', 'ュ', 'ョ',
+ 'ヮ', 'ヵ', 'ヶ', 'ㇰ', 'ㇱ', 'ㇲ', 'ㇳ', 'ㇴ', 'ㇵ', 'ㇶ', 'ㇷ', 'ㇸ', 'ㇹ', 'ㇺ',
'ㇻ', 'ㇼ', 'ㇽ', 'ㇾ', 'ㇿ', '$', '¢', '£'
},
align = 'middle', left = 0.0, down = 0.0,
},
[12] = {
chars = {
- 'ア', 'イ', 'ウ', 'オ', 'ケ', 'ゲ', 'サ', 'ザ', 'ソ', 'ゾ', 'チ', 'ヂ', 'ツ',
+ 'ア', 'イ', 'ウ', 'オ', 'ケ', 'ゲ', 'サ', 'ザ', 'ソ', 'ゾ', 'チ', 'ヂ', 'ツ',
'ヅ', 'ト', 'ド', 'ナ', 'フ', 'ブ', 'プ', 'ミ', 'メ', 'ラ', 'リ', 'ワ', 'ヲ'
},
align = 'left', left = 0.0, down = 0.0,
[1] = { -- fw. opening punctuations
chars = {
- 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
+ 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
0x3018, 0x301D, 0xFF08, 0xFF3B, 0xFF5B, 0xFF5F
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- fw. closing/colon/dot punctuations, except 4 & 7
chars = {
- 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
+ 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
0x3017, 0x3019, 0x301F, 0xFF09, 0xFF0C, 0xFF3D, 0xFF5D, 0xFF60,
0xFF0E, 0xFF1A, 0xFF1B, 0xFF01, 0xFF1F
},
[207] = { 0, 0, 0, kanjiskip_shrink=1 },
[8] = { 0, 0, 0, kanjiskip_shrink=1 },
},
- kern = { [307] = 0 },
+ kern = { [307] = 0 },
round_threshold = 0.01,
},
[6] = { 0, 0, 0, kanjiskip_shrink=1 },
[8] = { 0, 0, 0, kanjiskip_shrink=1 },
},
- kern = { [307] = 0 },
+ kern = { [307] = 0 },
},
[107] = { -- 1/3 角
[207] = { 0, 0, 0, kanjiskip_shrink=1 },
[8] = { 0, 0, 0, kanjiskip_shrink=1 },
},
- kern = { [307] = 0 },
+ kern = { [307] = 0 },
round_threshold = 0.01,
},
local getlang = node.direct.getlang
local getkern = node.direct.getkern
local getshift = node.direct.getshift
-local getwidth = node.direct.getwidth
+local getwidth = node.direct.getwidth
local getdepth = node.direct.getdepth
local setfield = node.direct.setfield
local setpenalty = node.direct.setpenalty
for i=0,63 do tmp[#tmp+1] = { (i%8)-4, FROM_JFM+i } end
else -- stretch
for i=0,63 do tmp[#tmp+1] = { math.floor(i/8)-4, FROM_JFM+i } end
- end
+ end
local pt = priority_table[glue_sign]
tmp[#tmp+1] = { pt[2]/10, XKANJI_SKIP }
tmp[#tmp+1] = { pt[2]/10, XKANJI_SKIP_JFM }
for q in node_traverse_id(id_glue, ph) do
local a = getfield(q, 'stretch_order')
if a==0 then
- local b = at2pr_st[get_attr_icflag(q)];
+ local b = at2pr_st[get_attr_icflag(q)];
total_st[b] = total_st[b]+getfield(q, 'stretch')
end
total_st[a*65536] = total_st[a]+getfield(q, 'stretch')
local a = getfield(q, 'shrink_order')
if a==0 then
- local b = at2pr_sh[get_attr_icflag(q)];
+ local b = at2pr_sh[get_attr_icflag(q)];
total_sh[b] = total_sh[b]+getfield(q, 'shrink')
end
total_sh[a*65536] = total_sh[a]+getfield(q, 'shrink')
end
local eadt = ltjf_font_metric_table[getfont(xc)]
.char_type[get_attr(xc, attr_jchar_class) or 0].end_adjust
- if not eadt then
+ if not eadt then
return total, false
end
local eadt_ratio = {}
eadt_ratio[i] = {i, t/total_sh[65536*total_sh.order], t, v}
end
end
- table.sort(eadt_ratio,
- function (a,b)
+ table.sort(eadt_ratio,
+ function (a,b)
for i=2,4 do
local at, bt = abs(a[i]), abs(b[i])
if at~=bt then return at<bt end
end
local eadt = ltjf_font_metric_table[getfont(xc)]
.char_type[get_attr(xc, attr_jchar_class) or 0].end_adjust
- if not eadt then
+ if not eadt then
return total, false
end
-- 続行条件2: min(eadt[1], 0)<= \parfillskip <= max(eadt[#eadt], 0)
local pfw = getwidth(pf)
- + (total>0 and getfield(pf, 'stretch') or -getfield(pf, 'shrink')) *getfield(p, 'glue_set')
+ + (total>0 and getfield(pf, 'stretch') or -getfield(pf, 'shrink')) *getfield(p, 'glue_set')
if pfw<min(0,eadt[1]) or max(0,eadt[#eadt])<pfw then return total, false end
-- \parfillskip を 0 にする
total = total + getwidth(pf)
total_st.order, total_sh.order = 0, 0
- if getfield(pf, 'stretch_order')==0 then
- local i = at2pr_st[-1]
- total_st[0] = total_st[0] - getfield(pf, 'stretch')
- total_st[i] = total_st[i] - getfield(pf, 'stretch')
+ if getfield(pf, 'stretch_order')==0 then
+ local i = at2pr_st[-1]
+ total_st[0] = total_st[0] - getfield(pf, 'stretch')
+ total_st[i] = total_st[i] - getfield(pf, 'stretch')
total_st.order = (total_st[0]==0) and -1 or 0
end
- if getfield(pf, 'shrink_order')==0 then
- local i = at2pr_sh[-1]
- total_sh[0] = total_sh[0] - getfield(pf, 'shrink')
- total_sh[i] = total_sh[i] - getfield(pf, 'shrink')
+ if getfield(pf, 'shrink_order')==0 then
+ local i = at2pr_sh[-1]
+ total_sh[0] = total_sh[0] - getfield(pf, 'shrink')
+ total_sh[i] = total_sh[i] - getfield(pf, 'shrink')
total_sh.order = (total_sh[0]==0) and -1 or 0
end
setsubtype(pf, 1); setglue(pf)
eadt_ratio[i] = {i, t/total_sh[65536*total_sh.order], t, v}
end
end
- table.sort(eadt_ratio,
- function (a,b)
+ table.sort(eadt_ratio,
+ function (a,b)
for i=2,4 do
local at, bt = abs(a[i]), abs(b[i])
if at~=bt then return at<bt end
local id = (total>0) and 1 or 2
local res = total_stsh[id]
local pnum = priority_num[id]
- if total==0 or res.order > 0 then
+ if total==0 or res.order > 0 then
-- もともと伸縮の必要なしか,残りの伸縮量は無限大
if added_flag then return repack(p) end
end
total = abs(total)
for i = 1, pnum do
if total <= res[i] then
- local a = at2pr[id]
+ local a = at2pr[id]
for j = i+1,pnum do
clear_stretch(p, j, a, name)
end
local insert_before = node.direct.insert_before
local KINSOKU = luatexja.icflag_table.KINSOKU
insert_lineend_kern = function (head, nq, np, Bp)
- if nq.met then
+ if nq.met then
local eadt = nq.met.char_type[nq.class].end_adjust
if not eadt then return end
if eadt[1]~=0 then
local function enable_cb(status_le, status_pr, status_lp, status_ls)
if (status_le>0 or status_pr>0) and (not is_reg) then
ltjb.add_to_callback('post_linebreak_filter',
- adjust_width, 'Adjust width',
+ adjust_width, 'Adjust width',
luatexbase.priority_in_callback('post_linebreak_filter', 'ltj.lineskip')-1)
is_reg = true
elseif is_reg and (status_le==0 and status_pr==0) then
end
w_acc = w_new; x = xn; if x then xn = node_next(x) end
end
- end
+ end
function ltjl.p_profile(before, after, mirrored, bw)
- local range, tls
+ local range, tls
= init_range(), luatexja.adjust.profile_hgap_factor*tex.get('lineskip', false)
profile_inner(before, range, 3, true, tls)
profile_inner(after, range, 4, mirrored, tls)
if bw-h-d<lmin then lmin=bw-h-d end
end
if lmin==1/0 then lmin = bw end
- return lmin,
+ return lmin,
bw - lmin - getdepth(before)
- getfield(after, mirrored and 'depth' or 'height')
end
local cat_lp = luatexbase.catcodetables['latex-package']
---------------------
+--------------------
local ltjb = {}
luatexja.base = ltjb
_error_set_message = function (msgcont, main, help)
err_main = message_cont(main, msgcont):gsub(BEL, LF)
err_help = (help and help~="") and into_lines(help)
- or {"Sorry, I don't know how to help in this situation.",
+ or {"Sorry, I don't know how to help in this situation.",
"Maybe you should try asking a human?" }
end
--- Extension to tex.print(). Each argument string may contain
-- newline characters, in which case the string is output (to
-- TeX input stream) as multiple lines.
--- @param ... (string) string to output
+-- @param ... (string) string to output
local function mprint(...)
local arg = {...}
local lines = {}
local function in_unicode(c, admit_math)
local low = admit_math and -1 or 0
if type(c)~='number' or c<low or c>0x10FFFF then
- local s = 'A character number must be between ' .. tostring(low)
+ local s = 'A character number must be between ' .. tostring(low)
.. ' and 0x10ffff.\n'
.. (admit_math and "(-1 is used for denoting `math boundary')\n" or '')
.. 'So I changed this one to zero.'
-- * return value: non-nil iff the cache is up-to-date
-- save_cache (filename, t): no return value
-- save_cache_luc (filename, t): no return value
--- save_cache always calls save_cache_luc.
+-- save_cache always calls save_cache_luc.
-- But sometimes we want to create only the precompiled cache,
-- when its 'text' version is already present in LuaTeX-ja distribution.
if s then
local sa = load(s)
local f = io.open(fullpath, 'wb')
- if f and sa then
- f:write(dump(sa, true))
+ if f and sa then
+ f:write(dump(sa, true))
texio.write('log', '(save cache: ' .. fullpath .. ')')
f:close()
end
break
end
end
- if (not result) or outdate(result) then
- return nil
- else
- return result
+ if (not result) or outdate(result) then
+ return nil
+ else
+ return result
end
end
-
+
local function load_cache(filename, outdate)
remove_file_if_exist(savepath .. '/' .. filename .. '.lua')
local r = load_cache_a(filename .. luc_suffix, outdate, false)
- if r then
+ if r then
return r
else
local r = load_cache_a(filename .. '.lua.gz', outdate, true)
for i = 0, 30 do
local pw = 2^i; kcat_attr_table[i], pow_table[i] = ka, pw
fn_table[i] = function(p) return get_attr(p, ka)&pw==0 end
- nfn_table[i] = function(p) return get_attr_node(p, ka)&pw==0 end
+ nfn_table[i] = function(p) return get_attr_node(p, ka)&pw==0 end
end
end
for i = 31, 31*ATTR_RANGE-1 do
local ka, pw = luatexbase.attributes['ltj@kcat'..floor(i/31)], 2^(i%31)
kcat_attr_table[i], pow_table[i] = ka, pw
fn_table[i] = function(p) return (get_attr(p, ka) or 0)&pw==0 end
- nfn_table[i] = function(p) return (get_attr_node(p, ka) or 0)&pw==0 end
+ nfn_table[i] = function(p) return (get_attr_node(p, ka) or 0)&pw==0 end
end
fn_table[-1] = function() return false end -- for char --U+007F
nfn_table[-1] = function() return false end -- for char --U+007F
if type(i)~='number' then error_invalid_charcode(i); i=0 end
if (i%256==0)or(i%256>94) then
tex.write '0'
- else
+ else
tex.write(tostring(jisx0208.table_jisx0208_uptex[math.floor(i/256)*94+(i%256)-94] or 0))
end
end
-- \euc: EUC-JP による符号位置 => Unicode 符号位置
local function from_euc(i)
- if type(i)~='number' then
+ if type(i)~='number' then
error_invalid_charcode(i); i=0
elseif i>=0x10000 or i<0xa0a0 then
i=0
local function pformat(fmt, ...)
if type(fmt) == "string" then
return do_pformat(fmt, ...)
- else
+ else
return tosource(fmt)
end
end
luatexja.base.start_time_measure = start_time_measure
luatexja.base.stop_time_measure = stop_time_measure
luatexbase.add_to_callback('stop_run', print_measure, 'luatexja.time_measure', 1)
- luatexbase.add_to_callback('pre_linebreak_filter',
- function(p)
- start_time_measure('tex_linebreak'); return p
- end,
+ luatexbase.add_to_callback('pre_linebreak_filter',
+ function(p)
+ start_time_measure('tex_linebreak'); return p
+ end,
'measure_tex_linebreak', 20000)
end
end
dir_pool = {}
for _,i in pairs({dir_tate, dir_yoko, dir_dtou, dir_utod}) do
local w = node_new(id_whatsit, sid_user)
- dnode.setattributelist(w, nil)
+ dnode.setattributelist(w, nil)
set_attr(w, attr_dir, i); set_attr(w, attr_icflag, 0)
setfield(w, 'user_id', DIR)
setfield(w, 'type', 110); setnext(w, nil)
-- adjust
do
local id_adjust = node.id 'adjust'
- local last_node = dnode.last_node
+ local last_node = dnode.last_node
local scan_keyword = token.scan_keyword
function luatexja.direction.adjust_begin()
if scan_keyword 'pre' then tex.sprint(cat_lp, '\\ltj@@vadjust@pre')
if split_dir_whatsit then split_dir_watsit = nil end
if p then
local bh = getlist(p)
- if getid(bh)==id_whatsit and getsubtype(bh)==sid_user and getfield(bh, 'user_id')==DIR
+ if getid(bh)==id_whatsit and getsubtype(bh)==sid_user and getfield(bh, 'user_id')==DIR
and node_next(bh) then
ltjs.list_dir = get_attr(bh, attr_dir)
setlist(p, (node_remove(bh,bh)))
end
end
sprint(cat_lp, '\\ltj@@orig@vsplit' .. tostring(n))
- end
+ end
local function dir_adjust_vpack(h, gc)
start_time_measure 'direction_vpack'
local hd = to_direct(h)
local function dir_adjust_pre_output(h, gc)
return to_node(create_dir_whatsit_vbox(to_direct(h), gc))
end
- ltjb.add_to_callback('pre_output_filter', dir_adjust_pre_output,
+ ltjb.add_to_callback('pre_output_filter', dir_adjust_pre_output,
'ltj.direction', 10000)
end
tex.setattribute(attr_dir, dir_yoko)
local shipout_temp = node_new(id_hlist)
- dnode.setattributelist(shipout_temp, nil)
+ dnode.setattributelist(shipout_temp, nil)
tex.setattribute(attr_dir, 0)
finalize_inner = function (box)
end
local setpenalty = node.direct.setpenalty
local setkern = node.direct.setkern
-
+
local get_attr = node.direct.get_attribute
local set_attr = node.direct.set_attribute
local insert_before = node.direct.insert_before
function (stat, Nq, Np) return false end)
-- calc next Np
-local calc_np
+local calc_np
do -- 001 -----------------------------------------------
local traverse = node.direct.traverse
local function check_next_ickern(lp)
local lx = Np.nuc
- while lp and getid(lp) == id_kern and ( getsubtype(lp)==0 or
+ while lp and getid(lp) == id_kern and ( getsubtype(lp)==0 or
getsubtype(lp)==3 or ITALIC == get_attr_icflag(lp)) do
set_attr(lp, attr_icflag, IC_PROCESSED)
lx, lp = lp, node_next(lp)
local function calc_np_notdef(lp)
if not font_getfont(getfont(lp)).characters[getchar(lp)] then
local ln = node_next(lp)
- if ltju.specified_feature(getfont(lp), 'notdef') and ln and getid(ln)==id_glyph then
+ if ltju.specified_feature(getfont(lp), 'notdef') and ln and getid(ln)==id_glyph then
set_attr(lp, attr_icflag, PROCESSED)
set_attr(ln, attr_jchar_code, get_attr(lp, attr_jchar_code) or getchar(lp))
set_attr(ln, attr_jchar_class, get_attr(lp, attr_jchar_class) or 0)
end
end
return lp
- end
+ end
function calc_np_aux_glyph_common(lp, acc_flag)
Np.nuc, Np.first = lp, (Np.first or lp)
if if_lang_ja(lp) then -- JAchar
end,
[id_glue] = function(lp)
Np.first, Np.nuc, Np.last = (Np.first or lp), lp, lp;
- Np.id = getid(lp);
+ Np.id = getid(lp);
local f = luatexbase.call_callback("luatexja.jfmglue.special_jaglue", lp)
if f then
set_attr(lp, attr_icflag, PROCESSED)
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,
+ -- auto_kspc, auto_xspc: normally true/false,
-- but the number 0 when Np is ''the beginning of the box/paragraph''.
for k in pairs(Np) do Np[k] = nil end
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
+ Nx.auto_kspc, Nx.auto_xspc
= not has_attr(x, attr_autospc, 0), not has_attr(x, attr_autoxspc, 0)
return m, mc, cls
end
setpenalty(p, 10000); head = insert_before(head, Np.first, p)
Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
end
- else
+ else
local a = (pre or 0) + (post or 0)
for _, v in pairs(Bp) do add_penalty(v,a) end
end
local g = mc[bc][ac]
if g then
if g[1] then
- local k = node_new(id_kern, 1); setkern(k, g[1])
+ local k = node_new(id_kern, 1); setkern(k, g[1])
set_attr(k, attr_icflag, FROM_JFM)
return k, g.ratio, false, false, false
else
if kanjiskip_jfm_flag then
local g = node_new(id_glue);
local bk = qm.kanjiskip or null_skip_table
- setglue(g, bn and (bn*bk[1]) or 0,
- bp and (bp*bk[2]) or 0,
+ setglue(g, bn and (bn*bk[1]) or 0,
+ bp and (bp*bk[2]) or 0,
bh and (bh*bk[3]) or 0, 0, 0)
set_attr(g, attr_icflag, KANJI_SKIP_JFM)
return g
local sh = bh and (bh*getfield(kanji_skip, 'shrink')) or 0
setglue(g,
bn and (bn*getwidth(kanji_skip)) or 0,
- st, sh,
+ st, sh,
(st==0) and 0 or getfield(kanji_skip, 'stretch_order'),
(sh==0) and 0 or getfield(kanji_skip, 'shrink_order'))
set_attr(g, attr_icflag, KANJI_SKIP_JFM)
end
end
end
-
+
get_kanjiskip = function()
- if Np.auto_kspc==0 or Nq.auto_kspc==0 then return nil
+ if Np.auto_kspc==0 or Nq.auto_kspc==0 then return nil
elseif Np.auto_kspc or Nq.auto_kspc then
local pm, qm = Np.met, Nq.met
if (pm.char_type==qm.char_type) and (qm.var==pm.var) then
else
local gb = get_kanjiskip_low(false, qm, 1, 1, 1)
if gb then
- return calc_ja_ja_aux(gb,
- get_kanjiskip_low(false, pm, 1, 1, 1) or node_copy(kanji_skip), 0, 1)
+ return calc_ja_ja_aux(gb,
+ get_kanjiskip_low(false, pm, 1, 1, 1) or node_copy(kanji_skip), 0, 1)
else
local ga = get_kanjiskip_low(false, pm, 1, 1, 1)
return (ga and calc_ja_ja_aux(node_copy(kanji_skip), ga, 0, 1))
or node_copy(kanji_skip)
end
end
- else
+ else
local g = node_new(id_glue)
set_attr(g, attr_icflag, kanjiskip_jfm_flag and KANJI_SKIP_JFM or KANJI_SKIP)
return g
return g, (Np.auto_kspc or Nq.auto_kspc) and get_kanjiskip_low(true, qm, kn, kp, kh)
else
local npn, nqn = Np.nuc, Nq.nuc
- local gb, db, bn, bp, bh
+ local gb, db, bn, bp, bh
= new_jfm_glue(qmc, Nq.class,
slow_find_char_class(Np.char,
qm, getchar(npn)))
- local ga, da, an, ap, ah
+ local ga, da, an, ap, ah
= new_jfm_glue(pmc,
slow_find_char_class(Nq.char,
pm, getchar(nqn)),
return node_copy(xkanji_skip)
else
local g = node_new(id_glue)
- local w, st, sh, sto, sho = getglue(xkanji_skip)
+ local w, st, sh, sto, sho = getglue(xkanji_skip)
setglue(g,
bn and (bn*w) or 0,
bp and (bp*st) or 0,
end
end
end
-
+
get_xkanjiskip = function(Nn)
if Np.auto_xspc==0 or Nq.auto_xspc==0 then
- return nil
+ return nil
elseif (Nq.xspc>=2) and (Np.xspc%2==1) and (Nq.auto_xspc or Np.auto_xspc) then
return get_xkanjiskip_low(true, Nn.met, 1, 1, 1)
else
local g, _, kn, kp, kh = new_jfm_glue(
pm.char_type,
fast_find_char_class(
- (((Nq.id==id_glue)or(Nq.id==id_kern)) and 'glue' or 'jcharbdd'), pm),
+ (((Nq.id==id_glue)or(Nq.id==id_kern)) and 'glue' or 'jcharbdd'), pm),
Np.class)
local k
if insert_ksp then
local g, k
if non_ihb_flag then g, k = calc_ja_ja_glue() end -- M->K
if not g then g = get_kanjiskip() end
- handle_penalty_normal(Nq.post, Np.pre, g);
+ handle_penalty_normal(Nq.post, Np.pre, g);
real_insert(g); real_insert(k)
elseif Nq.met then -- qid==id_hlist
local g, k
elseif Nq.pre then
local g, k; if non_ihb_flag then g, k = get_NA_skip() end -- N_A->X
if not g then g = get_xkanjiskip(Np) end
- handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g);
+ handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g);
real_insert(g); real_insert(k)
else
local g = non_ihb_flag and (get_OA_skip()) -- O_A
[id_hlist] = function() after_hlist(Nq) end,
[id_pbox] = function() after_hlist(Nq) end,
[id_disc] = function() after_hlist(Nq) end,
- [id_glue] = function()
+ [id_glue] = function()
luatexbase.call_callback("luatexja.jfmglue.special_jaglue_after", Nq.nuc)
end,
[id_pbox_w]= function()
-- Insert \jcharwidowpenalty
if widow_Np.first then handle_penalty_jwp() end
else
- Np = Nq
+ Np = Nq
-- the current list is the contents of a hbox
local npi, pm = Np.id, Np.met
if npi == id_jglyph or (npi==id_pbox and pm) then
{}, {}, {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, gk=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, gk=nil },
local is_dir_tate = list_dir==dir_tate
capsule_glyph = is_dir_tate and ltjw.capsule_glyph_tate or ltjw.capsule_glyph_yoko
attr_ablshift = is_dir_tate and attr_tablshift or attr_yablshift
- local TEMP = node_new(id_glue)
- -- TEMP is a dummy node, which will be freed at the end of the callback.
+ local TEMP = node_new(id_glue)
+ -- TEMP is a dummy node, which will be freed at the end of the callback.
-- Without this node, set_attr(kanji_skip, ...) somehow creates an "orphaned" attribute list.
do
kanji_skip, kanjiskip_jfm_flag = skip_table_to_glue(KSK)
-- 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)
- while lp and
+ while lp and
((lpi==id_whatsit and lps~=sid_user)
or ((lpi==id_hlist) and (lps==3))
or (lpi==id_local)) do
lp = calc_np(last, lp)
if Np then
handle_list_head(par_indented)
- lp = calc_np(last,lp);
+ lp = calc_np(last,lp);
while Np do
adjust_nq();
local pid, pm = Np.id, Np.met
end
-- adjust attr_icflag for avoiding error
if tex_getattr(attr_icflag)~=0 then ensure_tex_attr(attr_icflag, 0) end
- node_free(kanji_skip);
+ node_free(kanji_skip);
node_free(xkanji_skip); node_free(TEMP)
return head
end
end
do
- local IHB = luatexja.userid_table.IHB
+ local IHB = luatexja.userid_table.IHB
local BPAR = luatexja.userid_table.BPAR
local BOXB = luatexja.userid_table.BOXB
local node_prev = node.direct.getprev
end
Np.met = Nq.met; Np.pre = 0; Np.post = 0; Np.xspc = 0
Np.auto_xspc, Np.auto_kspc = 0, 0
- end
+ end
return Np
else
return Np
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
local attr_curtfnt = luatexbase.attributes['ltj@curtfnt']
local dir_tate = luatexja.dir_table.dir_tate
- local get_dir_count = ltjd.get_dir_count
+ local get_dir_count = ltjd.get_dir_count
function get_current_jfont()
return tex_getattr((get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
end
set_attr(g, attr_yablshift, ica)
else
set_attr(g, attr_yablshift, PROCESSED_BEGIN_FLAG + ica)
- set_attr(g, attr_tablshift, get_current_jfont())
+ set_attr(g, attr_tablshift, get_current_jfont())
end
node_write(g)
end
if lxi>=PROCESSED_BEGIN_FLAG then
lxi = lxi%PROCESSED_BEGIN_FLAG
if lxi == KANJI_SKIP then
- special_jaglue_after_inner(lx, lxi, KANJI_SKIP_JFM, kanji_skip,
+ special_jaglue_after_inner(lx, lxi, KANJI_SKIP_JFM, kanji_skip,
ltjf_font_metric_table[get_attr(lx, attr_tablshift)].kanjiskip or null_skip_table)
else -- lxi == XKANJI_SKIP
- special_jaglue_after_inner(lx, lxi, XKANJI_SKIP_JFM, xkanji_skip,
+ special_jaglue_after_inner(lx, lxi, XKANJI_SKIP_JFM, xkanji_skip,
ltjf_font_metric_table[get_attr(lx, attr_tablshift)].xkanjiskip or null_skip_table)
end
else
v.end_adjust = nil
elseif #(v.end_adjust)==0 then
v.end_adjust = nil
- else
+ else
table.sort(v.end_adjust)
end
end
else
v.end_adjust = nil
- if v.end_stretch and v.end_stretch~=0.0 then
- v.end_adjust = (v.end_adjust or {})
+ if v.end_stretch and v.end_stretch~=0.0 then
+ v.end_adjust = (v.end_adjust or {})
v.end_adjust[#(v.end_adjust)+1] = v.end_stretch
end
- if v.end_shrink and v.end_ahrink~=0.0 then
- v.end_adjust = (v.end_adjust or {})
+ if v.end_shrink and v.end_ahrink~=0.0 then
+ v.end_adjust = (v.end_adjust or {})
v.end_adjust[#(v.end_adjust)+1] = -v.end_shrink
end
if v.end_adjust then v.end_adjust[#(v.end_adjust)+1] = 0.0 end
elseif xp and type(xp)~='number' then
defjfm_res = nil
else
- xp = (xp or 0)*9+36
- if xp<0 or xp>=64 then defjfm_res=nil end
+ xp = (xp or 0)*9+36
+ if xp<0 or xp>=64 then defjfm_res=nil end
end
x.priority = xp
end
end
end
if t.version<3 then
- -- In version 3, 'jcharbdd' is divided into
- -- 'alchar': ALchar (or math boundary)
+ -- In version 3, 'jcharbdd' is divided into
+ -- 'alchar': ALchar (or math boundary)
-- 'nox_alchar': ALchar (or math boundary), where xkanjiskip won't inserted
-- 'glue': glue/kern, 'jcharbdd': other cases (和文B, rule, ...)
t.chars.alchar = t.chars.jcharbdd
}
if auto_enable_vrt2 then
local vert_name = ltju.exist_feature(fn, 'vrt2') and 'vrt2' or 'vert'
- local rot = fmtable.rotation
+ local rot = fmtable.rotation
ltju.enable_feature(fn, vert_name)
ltju.loop_over_feat(f, {[vert_name]=true}, function (i,k) rot[i] = nil end)
end
to_be_checked[i]=nil
if ltj_cb<lotf_cb then
local f = ltb.remove_from_callback(n,'luaotfload.letterspace')
- ltb.add_to_callback(n, f, 'luaotfload.letterspace',
+ ltb.add_to_callback(n, f, 'luaotfload.letterspace',
ltb.priority_in_callback(n, 'luaotfload.node_processor') + 1)
end
end
local parser=luaotfload.parsers.font_request
function is_feature_specified(s,fname)
local t = lpegmatch(parser,s); return t and t.features and t.features[fname]
- end
+ end
-- extract jfm_name, jfm_spec and jfm_var
-- normalize position of 'jfm=' and 'jfmvar=' keys
local function extract_jfm_spec(name)
jfm_ksp = (is_feature_specified(name,'ltjksp')~=false)
if jfm_dir == 'tate' then
vert_activated = (is_feature_specified(name,'vert')~=false) and (is_feature_specified(name,'vrt2')~=false)
- auto_enable_vrt2
+ auto_enable_vrt2
= (is_feature_specified(name,'vert')==nil) and (is_feature_specified(name,'vrt2')==nil)
else
vert_activated, auto_enable_vrt2 = nil, nil
local lo, hi = 1, #t
while lo < hi do
local mi = ceil((lo+hi)/2)
- if t[mi]<=i then lo=mi else hi=mi-1 end
+ if t[mi]<=i then lo=mi else hi=mi-1 end
end
return lo%2==1
end
local bname = tfmdata.psname or nameonly(tfmdata.filename)
if not font_extra_basename[bname] then
-- if the cache is present, read it
- --
+ --
local newtime = file_attributes(tfmdata.filename,"modification")
local v = "extra_" .. string.lower(bname)
local dest = load_cache(
v,
- function (t)
+ function (t)
return (t.lotf_version~=luaotfload.version)
- or (t.version~=cache_ver) or (t.modtime~=newtime)
+ or (t.version~=cache_ver) or (t.modtime~=newtime)
end
)
-- if the cache is not found or outdated, save the cache
dummytable.vorigin, dummytable.vheight = dtvo, dtvh
end
end
-
+
local function prepare_extra_data_font(id, res, name)
if type(res)=='table' and (res.psname or res.filename) then
if (res.embedding=='no') and (type(name)=='string') and (name:sub(1,5)=='psft:') then
[0x3014]=0xFE39, [0x3015]=0xFE3A, [0x3010]=0xFE3B, [0x3011]=0xFE3C,
[0x300A]=0xFE3D, [0x300B]=0xFE3E, [0x3008]=0xFE3F, [0x3009]=0xFE40,
[0x300C]=0xFE41, [0x300D]=0xFE42, [0x300E]=0xFE43, [0x300F]=0xFE44,
- [0xFF3B]=0xFE47, [0xFF3D]=0xFE48,
+ [0xFF3B]=0xFE47, [0xFF3D]=0xFE48,
}
local vert_jpotf_table, vert_feat = {}, {vert=true}
local utfbyte, utfsub = utf.byte, utf.sub
luatexja.jfont.register_vert_replace = function(t)
for i,v in pairs(t) do
- local ic = (type(i)=='number') and i or
+ local ic = (type(i)=='number') and i or
((type(i)=='string') and utfbyte(utfsub(i,1,1)) or nil)
if ic then
- vert_jpotf_table[ic] = (type(v)=='number') and v or
+ vert_jpotf_table[ic] = (type(v)=='number') and v or
((type(v)=='string') and utfbyte(utfsub(v,1,1)) or nil)
end
- end
+ end
end
luatexbase.add_to_callback(
local p, n = node_prev(x), node_next(x)
if p then
local pid = getid(p)
- while (id_glue<=pid) and (pid<=id_penalty) and node_prev(p) do
+ while (id_glue<=pid) and (pid<=id_penalty) and node_prev(p) do
p = node_prev(p); pid = getid(p)
end
if pid==id_hlist and getid(n)==id_hlist then
local function dir_adjust_append_vlist(b, loc, prev, mirrored)
local old_b = to_direct(b)
- local new_b = loc=='box' and
+ local new_b = loc=='box' and
make_dir_whatsit(old_b, old_b, get_dir_count(), 'append_vlist') or old_b
local _, ht, dp = getwhd(new_b)
if prev > -65536000 then
end
if tail then
if getid(tail)==id_hlist and getid(new_b)==id_hlist then
- if getdepth(tail)==prev then
+ if getdepth(tail)==prev then
lmin, adj = ltj_profiler(tail, new_b, mirrored, bw)
end
end
return provides_feature(id, t.properties.script, t.properties.language, name)
else return false
end
-end
+end
function aux.enable_feature(id, name)
local t = getfont(id)
elseif t.hb then -- HARF
local hbfont, u = t.hb.shared.font, t.hb.shared.upem
local h = hbfont:get_h_extents()
- if h and u then
+ if h and u then
a, d = h.ascender and h.ascender/u, h.descender and -h.descender/u
end
end
end
local rawdata = tfmdata.shared.rawdata
local ascender = rawdata.metadata.ascender or 0
- local default_vheight
+ local default_vheight
= rawdata.metadata.defaultvheight
or (rawdata.metadata.descender and (ascender+rawdata.metadata.descender) or units)
local units = tfmdata.units
for _,i in pairs(t.resources.sequences) do
if i.order[1] and feature_name[i.order[1]] then
local f = i.features and i.features[i.order[1]]
- if i.type == 'gsub_single' and i.steps
+ if i.type == 'gsub_single' and i.steps
and f and (universal or (f[t.properties.script] and f[t.properties.script][t.properties.language])) then
for _,j in pairs(i.steps) do
- if type(j)=='table' then
+ if type(j)=='table' then
if type(j.coverage)=='table' then
for i,k in pairs(j.coverage) do
local s = func(i,k); if s then return s end
local vert_vrt2 = { vert=true, vrt2=true }
function aux.replace_vert_variant(id, c)
- return loop_over_feat(id, vert_vrt2,
+ return loop_over_feat(id, vert_vrt2,
function (i,k) if i==c then return k end end)
or c
end
--for name, func in pairs(aux) do
--- if type(func)=="function" then
+-- if type(func)=="function" then
-- aux[name] = function(...)
-- print('LOTF_AUX', name, ...);
-- local a = func(...); print('RESULT', a); return a
search = function (t, key, prefix)
if type(t)=="table" then
prefix = prefix or ''
- for i,v in pairs(t) do
- if i==key then print(prefix..'.'..i, v)
+ for i,v in pairs(t) do
+ if i==key then print(prefix..'.'..i, v)
else search(v,key,prefix..'.'..tostring(i)) end
end
end
-- vcenter noad は軸に揃えるため,欧文ベースライン補正がかかる
local function conv_vcenter(sb)
local h = getlist(sb) ; local hd = getlist(h)
- if getid(hd)==id_whatsit and getsubtype(hd)==sid_user
+ if getid(hd)==id_whatsit and getsubtype(hd)==sid_user
and getfield(hd, 'user_id')==DIR then
local d = node_next(hd)
if getid(d)==id_vlist and get_attr(d, attr_dir)>=dir_node_auto then
elseif v<0xF0000 then -- 素直に Unicode にマップ可能
return v
else -- privete use area
- local r, aj = nil, ltjr_cidfont_data["Adobe-Japan1"]
+ local r, aj = nil, ltjr_cidfont_data["Adobe-Japan1"]
-- 先に ltj_vert_table を見る
for i,w in pairs(aj.ltj_vert_table) do
if w==v then r=i; break end
local fontdata = font_getfont(fnum)
if head and luatexja.jfont.font_metric_table[fnum] and luatexja.jfont.font_metric_table[fnum].vert_activated then
local vt = fontdata.ltj_vert_table
- local nh = is_node(head) and to_direct(head) or head
+ local nh = is_node(head) and to_direct(head) or head
for n in traverse_id(id_glyph, head) do
if getfont(n)==fnum then
local c = getchar(n); setchar(n, vt[c] or c)
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
+ if cache_handle then
cache_handle:write('local lrob=luatexja.ruby.old_break_info\n')
end
end
do
local RIPRE = luatexja.stack_table_index.RIPRE
local RIPOST = luatexja.stack_table_index.RIPOST
- local abs = math.abs
+ local abs = math.abs
local function whatsit_callback(Np, lp, Nq)
if Np.nuc then return Np
elseif getfield(lp, 'user_id') == RUBY_PRE then
end
local nqnv = getfield(Nq.nuc, 'value')
local rst = getfield(nqnv, 'value')
- if Nq.gk then
+ if Nq.gk then
if type(Nq.gk)=="table" then
for _,v in ipairs(Nq.gk) do add_gk(rst, 'before_jfmgk', v) end
else add_gk(rst, 'before_jfmgk', Nq.gk) end
local function w (s, Nq, Np)
if not s and getfield(Nq.nuc, 'user_id') == RUBY_PRE then
local rst = getfield(getfield(Nq.nuc, 'value'), 'value')
- if Np.gk then
+ if Np.gk then
if type(Np.gk)=="table" then
for _,v in ipairs(Np.gk) do add_gk(rst, 'after_jfmgk', v) end
else add_gk(rst, 'after_jfmgk', Np.gk) end
local f = font_getfont(pf)
local r, l = met.rotation[pc], f.properties and f.properties.language
if ((r==true) or (type(r)=="table" and not r[l])) and (get_attr(p, attr_vert_ori) or 0)<=0 then
- return capsule_glyph_tate_rot(p, met, char_data, head, dir,
+ return capsule_glyph_tate_rot(p, met, char_data, head, dir,
0.5*(get_ascender(pf)-get_descender(pf)))
end
end
return
elseif (get_attr(p, attr_icflag) or 0) ~= PROCESSED then
if pid==id_hlist or pid==id_vlist then
- setshift(p, getshift(p) + (get_attr(p,attr_ablshift) or 0))
+ setshift(p, getshift(p) + (get_attr(p,attr_ablshift) or 0))
elseif pid==id_rule then
local v = get_attr(p,attr_ablshift) or 0
setheight(p, getheight(p)-v); setdepth(p, getdepth(p)+v)
setfield(g,'stretch_order',sto or 0)
setfield(g,'shrink_order', sho or 0)
end
- for _,v in pairs({'char', 'depth', 'dir', 'font', 'height', 'kern', 'lang', 'next',
+ for _,v in pairs({'char', 'depth', 'dir', 'font', 'height', 'kern', 'lang', 'next',
'nucleus', 'offsets', 'penalty', 'shift', 'sub', 'subtype', 'sup'}) do
- if not dnode['set'..v] then
+ if not dnode['set'..v] then
dnode['set'..v] = function(n, ...) return setfield(n, v, ...) end
end
end
return getfield(g,'width'), getfield(g,'stretch'), getfield(g,'shrink'),
getfield(g,'stretch_order'), getfield(g,'shrink_order')
end
- for _,v in pairs({'box', 'components', 'char', 'depth', 'font', 'height', 'kern', 'lang',
+ for _,v in pairs({'box', 'components', 'char', 'depth', 'font', 'height', 'kern', 'lang',
'list', 'next', 'nucleus', 'offsets', 'penalty', 'prev', 'shift', 'sub',
'subtype', 'sup', 'whd', 'width', 'dir'}) do
- if not dnode['get'..v] then
+ if not dnode['get'..v] then
dnode['get'..v] = function(n, ...) return getfield(n, v, ...) end
end
end
local function getattr(a, d)
local r = tex_getattr(a); d = d or 0
return (r==-0x7FFFFFFF) and d or r
- end
+ end
luatexja.unary_pars = {
yalbaselineshift = function(t)
return print_scaled(getattr('ltj@yablshift'))..'pt'
local pt, pic = node_type(p.id), (get_attr(p, attr_icflag) or 0) % icflag_table.PROCESSED_BEGIN_FLAG
local base = prefix .. string.format('%X', pic) .. ' ' .. pt .. ' ' .. tostring(p.subtype) .. ' '
if pt == 'glyph' then
- s = base .. ' '
- .. (p.char<0xF0000 and utfchar(p.char) or '')
+ s = base .. ' '
+ .. (p.char<0xF0000 and utfchar(p.char) or '')
.. string.format(' (U+%X) ', p.char)
.. tostring(p.font) .. ' (' .. print_scaled(p.height) .. '+'
.. print_scaled(p.depth) .. ')x' .. print_scaled(p.width)