From d16a93579dfec03a0dab4281b45f63d877fc4c88 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 26 Apr 2013 22:33:37 +0200 Subject: install the new file: lookup in luaotfload.lua --- luaotfload-database.lua | 35 +++++++++++++++++++++-------------- luaotfload-features.lua | 17 +++++++++++------ luaotfload.dtx | 15 +++++++++++++-- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 4980766..576971e 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -230,6 +230,8 @@ local load_lua_file = function (path) end --- define locals in scope +local crude_file_lookup +local crude_file_lookup_verbose local find_closest local flush_cache local font_fullinfo @@ -290,8 +292,12 @@ do end --- chain: barenames -> [fullnames ->] basenames -> findfile -local crude_file_lookup_verbose = function (data, filename) - local mappings = data.mappings + +--- string -> (string * bool | int) +crude_file_lookup_verbose = function (filename) + if not names.data then names.data = names_reload() end + local data = names.data + local mappings = data.mappings local found --- look up in db first ... @@ -336,7 +342,11 @@ local crude_file_lookup_verbose = function (data, filename) return false end -local crude_file_lookup = function (data, filename) +--- string -> (string * bool | int) +crude_file_lookup = function (filename) + if not names.data then names.data = names_reload() end + local data = names.data + local mappings = data.mappings local found = data.barenames[filename] -- or data.fullnames[filename] or data.basenames[filename] @@ -470,6 +480,7 @@ local resolvers = { fonts.definers.resolve = resolvers[config.luaotfload.resolver] --fonts.definers.resolve = resolvers.cached +fonts.definers.resolve = resolvers.dummy --[[doc-- @@ -513,12 +524,6 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con if not fonts_loaded then names.data = load_names() end local data = names.data - if specification.lookup == "file" then - local found = crude_file_lookup(data, specification.name) - --local found = crude_file_lookup_verbose(data, specification.name) - if found then return found[1], found[2], true end - end - local name = sanitize_string(specification.name) local style = sanitize_string(specification.style) or "regular" @@ -1380,11 +1385,13 @@ scan_external_dir = function (dir) end --- export functionality to the namespace “fonts.names” -names.flush_cache = flush_cache -names.load = load_names -names.save = save_names -names.scan = scan_external_dir -names.update = update_names +names.flush_cache = flush_cache +names.load = load_names +names.save = save_names +names.scan = scan_external_dir +names.update = update_names +names.crude_file_lookup = crude_file_lookup +names.crude_file_lookup_verbose = crude_file_lookup_verbose names.resolve = resolve --- replace the resolver from luatex-fonts names.resolvespec = resolve diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 78f8256..0171dba 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -163,7 +163,7 @@ local set_default_features = function (speclist) return speclist end -local function issome () feature_list.lookup = 'name' end +local function issome () feature_list.lookup = 'file' end local function isfile () feature_list.lookup = 'file' end local function isname () feature_list.lookup = 'name' end local function thename(s) feature_list.name = s end @@ -180,7 +180,8 @@ local spaces = P(" ")^0 local namespec = (1-S("/:("))^1 local filespec = (R("az", "AZ") * P(":"))^-1 * (1-S(":("))^1 local stylespec = spaces * P("/") * (((1-P(":"))^0)/isstyle) * spaces -local filename = (P("file:")/isfile * (filespec/thename)) + (P("[") * P(true)/isname * (((1-P("]"))^0)/thename) * P("]")) +local filename = (P("file:")/isfile * (filespec/thename)) + + (P("[") * P(true)/isname * (((1-P("]"))^0)/thename) * P("]")) local fontname = (P("name:")/isname * (namespec/thename)) + P(true)/issome * (namespec/thename) local sometext = (R("az","AZ","09") + S("+-.,"))^1 local truevalue = P("+") * spaces * (sometext/istrue) @@ -216,10 +217,12 @@ local function colonized(specification) -- xetex mode specification.name = feature_list.name feature_list.name = nil end - if feature_list.lookup then - specification.lookup = feature_list.lookup - feature_list.lookup = nil - end + --- this test overwrites valid file: requests for xetex bracket + --- syntax +-- if feature_list.lookup then +-- specification.lookup = feature_list.lookup +-- feature_list.lookup = nil +-- end if feature_list.sub then specification.sub = feature_list.sub feature_list.sub = nil @@ -229,6 +232,8 @@ local function colonized(specification) -- xetex mode feature_list.mode = fonts.mode end specification.features.normal = fonts.handlers.otf.features.normalize(feature_list) + --inspect(specification) + --os.exit() return specification end diff --git a/luaotfload.dtx b/luaotfload.dtx index 18e01d8..8b3616a 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1328,7 +1328,7 @@ add_to_callback("find_vf_file", loadmodule"lib-dir.lua" --- required by luaofload-database.lua loadmodule"override.lua" --- “luat-ovr” -logs.set_loglevel(0) +logs.set_loglevel(config.luaotfload.loglevel or 2) % \end{macrocode} % \CONTEXT does not support ofm, these lines were added in order to make it @@ -1365,8 +1365,19 @@ loadmodule"colors.lua" --- “font-clr” % % \begin{macrocode} +--- below lines already (2013-04-25) lead to warnings by +--- the font loader +--fonts.definers.resolvers.file = function (specification) +-- specification.name = fonts.names.resolve('', '', specification) +--end + fonts.definers.resolvers.file = function (specification) - specification.name = fonts.names.resolve('', '', specification) + --inspect(specification) + if specification.lookup == "file" then + local found = fonts.names.crude_file_lookup(specification.name) + --local found = fonts.names.crude_file_lookup_verbose(specification.name) + specification.name = found[1] + end end % \end{macrocode} -- cgit v1.2.3