From 77e16fb8cde7fb30b4654311a8d7933524acd665 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Mon, 17 May 2010 07:57:34 +0300 Subject: Only index the last found instance of a font We were keeping previously found versions of the font in the database and only overriding the status[filename].index which is useless since names.resolve will then found the first instance. --- otfl-font-nms.lua | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index a31c37a..a3bc7e1 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -340,19 +340,22 @@ local function load_font(filename, fontnames, newfontnames, texmf) local status = fontnames.status local basefile = texmf and basename(filename) or filename if filename then + local timestamp, db_timestamp + db_timestamp = status[basefile] and status[basefile].timestamp + timestamp = lfs.attributes(filename, "modification") + if newstatus[basefile] then -- already indexed in this run - return + if newstatus[basefile].timestamp == timestamp then + return + end end - local timestamp, db_timestamp - db_timestamp = status[basefile] and status[basefile].timestamp - timestamp = lfs.attributes(filename, "modification") - newstatus[basefile] = { } + newstatus[basefile] = newstatus[basefile] or { } newstatus[basefile].timestamp = timestamp - newstatus[basefile].index = {} + newstatus[basefile].index = newstatus[basefile].index or { } - if db_timestamp == timestamp or nd_timestamp == timestamp then + if db_timestamp == timestamp then for _,v in ipairs(status[basefile].index) do local index = #newstatus[basefile].index newmappings[#newmappings+1] = mappings[v] @@ -371,14 +374,25 @@ local function load_font(filename, fontnames, newfontnames, texmf) if type(info) == "table" and #info > 1 then for i in ipairs(info) do local fullinfo = font_fullinfo(filename, i-1, texmf) - local index = #newstatus[basefile].index - newmappings[#newmappings+1] = fullinfo - newstatus[basefile].index[index+1] = #newmappings + local index = newstatus[basefile].index[i] + if newstatus[basefile].index[i] then + index = newstatus[basefile].index[i] + else + index = #newmappings+1 + end + newmappings[index] = fullinfo + newstatus[basefile].index[i] = index end else local fullinfo = font_fullinfo(filename, false, texmf) - newmappings[#newmappings+1] = fullinfo - newstatus[basefile].index[1] = #newmappings + local index + if newstatus[basefile].index[1] then + index = newstatus[basefile].index[1] + else + index = #newmappings+1 + end + newmappings[index] = fullinfo + newstatus[basefile].index[1] = index end else if trace_loading then -- cgit v1.2.3