summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luatexja/src/ltj-jfont.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/generic/luatexja/src/ltj-jfont.lua')
-rw-r--r--macros/luatex/generic/luatexja/src/ltj-jfont.lua54
1 files changed, 33 insertions, 21 deletions
diff --git a/macros/luatex/generic/luatexja/src/ltj-jfont.lua b/macros/luatex/generic/luatexja/src/ltj-jfont.lua
index bb5d99561a..cecb8d6625 100644
--- a/macros/luatex/generic/luatexja/src/ltj-jfont.lua
+++ b/macros/luatex/generic/luatexja/src/ltj-jfont.lua
@@ -3,7 +3,7 @@
--
luatexbase.provides_module({
name = 'luatexja.jfont',
- date = '2020-04-01',
+ date = '2020-05-17',
description = 'Loader for Japanese fonts',
})
@@ -108,6 +108,8 @@ function luatexja.jfont.define_jfm(to)
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
@@ -184,13 +186,17 @@ local update_jfm_cache
do
local floor = math.floor
local function myround(a) return floor(a+0.5) end
+ local mult_ignore_key = {
+ round_threshold=true, kanjiskip_natural=true, kanjiskip_stretch=true, kanjiskip_shrink=true,
+ raio=true, priority=true
+ }
local function mult_table(old,scale) -- modified from table.fastcopy
if old then
local new = { }
for k,v in next, old do
if type(v) == "table" then
new[k] = mult_table(v,scale)
- elseif type(v) == "number" then
+ elseif type(v) == "number" and not mult_ignore_key[k] then
new[k] = myround(v*scale)
else
new[k] = v
@@ -213,12 +219,13 @@ do
for k,w in pairs(v.glue) do
v[k] = {
nil,
- ratio=w.ratio/sz,
- priority=FROM_JFM + w.priority/sz,
+ ratio=w.ratio,
+ priority=FROM_JFM + w.priority,
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_natural = w.kanjiskip_natural,
+ kanjiskip_stretch = w.kanjiskip_stretch,
+ kanjiskip_shrink = w.kanjiskip_shrink,
+ round_threshold = w.round_threshold,
}
end
for k,w in pairs(v.kern) do
@@ -331,7 +338,7 @@ 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,
@@ -449,9 +456,10 @@ do
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()
@@ -485,10 +493,12 @@ do
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
@@ -510,11 +520,11 @@ do
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 = ''
@@ -523,7 +533,8 @@ do
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
@@ -645,11 +656,12 @@ end
-- ここから先は 新 \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