local attr_jchar_class = luatexbase.attributes['ltj@charclass']
local attr_autospc = luatexbase.attributes['ltj@autospc']
local attr_autoxspc = luatexbase.attributes['ltj@autoxspc']
- local ltjf_get_vert_glyph = ltjf.get_vert_glyph
+ --local ltjf_get_vert_glyph = ltjf.get_vert_glyph
function set_np_xspc_jachar_yoko(Nx, x)
local m = ltjf_font_metric_table[getfont(x)]
local cls, c = slow_find_char_class(ltjs_orig_char_table[x], m, getchar(x))
local xf = getfont(x)
local m = ltjf_font_metric_table[xf]
local cls = slow_find_char_class(c, m, c_glyph)
- setfield(x, 'char', ltjf_get_vert_glyph(xf, c_glyph) or c_glyph)
+ --setfield(x, 'char', ltjf_get_vert_glyph(xf, c_glyph) or c_glyph)
Nx.met = m; Nx.class = cls;
if cls~=0 then set_attr(x, attr_jchar_class, cls) end
Nx.pre = table_current_stack[PRE + c] or 0
local jfm_file_name, jfm_var
local defjfm_res
-local jfm_dir
+local jfm_dir, is_def_jfont
function define_jfm(t)
local real_char -- Does current character class have the 'real' character?
end
-- EXT
- function jfontdefX(g)
+ function jfontdefX(g, dir)
+ jfm_dir, is_def_jfont = dir, true
local t = token.get_next()
cstemp=token.csname_name(t)
global_flag = g and '\\global' or ''
-- EXT
local identifiers = fonts.hashes.identifiers
- function jfontdefY(dir)
- jfm_dir = dir
- local j = load_jfont_metric(dir)
+ function jfontdefY()
+ local j = load_jfont_metric(jfm_dir)
local fn = font.id(cstemp)
local f = font_getfont(fn)
if not j then
font_metric_table[fn]=fmtable
tex.sprint(cat_lp, global_flag, '\\protected\\expandafter\\def\\csname ',
cstemp , '\\endcsname{\\ltj@cur'..
- (dir == 'yoko' and 'j' or 't') .. 'fnt', fn, '\\relax}')
+ (jfm_dir == 'yoko' and 'j' or 't') .. 'fnt', fn, '\\relax}')
end
end
name = name .. 'jfmvar=' .. jfm_var
end
end
+ if jfm_dir == 'tate' then
+ if not name:match('vert') and not name:match('vrt2') then
+ name = name .. ';vrt2'
+ end
+ end
return name
end
local otfl_fdr = fonts.definers.read
local ltjr_font_callback = ltjr.font_callback
function luatexja.font_callback(name, size, id)
- local new_name = extract_metric(name)
+ local new_name = is_def_jfont and extract_metric(name) or name
+ is_def_jfont = false
local res = ltjr_font_callback(new_name, size, id, otfl_fdr)
luatexbase.call_callback('luatexja.define_font', res, new_name, size, id)
+ -- this callback processes variation selector, so we execute it always
return res
end
luatexbase.create_callback('luatexja.define_font', 'simple', function (n) return n end)
end
return vw, tsb, vk
end
-
+
local sort = table.sort
local function add_fl_table(dest, tg, unitable, glyphmax, asc_des, units)
for i = 0, glyphmax-1 do
end
-- vertical kern
if vk then
- dest = dest or {};
+ dest = dest or {};
local dest_vk = dest.vkerns or {}; dest.vkerns = dest_vk
for _,v in pairs(vk) do
local vl = v.lookup
end
return dest
end
- prepare_vert_data = function (dest, id)
+ prepare_vert_data = function (dest, id)
local a = id.resources.sequences
if a then
local s = id.shared.rawdata.descriptions
end
return dest
end
- -- 縦書き用字形への変換
- function get_vert_glyph(n, chr)
- local fn = font_extra_info[n]
- return (fn and fn[chr] and fn[chr].vert) or chr
- end
+ -- -- 縦書き用字形への変換
+ -- function get_vert_glyph(n, chr)
+ -- local fn = font_extra_info[n]
+ -- return (fn and fn[chr] and fn[chr].vert) or chr
+ -- end
end
---
+--
do
- local cache_ver = 5
+ local cache_ver = 6
local checksum = file.checksum
local function prepare_extra_data_base(id)
font_extra_basename[bname] = dat[1] or {}
else
local dat = nil
- dat = prepare_vert_data(dat, id)
dat = prepare_fl_data(dat, id)
font_extra_basename[bname] = dat or {}
ltjb.save_cache( v,
end
end
local function prepare_extra_data_font(id, res)
- if type(res)=='table' and res.shared then
+ if type(res)=='table' and res.shared then
font_extra_info[id] = font_extra_basename[file.nameonly(res.filename)]
end
end
local identifiers = fonts.hashes.identifiers
for i=1,font.nextid()-1 do
- if identifiers[i] then
+ if identifiers[i] then
prepare_extra_data_base(identifiers[i])
prepare_extra_data_font(i,identifiers[i])
end
if v.slookups then
for sn, sv in pairs(v.slookups) do
if subtables[sn] and type(sv)=='table' then
- if sv[4]~=0 then
- table_vadv[char_num]
+ if sv[4]~=0 then
+ table_vadv[char_num]
= (table_vadv[char_num] or 0) + sv[4]
end
- if sv[2]~=0 and not already_vert then
- table_vorg[char_num]
+ if sv[2]~=0 and not already_vert then
+ table_vorg[char_num]
= (table_vorg[char_num] or 0) + sv[2]
end
end
end
luatexbase.add_to_callback(
- "luatexja.define_jfont",
+ "luatexja.define_jfont",
function (fmtable, fnum)
local vadv = {}; fmtable.v_advance = vadv
local vorg = {}; fmtable.v_origin = vorg
end
end
end
- acc_feature(vadv, vorg, subtables, ft,
+ acc_feature(vadv, vorg, subtables, ft,
ft.specification.features.normal.vrt2 or ft.specification.features.normal.vert)
for i,v in pairs(vadv) do
vadv[i]=vadv[i]/ft.units_per_em*fmtable.size
vorg[i]=vorg[i]/ft.units_per_em*fmtable.size
end
end
- return fmtable
+ return fmtable
end, 1, 'ltj.v_advance'
)
end
end
end
end
-
local ltjf_font_metric_table = ltjf.font_metric_table
local ltjf_font_extra_info = ltjf.font_extra_info
-local ltjf_get_vert_glyph = ltjf.get_vert_glyph
local PACKED = luatexja.icflag_table.PACKED
local PROCESSED = luatexja.icflag_table.PROCESSED
fshift = call_callback("luatexja.set_width", fshift, met, class)
local fheight, fdepth = char_data.height, char_data.depth
local kbl = has_attr(p, attr_ykblshift) or 0
- --
+ --
local need_hbox
if pwidth==fwidth then
-- 補正後glyph node は ht: p.height - kbl - down, dp: p.depth + min(0, kbl+down) を持つ
-- 設定されるべき寸法: ht: fheight - kbl, dp: fdepth + kbl
- local ht_diff = fheight + fshift.down - getfield(p, 'height')
+ local ht_diff = fheight + fshift.down - getfield(p, 'height')
local dp_diff = fdepth + kbl - getfield(p, 'depth') - min(kbl + fshift.down, 0)
if ht_diff == 0 and dp_diff ==0 then -- offset only
set_attr(p, attr_icflag, PROCESSED)
else
need_hbox = true
end
- else
+ else
need_hbox = true
end
local box = node_new(id_hlist)
setfield(p, 'yoffset', getfield(p, 'yoffset') -fshift.down);
setfield(p, 'next', nil)
- setfield(p, 'xoffset', getfield(p, 'xoffset')
+ setfield(p, 'xoffset', getfield(p, 'xoffset')
+ char_data.align*(fwidth-pwidth) - fshift.left)
local box = node_new(id_hlist)
setfield(box, 'width', fwidth)
local pf = getfont(p)
local pc = getchar(p)
setfield(p, 'char', pc)
- pwidth = ltjf_font_extra_info[pf] and ltjf_font_extra_info[pf][pc]
- and ltjf_font_extra_info[pf][pc].vwidth
+ pwidth = ltjf_font_extra_info[pf] and ltjf_font_extra_info[pf][pc]
+ and ltjf_font_extra_info[pf][pc].vwidth
and ltjf_font_extra_info[pf][pc].vwidth * met.size or (ascent+descent)
pwidth = pwidth + (met.v_advance[pc] or 0)
ascent = met.v_origin[pc] and ascent - met.v_origin[pc] or ascent
function luatexja.setwidth.apply_ashift_math(head, last, attr_ablshift)
for p in node_traverse(head) do
local pid = getid(p)
- if p==last then
+ if p==last then
return
elseif (has_attr(p, attr_icflag) or 0) ~= PROCESSED then
if pid==id_hlist or pid==id_vlist then
%%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
\protected\def\jfont{%
- \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false)}}
+ \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko')}}
\protected\def\globaljfont{%
- \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true)}}
-\def\ltj@@jfont{\directlua{luatexja.jfont.jfontdefY('yoko')}}
+ \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'yoko')}}
+\def\ltj@@jfont{\directlua{luatexja.jfont.jfontdefY()}}
%%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont
-\protected\def\tfont{\afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(false)}}
+\protected\def\tfont{%
+ \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(false, 'tate')}}
\protected\def\globaltfont{%
- \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(true)}}
-\def\ltj@@tfont{\directlua{luatexja.jfont.jfontdefY('tate')}}
+ \afterassignment\ltj@@tfont\directlua{luatexja.jfont.jfontdefX(true, 'tate')}}
+\def\ltj@@tfont{\directlua{luatexja.jfont.jfontdefY()}}
%%%%%%%% \zw, \zh