-local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct
--- EXT: italic correction
-function append_italic()
- local p = to_direct(tex.nest[tex.nest.ptr].tail)
- if p and getid(p)==id_glyph then
- local f = getfont(p)
- local g = node_new(id_kern)
- setfield(g, 'subtype', 1)
- set_attr(g, attr_icflag, ITALIC)
- if is_ucs_in_japanese_char(p) then
- f = has_attr(p, attr_curjfnt)
- local j = font_metric_table[f]
- setfield(g, 'kern', j.char_type[find_char_class(getchar(p), j)].italic)
- else
- local h = font_getfont(f)
- if h then
- setfield(g, 'kern', h.characters[getchar(p)].italic)
+ local function prepare_vert_data(n, id)
+ -- test if already loaded
+ if type(id)=='number' then -- sometimes id is an integer
+ font_vert_table[n] = font_vert_table[id]; return
+ elseif (not id) or font_vert_table[n] then return
+ end
+ local fname = id.filename
+ local bname = file.basename(fname)
+ if not fname then
+ font_vert_table[n] = {}; return
+ elseif font_vert_basename[bname] then
+ font_vert_table[n] = font_vert_basename[bname]; return
+ end
+ local vtable = {}
+ local a = id.resources.sequences
+ if a then
+ local s = id.shared.rawdata.descriptions
+ for i,v in pairs(a) do
+ if v.features.vert or v.features.vrt2 then
+ add_feature_table(v.subtables[1], s, vtable)
+ end
+ end
+ end
+ font_vert_basename[bname] = vtable
+ font_vert_table[n] = vtable
+ end
+ -- 縦書き用字形への変換
+ function get_vert_glyph(n, chr)
+ local fn = font_vert_table[n]
+ return fn and fn[chr] or chr
+ end
+ luatexbase.add_to_callback('luatexja.define_font',
+ function (res, name, size, id)
+ prepare_vert_data(id, res)
+ end,
+ 'prepare_vert_data', 1)
+
+ local function a (n, dat) font_vert_table[n] = dat end
+ ltjr.vert_addfunc = a
+
+end
+
+------------------------------------------------------------------------
+-- MISC
+------------------------------------------------------------------------
+do
+ local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct
+ local tex_set_attr = tex.setattribute
+ -- EXT: italic correction
+ function append_italic()
+ local p = to_direct(tex.nest[tex.nest.ptr].tail)
+ if p and getid(p)==id_glyph then
+ local f = getfont(p)
+ local g = node_new(id_kern)
+ setfield(g, 'subtype', 1)
+ set_attr(g, attr_icflag, ITALIC)
+ if is_ucs_in_japanese_char(p) then
+ f = has_attr(p, attr_curjfnt)
+ local j = font_metric_table[f]
+ setfield(g, 'kern', j.char_type[find_char_class(getchar(p), j)].italic)