From c2e57ff4e741bf8f2a44cf98101bce0447c72190 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 1 Aug 2013 17:17:17 +0200 Subject: [tool] seek correct language data with --inspect --- luaotfload-tool.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 3bec847..9ccf27c 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -486,7 +486,7 @@ local general_fields = { { "design_range_bottom", "l", "design size min" }, { "design_range_top", "l", "design size max" }, { "fontstyle_id", "l", "font style id" }, - { "fontstyle_name", "l", "font style name" }, + { "fontstyle_name", "S", "font style name" }, { "strokewidth", "l", "stroke width" }, { "units_per_em", "l", "units per em" }, { "ascent", "l", "ascender height" }, @@ -506,6 +506,25 @@ local display_general = function (fullinfo) local val if mode == "l" then val = fullinfo[key] + elseif mode == "S" then --- style names table + local data = fullinfo[key] + if type (data) == "table" then + if #data > 0 then + for n = 1, #data do + local nth = data[n] + if nth.lang == 1033 then + val = nth.name + goto found + end + end + val = next (data).name + else + val = "" + end + ::found:: + else + val = data + end elseif mode == "n" then local v = fullinfo[key] if v then -- cgit v1.2.3 From 2a31ed63dccd4eb59c58f2b30c7b5170fe246e24 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 2 Aug 2013 21:41:58 +0200 Subject: [db] fix missing write after auto-update fixes issues like this one: http://tex.stackexchange.com/q/126467/14066 --- luaotfload-database.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index ac2d0db..ab0d32c 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -400,7 +400,13 @@ load_names = function (dry_run) nms_version, db_version) if not fonts_reloaded then report("both", 0, "db", [[Force rebuild]]) - return update_names({ }, true, false) + data = update_names({ }, true, false) + local success = save_names (data) + if not success then + report ("both", 0, "db", + "Database creation unsuccessful.") + end + return data end end else -- cgit v1.2.3 From c23480eb487cce1a55c6e3957a17b52330ad34c4 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 2 Aug 2013 22:00:39 +0200 Subject: [db] always save on update --- luaotfload-database.lua | 53 +++++++++++++++++++++++++------------------------ luaotfload-tool.lua | 3 +-- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index ab0d32c..22a3744 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -384,41 +384,38 @@ local fuzzy_limit = 1 --- display closest only --- bool? -> dbobj load_names = function (dry_run) - local starttime = os.gettimeofday() - local foundname, data = load_lua_file(names.path.index.lua) + local starttime = os.gettimeofday () + local foundname, data = load_lua_file (names.path.index.lua) if data then - report("both", 2, "db", - "Font names database loaded", "%s", foundname) - report("info", 3, "db", "Loading took %0.f ms", - 1000*(os.gettimeofday()-starttime)) + report ("both", 2, "db", + "Font names database loaded", "%s", foundname) + report ("info", 3, "db", "Loading took %0.f ms", + 1000*(os.gettimeofday()-starttime)) local db_version, nms_version = data.version, names.version if db_version ~= nms_version then - report("both", 0, "db", - [[Version mismatch; expected %4.3f, got %4.3f]], - nms_version, db_version) + report ("both", 0, "db", + [[Version mismatch; expected %4.3f, got %4.3f]], + nms_version, db_version) if not fonts_reloaded then - report("both", 0, "db", [[Force rebuild]]) - data = update_names({ }, true, false) - local success = save_names (data) - if not success then + report ("both", 0, "db", [[Force rebuild]]) + data = update_names ({ }, true, false) + if not data then report ("both", 0, "db", "Database creation unsuccessful.") end - return data end end else - report("both", 0, "db", - [[Font names database not found, generating new one.]]) - report("both", 0, "db", - [[This can take several minutes; please be patient.]]) + report ("both", 0, "db", + [[Font names database not found, generating new one.]]) + report ("both", 0, "db", + [[This can take several minutes; please be patient.]]) data = update_names (fontnames_init (get_font_filter ()), nil, dry_run) - local success = save_names(data) if not success then - report("both", 0, "db", "Database creation unsuccessful.") + report ("both", 0, "db", "Database creation unsuccessful.") end end fonts_loaded = true @@ -993,14 +990,13 @@ end --- string -> ('a -> 'a) -> 'a list -> 'a reload_db = function (why, caller, ...) - report("both", 1, "db", "Reload initiated; reason: %q", why) - names.data = update_names(names.data, false, false) - local success = save_names() - if success then + report ("both", 1, "db", "Reload initiated; reason: %q", why) + names.data = update_names (names.data, false, false) + if names.data then fonts_reloaded = true - return caller(...) + return caller (...) end - report("both", 0, "db", "Database update unsuccessful.") + report ("both", 0, "db", "Database update unsuccessful.") end --- string -> string -> int @@ -2226,6 +2222,11 @@ update_names = function (fontnames, force, dry_run) "Scanned %d font files; %d new entries.", n_scanned, n_new) report("info", 3, "db", "Rebuilt in %0.f ms", 1000*(os.gettimeofday()-starttime)) + names.data = newfontnames + + if dry_run ~= true then + save_names () + end return newfontnames end diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 9ccf27c..c3bf3bb 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -763,8 +763,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) - local success = names.save(fontnames) - if success then + if names.data then return true, true end return false, false -- cgit v1.2.3 From 56e3035e8892cdec21931340536a8244faae1d10 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 2 Aug 2013 23:28:03 +0200 Subject: sync with Context as of 2013-08-02 --- luaotfload-features.lua | 3 --- luaotfload-merged.lua | 53 +++++++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 4088379..213a529 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -39,9 +39,6 @@ local stringformat = string.format local stringis_empty = string.is_empty local mathceil = math.ceil ---- TODO an option to dump the default features for a script would make ---- a nice addition to luaotfload-tool - local defaults = { dflt = { "ccmp", "locl", "rlig", "liga", "clig", diff --git a/luaotfload-merged.lua b/luaotfload-merged.lua index c17a541..146ba36 100644 --- a/luaotfload-merged.lua +++ b/luaotfload-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 07/14/13 14:53:44 +-- merge date : 08/01/13 01:31:02 do -- begin closure to overcome local limits and interference @@ -2416,9 +2416,9 @@ function string.booleanstring(str) end function string.is_boolean(str,default) if type(str)=="string" then - if str=="true" or str=="yes" or str=="on" or str=="t" then + if str=="true" or str=="yes" or str=="on" or str=="t" or str=="1" then return true - elseif str=="false" or str=="no" or str=="off" or str=="f" then + elseif str=="false" or str=="no" or str=="off" or str=="f" or str=="0" then return false end end @@ -4880,33 +4880,38 @@ function mappings.addtounicode(data,filename) if not unicode or unicode=="" then local split=lpegmatch(namesplitter,name) local nsplit=split and #split or 0 - if nsplit>=2 then - local t,n={},0 - for l=1,nsplit do - local base=split[l] - local u=unicodes[base] or unicodevector[base] - if not u then + local t,n={},0 + unicode=true + for l=1,nsplit do + local base=split[l] + local u=unicodes[base] or unicodevector[base] + if not u then + break + elseif type(u)=="table" then + if u[1]>=private then + unicode=false break - elseif type(u)=="table" then - n=n+1 - t[n]=u[1] - else - n=n+1 - t[n]=u end - end - if n==0 then - elseif n==1 then - originals[index]=t[1] - tounicode[index]=tounicode16(t[1],name) + n=n+1 + t[n]=u[1] else - originals[index]=t - tounicode[index]=tounicode16sequence(t) + if u>=private then + unicode=false + break + end + n=n+1 + t[n]=u end - nl=nl+1 - unicode=true + end + if n==0 then + elseif n==1 then + originals[index]=t[1] + tounicode[index]=tounicode16(t[1],name) else + originals[index]=t + tounicode[index]=tounicode16sequence(t) end + nl=nl+1 end if not unicode or unicode=="" then local foundcodes,multiple=lpegmatch(uparser,name) -- cgit v1.2.3 From 8d890cb8e98d50f13bfe2a279da5ce3518458ac1 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 3 Aug 2013 22:06:03 +0200 Subject: [tool] add option --no-reload to suppress database updates --- luaotfload-tool.lua | 6 +++++- luaotfload-tool.rst | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index c3bf3bb..11013e9 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -209,6 +209,7 @@ This tool is part of the luaotfload package. Valid options are: DATABASE -u --update update the database + -n --no-reload suppress db update -f --force force re-indexing all fonts -l --flush-lookups empty lookup cache of font requests -D --dry-run skip loading of fonts, just scan @@ -1044,6 +1045,7 @@ local process_cmdline = function ( ) -- unit -> jobspec limit = 1, list = 1, log = 1, + ["no-reload"] = "n", ["prefer-texmf"] = "p", quiet = "q", ["show-blacklist"] = "b", @@ -1054,7 +1056,7 @@ local process_cmdline = function ( ) -- unit -> jobspec warnings = "w", } - local short_options = "bDfFiIlpquvVhw" + local short_options = "bDfFiIlnpquvVhw" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -1133,6 +1135,8 @@ local process_cmdline = function ( ) -- unit -> jobspec result.asked_diagnostics = optarg[n] elseif v == "formats" then names.set_font_filter (optarg[n]) + elseif v == "n" then + config.luaotfload.update_live = false end end diff --git a/luaotfload-tool.rst b/luaotfload-tool.rst index 2d3ae2f..4bbabfd 100644 --- a/luaotfload-tool.rst +++ b/luaotfload-tool.rst @@ -15,13 +15,14 @@ SYNOPSIS ======================================================================= -**luaotfload-tool** [ -bDfFiIlpquvVhw ] +**luaotfload-tool** [ -bDfFiIlnpquvVhw ] **luaotfload-tool** --update [ --force ] [ --quiet ] [ --verbose ] [ --prefer-texmf ] [ --dry-run ] [ --formats=[+|-]EXTENSIONS ] **luaotfload-tool** --find=FONTNAME [ --fuzzy ] [ --info ] [ --inspect ] + [ --no-reload ] **luaotfload-tool** --flush-lookups @@ -59,6 +60,9 @@ update mode --update, -u Update the database; indexes new fonts. --force, -f Force rebuilding of the database; re-indexes all fonts. +--no-reload, -n Suppress auto-updates to the database (e.g. + when ``--find`` is passed an unknown name). + --prefer-texmf, -p Organize the file name database in a way so that it prefer fonts in the *TEXMF* tree over system fonts if they are installed in both. -- cgit v1.2.3 From 24ef88fda9d592e880c4694b50c64c5ae0b74a92 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 3 Aug 2013 22:22:56 +0200 Subject: [tool] make --find process normal requests --- luaotfload-database.lua | 2 +- luaotfload-features.lua | 37 ++++++++++++++++++++++++++----------- luaotfload-tool.lua | 14 ++++++++++---- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 22a3744..939b6bb 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -2169,7 +2169,7 @@ update_names = function (fontnames, force, dry_run) if config.luaotfload.update_live == false then report("info", 2, "db", - "skipping database update") + "Skipping database update") --- skip all db updates return fontnames or names.data end diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 213a529..db0b1d0 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -14,11 +14,25 @@ local lpegmatch = lpeg.match ---[[ begin included font-ltx.lua ]] --- this appears to be based in part on luatex-fonts-def.lua -local fonts = fonts +local fonts = fonts +local definers = fonts.definers +local handlers = fonts.handlers + +local as_script, normalize + +if handlers then + normalize = handlers.otf.features.normalize +else + normalize = function () end + as_script = true +end + --HH A bit of tuning for definitions. -fonts.constructors.namemode = "specification" -- somehow latex needs this (changed name!) => will change into an overload +if fonts.constructors then + fonts.constructors.namemode = "specification" -- somehow latex needs this (changed name!) => will change into an overload +end --[[HH-- tricky: we sort of bypass the parser and directly feed all into @@ -1182,20 +1196,21 @@ local handle_request = function (specification) --- The next line sets the “rand” feature to “random”; I haven’t --- investigated it any further (luatex-fonts-ext), so it will --- just stay here. - specification.features.normal - = fonts.handlers.otf.features.normalize(request.features) + specification.features.normal = normalize (request.features) return specification end -local compare_requests = function (spec) - local old = old_behavior(spec) - local new = handle_request(spec) - return new +if as_script == true then --- skip the remainder of the file + fonts.names.handle_request = handle_request + report ("log", 5, "load", + "Exiting early from luaotfload-features.lua.") + return +else + local registersplit = definers.registersplit + registersplit (":", handle_request, "cryptic") + registersplit ("", handle_request, "more cryptic") -- catches \font\text=[names] end -fonts.definers.registersplit(":", handle_request, "cryptic") -fonts.definers.registersplit("", handle_request, "more cryptic") -- catches \font\text=[names] - ---[[ end included font-ltx.lua ]] --[[doc-- diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 11013e9..a187e12 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -753,7 +753,7 @@ end actions.blacklist = function (job) names.read_blacklist() local n = 0 - for n, entry in next, table.sortedkeys(fonts.names.blacklist) do + for n, entry in next, table.sortedkeys(names.blacklist) do texiowrite_nl(stringformat("(%d %s)", n, entry)) end return true, false @@ -803,16 +803,22 @@ end actions.query = function (job) + require "luaotfload-features" + local query = job.query + local tmpspec = { name = query, lookup = "name", - specification = "name:" .. query, + specification = query, optsize = 0, + features = { }, } + tmpspec = names.handle_request (tmpspec) + local foundname, subfont, success = - fonts.names.resolve(nil, nil, tmpspec) + names.resolve(nil, nil, tmpspec) if success then logs.names_report(false, 0, @@ -835,7 +841,7 @@ actions.query = function (job) if job.fuzzy == true then logs.names_report(false, 0, "resolve", "Looking for close matches, this may take a while ...") - local success = fonts.names.find_closest(query, job.fuzzy_limit) + local success = names.find_closest(query, job.fuzzy_limit) end end return true, true -- cgit v1.2.3 From 358258ab83d2bc0d9d8ad141427c7df989425c90 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 3 Aug 2013 22:44:30 +0200 Subject: [tool] handle anon: and file: requests with --find --- luaotfload-database.lua | 16 +++++++++------- luaotfload-tool.lua | 21 +++++++++++++++++---- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 939b6bb..8da0713 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -523,21 +523,21 @@ crude_file_lookup_verbose = function (filename) --- look up in db first ... found = verbose_lookup(filenames, "bare", filename) if found then - return found + return found, nil, true end found = verbose_lookup(filenames, "base", filename) if found then - return found + return found, nil, true end --- ofm and tfm, returns pair for i=1, #type1_formats do local format = type1_formats[i] if resolvers.findfile(filename, format) then - return file.addsuffix(filename, format), format + return file.addsuffix(filename, format), format, true end end - return filename, nil + return filename, nil, false end --- string -> (string | string * string) @@ -557,15 +557,17 @@ crude_file_lookup = function (filename) if found == nil then found = dummy_findfile(filename) end - return found or filename + return found or filename, nil, true end + for i=1, #type1_formats do local format = type1_formats[i] if resolvers.findfile(filename, format) then - return file.addsuffix(filename, format), format + return file.addsuffix(filename, format), format, true end end - return filename, nil + + return filename, nil, false end --[[doc-- diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index a187e12..e8513be 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -554,7 +554,6 @@ local print_features = function (features) for script, languages in next, data do local field = stringformat(key_fmt, script).. fieldseparator .. " " local wd_field = #field - --inspect(languages.list) local lines = reflow(languages.list, textwidth - wd_field) local indent = stringrep(" ", wd_field) texiowrite_nl(field) @@ -817,8 +816,22 @@ actions.query = function (job) tmpspec = names.handle_request (tmpspec) - local foundname, subfont, success = - names.resolve(nil, nil, tmpspec) + local foundname, subfont, success + + if tmpspec.lookup == "name" + or tmpspec.lookup == "anon" --- not *exactly* as resolvers.anon + then + foundname, subfont = names.resolve (nil, nil, tmpspec) + if foundname then + foundname = names.crude_file_lookup (foundname) + if foundname then + success = true + end + end + elseif tmpspec.lookup == "file" then + foundname, subfont, success = + names.crude_file_lookup (tmpspec.name) + end if success then logs.names_report(false, 0, @@ -841,7 +854,7 @@ actions.query = function (job) if job.fuzzy == true then logs.names_report(false, 0, "resolve", "Looking for close matches, this may take a while ...") - local success = names.find_closest(query, job.fuzzy_limit) + local _success = names.find_closest(query, job.fuzzy_limit) end end return true, true -- cgit v1.2.3 From c1ce4dbe0869e6b276908232afc3336b67f69a78 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 3 Aug 2013 22:48:03 +0200 Subject: [meta] update NEWS --- NEWS | 8 +++++--- luaotfload-tool.rst | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 960a8d5..399ed97 100644 --- a/NEWS +++ b/NEWS @@ -2,11 +2,13 @@ Change History -------------- 2013/XX/XX, luaotfload v2.4 - * additional self-tests, now in separate file (luaotfload-diagnostics.lua) - * better path and directory handling, especially on Windows + * Additional self-tests, now in separate file (luaotfload-diagnostics.lua) + * Better path and directory handling, especially on Windows * database now indexes Type1 fonts (PFA, PFB) and makes them accessible with style modifiers (requires --format=+pfa,pfb option to luaotfload-tool) - * test runner (script mktests) + * Test runner (script mktests) + * New luaotfload-tool option: ``--no-reload`` + * ``luaotfload-tool --find`` now understands request syntax 2013/07/10, luaotfload v2.3a * Detect LuaJIT interpreter (LuaJITTeX) diff --git a/luaotfload-tool.rst b/luaotfload-tool.rst index 4bbabfd..03ff407 100644 --- a/luaotfload-tool.rst +++ b/luaotfload-tool.rst @@ -93,6 +93,9 @@ query mode --find=NAME Resolve a font name; this looks up in the database and prints the file name it is mapped to. + ``--find`` also understands request syntax, + i.e. ``--find=file:foo.otf`` checks whether + ``foo.otf`` is indexed. --fuzzy, -F Show approximate matches to the file name if the lookup was unsuccessful (requires ``--find``). -- cgit v1.2.3 From 04f06993d2d9981267e803eaa7dd034a3d57f9eb Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 3 Aug 2013 22:50:13 +0200 Subject: [tool] interpret file lookup result correctly --- luaotfload-tool.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index e8513be..e95bba4 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -823,13 +823,10 @@ actions.query = function (job) then foundname, subfont = names.resolve (nil, nil, tmpspec) if foundname then - foundname = names.crude_file_lookup (foundname) - if foundname then - success = true - end + foundname, _, success = names.crude_file_lookup (foundname) end elseif tmpspec.lookup == "file" then - foundname, subfont, success = + foundname, _, success = names.crude_file_lookup (tmpspec.name) end -- cgit v1.2.3 From 51ac04816f89f7d38ce499d3ce81b34621e1869e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 3 Aug 2013 22:56:12 +0200 Subject: [tool] handle missing size info --- luaotfload-tool.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index e95bba4..c80f98e 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -816,6 +816,10 @@ actions.query = function (job) tmpspec = names.handle_request (tmpspec) + if not tmpspec.size then + tmpspec.size = 655360 --- assume 10pt + end + local foundname, subfont, success if tmpspec.lookup == "name" -- cgit v1.2.3 From a0d59a1cf91675a18f7062e11053aedf52585b2d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 4 Aug 2013 09:58:23 +0200 Subject: [db] pre-resolve style synonyms when matching --- luaotfload-database.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 8da0713..0fbbd44 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -823,12 +823,15 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C return specification.name, false, false end + local synonym_set = style_synonyms.set + local stylesynonyms = synonym_set[style] + local regularsynonyms = synonym_set.regular + local exact = { } --> collect exact style matches local synonymous = { } --> collect matching style synonyms local fallback --> e.g. non-matching style (fontspec is anal about this) local candidates = { } --> secondary results, incomplete matches - local synonym_set = style_synonyms.set for n, face in next, data.mappings do local family, subfamily, fullname, prefmodifiers local psname, fontname, pfullname, metafamily @@ -856,8 +859,8 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C if continue == false then break end elseif style == subfamily then exact = add_to_match(exact, askedsize, face) - elseif synonym_set[style] and synonym_set[style][prefmodifiers] - or synonym_set.regular[prefmodifiers] + elseif stylesynonyms and stylesynonyms[prefmodifiers] + or regularsynonyms[prefmodifiers] then --- treat synonyms for prefmodifiers as first-class --- (needed to prioritize DejaVu Book over Condensed) @@ -868,8 +871,8 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C or name == psname then synonymous = add_to_match(synonymous, askedsize, face) - elseif synonym_set[style] and synonym_set[style][subfamily] - or synonym_set.regular[subfamily] + elseif stylesynonyms and stylesynonyms[subfamily] + or regularsynonyms[subfamily] then synonymous = add_to_match(synonymous, askedsize, face) elseif prefmodifiers == "regular" -- cgit v1.2.3 From 59efa957a012b64fe970d6ea95521ea5e99fb5ad Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 4 Aug 2013 12:00:25 +0200 Subject: [db] use consistent identifiers --- luaotfload-database.lua | 81 +++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 0fbbd44..bd7a97b 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1134,7 +1134,7 @@ table as returned by the font file reader need to be relocated. --- string -> int -> bool -> string -> fontentry ot_fullinfo = function (filename, subfont, texmf, basename) - local tfmdata = { } + local namedata = { } local metadata = load_font_file (filename, subfont) if not metadata then @@ -1145,68 +1145,74 @@ ot_fullinfo = function (filename, subfont, texmf, basename) if metadata.fontstyle_name then for _, name in next, metadata.fontstyle_name do if name.lang == 1033 then --- I hate magic numbers - tfmdata.fontstyle_name = name.name + namedata.fontstyle_name = name.name end end end if metadata.names then - for _, namedata in next, metadata.names do - if namedata.lang == "English (US)" then + for _, raw_namedata in next, metadata.names do + if raw_namedata.lang == "English (US)" then local names = { --- see --- https://developer.apple.com/fonts/TTRefMan/RM06/Chap6name.html - fullname = namedata.names.compatfull - or namedata.names.fullname, - family = namedata.names.preffamilyname - or namedata.names.family, - prefmodifiers = namedata.names.prefmodifiers, - subfamily = tfmdata.fontstyle_name - or namedata.names.subfamily, - psname = namedata.names.postscriptname, + fullname = raw_namedata.names.compatfull + or raw_namedata.names.fullname, + family = raw_namedata.names.preffamilyname + or raw_namedata.names.family, + prefmodifiers = raw_namedata.names.prefmodifiers, + subfamily = namedata.fontstyle_name + or raw_namedata.names.subfamily, + psname = raw_namedata.names.postscriptname, pfullname = metadata.fullname, fontname = metadata.fontname, metafamily = metadata.familyname, } --- tfmdata.names = names - tfmdata.sanitized = sanitize_names(names) +-- namedata.names = names + namedata.sanitized = sanitize_names(names) end end else -- no names table, propably a broken font - report("log", 1, "db", "Broken font rejected", "%s", basefile) + report("log", 1, "db", + "Broken font %s rejected due to missing names table.", + basename) return end - tfmdata.fontname = metadata.fontname - tfmdata.fullname = metadata.fullname - tfmdata.familyname = metadata.familyname - tfmdata.weight = metadata.pfminfo.weight - tfmdata.width = metadata.pfminfo.width - tfmdata.slant = metadata.italicangle - --- this is for querying - tfmdata.units_per_em = metadata.units_per_em - tfmdata.version = metadata.version + + + namedata.fontname = metadata.fontname + namedata.fullname = metadata.fullname + namedata.familyname = metadata.familyname + namedata.weight = metadata.pfminfo.weight + namedata.width = metadata.pfminfo.width + namedata.slant = metadata.italicangle + --- this is for querying, see www.ntg.nl/maps/40/07.pdf for details + namedata.units_per_em = metadata.units_per_em + namedata.version = metadata.version -- don't waste the space with zero values - tfmdata.size = { + namedata.size = { metadata.design_size ~= 0 and metadata.design_size or nil, metadata.design_range_top ~= 0 and metadata.design_range_top or nil, metadata.design_range_bottom ~= 0 and metadata.design_range_bottom or nil, } --- file location data (used to be filename field) - tfmdata.filename = filename --> sys - tfmdata.basename = basename --> texmf - tfmdata.texmf = texmf or false - tfmdata.subfont = subfont + namedata.filename = filename --> sys + namedata.basename = basename --> texmf + namedata.texmf = texmf or false + namedata.subfont = subfont - return tfmdata + return namedata end --[[doc-- - Type1 font inspector. PFB’s contain a good deal less name fields - which makes it tricky in some parts to find a meaningful representation - for the database. + Type1 font inspector. In comparison with OTF, PFB’s contain a good + deal less name fields which makes it tricky in some parts to find a + meaningful representation for the database. + + Good read: http://www.adobe.com/devnet/font/pdfs/5004.AFM_Spec.pdf --doc]]-- @@ -1219,7 +1225,7 @@ t1_fullinfo = function (filename, _subfont, texmf, basename) local fullname = metadata.fullname local familyname = metadata.familyname local italicangle = metadata.italicangle - local weight = metadata.weight + local weight = metadata.weight --- string identifier --- we have to improvise and detect whether we deal with --- italics since pfb fonts don’t come with a “subfamily” @@ -1268,15 +1274,18 @@ t1_fullinfo = function (filename, _subfont, texmf, basename) namedata.fullname = fullname namedata.familyname = familyname - namedata.weight = 0 -- dummy + namedata.slant = italicangle + namedata.units_per_em = 1000 --- ps fonts standard namedata.version = metadata.version + namedata.weight = metadata.pfminfo.weight --- integer + namedata.width = metadata.pfminfo.width namedata.size = { } namedata.filename = filename --> sys namedata.basename = basename --> texmf namedata.texmf = texmf or false - namedata.subfont = subfont + namedata.subfont = false return namedata end -- cgit v1.2.3 From ec5e064bf604d5984d3a85ba6f63943617111e51 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 4 Aug 2013 12:15:54 +0200 Subject: [db] employ the info from fontstyle_name when matching styles --- luaotfload-database.lua | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index bd7a97b..31d3591 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -512,7 +512,7 @@ local verbose_lookup = function (data, kind, filename) return false end ---- string -> (string | string * string) +--- string -> (string * string * bool) crude_file_lookup_verbose = function (filename) if not names.data then names.data = load_names() end local data = names.data @@ -540,7 +540,7 @@ crude_file_lookup_verbose = function (filename) return filename, nil, false end ---- string -> (string | string * string) +--- string -> (string * string * bool) crude_file_lookup = function (filename) if not names.data then names.data = load_names() end local data = names.data @@ -833,14 +833,16 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C local candidates = { } --> secondary results, incomplete matches for n, face in next, data.mappings do - local family, subfamily, fullname, prefmodifiers - local psname, fontname, pfullname, metafamily + local family, metafamily + local prefmodifiers, fontstyle_name, subfamily + local psname, fullname, fontname, pfullname local facenames = face.sanitized if facenames then family = facenames.family subfamily = facenames.subfamily - prefmodifiers = facenames.prefmodifiers or facenames.subfamily + fontstyle_name = facenames.fontstyle_name + prefmodifiers = facenames.prefmodifiers or fontstyle_name or subfamily fullname = facenames.fullname psname = facenames.psname fontname = facenames.fontname @@ -853,7 +855,9 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C if name == family or name == metafamily then - if style == prefmodifiers then + if style == prefmodifiers + or style == fontstyle_name + then local continue exact, continue = add_to_match(exact, askedsize, face) if continue == false then break end @@ -1141,35 +1145,12 @@ ot_fullinfo = function (filename, subfont, texmf, basename) return nil end - -- see http://www.microsoft.com/typography/OTSPEC/features_pt.htm#size - if metadata.fontstyle_name then - for _, name in next, metadata.fontstyle_name do - if name.lang == 1033 then --- I hate magic numbers - namedata.fontstyle_name = name.name - end - end - end + local english_names if metadata.names then for _, raw_namedata in next, metadata.names do if raw_namedata.lang == "English (US)" then - local names = { - --- see - --- https://developer.apple.com/fonts/TTRefMan/RM06/Chap6name.html - fullname = raw_namedata.names.compatfull - or raw_namedata.names.fullname, - family = raw_namedata.names.preffamilyname - or raw_namedata.names.family, - prefmodifiers = raw_namedata.names.prefmodifiers, - subfamily = namedata.fontstyle_name - or raw_namedata.names.subfamily, - psname = raw_namedata.names.postscriptname, - pfullname = metadata.fullname, - fontname = metadata.fontname, - metafamily = metadata.familyname, - } --- namedata.names = names - namedata.sanitized = sanitize_names(names) + english_names = raw_namedata.names end end else @@ -1180,6 +1161,31 @@ ot_fullinfo = function (filename, subfont, texmf, basename) return end + local fontnames = { + --- see + --- https://developer.apple.com/fonts/TTRefMan/RM06/Chap6name.html + fullname = english_names.compatfull + or english_names.fullname, + family = english_names.preffamilyname + or english_names.family, + prefmodifiers = english_names.prefmodifiers, + subfamily = english_names.subfamily, + psname = english_names.postscriptname, + pfullname = metadata.fullname, + fontname = metadata.fontname, + metafamily = metadata.familyname, + } + + -- see http://www.microsoft.com/typography/OTSPEC/features_pt.htm#size + if metadata.fontstyle_name then + for _, name in next, metadata.fontstyle_name do + if name.lang == 1033 then --- I hate magic numbers + fontnames.fontstyle_name = name.name + end + end + end + + namedata.sanitized = sanitize_names (fontnames) namedata.fontname = metadata.fontname namedata.fullname = metadata.fullname -- cgit v1.2.3 From 98b8117843b91eea6d60a195f2905f249bfb7044 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 4 Aug 2013 13:33:24 +0200 Subject: [db] improve handling of zero values in design sizes --- luaotfload-database.lua | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 31d3591..271e93c 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -102,7 +102,7 @@ if config.luaotfload.update_live ~= false then config.luaotfload.update_live = true end -names.version = 2.208 +names.version = 2.209 names.data = nil --- contains the loaded database names.lookups = nil --- contains the lookup cache @@ -259,6 +259,7 @@ This is a sketch of the luaotfload db: fullname : string; // <- metadata sanitized : { family : string; + fontstyle_name : string; // <- new in 2.4 fontname : string; // <- metadata fullname : string; // <- namedata.names metafamily : string; @@ -726,7 +727,7 @@ end local add_to_match = function (found, size, face) local optsize, dsnsize, maxsize, minsize - if #face.size > 0 then + if face.size ~= false then optsize = face.size dsnsize = optsize[1] and optsize[1] / 10 -- can be nil @@ -1197,11 +1198,21 @@ ot_fullinfo = function (filename, subfont, texmf, basename) namedata.units_per_em = metadata.units_per_em namedata.version = metadata.version -- don't waste the space with zero values - namedata.size = { - metadata.design_size ~= 0 and metadata.design_size or nil, - metadata.design_range_top ~= 0 and metadata.design_range_top or nil, - metadata.design_range_bottom ~= 0 and metadata.design_range_bottom or nil, - } + + local design_size = metadata.design_size + local design_range_top = metadata.design_range_top + local design_range_bottom = metadata.design_range_bottom + + if design_size ~= 0 + or design_range_top ~= 0 + or design_range_bottom ~= 0 + then + namedata.size = { + design_size, design_range_top, design_range_bottom, + } + else + namedata.size = false + end --- file location data (used to be filename field) namedata.filename = filename --> sys -- cgit v1.2.3 From 645d1c970f45b4f322b687882af351f088dd748c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 5 Aug 2013 10:47:58 +0200 Subject: [tool] make --inspect skip empty feature sets --- luaotfload-tool.lua | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index c80f98e..d5cd8e7 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -610,11 +610,20 @@ end local display_features = function (gsub, gpos) texiowrite_nl "" - print_heading("Features", 2) - print_heading("GSUB Features", 3) - display_feature_set(gsub) - print_heading("GPOS Features", 3) - display_feature_set(gpos) + + if gsub or gpos then + print_heading("Features", 2) + + if gsub then + print_heading("GSUB Features", 3) + display_feature_set(gsub) + end + + if gpos then + print_heading("GPOS Features", 3) + display_feature_set(gpos) + end + end end local show_full_info = function (path, subfont, warnings) -- cgit v1.2.3 From 3cbbd94c24c6d3a3b7b6b0cda3ed2175b84373ad Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 5 Aug 2013 12:15:46 +0200 Subject: [db] handle missing optical size info --- luaotfload-database.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 271e93c..7670ee6 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -726,16 +726,17 @@ end --- “found” is the match accumulator local add_to_match = function (found, size, face) - local optsize, dsnsize, maxsize, minsize - if face.size ~= false then - optsize = face.size + local continue = true + + local optsize = face.size + + if next (optsize) then + local dsnsize, maxsize, minsize dsnsize = optsize[1] and optsize[1] / 10 -- can be nil maxsize = optsize[2] and optsize[2] / 10 or dsnsize minsize = optsize[3] and optsize[3] / 10 or dsnsize - end - local continue = true - if optsize then + if dsnsize == size or (size > minsize and size <= maxsize) then found[1] = face continue = false ---> break @@ -746,6 +747,7 @@ local add_to_match = function (found, size, face) found[1] = face continue = false ---> break end + return found, continue end @@ -925,7 +927,7 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C local closest local least = math.huge -- initial value is infinity for i,face in next, found do - local dsnsize = face.size[1]/10 + local dsnsize = (face.size[1] or 0) / 10 local difference = mathabs(dsnsize - askedsize) if difference < least then closest = face -- cgit v1.2.3 From 1075688dae6cd26a52628d595bab3c4c5dae2e1d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 5 Aug 2013 12:33:50 +0200 Subject: [db] pre-calculate design size values --- luaotfload-database.lua | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 7670ee6..7e1a274 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -730,12 +730,11 @@ local add_to_match = function (found, size, face) local optsize = face.size - if next (optsize) then + if optsize and next (optsize) then local dsnsize, maxsize, minsize - dsnsize = optsize[1] and optsize[1] / 10 - -- can be nil - maxsize = optsize[2] and optsize[2] / 10 or dsnsize - minsize = optsize[3] and optsize[3] / 10 or dsnsize + dsnsize = optsize[1] + maxsize = optsize[2] + minsize = optsize[3] if dsnsize == size or (size > minsize and size <= maxsize) then found[1] = face @@ -926,14 +925,17 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C -- least difference from the requested size. local closest local least = math.huge -- initial value is infinity + for i,face in next, found do - local dsnsize = (face.size[1] or 0) / 10 + + local dsnsize = face.size and face.size[1] or 0 local difference = mathabs(dsnsize - askedsize) if difference < least then closest = face least = difference end end + local success, filename, subfont = get_font_file(data.filenames.full, closest) if success == true then @@ -1205,10 +1207,14 @@ ot_fullinfo = function (filename, subfont, texmf, basename) local design_range_top = metadata.design_range_top local design_range_bottom = metadata.design_range_bottom - if design_size ~= 0 - or design_range_top ~= 0 - or design_range_bottom ~= 0 - then + local fallback_size = design_size ~= 0 and design_size + or design_range_bottom ~= 0 and design_range_bottom + or design_range_top ~= 0 and design_range_top + + if fallback_size then + design_size = (design_size or fallback_size) / 10 + design_range_top = (design_range_top or fallback_size) / 10 + design_range_bottom = (design_range_bottom or fallback_size) / 10 namedata.size = { design_size, design_range_top, design_range_bottom, } @@ -1299,7 +1305,7 @@ t1_fullinfo = function (filename, _subfont, texmf, basename) namedata.weight = metadata.pfminfo.weight --- integer namedata.width = metadata.pfminfo.width - namedata.size = { } + namedata.size = false namedata.filename = filename --> sys namedata.basename = basename --> texmf -- cgit v1.2.3 From d6328e783739d68a132a33e0a95a2f7f90494f37 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 5 Aug 2013 12:51:49 +0200 Subject: [db] flush lookup cache on db version change; bump version --- luaotfload-database.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 7e1a274..5cbedd4 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -102,7 +102,7 @@ if config.luaotfload.update_live ~= false then config.luaotfload.update_live = true end -names.version = 2.209 +names.version = 2.210 names.data = nil --- contains the loaded database names.lookups = nil --- contains the lookup cache @@ -2264,7 +2264,18 @@ update_names = function (fontnames, force, dry_run) names.data = newfontnames if dry_run ~= true then + save_names () + + local success, _lookups = flush_lookup_cache () + if success then + local success = names.save_lookups () + if success then + logs.names_report ("info", 2, "cache", + "Lookup cache emptied") + return true, true + end + end end return newfontnames end -- cgit v1.2.3 From 749917ae9796808d937c38375ebdb3fbfb0fcc1c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 7 Aug 2013 12:26:22 +0200 Subject: [db] treat empty style in pfb as regular --- luaotfload-database.lua | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 5cbedd4..11cc97d 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1280,7 +1280,7 @@ t1_fullinfo = function (filename, _subfont, texmf, basename) end end - if not style then + if not style or style == "" then style = "regular" --- else italic end @@ -2273,18 +2273,13 @@ update_names = function (fontnames, force, dry_run) if success then logs.names_report ("info", 2, "cache", "Lookup cache emptied") - return true, true + return newfontnames end end end return newfontnames end ---- The lookup cache is an experimental feature of version 2.2; ---- instead of incorporating it into the database it gets its own ---- file. As we update it after every single addition this saves us ---- quite some time. - --- unit -> bool save_lookups = function ( ) local lookups = names.lookups -- cgit v1.2.3