summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luaotfload/luaotfload-init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/generic/luaotfload/luaotfload-init.lua')
-rw-r--r--macros/luatex/generic/luaotfload/luaotfload-init.lua50
1 files changed, 37 insertions, 13 deletions
diff --git a/macros/luatex/generic/luaotfload/luaotfload-init.lua b/macros/luatex/generic/luaotfload/luaotfload-init.lua
index cfbcb68eab..3b67738fe5 100644
--- a/macros/luatex/generic/luaotfload/luaotfload-init.lua
+++ b/macros/luatex/generic/luaotfload/luaotfload-init.lua
@@ -5,17 +5,13 @@
-- AUTHOR: Philipp Gesang (Phg), <phg@phi-gamma.net>, Marcel Krüger
-----------------------------------------------------------------------
-local ProvidesLuaModule = {
+assert(luaotfload_module, "This is a part of luaotfload and should not be loaded independently") {
name = "luaotfload-init",
- version = "3.15", --TAGVERSION
- date = "2020-09-02", --TAGDATE
+ version = "3.16", --TAGVERSION
+ date = "2020-12-31", --TAGDATE
description = "luaotfload submodule / initialization",
license = "GPL v2.0"
}
-
-if luatexbase and luatexbase.provides_module then
- luatexbase.provides_module (ProvidesLuaModule)
-end
-----------------------------------------------------------------------
@@ -299,7 +295,6 @@ local function init_main(early_hook)
local saved_exit = os.exit
local errmsg
function texio.reporter(msg, ...)
- print(...)
errmsg = msg
end
function os.exit()
@@ -407,6 +402,11 @@ local function init_main(early_hook)
-- fontloader
end --- [init_main]
+if not luatexbase.callbacktypes.pre_shaping_filter then
+ luatexbase.create_callback('pre_shaping_filter', 'list')
+ luatexbase.create_callback('post_shaping_filter', 'reverselist')
+end
+
local init_post_install_callbacks = function ()
--[[doc--
@@ -423,17 +423,42 @@ local init_post_install_callbacks = function ()
local fallback = luaotfload.loaders.luaotfload "fallback".process
local multiscript = luaotfload.loaders.luaotfload "multiscript".process
- -- MK Pass current text direction to simple_font_handler
+ local call_callback = luatexbase.call_callback
+ local tex_get = tex.get
+ local flush_list = node.flush_list
local handler = luaotfload.fontloader.nodes.simple_font_handler
- local callback = function(head, groupcode, _, _, direction)
+ local function callback(head, groupcode, _, _, direction)
if not direction then
- direction = tex.get'textdirection'
+ direction = tex_get'textdirection'
else
direction = direction == "TRT" and 1 or 0
end
+ local result = call_callback("pre_shaping_filter", head, groupcode, direction)
+ if result == false then
+ return false
+ elseif result ~= true then
+ head = result
+ end
multiscript(head, nil, nil, nil, direction)
fallback(head, nil, nil, nil, direction)
- return handler(head, groupcode, nil, nil, direction)
+ result = handler(head, groupcode, nil, nil, direction)
+ -- handler never returns a boolean and only returns nil if it was passed in
+ -- We keep it general though for consistency
+ if result == false then
+ flush_list(head)
+ return nil
+ elseif result ~= true then
+ head = result
+ end
+ result = call_callback("post_shaping_filter", head, groupcode, direction)
+ if result == false then
+ flush_list(head)
+ return nil
+ elseif result == true then
+ return head
+ else
+ return result
+ end
end
luatexbase.add_to_callback("pre_linebreak_filter",
callback,
@@ -443,7 +468,6 @@ local init_post_install_callbacks = function ()
callback,
"luaotfload.node_processor",
1)
- -- /MK
local streams = fonts.hashes.streams
luatexbase.add_to_callback("glyph_stream_provider",function(id,index,mode)