summaryrefslogtreecommitdiff
path: root/luaotfload-database.lua
diff options
context:
space:
mode:
Diffstat (limited to 'luaotfload-database.lua')
-rw-r--r--luaotfload-database.lua52
1 files changed, 32 insertions, 20 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index 4632626..1deca07 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -86,7 +86,7 @@ local tablefastcopy = table.fastcopy
local tabletofile = table.tofile
local tabletohash = table.tohash
local tableserialize = table.serialize
-
+local runasscript = caches == nil
--- the font loader namespace is “fonts”, same as in Context
--- we need to put some fallbacks into place for when running
--- as a script
@@ -127,7 +127,10 @@ local make_luanames = function (path)
filereplacesuffix(path, "luc")
end
-local report = logs.names_report
+local report = logs.names_report
+local report_status = logs.names_status
+local report_status_start = logs.names_status_start
+local report_status_stop = logs.names_status_stop
names.patterns = { }
local patterns = names.patterns
@@ -164,7 +167,7 @@ local location_precedence = {
created by different user.
--doc]]--
-if caches then
+if not runasscript then
local globals = names.path.globals
local names_dir = globals.names_dir
@@ -1349,6 +1352,7 @@ local organize_namedata = function (metadata,
},
}
+ -- see http://www.microsoft.com/typography/OTSPEC/features_pt.htm#size
if metadata.fontstyle_name then
--- not present in all fonts, often differs from the preferred
--- subfamily as well as subfamily fields, e.g. with LMSans10-BoldOblique:
@@ -1694,6 +1698,7 @@ local read_font_names = function (fullname,
local format = stringlower (filesuffix (basename))
local loader = loaders [format] --- ot_fullinfo, t1_fullinfo
+ local loader = loaders[format] --- ot_fullinfo, t1_fullinfo
if not loader then
report ("both", 0, "db",
"Unknown format: %q, skipping.", format)
@@ -2076,27 +2081,25 @@ local scan_dir = function (dirname, currentnames, targetnames,
local n_new = 0 --- total of fonts collected
local n_found = #found
- report ("both", 5, "db", "%d font files detected", n_found)
+ report ("both", 4, "db", "%d font files detected", n_found)
for j=1, n_found do
local fullname = found[j]
fullname = path_normalize(fullname)
local new
if dry_run == true then
- report ("both", 1, "db",
- "Would have been extracting metadata from %q",
- fullname)
+ report_status ("both", "db",
+ "Would have been loading %q", fullname)
else
- report ("both", 5, "db",
- "Extracting metadata from font %q", fullname)
- local new = read_font_names (fullname, currentnames,
- targetnames, location)
+ report_status ("both", "db", "Loading font %q", fullname)
+ local new = load_font (fullname, fontnames,
+ newfontnames, texmf)
if new == true then
n_new = n_new + 1
end
end
end
-
- report("both", 5, "db", "%d fonts found in '%s'", n_found, dirname)
+ report ("both", 4, "db", "Done. %d fonts indexed in %q",
+ n_found, dirname)
return n_found, n_new
end
@@ -2132,9 +2135,9 @@ local scan_texmf_fonts = function (currentnames, targetnames, dry_run)
local osfontdir = kpseexpand_path "$OSFONTDIR"
if stringis_empty (osfontdir) then
- report ("info", 2, "db", "Scanning TEXMF fonts...")
+ report ("info", 1, "db", "Scanning TEXMF fonts...")
else
- report ("info", 2, "db", "Scanning TEXMF and OS fonts...")
+ report ("info", 1, "db", "Scanning TEXMF and OS fonts...")
if logs.get_loglevel () > 3 then
local osdirs = filesplitpath (osfontdir)
report ("info", 0, "db",
@@ -2153,12 +2156,14 @@ local scan_texmf_fonts = function (currentnames, targetnames, dry_run)
local tasks = filter_out_pwd (filesplitpath (fontdirs))
report ("info", 3, "db",
"Initiating scan of %d directories.", #tasks)
+ report_status_start (2, 4)
for _, d in next, tasks do
local found, new = scan_dir (d, currentnames, targetnames,
dry_run, "texmf")
n_scanned = n_scanned + found
n_new = n_new + new
end
+ report_status_stop ("term", "db", "Scanned %d files, %d new.", n_scanned, n_new)
end
return n_scanned, n_new
@@ -2443,12 +2448,14 @@ local scan_os_fonts = function (currentnames,
report ("info", 3, "db",
"Searching in static system directories...")
+ report_status_start (2, 4)
for _, d in next, get_os_dirs () do
local found, new = scan_dir (d, currentnames,
targetnames, dry_run)
n_scanned = n_scanned + found
n_new = n_new + new
end
+ report_status_stop ("term", "db", "Scanned %d files, %d new.", n_scanned, n_new)
return n_scanned, n_new
end
@@ -2519,7 +2526,12 @@ local generate_filedata = function (mappings)
barename = filenameonly (fullpath)
subfont = entry.subfont
end
+ end
+ local addmap = function (lst)
+ --- this will overwrite existing entries
+ for i=1, #lst do
+ local idx, base, bare, intexmf, full = unpack(lst[i])
entry.index = index
@@ -3078,8 +3090,8 @@ update_names = function (currentnames, force, dry_run)
- “targetnames” is the final table to return
- force is whether we rebuild it from scratch or not
]]
- report ("both", 2, "db", "Updating the font names database"
- .. (force and " forcefully" or ""))
+ report("both", 1, "db", "Updating the font names database"
+ .. (force and " forcefully" or ""))
--- pass 1 get raw data: read font files (normal case) or reuse
--- information present in index
@@ -3260,9 +3272,9 @@ end
--- string -> string -> string list -> bool -> bool
local purge_from_cache = function (category, path, list, all)
- report("info", 2, "cache", "Luaotfload cache: %s %s",
+ report("info", 1, "cache", "Luaotfload cache: %s %s",
(all and "erase" or "purge"), category)
- report("info", 2, "cache", "location: %s",path)
+ report("info", 1, "cache", "location: %s",path)
local n = 0
for i=1,#list do
local filename = list[i]
@@ -3285,7 +3297,7 @@ local purge_from_cache = function (category, path, list, all)
end
end
end
- report("info", 2, "cache", "Removed lua files : %i", n)
+ report("info", 1, "cache", "Removed lua files : %i", n)
return true
end