diff options
Diffstat (limited to 'macros/luatex/generic/luaotfload/luaotfload-features.lua')
-rw-r--r-- | macros/luatex/generic/luaotfload/luaotfload-features.lua | 128 |
1 files changed, 67 insertions, 61 deletions
diff --git a/macros/luatex/generic/luaotfload/luaotfload-features.lua b/macros/luatex/generic/luaotfload/luaotfload-features.lua index 01c04becb1..6e64020570 100644 --- a/macros/luatex/generic/luaotfload/luaotfload-features.lua +++ b/macros/luatex/generic/luaotfload/luaotfload-features.lua @@ -5,8 +5,8 @@ assert(luaotfload_module, "This is a part of luaotfload and should not be loaded independently") { name = "luaotfload-features", - version = "3.21", --TAGVERSION - date = "2022-03-18", --TAGDATE + version = "3.22", --TAGVERSION + date = "2022-06-15", --TAGDATE description = "luaotfload submodule / features", license = "GPL v2.0", author = "Hans Hagen, Khaled Hosny, Elie Roux, Philipp Gesang, Marcel Krüger", @@ -30,8 +30,6 @@ local table = table local tabletohash = table.tohash local tablesort = table.sort -local stringunpack = string.unpack - --- this appears to be based in part on luatex-fonts-def.lua local fonts = fonts @@ -56,15 +54,6 @@ else normalize = otf.features.normalize end ---[[HH (font-xtx) -- - tricky: we sort of bypass the parser and directly feed all into - the sub parser ---HH]]-- - -function definers.getspecification(str) - return "", str, "", ":", str -end - local log = luaotfload.log local report = log.report @@ -76,7 +65,7 @@ local function cmp_by_idx (a, b) return a.idx < b.idx end local defined_combos = 0 -local function handle_combination (combo, spec) +local function handle_combination (combo, spec, size) defined_combos = defined_combos + 1 if not combo [1] then report ("both", 0, "features", @@ -143,7 +132,7 @@ local function handle_combination (combo, spec) local basechar = basefnt.characters local baseprop = basefnt.properties - baseprop.name = spec.name + baseprop.name = spec baseprop.virtualized = true basefnt.fonts = fontids @@ -194,13 +183,16 @@ local function handle_combination (combo, spec) " *> font %d / %d: imported %d glyphs into combo.", i, nc, cnt) end - spec.lookup = "combo" - spec.file = basefnt.filename - spec.name = stringformat ("luaotfload<%d>", defined_combos) - spec.features = { normal = { spec.specification } } - spec.forced = "evl" - spec.eval = function () return basefnt end - return spec + return { + lookup = "combo", + file = basefnt.filename, + name = stringformat ("luaotfload<%d>", defined_combos), + specification = spec, + features = { normal = { } }, + forced = "evl", + eval = function () return basefnt end, + size = size, + } end ---[[ begin excerpt from font-ott.lua ]] @@ -359,10 +351,9 @@ do extract_subfont = full_path * sub_expr end ---- spec -> spec -local function handle_request (specification) +local function analyze(spec_string, size) local request = lpegmatch(luaotfload.parsers.font_request, - specification.specification) + spec_string) ----inspect(request) if not request then --- happens when called with an absolute path @@ -370,7 +361,7 @@ local function handle_request (specification) --- we try to behave as friendly as possible --- just go with it ... report("log", 1, "features", "invalid request %q of type anon", - specification.specification) + spec_string) report("log", 1, "features", "use square bracket syntax or consult the documentation.") --- The result of \fontname must be re-feedable into \font @@ -382,36 +373,62 @@ local function handle_request (specification) --- parentheses). --- https://github.com/lualatex/luaotfload/issues/57 local fullpath, sub = lpegmatch(extract_subfont, - specification.specification) + spec_string) if fullpath and sub then - specification.sub = tonumber(sub) or sub - specification.name = fullpath + return { + lookup = 'path', + sub = tonumber(sub) or sub, + name = fullpath, + size = size, + } else - specification.name = specification.specification + return { + lookup = 'path', + name = spec_string, + size = size, + } end - specification.lookup = "path" - return specification end local lookup, name = request.lookup, request.name if lookup == "combo" then - return handle_combination (name, specification) + return handle_combination (name, spec_string, size) end - local features = specification.features - if not features then - features = { } - specification.features = features - end + local features = { + raw = request.features or {} + } - features.raw = request.features or {} - request.features = apply_default_features(features.raw) + local specification = { + specification = spec_string, + size = size, + lookup = lookup, + name = name, + sub = request.sub or false, + features = features, + } - if name then - specification.name = name - specification.lookup = lookup or specification.lookup + if lookup == 'id' then + local original_font = fontidentifiers [request.id] + if not original_font then return end + local original_spec = original_font.specification + if not original_spec then return end + if size < 0 then + specification.size = original_spec.size * size // -1000 + end + specification.lookup = original_spec.lookup + specification.name = original_spec.name + specification.sub = specification.sub or original_spec.sub + specification.style = original_spec.style + specification.optsize = original_spec.optsize + specification.forced = original_spec.forced + if original_spec.features then + features.raw = table.merged(original_spec.features.raw, features.raw) + end end + local processed_features = apply_default_features(features.raw) + if request.modifiers then local style, optsize = handle_slashed(request.modifiers) specification.style, specification.optsize = style, optsize @@ -420,11 +437,11 @@ local function handle_request (specification) for n=1, #import_values do local feat = import_values[n][1] local keep = import_values[n][2] - local newvalue = request.features[feat] + local newvalue = processed_features[feat] if newvalue then - specification[feat] = request.features[feat] + specification[feat] = newvalue if not keep then - request.features[feat] = nil + processed_features[feat] = nil end end end @@ -432,7 +449,7 @@ local function handle_request (specification) --- The next line sets the “rand” feature to “random”; I haven’t --- investigated it any further (luatex-fonts-ext), so it will --- just stay here. - features.normal = normalize (request.features) + features.normal = normalize (processed_features) if features.normal.instance then if features.normal.axis then report("term and log", 0, "features", "instance and axis provided, instance will be ignored") @@ -440,7 +457,6 @@ local function handle_request (specification) specification.instance = features.normal.instance end end - specification.sub = request.sub or specification.sub or false local forced_mode = request.features and request.features.mode if forced_mode then @@ -453,8 +469,7 @@ local function handle_request (specification) return specification end -fonts.names.handle_request = handle_request - +fonts.definers.analyze = analyze if as_script == true then --- skip the remainder of the file report ("log", 5, "features", @@ -463,7 +478,7 @@ if as_script == true then --- skip the remainder of the file end do - local helpers = fonts.handlers.otf.readers.helpers + local helpers = otf.readers.helpers local axistofactors = helpers.axistofactors local cleanname = helpers.cleanname local getaxisscale = helpers.getaxisscale @@ -479,7 +494,7 @@ do function helpers.getfactors(tfmdata, instance) -- `instance` might refer to an `axis` value here assert(instance == true or type(instance) == "string", "Fontloader changed interface of helpers.getfactors. This is a bug, please notify the luaotfload maintainers.") local variabledata = tfmdata.variabledata - if not variabledata or instance == "" then return end + if not variabledata then return end local instances = variabledata.instances local axis = variabledata.axis local designaxis = variabledata.designaxis @@ -525,15 +540,6 @@ do end end --- MK: Added -function fonts.definers.analyze (spec_string, size) - return handle_request { - size = size, - specification = spec_string, - } -end --- /MK - -- We assume that the other otf stuff is loaded already; though there’s -- another check below during the initialization phase. |