diff options
Diffstat (limited to 'luaotfload-deferred.lua')
-rw-r--r-- | luaotfload-deferred.lua | 58 |
1 files changed, 40 insertions, 18 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 |