summaryrefslogtreecommitdiff
path: root/otfl-font-nms.lua
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-05-17 06:31:25 +0300
committerKhaled Hosny <khaledhosny@eglug.org>2010-05-17 06:38:31 +0300
commit76a32b5d836c6dd63e5fe1f9cd8e778294deddea (patch)
treed64b71af1993e77dde98d223f4a299208473103e /otfl-font-nms.lua
parent0720db026ba8fc1f2cf3791a8d4d868b8c0c8d4d (diff)
downloadluaotfload-76a32b5d836c6dd63e5fe1f9cd8e778294deddea.tar.gz
Measures to avoid re-scanning files
We now index TEXMF fonts by their base names not absolute paths, and we check if the font already indexed. This simplifies other parts of the code.
Diffstat (limited to 'otfl-font-nms.lua')
-rw-r--r--otfl-font-nms.lua53
1 files changed, 27 insertions, 26 deletions
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua
index 1f9da96..a31c37a 100644
--- a/otfl-font-nms.lua
+++ b/otfl-font-nms.lua
@@ -11,7 +11,7 @@ fonts.names = fonts.names or { }
local names = fonts.names
local names_dir = "/luatex/generic/luaotfload/names/"
-names.version = 2.008 -- not the same as in context
+names.version = 2.009 -- not the same as in context
names.data = nil
names.path = {
basename = "otfl-names.lua",
@@ -338,44 +338,51 @@ local function load_font(filename, fontnames, newfontnames, texmf)
local newstatus = newfontnames.status
local mappings = fontnames.mappings
local status = fontnames.status
+ local basefile = texmf and basename(filename) or filename
if filename then
+ if newstatus[basefile] then
+ -- already indexed in this run
+ return
+ end
+
local timestamp, db_timestamp
- db_timestamp = status[filename] and status[filename].timestamp
+ db_timestamp = status[basefile] and status[basefile].timestamp
timestamp = lfs.attributes(filename, "modification")
- newstatus[filename] = { }
- newstatus[filename].timestamp = timestamp
- newstatus[filename].index = {}
- if db_timestamp == timestamp then
- for _,v in ipairs(status[filename].index) do
- local index = #newstatus[filename].index
+ newstatus[basefile] = { }
+ newstatus[basefile].timestamp = timestamp
+ newstatus[basefile].index = {}
+
+ if db_timestamp == timestamp or nd_timestamp == timestamp then
+ for _,v in ipairs(status[basefile].index) do
+ local index = #newstatus[basefile].index
newmappings[#newmappings+1] = mappings[v]
- newstatus[filename].index[index+1] = #newmappings
+ newstatus[basefile].index[index+1] = #newmappings
end
if trace_loading then
- logs.report("font already indexed: %s", filename)
+ logs.report("font already indexed: %s", basefile)
end
return
end
if trace_loading then
- logs.report("loading font: %s", filename)
+ logs.report("loading font: %s", basefile)
end
local info = fontloader.info(filename)
if info then
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[filename].index
+ local index = #newstatus[basefile].index
newmappings[#newmappings+1] = fullinfo
- newstatus[filename].index[index+1] = #newmappings
+ newstatus[basefile].index[index+1] = #newmappings
end
else
local fullinfo = font_fullinfo(filename, false, texmf)
newmappings[#newmappings+1] = fullinfo
- newstatus[filename].index[1] = #newmappings
+ newstatus[basefile].index[1] = #newmappings
end
else
if trace_loading then
- logs.report("failed to load %s", filename)
+ logs.report("failed to load %s", basefile)
end
end
end
@@ -450,21 +457,15 @@ local function scan_texmf_tree(fontnames, newfontnames)
logs.report("scanning TEXMF and OS fonts:")
end
end
- local fontdirs = expandpath("$OPENTYPEFONTS")
- fontdirs = fontdirs .. gsub(expandpath("$TTFONTS"), "^\.", "")
+ local fontdirs = expandpath("$OPENTYPEFONTS"):gsub("^\.", "")
+ fontdirs = fontdirs .. expandpath("$TTFONTS"):gsub("^\.", "")
if not fontdirs:is_empty() then
- local explored_dirs = {}
fontdirs = splitpath(fontdirs)
- -- hack, don't scan current dir
- table.remove(fontdirs, 1)
count = 0
for _,d in ipairs(fontdirs) do
- if not explored_dirs[d] then
- count = count + 1
- progress(count, #fontdirs)
- scan_dir(d, fontnames, newfontnames, true)
- explored_dirs[d] = true
- end
+ count = count + 1
+ progress(count, #fontdirs)
+ scan_dir(d, fontnames, newfontnames, true)
end
end
end