summaryrefslogtreecommitdiff
path: root/otfl-font-nms.lua
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-05-16 19:13:25 +0300
committerKhaled Hosny <khaledhosny@eglug.org>2010-05-16 19:13:25 +0300
commit10c292a735ebafc7870dd342fd0d7739f6bf5af2 (patch)
tree0782fba86f6bcd1b1bb0c79772b128d1c5defe88 /otfl-font-nms.lua
parent36507882318ca56f0b357846ae62ca21e7cddc0f (diff)
downloadluaotfload-10c292a735ebafc7870dd342fd0d7739f6bf5af2.tar.gz
Auto generate font names database
If no font names database is found, generate a new one. Broken unless luatex is run with "--shell-escape".
Diffstat (limited to 'otfl-font-nms.lua')
-rw-r--r--otfl-font-nms.lua32
1 files changed, 16 insertions, 16 deletions
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua
index d708f5b..935500c 100644
--- a/otfl-font-nms.lua
+++ b/otfl-font-nms.lua
@@ -37,6 +37,14 @@ local function sanitize(str)
end
end
+local function fontnames_init()
+ return {
+ mappings = { },
+ status = { },
+ version = names.version,
+ }
+end
+
function names.load()
local localpath = names.path.localdir .. names.path.basename
local systempath = names.path.systemdir .. names.path.basename
@@ -55,8 +63,15 @@ function names.load()
"loaded font names database: %s",
foundname)
end
- return data
+ else
+ logs.report("load font",
+ "no font names database found, generating new one")
+ local fontnames = fontnames_init()
+ local savepath = names.path.localdir .. names.path.basename
+ data = names.update(fontnames, false)
+ io.savedata(savepath, table.serialize(data, true))
end
+ return data
end
local loaded = false
@@ -81,10 +96,6 @@ local synonyms = {
},
}
--- a small hack to get the log message "no font names database loaded" only
--- once in the log
-local log_message_shown = false
-
function names.resolve(specification)
local tfm = resolvers.find_file(specification.name, "ofm")
local name = sanitize(specification.name)
@@ -197,9 +208,6 @@ function names.resolve(specification)
-- no font found so far, fallback to filename
return specification.name, false
end
- elseif not log_message_shown then
- logs.report("load font", "no font names database loaded")
- log_message_shown = true
end
end
@@ -517,14 +525,6 @@ local function scan_os_fonts(fontnames, newfontnames)
end
end
-local function fontnames_init()
- return {
- mappings = { },
- status = { },
- version = names.version,
- }
-end
-
local function update(fontnames, force)
--[[
The main function, scans everything