--
luatexbase.provides_module({
name = 'luatexja.jfont',
- date = '2022-08-20',
+ date = '2023-03-11',
description = 'Loader for Japanese fonts',
})
luatexbase.create_callback("luatexja.load_jfm", "data", function (ft, jn) return ft end)
-local jfm_spec, jfm_name, jfm_var, jfm_ksp
+local jfm_spec, jfm_name, jfm_var, jfm_ksp, jfm_pci
local defjfm_res
local jfm_dir, is_def_jfont, vert_activated, auto_enable_vrt2
update_jfm_cache(j, f.size); check_callback_order()
local sz = metrics[j].size_cache[f.size]
local fmtable = { jfm = j, size = f.size, var = jfm_var,
- with_kanjiskip = jfm_ksp,
+ with_kanjiskip = jfm_ksp, protect_compat_ig = jfm_pci,
zw = sz.zw, zh = sz.zh,
chars = sz.chars, char_type = sz.char_type,
kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip,
-- print('NN>', name)
end
jfm_ksp = (is_feature_specified(name,'ltjksp')~=false)
+ jfm_pci = (is_feature_specified(name,'ltjpci')~=false)
if jfm_dir == 'tate' then
vert_activated = (is_feature_specified(name,'vert')~=false) and (is_feature_specified(name,'vrt2')~=false)
auto_enable_vrt2
local a = alt_font_table[pf]
return a and a[pc] or pf
end
-
------ for LaTeX interface
local alt_font_table_latex = {}
setfield(b, 'type', 100); setfield(b, 'user_id', JA_AL_BDD);
insert_before(head, p, b)
end
- local pf = get_attr(p, attr_curjfnt)
- pf = (pf and pf>0 and pf) or getfont(p)
- setfont(p, ltjf_replace_altfont(pf, pc))
setlang(p, lang_ja)
ltjs_orig_char_table[p], prev_chartype = pc, 2
elseif prev_chartype==2 then
local traverse_id = node.direct.traverse_id
local cnt_stack = luatexbase.registernumber 'ltj@@stack'
local texget, getvalue = tex.get, node.direct.getdata
+--
+ local compat_ig = {}
+ for i=0xf900, 0xfaff do compat_ig[i] = true end
+ for i=0x2f800, 0x2fa1f do compat_ig[i] = true end
+ local protect_glyph = node.direct.protect_glyph
+--
function set_box_stack_level(head, mode)
local box_set = 0
if mode then
if ltjs.list_dir == dir_tate then
for p in traverse_id(id_glyph,to_direct(head)) do
if has_attr(p, attr_icflag, 0) and getlang(p)==lang_ja then
- local nf = ltjf_replace_altfont( get_attr(p, attr_curtfnt) or getfont(p) , ltjs_orig_char_table[p])
+ local pf, pc = get_attr(p, attr_curtfnt), ltjs_orig_char_table[p]
+ local nf = ltjf_replace_altfont( (pf and pf>0 and pf) or getfont(p), pc)
setfont(p, nf)
+ if compat_ig[pc] and ltjf_font_metric_table[nf].protect_compat_ig then
+ protect_glyph(p)
+ end
if ltjf_font_metric_table[nf].vert_activated then
- local pc = getchar(p); pc = ltjf_font_metric_table[nf].vform[pc]
- if pc then setchar(p, pc) end
+ pc = ltjf_font_metric_table[nf].vform[pc]; if pc then setchar(p, pc) end
+ end
+ end
+ end
+ else
+ for p in traverse_id(id_glyph,to_direct(head)) do
+ if has_attr(p, attr_icflag, 0) and getlang(p)==lang_ja then
+ local pf, pc = get_attr(p, attr_curjfnt), ltjs_orig_char_table[p]
+ local nf = ltjf_replace_altfont( (pf and pf>0 and pf) or getfont(p), pc)
+ setfont(p, nf)
+ if compat_ig[pc] and ltjf_font_metric_table[nf].protect_compat_ig then
+ protect_glyph(p)
end
end
end