summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--luaotfload-deferred.lua58
-rw-r--r--luaotfload.lua9
2 files changed, 48 insertions, 19 deletions
diff --git a/luaotfload-deferred.lua b/luaotfload-deferred.lua
index bfbf644..93e8bb2 100644
--- a/luaotfload-deferred.lua
+++ b/luaotfload-deferred.lua
@@ -85,6 +85,19 @@ local define_font_wrapper = function (...)
end
return tfmdata
end
+
+--[[doc--
+We provide a simplified version of the original font definition
+callback.
+--doc]]--
+local patch_defined_font = function (...)
+ local tfmdata = fonts.definers.read(...)
+ if type(tfmdata) == "table" and tfmdata.shared then
+ call_callback("luaotfload.patch_font", tfmdata)
+ end
+ return tfmdata
+end
+
fonts.mode = "node"
function attributes.private(name)
@@ -98,16 +111,21 @@ end
reset_callback("define_font")
-if luaotfload.old_font_definer then
+if luaotfload.font_definer == "old" then
add_to_callback("define_font",
old_define_font_wrapper,
"luaotfload.define_font",
1)
-else -- use default font loader
+elseif luaotfload.font_definer == "generic" then
add_to_callback("define_font",
generic_context.callback_define_font,
"luaotfload.define_font",
1)
+elseif luaotfload.font_definer == "patch" then
+ add_to_callback("define_font",
+ patch_defined_font,
+ "luaotfload.define_font",
+ 1)
end
--luaotfload.loadmodule("font-otc.lua") -- broken
@@ -126,23 +144,27 @@ end
--add_to_callback("find_vf_file",
--fonts.vf.find,
--"luaotfload.find_vf_file")
---local function set_sscale_diments(fontdata)
- --local mc = fontdata.MathConstants
- --if mc then
- --if mc["ScriptPercentScaleDown"] then
- --fontdata.parameters[10] = mc.ScriptPercentScaleDown
- --else -- resort to plain TeX default
- --fontdata.parameters[10] = 70
- --end
- --if mc["ScriptScriptPercentScaleDown"] then
- --fontdata.parameters[11] = mc.ScriptScriptPercentScaleDown
- --else -- resort to plain TeX default
- --fontdata.parameters[11] = 50
- --end
- --end
---end
---luatexbase.add_to_callback("luaotfload.patch_font", set_sscale_diments, "unicodemath.set_sscale_diments")
+local set_sscale_diments = function (tfmdata)
+ local mathconstants = tfmdata.MathConstants
+ if mathconstants then
+ local tfmparameters = tfmdata.parameters
+ if mathconstants.ScriptPercentScaleDown then
+ tfmparameters[10] = mathconstants.ScriptPercentScaleDown
+ else -- resort to plain TeX default
+ tfmparameters[10] = 70
+ end
+ if mathconstants.ScriptScriptPercentScaleDown then
+ tfmparameters[11] = mathconstants.ScriptScriptPercentScaleDown
+ else -- resort to plain TeX default
+ tfmparameters[11] = 50
+ end
+ end
+end
+
+add_to_callback("luaotfload.patch_font",
+ set_sscale_diments,
+ "unicodemath.set_sscale_diments")
-- vim:tw=71:sw=2:ts=2:expandtab
diff --git a/luaotfload.lua b/luaotfload.lua
index 1bfca79..0a3b398 100644
--- a/luaotfload.lua
+++ b/luaotfload.lua
@@ -29,7 +29,14 @@ luaotfload.module = {
license = "CC0"
}
-luaotfload.old_font_definer = false --- toggle wrapper for font loader
+--[[doc--
+No final decision has been made on how to handle font definition.
+At the moment, there are three candidates: The \textsf{generic}
+callback as hard-coded in the font loader, the \textsf{old} wrapper,
+and a simplified version of the latter (\textsf{patch}) that does
+nothing besides applying font patches.
+--doc]]--
+luaotfload.font_definer = "patch" --- | “generic” | “old”
local fl_prefix = "otfl" -- “luatex” for luatex-plain