--
--- luatexja/jfont.lua
+-- ltj-jfont.lua
--
luatexbase.provides_module({
name = 'luatexja.jfont',
- date = '2019/08/27',
+ date = '2020-04-01',
description = 'Loader for Japanese fonts',
})
if type(v.down)~='number' then
v.down = 0.0
end
+ v.round_threshold = ((t.version>=3)and(i==0)and(type(v.round_threshold)=='number'))
+ and v.round_threshold or nil
if t.version>=2 then
if v.end_stretch then defjfm_res= nil; return end
if v.end_shrink then defjfm_res= nil; return end
width = w[1], stretch = w[2], shrink = w[3],
kanjiskip_natural = w.kanjiskip_natural and w.kanjiskip_natural/sz,
kanjiskip_stretch = w.kanjiskip_stretch and w.kanjiskip_stretch/sz,
- kanjiskip_shrink = w.kanjiskip_shrink and w.kanjiskip_shrink/sz,
+ kanjiskip_shrink = w.kanjiskip_shrink and w.kanjiskip_shrink/sz,
+ round_threshold = w.round_threshold and w.round_threshold/zw,
}
end
for k,w in pairs(v.kern) do
local fmtable = { jfm = j, size = f.size, var = jfm_var,
with_kanjiskip = jfm_ksp,
zw = sz.zw, zh = sz.zh,
- chars = sz.chars, char_type = sz.char_type,
+ chars = sz.chars, char_type = sz.char_type,
kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip,
chars_cbcache = {},
vert_activated = vert_activated,
otfl_fdr= luatexbase.remove_from_callback('define_font', 'luaotfload.define_font')
luatexbase.add_to_callback('define_font',luatexja.font_callback,"luatexja.font_callback", 1)
- local match, sp = string.match, tex.sp
- local function load_jfmonly(spec, dir)
- local spec, size = match(spec,'(.+)%s+at%s*([%.%w]*)')
+ local match, sp, scan_arg = string.match, tex.sp, token.scan_argument
+ local function load_jfmonly()
+ local spec, size = match(scan_arg(), '(.+)%s+at%s*([%.%w]*)')
+ local dir = scan_arg()
size = sp(size); extract_metric(spec)
jfm_dir = dir
local i = load_jfont_metric()
-- LATEX INTERFACE
------------------------------------------------------------------------
do
+ local scan_arg = token.scan_argument
-- these function are called from ltj-latex.sty
local fenc_list, kyenc_list, ktenc_list = {}, {}, {}
- function luatexja.jfont.add_fenc_list(enc) fenc_list[enc] = 'true ' end
- function luatexja.jfont.add_kyenc_list(enc) kyenc_list[enc] = 'true ' end
- function luatexja.jfont.add_ktenc_list(enc) ktenc_list[enc] = 'true ' end
- function luatexja.jfont.is_kyenc(enc)
- tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (kyenc_list[enc] or 'false '))
+ function luatexja.jfont.add_fenc_list() fenc_list[scan_arg()] = 'true ' end
+ function luatexja.jfont.add_kyenc_list() kyenc_list[scan_arg()] = 'true ' end
+ function luatexja.jfont.add_ktenc_list() ktenc_list[scan_arg()] = 'true ' end
+ function luatexja.jfont.is_kyenc()
+ tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (kyenc_list[scan_arg()] or 'false '))
end
- function luatexja.jfont.is_ktenc(enc)
- tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (ktenc_list[enc] or 'false '))
+ function luatexja.jfont.is_ktenc()
+ tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (ktenc_list[scan_arg()] or 'false '))
end
- function luatexja.jfont.is_kenc(enc)
+ function luatexja.jfont.is_kenc()
+ local enc = scan_arg()
tex.sprint(cat_lp, '\\let\\ifin@\\if'
.. (kyenc_list[enc] or ktenc_list[enc] or 'false '))
end
local kfam_list, Nkfam_list = {}, {}
- function luatexja.jfont.add_kfam(fam)
- kfam_list[fam]=true
+ function luatexja.jfont.add_kfam()
+ kfam_list[scan_arg()]=true
end
- function luatexja.jfont.search_kfam(fam, use_fd)
+ function luatexja.jfont.search_kfam()
+ local fam = scan_arg()
+ local use_fd = (scan_arg() =='true')
if kfam_list[fam] then
tex.sprint(cat_lp, '\\let\\ifin@\\iftrue '); return
elseif Nkfam_list[fam] then
end
end
local ffam_list, Nffam_list = {}, {}
- function luatexja.jfont.is_ffam(fam)
- tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (ffam_list[fam] or 'false '))
+ function luatexja.jfont.is_ffam()
+ tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (ffam_list[scan_arg()] or 'false '))
end
- function luatexja.jfont.add_ffam(fam)
- ffam_list[fam]='true '
+ function luatexja.jfont.add_ffam()
+ ffam_list[scan_arg()]='true '
end
function luatexja.jfont.search_ffam_declared()
local s = ''
end
tex.sprint(cat_lp, s)
end
- function luatexja.jfont.search_ffam_fd(fam)
+ function luatexja.jfont.search_ffam_fd()
+ local fam = scan_arg()
if Nffam_list[fam] then
tex.sprint(cat_lp, '\\let\\ifin@\\iffalse '); return
else
-- ここから先は 新 \selectfont の内部でしか実行されない
do
+ local scan_arg = token.scan_argument
local alt_font_base, alt_font_base_num
local aftl_base
-- EXT
- function luatexja.jfont.does_alt_set(bbase)
- aftl_base = alt_font_table_latex[bbase]
+ function luatexja.jfont.does_alt_set()
+ aftl_base = alt_font_table_latex[scan_arg()]
tex.sprint(cat_lp, aftl_base and '\\@firstofone' or '\\@gobble')
end
-- EXT
if rotate_in_uax50(i) then rot[i] = true end
end
ltju.loop_over_feat(tfmdata, vert_vrt2, function (i,k) rot[i] = nil end)
- -- 同じグリフが複数の Unicode ポイントを持っている場合.
- -- いずれかの Unicode ポイントで rot = true ならば全体で rotate
- ltju.loop_over_duplicates(tfmdata,
- function (i, v)
- local f = rot[i]
- if not f then
- for j,_ in pairs(v) do if rot[j] then f=true; break end end
- end
- rot[i]=f; for j,_ in pairs(v) do rot[j]=f end
- end)
+ -- ↓「TeX Live 2019のLuaLaTeXで縦書きの三点リーダーが横書きになる」
+ -- (https://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=2722) により無効化
+ -- -- 同じグリフが複数の Unicode ポイントを持っている場合.
+ -- -- いずれかの Unicode ポイントで rot = true ならば全体で rotate
+ --ltju.loop_over_duplicates(tfmdata,
+ -- function (i, v)
+ -- local f = rot[i]
+ -- if not f then
+ -- for j,_ in pairs(v) do if rot[j] then f=true; break end end
+ -- end
+ -- rot[i]=f; for j,_ in pairs(v) do rot[j]=f end
+ -- end)
for i,_ in pairs(rot) do
dest = dest or {}; dest.rotation = dest.rotation or {}
dest.rotation[i] = true