From 074355a0d96d204d92307a4066c231cb89b2d8bf Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 10 Nov 2013 19:22:13 +0100 Subject: [db] call fontloader.close() for some minor gain --- luaotfload-database.lua | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 5198b16..0b9f1f8 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -6,10 +6,35 @@ if not modules then modules = { } end modules ['luaotfload-database'] = { license = "GNU GPL v2" } ---- TODO: if the specification is an absolute filename with a font not in the ---- database, add the font to the database and load it. There is a small ---- difficulty with the filenames of the TEXMF tree that are referenced as ---- relative paths... +--[[doc-- + + Some statistics: + + a) TL 2012, mkluatexfontdb --force + b) v2.4, luaotfload-tool --update --force + c) v2.4, luaotfload-tool --update --force --formats=+afm,pfa,pfb + d) Context, mtxrun --script fonts --reload --force + + (Keep in mind that Context does index fewer fonts since it + considers only the contents of the minimals tree, not the + tex live one!) + + time (m:s) peak VmSize (B) + a 1:19 386 018 + b 0:37 715 797 + c 2:27 1 017 674 + d 0:44 1 082 313 + + Most of the increase in memory consumption from version 1.x to 2.2+ + can be attributed to the move from single-pass to a multi-pass + approach to building the index: Information is first gathered from + all reachable fonts and only afterwards processed, classified and + discarded. Also, there is a good deal of additional stuff kept in + the database now: two extra tables for file names and font families + have been added, making font lookups more efficient while improving + maintainability of the code. + +--doc]]-- local lpeg = require "lpeg" @@ -1481,7 +1506,7 @@ ot_fullinfo = function (filename, english_names, info) - return { + local res = { file = { base = basename, full = filename, subfont = subfont, @@ -1491,6 +1516,10 @@ ot_fullinfo = function (filename, style = style, version = metadata.version, } + --- Closing the file manually is a tad faster and more memory + --- efficient than having it closed by the gc + fontloaderclose (metadata) + return res end --[[doc-- -- cgit v1.2.3 From 1ad4aec62a0cdc6eaf12f17126eeb346e86d3146 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 10 Nov 2013 19:28:55 +0100 Subject: [*] bump version globally --- luaotfload-database.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 0b9f1f8..a2535fa 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ['luaotfload-database'] = { - version = "2.3b", + version = "2.4", comment = "companion to luaotfload.lua", author = "Khaled Hosny, Elie Roux, Philipp Gesang", copyright = "Luaotfload Development Team", -- cgit v1.2.3 From a59d8dc80df1e9359938f0fc2e2b1d335f863bbf Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 12 Nov 2013 23:21:11 +0100 Subject: [db,tool] default to compressed plaintext index --- luaotfload-database.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index a2535fa..a12cdd1 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -19,7 +19,7 @@ if not modules then modules = { } end modules ['luaotfload-database'] = { considers only the contents of the minimals tree, not the tex live one!) - time (m:s) peak VmSize (B) + time (m:s) peak VmSize (kB) a 1:19 386 018 b 0:37 715 797 c 2:27 1 017 674 @@ -124,11 +124,10 @@ luaotfloadconfig.resolver = luaotfloadconfig.resolver or "normal" luaotfloadconfig.formats = luaotfloadconfig.formats or "otf,ttf,ttc,dfont" luaotfloadconfig.strip = luaotfloadconfig.strip == true -if luaotfloadconfig.update_live ~= false then - --- this option allows for disabling updates - --- during a TeX run - luaotfloadconfig.update_live = true -end +--- this option allows for disabling updates +--- during a TeX run +luaotfloadconfig.update_live = luaotfloadconfig.update_live ~= false +luaotfloadconfig.compress = luaotfloadconfig.compress ~= false local names = fonts.names local name_index = nil --> upvalue for names.data -- cgit v1.2.3 From a914c23b674ff6bacb85a9701a828e03ec24cbc0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 13 Nov 2013 00:32:35 +0100 Subject: [tool,man,db] add --max-fonts option to restrict db size --- luaotfload-database.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index a12cdd1..4ee07f4 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -533,6 +533,7 @@ local set_font_filter --- state of the database local fonts_reloaded = false +local fonts_read = 0 --- limit output when approximate font matching (luaotfload-tool -F) local fuzzy_limit = 1 --- display closest only @@ -2112,15 +2113,20 @@ local scan_dir = function (dirname, currentnames, targetnames, local fullname = found[j] fullname = path_normalize(fullname) local new - if dry_run == true then - report_status ("both", "db", - "Would have been loading %q", fullname) - else - report_status ("both", "db", "Loading font %q", fullname) - local new = read_font_names (fullname, currentnames, - targetnames, texmf) - if new == true then - n_new = n_new + 1 + if not luaotfloadconfig.max_fonts + or luaotfloadconfig.max_fonts and fonts_read < luaotfloadconfig.max_fonts + then + if dry_run == true then + report_status ("both", "db", + "Would have been loading %q", fullname) + else + report_status ("both", "db", "Loading font %q", fullname) + local new = read_font_names (fullname, currentnames, + targetnames, texmf) + if new == true then + fonts_read = fonts_read + 1 + n_new = n_new + 1 + end end end end -- cgit v1.2.3 From 32a5a40a2f99bf82436bfec8926fe7bfeaa1194d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 13 Nov 2013 00:38:07 +0100 Subject: [db] simplify loop exit condition --- luaotfload-database.lua | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 4ee07f4..638f1c3 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -2106,27 +2106,30 @@ local scan_dir = function (dirname, currentnames, targetnames, end report ("both", 4, "db", "Scanning directory %s", dirname) - local n_new = 0 --- total of fonts collected - local n_found = #found + local n_new = 0 --- total of fonts collected + local n_found = #found + local max_fonts = luaotfloadconfig.max_fonts + report ("both", 4, "db", "%d font files detected", n_found) for j=1, n_found do + if max_fonts and fonts_read >= max_fonts then + break + end + local fullname = found[j] fullname = path_normalize(fullname) local new - if not luaotfloadconfig.max_fonts - or luaotfloadconfig.max_fonts and fonts_read < luaotfloadconfig.max_fonts - then - if dry_run == true then - report_status ("both", "db", - "Would have been loading %q", fullname) - else - report_status ("both", "db", "Loading font %q", fullname) - local new = read_font_names (fullname, currentnames, - targetnames, texmf) - if new == true then - fonts_read = fonts_read + 1 - n_new = n_new + 1 - end + + if dry_run == true then + report_status ("both", "db", + "Would have been loading %q", fullname) + else + report_status ("both", "db", "Loading font %q", fullname) + local new = read_font_names (fullname, currentnames, + targetnames, texmf) + if new == true then + fonts_read = fonts_read + 1 + n_new = n_new + 1 end end end -- cgit v1.2.3 From 7c0629c2c2748e3ba32d0fc92f6a425629f1c4b9 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 13 Nov 2013 00:43:33 +0100 Subject: [db] prefer split style with Type1 fonts --- luaotfload-database.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 638f1c3..c15cd60 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1543,6 +1543,7 @@ t1_fullinfo = function (filename, _subfont, location, basename, format) local familyname = metadata.familyname local italicangle = metadata.italicangle local weight = metadata.weight --- string identifier + local splitstyle = split_fontname (fontname) sanitized = sanitize_fontnames ({ fontname = fontname, @@ -1567,8 +1568,8 @@ t1_fullinfo = function (filename, _subfont, location, basename, format) psname = sanitized.fontname, version = metadata.version, size = false, - splitstyle = split_fontname (fontname), - fontstyle_name = sanitized.subfamily, + splitstyle = splitstyle, + fontstyle_name = splitstyle or sanitized.subfamily, weight = { metadata.pfminfo.weight, sanitized.subfamily }, italicangle = italicangle, -- cgit v1.2.3 From 346d218c26f96764414def46d829ab841daabfbc Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 13 Nov 2013 02:04:03 +0100 Subject: [db] infer style for Type1 fonts --- luaotfload-database.lua | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index c15cd60..fba01cc 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1536,14 +1536,14 @@ end t1_fullinfo = function (filename, _subfont, location, basename, format) local sanitized - local metadata = load_font_file (filename) - + local metadata = load_font_file (filename) local fontname = metadata.fontname local fullname = metadata.fullname local familyname = metadata.familyname local italicangle = metadata.italicangle - local weight = metadata.weight --- string identifier local splitstyle = split_fontname (fontname) + local style = "" + local weight sanitized = sanitize_fontnames ({ fontname = fontname, @@ -1551,10 +1551,20 @@ t1_fullinfo = function (filename, _subfont, location, basename, format) pfullname = fullname, metafamily = family, familyname = familyname, - subfamily = weight, + weight = metadata.weight, --- string identifier prefmodifiers = style, }) + weight = sanitized.weight + + if weight == "bold" then + style = weight + end + + if italicangle ~= 0 then + style = style .. "italic" + end + return { basename = basename, fullpath = filename, @@ -1569,9 +1579,9 @@ t1_fullinfo = function (filename, _subfont, location, basename, format) version = metadata.version, size = false, splitstyle = splitstyle, - fontstyle_name = splitstyle or sanitized.subfamily, + fontstyle_name = style ~= "" and style or weight, weight = { metadata.pfminfo.weight, - sanitized.subfamily }, + weight }, italicangle = italicangle, } end -- cgit v1.2.3