+
+-- EXT
+ function jfontdefX(g)
+ local t = token.get_next()
+ cstemp=token.csname_name(t)
+ global_flag = g and '\\global' or ''
+ tex.sprint(cat_lp, '\\expandafter\\font\\csname ' .. cstemp .. '\\endcsname')
+ end
+
+ luatexbase.create_callback("luatexja.define_jfont", "data", function (ft, fn) return ft end)
+
+-- EXT
+ local identifiers = fonts.hashes.identifiers
+ function jfontdefY(dir)
+ jfm_dir = dir
+ local j = load_jfont_metric(dir)
+ local fn = font.id(cstemp)
+ local f = font_getfont(fn)
+ if not j then
+ ltjb.package_error('luatexja',
+ "bad JFM `" .. jfm_file_name .. "'",
+ 'The JFM file you specified is not valid JFM file.\n'..
+ 'So defining Japanese font is cancelled.')
+ tex.sprint(cat_lp, global_flag .. '\\expandafter\\let\\csname ' ..cstemp
+ .. '\\endcsname=\\relax')
+ return
+ end
+ update_jfm_cache(j, f.size)
+ local ad = identifiers[fn].parameters
+ local sz = metrics[j].size_cache[f.size]
+ local fmtable = { jfm = j, size = f.size, var = jfm_var,
+ zw = sz.zw, zh = sz.zh,
+ ascent = ad.ascender,
+ descent = ad.descender,
+ chars = sz.chars, char_type = sz.char_type,
+ kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip,
+ }
+
+ fmtable = luatexbase.call_callback("luatexja.define_jfont", fmtable, fn)
+ 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}')
+ end
+end
+
+do
+ -- PUBLIC function
+ function get_zw()
+ local a = font_metric_table[tex.attribute[attr_curjfnt]]
+ return a and a.zw or 0