From 1f8bcae1bfd697adf582d2a6c1add145eb304f9b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 1 Sep 2013 19:43:00 +0200 Subject: [db] refactor fontname extraction --- luaotfload-tool.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index c4670e8..1ef74fb 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -172,7 +172,7 @@ local status_file = "luaotfload-status" local luaotfloadstatus = require (status_file) config.luaotfload.status = luaotfloadstatus -local sanitize_string = names.sanitize_string +local sanitize_fontname = names.sanitize_fontname local pathdata = names.path local names_plain = pathdata.index.lua @@ -656,7 +656,7 @@ subfont_by_name = function (lst, askedname, n) local font = lst[n] if font then - if sanitize_string(font.fullname) == askedname then + if sanitize_fontname (font.fullname) == askedname then return font end return subfont_by_name (lst, askedname, n+1) @@ -676,7 +676,7 @@ local show_font_info = function (basename, askedname, detail, warnings) local filenames = names.data.filenames local index = filenames.base[basename] local fullname = filenames.full[index] - askedname = sanitize_string(askedname) + askedname = sanitize_fontname (askedname) if not fullname then -- texmf fullname = resolvers.findfile(basename) end -- cgit v1.2.3 From e29c39733ad90a0ca354808aef71b1b2e0acc9c9 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 1 Sep 2013 23:49:14 +0200 Subject: [tool] include stats on demand only (--stats option) --- luaotfload-tool.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 1ef74fb..9739e17 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -1068,6 +1068,7 @@ local process_cmdline = function ( ) -- unit -> jobspec fields = 1, find = 1, force = "f", + formats = 1, fuzzy = "F", help = "h", info = "i", @@ -1079,14 +1080,14 @@ local process_cmdline = function ( ) -- unit -> jobspec ["prefer-texmf"] = "p", quiet = "q", ["show-blacklist"] = "b", - formats = 1, + stats = "S", update = "u", verbose = 1, version = "V", warnings = "w", } - local short_options = "bDfFiIlnpquvVhw" + local short_options = "bDfFiIlnpqSuvVhw" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -1156,7 +1157,7 @@ local process_cmdline = function ( ) -- unit -> jobspec result.cache = optarg[n] elseif v == "D" then result.dry_run = true - elseif v == "p" then + elseif v == "p" then --- TODO adapt to new db structure config.luaotfload.prioritize = "texmf" elseif v == "b" then action_pending["blacklist"] = true @@ -1167,6 +1168,8 @@ local process_cmdline = function ( ) -- unit -> jobspec names.set_font_filter (optarg[n]) elseif v == "n" then config.luaotfload.update_live = false + elseif v == "S" then + config.luaotfload.statistics = true end end -- cgit v1.2.3 From 9ab1917e9b492abaef43a9d9a45ceba23391003f Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 15 Sep 2013 22:46:21 +0200 Subject: [tool] add option to skip reading font files --- luaotfload-tool.lua | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 9739e17..e410d44 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -102,13 +102,16 @@ to be the more appropriate. config = config or { } local config = config -config.luaotfload = config.luaotfload or { } -config.luaotfload.version = config.luaotfload.version or version -config.luaotfload.names_dir = config.luaotfload.names_dir or "names" -config.luaotfload.cache_dir = config.luaotfload.cache_dir or "fonts" -config.luaotfload.index_file = config.luaotfload.index_file +local luaotfloadconfig = config.luaotfload or { } +config.luaotfload = luaotfloadconfig +luaotfloadconfig.version = luaotfloadconfig.version or version +luaotfloadconfig.names_dir = luaotfloadconfig.names_dir or "names" +luaotfloadconfig.cache_dir = luaotfloadconfig.cache_dir or "fonts" +luaotfloadconfig.index_file = luaotfloadconfig.index_file or "luaotfload-names.lua" -config.luaotfload.formats = config.luaotfload.formats or "otf,ttf,ttc,dfont" +luaotfloadconfig.formats = luaotfloadconfig.formats + or "otf,ttf,ttc,dfont" +luaotfloadconfig.reload = false do -- we don’t have file.basename and the likes yet, so inline parser ftw local slash = P"/" @@ -122,9 +125,9 @@ do -- we don’t have file.basename and the likes yet, so inline parser ftw local self = lpegmatch(p_basename, stringlower(arg[0])) if self == "luaotfload-tool" then - config.luaotfload.self = "luaotfload-tool" + luaotfloadconfig.self = "luaotfload-tool" else - config.luaotfload.self = "mkluatexfontdb" + luaotfloadconfig.self = "mkluatexfontdb" end end @@ -170,7 +173,7 @@ local names = fonts.names local status_file = "luaotfload-status" local luaotfloadstatus = require (status_file) -config.luaotfload.status = luaotfloadstatus +luaotfloadconfig.status = luaotfloadstatus local sanitize_fontname = names.sanitize_fontname @@ -283,16 +286,16 @@ Enter 'luaotfload-tool --help' for a larger list of options. local help_msg = function (version) local template = help_messages[version] iowrite(stringformat(template, - config.luaotfload.self, + luaotfloadconfig.self, names_plain, names_bin, caches.getwritablepath ( - config.luaotfload.cache_dir))) + luaotfloadconfig.cache_dir))) end local version_msg = function ( ) local out = function (...) texiowrite_nl (stringformat (...)) end - out ("%s version %q", config.luaotfload.self, version) + out ("%s version %q", luaotfloadconfig.self, version) out ("revision %q", luaotfloadstatus.notes.revision) out ("database version %q", names.version) out ("Lua interpreter: %s; version %q", runtime[1], runtime[2]) @@ -1077,6 +1080,7 @@ local process_cmdline = function ( ) -- unit -> jobspec list = 1, log = 1, ["no-reload"] = "n", + ["skip-read"] = "R", ["prefer-texmf"] = "p", quiet = "q", ["show-blacklist"] = "b", @@ -1087,7 +1091,7 @@ local process_cmdline = function ( ) -- unit -> jobspec warnings = "w", } - local short_options = "bDfFiIlnpqSuvVhw" + local short_options = "bDfFiIlnpqRSuvVhw" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -1144,7 +1148,7 @@ local process_cmdline = function ( ) -- unit -> jobspec result.show_info = true result.full_info = true elseif v == "alias" then - config.luaotfload.self = optarg[n] + luaotfloadconfig.self = optarg[n] elseif v == "l" then action_pending["flush"] = true elseif v == "list" then @@ -1158,7 +1162,7 @@ local process_cmdline = function ( ) -- unit -> jobspec elseif v == "D" then result.dry_run = true elseif v == "p" then --- TODO adapt to new db structure - config.luaotfload.prioritize = "texmf" + luaotfloadconfig.prioritize = "texmf" elseif v == "b" then action_pending["blacklist"] = true elseif v == "diagnose" then @@ -1167,13 +1171,16 @@ local process_cmdline = function ( ) -- unit -> jobspec elseif v == "formats" then names.set_font_filter (optarg[n]) elseif v == "n" then - config.luaotfload.update_live = false + luaotfloadconfig.update_live = false elseif v == "S" then - config.luaotfload.statistics = true + luaotfloadconfig.statistics = true + elseif v == "R" then + --- dev only, undocumented + luaotfloadconfig.skip_read = true end end - if config.luaotfload.self == "mkluatexfontdb" then + if luaotfloadconfig.self == "mkluatexfontdb" then --- TODO drop legacy ballast after 2.4 result.help_version = "mkluatexfontdb" action_pending["generate"] = true result.log_level = math.max(1, result.log_level) -- cgit v1.2.3 From 5e5f8de85320ba0ed005fc1676e6df4d877845df Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 3 Nov 2013 19:30:46 +0100 Subject: [db,tool] add --compress option for gzipping the index --- luaotfload-tool.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index e410d44..f2dd98a 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -1065,6 +1065,7 @@ local process_cmdline = function ( ) -- unit -> jobspec local long_options = { alias = 1, cache = 1, + compress = "c", diagnose = 1, ["dry-run"] = "D", ["flush-lookups"] = "l", @@ -1091,7 +1092,7 @@ local process_cmdline = function ( ) -- unit -> jobspec warnings = "w", } - local short_options = "bDfFiIlnpqRSuvVhw" + local short_options = "bcDfFiIlnpqRSuvVhw" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -1177,6 +1178,8 @@ local process_cmdline = function ( ) -- unit -> jobspec elseif v == "R" then --- dev only, undocumented luaotfloadconfig.skip_read = true + elseif v == "c" then + luaotfloadconfig.compress = true end end -- cgit v1.2.3 From 352272f48743f785c3a0cea0dcf4e76efc3270e5 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 3 Nov 2013 19:35:13 +0100 Subject: [news,man] mentions --compress in the appropriate places --- luaotfload-tool.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index f2dd98a..ab1d4d9 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -214,6 +214,7 @@ This tool is part of the luaotfload package. Valid options are: -u --update update the database -n --no-reload suppress db update -f --force force re-indexing all fonts + -c --compress gzip index file (text version only) -l --flush-lookups empty lookup cache of font requests -D --dry-run skip loading of fonts, just scan --formats=[+|-]EXTENSIONS set, add, or subtract formats to index -- cgit v1.2.3 From 8e65e677bb678de920ea55097b8889b4245c0e15 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 4 Nov 2013 20:45:27 +0100 Subject: [db] stop exposing the global index object --- luaotfload-tool.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index ab1d4d9..7c2beda 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -677,7 +677,7 @@ The font info knows two levels of detail: --doc]]-- local show_font_info = function (basename, askedname, detail, warnings) - local filenames = names.data.filenames + local filenames = names.data().filenames local index = filenames.base[basename] local fullname = filenames.full[index] askedname = sanitize_fontname (askedname) @@ -775,7 +775,7 @@ actions.generate = function (job) fontnames = names.update(fontnames, job.force_reload, job.dry_run) logs.names_report("info", 2, "db", "Fonts in the database: %i", #fontnames.mappings) - if names.data then + if names.data() then return true, true end return false, false @@ -933,8 +933,9 @@ local splitcomma = names.patterns.splitcomma actions.list = function (job) local criterion = job.criterion - local asked_fields = job.asked_fields + local name_index = names.data () + if asked_fields then asked_fields = lpegmatch(splitcomma, asked_fields) else @@ -942,11 +943,11 @@ actions.list = function (job) asked_fields = { "fullname", "version", } end - if not names.data then - names.data = names.load() + if not name_index then + name_index = names.load() end - local mappings = names.data.mappings + local mappings = name_index.mappings local nmappings = #mappings if criterion == "*" then -- cgit v1.2.3 From 847b5a1a519b3945a1734f5859a80d459e865457 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 5 Nov 2013 15:07:11 +0100 Subject: [db,tool] adapt --find to new db model --- luaotfload-tool.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 7c2beda..f9071d9 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -837,7 +837,7 @@ actions.query = function (job) if tmpspec.lookup == "name" or tmpspec.lookup == "anon" --- not *exactly* as resolvers.anon then - foundname, subfont = names.resolve (nil, nil, tmpspec) + foundname, subfont = names.resolve_name (tmpspec) if foundname then foundname, _, success = names.crude_file_lookup (foundname) end -- cgit v1.2.3 From f07090bcb38819badfbef38e0f929aab57ee8501 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 5 Nov 2013 15:49:19 +0100 Subject: [tool] adapt ``--list`` --- luaotfload-tool.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index f9071d9..29d3a43 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -138,6 +138,7 @@ config.lualibs.load_extended = true require "lualibs" local tabletohash = table.tohash +local stringsplit = string.split --[[doc-- \fileent{luatex-basics-gen.lua} calls functions from the @@ -882,14 +883,19 @@ end local get_fields get_fields = function (entry, fields, acc, n) if not acc then - return get_fields(entry, fields, { }, 1) + return get_fields (entry, fields, { }, 1) end - local field = fields[n] + local field = fields [n] if field then - local value = entry[field] + local chain = stringsplit (field, "->") + local tmp = entry + for i = 1, #chain - 1 do + tmp = tmp [chain [i]] + end + local value = tmp [chain [#chain]] acc[#acc+1] = value or false - return get_fields(entry, fields, acc, n+1) + return get_fields (entry, fields, acc, n+1) end return acc end @@ -940,7 +946,7 @@ actions.list = function (job) asked_fields = lpegmatch(splitcomma, asked_fields) else --- some defaults - asked_fields = { "fullname", "version", } + asked_fields = { "names->fullname", "version", } end if not name_index then @@ -1019,6 +1025,8 @@ actions.list = function (job) end end + texiowrite_nl "" + return true, true end -- cgit v1.2.3 From 80747ab46772d786b2adf066cd2db0ede11457bb Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 5 Nov 2013 15:51:36 +0100 Subject: [tool] fall back to defaults with empty --fields query --- luaotfload-tool.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 29d3a43..3d149d0 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -944,7 +944,9 @@ actions.list = function (job) if asked_fields then asked_fields = lpegmatch(splitcomma, asked_fields) - else + end + + if not asked_fields then --- some defaults asked_fields = { "names->fullname", "version", } end -- cgit v1.2.3 From bf255ef48e5b7710008141e4935183d8ca9a42aa Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 5 Nov 2013 16:05:54 +0100 Subject: [tool] adapt --list queries with criterion --- luaotfload-tool.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 3d149d0..17d9399 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -993,7 +993,12 @@ actions.list = function (job) local categories, by_category = { }, { } for i=1, nmappings do local entry = mappings[i] - local value = entry[criterion] + local tmp = entry + local chain = stringsplit (criterion, "->") + for i = 1, #chain - 1 do + tmp = tmp [chain [i]] + end + local value = tmp [chain [#chain]] if value then --value = tostring(value) local entries = by_category[value] -- cgit v1.2.3 From 8fbfd38b52e4e4c6381d10610211a5e66140c0c1 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 5 Nov 2013 16:17:45 +0100 Subject: [tool] protect --list and --field against invalid queries --- luaotfload-tool.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 17d9399..3bae175 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -892,9 +892,17 @@ local get_fields get_fields = function (entry, fields, acc, n) local tmp = entry for i = 1, #chain - 1 do tmp = tmp [chain [i]] + if not tmp then + --- invalid field + break + end + end + if tmp then + local value = tmp [chain [#chain]] + acc[#acc+1] = value or false + else + acc[#acc+1] = false end - local value = tmp [chain [#chain]] - acc[#acc+1] = value or false return get_fields (entry, fields, acc, n+1) end return acc @@ -997,8 +1005,11 @@ actions.list = function (job) local chain = stringsplit (criterion, "->") for i = 1, #chain - 1 do tmp = tmp [chain [i]] + if not tmp then + break + end end - local value = tmp [chain [#chain]] + local value = tmp and tmp [chain [#chain]] or "" if value then --value = tostring(value) local entries = by_category[value] -- cgit v1.2.3 From e83bdce6f53216620ae959fd55ba7025569d7e44 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 5 Nov 2013 20:07:34 +0100 Subject: [tool] add --no-strip option --- luaotfload-tool.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 3bae175..f7ac215 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -112,6 +112,9 @@ luaotfloadconfig.index_file = luaotfloadconfig.index_file luaotfloadconfig.formats = luaotfloadconfig.formats or "otf,ttf,ttc,dfont" luaotfloadconfig.reload = false +if not luaotfloadconfig.strip then + luaotfloadconfig.strip = true +end do -- we don’t have file.basename and the likes yet, so inline parser ftw local slash = P"/" @@ -214,6 +217,7 @@ This tool is part of the luaotfload package. Valid options are: -u --update update the database -n --no-reload suppress db update + --no-strip keep redundant information in db -f --force force re-indexing all fonts -c --compress gzip index file (text version only) -l --flush-lookups empty lookup cache of font requests @@ -1109,6 +1113,7 @@ local process_cmdline = function ( ) -- unit -> jobspec list = 1, log = 1, ["no-reload"] = "n", + ["no-strip"] = 0, ["skip-read"] = "R", ["prefer-texmf"] = "p", quiet = "q", @@ -1208,6 +1213,8 @@ local process_cmdline = function ( ) -- unit -> jobspec luaotfloadconfig.skip_read = true elseif v == "c" then luaotfloadconfig.compress = true + elseif v == "no-strip" then + luaotfloadconfig.strip = false end end -- cgit v1.2.3 From a59332596c26d57b84a609749f7b677683bde029 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 5 Nov 2013 20:10:48 +0100 Subject: [tool,man] adapt default fields for --list and --fields to stripped index format --- luaotfload-tool.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index f7ac215..737485f 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -960,7 +960,7 @@ actions.list = function (job) if not asked_fields then --- some defaults - asked_fields = { "names->fullname", "version", } + asked_fields = { "plainname", "version", } end if not name_index then -- cgit v1.2.3