From 3cbef76101d9aaef3b2c355c58675bf9f386d949 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 21 May 2010 06:46:45 +0300 Subject: Sync with ConTeXt beta (beta 2010.05.20) --- otfl-font-dum.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'otfl-font-dum.lua') diff --git a/otfl-font-dum.lua b/otfl-font-dum.lua index 5224ae1..2de1ae1 100644 --- a/otfl-font-dum.lua +++ b/otfl-font-dum.lua @@ -55,11 +55,14 @@ fonts.names.old_to_new = { } local data, loaded = nil, false +local fileformats = { "lua", "tex", "other text files" } + function fonts.names.resolve(name,sub) if not loaded then local basename = fonts.names.basename if basename and basename ~= "" then - for _, format in ipairs { "lua", "tex", "other text files" } do + for i=1,#fileformats do + local format = fileformats[i] local foundname = resolvers.find_file(basename,format) or "" if foundname ~= "" then data = dofile(foundname) @@ -356,3 +359,23 @@ fonts.otf.meanings.normalize = fonts.otf.meanings.normalize or function(t) t.rand = "random" end end + +-- bonus + +function fonts.otf.name_to_slot(name) + local tfmdata = fonts.ids[font.current()] + if tfmdata and tfmdata.shared then + local otfdata = tfmdata.shared.otfdata + local unicode = otfdata.luatex.unicodes[name] + return unicode and (type(unicode) == "number" and unicode or unicode[1]) + end +end + +function fonts.otf.char(n) + if type(n) == "string" then + n = fonts.otf.name_to_slot(n) + end + if type(n) == "number" then + tex.sprint("\\char" .. n) + end +end -- cgit v1.2.3