--
luatexbase.provides_module({
name = 'luatexja.jfont',
- date = '2019/02/11',
+ date = '2019/05/01',
description = 'Loader for Japanese fonts',
})
local jfm_file_name, jfm_var, jfm_ksp
local defjfm_res
-local jfm_dir, is_def_jfont, is_vert_enabled, auto_enable_vrt2
+local jfm_dir, is_def_jfont, vert_activated, auto_enable_vrt2
local function norm_val(a)
if (not a) or (a==0.) then
end
-- EXT
- local utf8 = unicode.utf8
+ local utfbyte = utf.byte
function luatexja.jfont.jfontdefX(g, dir, csname)
jfm_dir, is_def_jfont = dir, true
- cstemp = csname:sub( (utf8.byte(csname,1,1) == tex.escapechar) and 2 or 1, -1)
+ cstemp = csname:sub( (utfbyte(csname,1,1) == tex.escapechar) and 2 or 1, -1)
cstemp = cstemp:sub(1, ((cstemp:sub(-1,-1)==' ') and (cstemp:len()>=2)) and -2 or -1)
global_flag = g and '\\global' or ''
tex.sprint(cat_lp, '\\expandafter\\font\\csname ',
chars = sz.chars, char_type = sz.char_type,
kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip,
chars_cbcache = {},
- vert_activated = is_vert_enabled,
+ vert_activated = vert_activated,
}
local t = identifiers[fn]
if auto_enable_vrt2 then
jfm_ksp = not (x=='-')
end
if jfm_dir == 'tate' then
- is_vert_enabled = (not name:match('[:;]%-vert')) and (not name:match('[:;]%-vrt2'))
+ vert_activated = (not name:match('[:;]%-vert')) and (not name:match('[:;]%-vrt2'))
auto_enable_vrt2
= (not name:match('[:;][+%-]?vert')) and (not name:match('[:;][+%-]?vrt2'))
else
- is_vert_enabled, auto_enable_vrt2 = nil, nil
+ vert_activated, auto_enable_vrt2 = nil, nil
end
return name
end
[0x300C]=0xFE41, [0x300D]=0xFE42, [0x300E]=0xFE43, [0x300F]=0xFE44,
[0xFF3B]=0xFE47, [0xFF3D]=0xFE48,
}
- local function add_vform(coverage, vform, ft, add_vert)
- if type(coverage)~='table' then return end
- for i,v in pairs(vert_form_table) do
- if not coverage[i] and ft.characters[v] then
- vform[i] = v
- end
- end
- if add_vert then -- vert feature が有効にならない場合
- for i,v in pairs(coverage) do vform[i] = vform[i] or v end
- end
+ local vert_jpotf_table = {}
+ local function add_vform(coverage, vform, ft, add_vert, jpotf_vert)
+ if type(coverage)~='table' then return end
+ for i,v in pairs(vert_form_table) do
+ if not coverage[i] and ft.characters[v] then vform[i] = v end
+ end
+ if jpotf_vert then
+ for i,v in pairs(vert_jpotf_table) do
+ if ft.characters[v] then vform[i] = coverage[v] or vform[v] or v end
+ end
+ end
+ if add_vert then -- vert feature が有効にならない場合
+ for i,v in pairs(coverage) do vform[i] = vform[i] or v end
+ end
+ end
+
+ 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
+ ((type(i)=='string') and utfbyte(utfsub(i,1,1)) or nil)
+ if ic then
+ vert_jpotf_table[ic] = (type(v)=='number') and v or
+ ((type(v)=='string') and utfbyte(utfsub(v,1,1)) or nil)
+ end
+ end
end
luatexbase.add_to_callback(
local add_vert
= not (provides_feature(fnum, t.properties.script, t.properties.language, 'vert'))
and not (provides_feature(fnum, t.properties.script, t.properties.language, 'vrt2'))
+ local jpotf_vert = t.shared.features.jpotf
-- 現在の language, script で vert もvrt2 も有効にできない場合,強制的に vert 適用
for _,i in pairs(t.resources.sequences) do
if i.order[1]== 'vert' and i.type == 'gsub_single' and i.steps then
for _,j in pairs(i.steps) do
- if type(j)=='table' then add_vform(j.coverage,vform, t, add_vert) end
+ if type(j)=='table' then
+ add_vform(j.coverage,vform, t, add_vert, jpotf_vert)
+ end
end
end
end