summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luaotfload/luaotfload-auxiliary.lua
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-01-01 03:04:10 +0000
committerNorbert Preining <norbert@preining.info>2021-01-01 03:04:10 +0000
commit6c6a334f0aa3b95572afe30fa2d17e634c7019ce (patch)
treec544085b81c972031bc7bafb88c32b9f3d3750d6 /macros/luatex/generic/luaotfload/luaotfload-auxiliary.lua
parent80e0ab3c814b0dfd8ff304620dccbdea877f93ba (diff)
CTAN sync 202101010304
Diffstat (limited to 'macros/luatex/generic/luaotfload/luaotfload-auxiliary.lua')
-rw-r--r--macros/luatex/generic/luaotfload/luaotfload-auxiliary.lua58
1 files changed, 50 insertions, 8 deletions
diff --git a/macros/luatex/generic/luaotfload/luaotfload-auxiliary.lua b/macros/luatex/generic/luaotfload/luaotfload-auxiliary.lua
index 14a66da359..2d4e757bc0 100644
--- a/macros/luatex/generic/luaotfload/luaotfload-auxiliary.lua
+++ b/macros/luatex/generic/luaotfload/luaotfload-auxiliary.lua
@@ -4,19 +4,14 @@
-- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang
-----------------------------------------------------------------------
-local ProvidesLuaModule = {
+assert(luaotfload_module, "This is a part of luaotfload and should not be loaded independently") {
name = "luaotfload-auxiliary",
- version = "3.15", --TAGVERSION
- date = "2020-09-02", --TAGDATE
+ version = "3.16", --TAGVERSION
+ date = "2020-12-31", --TAGDATE
description = "luaotfload submodule / auxiliary functions",
license = "GPL v2.0"
}
-if luatexbase and luatexbase.provides_module then
- luatexbase.provides_module (ProvidesLuaModule)
-end
-
-
luaotfload = luaotfload or { }
local log = luaotfload.log
local logreport = log.report
@@ -912,6 +907,53 @@ function aux.get_quad(font_id)
end
-----------------------------------------------------------------------
+--- Script/language fixup
+-----------------------------------------------------------------------
+local otftables = fonts.constructors.handlers.otf.tables
+local function setscript(tfmdata, value)
+ if value then
+ local cleanvalue = string.lower(value)
+ local scripts = otftables and otftables.scripts
+ local properties = tfmdata.properties
+ if not scripts then
+ properties.script = cleanvalue
+ elseif scripts[value] then
+ properties.script = cleanvalue
+ else
+ properties.script = "dflt"
+ end
+ end
+ local resources = tfmdata.resources
+ local features = resources and resources.features
+ if features then
+ local properties = tfmdata.properties
+ local script, language = properties.script, properties.language
+ local script_found, language_found = false, false
+ for _, data in next, features do for _, feature_data in next, data do
+ local scr = feature_data[script]
+ if scr then
+ script_found = true
+ if scr[language] then
+ language_found = true
+ goto double_break
+ end
+ end
+ end end
+ ::double_break::
+ if not script_found then properties.script = "dflt" end
+ if not language_found then properties.language = "dflt" end
+ end
+end
+fonts.constructors.features.otf.register {
+ name = "script",
+ initializers = {
+ base = setscript,
+ node = setscript,
+ plug = setscript,
+ },
+}
+
+-----------------------------------------------------------------------
--- initialization
-----------------------------------------------------------------------