Automatically try to detect text fonts

This commit is contained in:
Marcel Fabian Krüger 2023-12-27 15:32:27 +01:00
parent e6d7b73beb
commit 3c033069f3

View File

@ -13,7 +13,22 @@ local left_brace = token.new(string.byte'{', 1)
local right_brace = token.new(string.byte'}', 2) local right_brace = token.new(string.byte'}', 2)
local output_hook_token local output_hook_token
local text_families = {} local global_text_families = {}
local text_families = setmetatable({}, {__index = function(t, fam)
if fam == nil then return nil end
local assignment = global_text_families[fam]
if assignment == nil then
local fid = node.family_font(fam)
local fontdir = font.getfont(fid)
if not fontdir then
-- FIXME(?): If there is no font...
error'Please load your fonts?!?'
end
assignment = not fontdir.MathConstants
end
t[fam] = assignment
return assignment
end})
local properties = node.get_properties_table() local properties = node.get_properties_table()
local mmode, hmode, vmode do local mmode, hmode, vmode do
@ -45,7 +60,7 @@ token.set_lua('RegisterTextFamily', funcid, 'protected')
lua.get_functions_table()[funcid] = function() lua.get_functions_table()[funcid] = function()
local fam = token.scan_int() local fam = token.scan_int()
local _kind = token.scan_string() local _kind = token.scan_string()
text_families[fam] = true global_text_families[fam] = true
end end
local function shallow_copy(t) local function shallow_copy(t)