From 9fd4c4523b1e69b5c49de7fda01da5540e60fcda Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 2 Jan 2014 17:19:53 +0100 Subject: [main] fix path resolver Close #162 --- luaotfload.dtx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/luaotfload.dtx b/luaotfload.dtx index adbdf26..08f56af 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -2078,13 +2078,14 @@ request_resolvers.path = function (specification) name) file_resolver (specification) else - local suffix = filesuffix (name) - if formats[suffix] then - specification.forced = suffix - specification.name = file.removesuffix(name) - else - specification.name = name - end + local suffix = filesuffix (name) + if formats[suffix] then + specification.forced = suffix + specification.name = file.removesuffix(name) + specification.forcedname = name + else + specification.name = name + end end end -- cgit v1.2.3 From f1b0fea5a84d36326f456643d54368a4ab0a7040 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 Jan 2014 18:14:20 +0100 Subject: [db] handle missing metadata table Fixes issue #164, hopefully. --- luaotfload-database.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index b47fc8b..535aa7e 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -574,7 +574,16 @@ load_names = function (dry_run) report ("info", 3, "db", "Loading took %0.f ms.", 1000 * (osgettimeofday () - starttime)) - local db_version, nms_version = data.meta.version, names.version + local db_version, nms_version + if data.meta then + db_version = data.meta.version + else + --- Compatibility branch; the version info used to be + --- stored in the table root which is why updating from + --- an earlier index version broke. + db_version = data.version or -42 --- invalid + end + nms_version = names.version if db_version ~= nms_version then report ("both", 0, "db", [[Version mismatch; expected %4.3f, got %4.3f.]], -- cgit v1.2.3 From 5b26498993e9e0e9ba4759ceb3976b17f42d1413 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 Jan 2014 18:17:16 +0100 Subject: [db] fix incorrect local --- luaotfload-database.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 535aa7e..9d7d912 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -83,7 +83,7 @@ local tableconcat = table.concat local tablesort = table.sort local utf8gsub = unicode.utf8.gsub local utf8lower = unicode.utf8.lower -local utf8length = unicode.utf8.length +local utf8len = unicode.utf8.len local zlibcompress = zlib.compress --- these come from Lualibs/Context @@ -2127,7 +2127,7 @@ end local truncate_string = function (str, restrict) local tw = luaotfloadconfig.termwidth local wd = tw - restrict - local len = utf8length (str) + local len = utf8len (str) if wd - len < 0 then --- combined length exceeds terminal, str = ".." .. stringsub(str, len - wd + 2) -- cgit v1.2.3 From 84c2015a58d019b87532111cd0bb5f7d4d1ccb8a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 Jan 2014 20:03:08 +0100 Subject: [db] use (sanitized) names.fullname field when resolving fonts by name --- luaotfload-database.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 9d7d912..7e5f8cb 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1070,9 +1070,10 @@ local resolve_fontname = function (specification, name, style) local face = mappings [i] local prefmodifiers = face.prefmodifiers local subfamily = face.subfamily - if face.fontname == name - or face.fullname == name - or face.psname == name + if face.fontname == name + or face.splainname == name + or face.fullname == name + or face.psname == name then return face.basename, face.subfont elseif face.familyname == name then @@ -1608,6 +1609,7 @@ t1_fullinfo = function (filename, _subfont, location, basename, format) fontname = sanitized.fontname, familyname = sanitized.familyname, plainname = fullname, + splainname = sanitized.fullname, psname = sanitized.fontname, version = metadata.version, size = false, @@ -2775,6 +2777,7 @@ local pull_values = function (entry) entry.psname = english.psname entry.fontname = info.fontname entry.fullname = english.fullname or info.fullname + entry.splainname = metadata.fullname entry.prefmodifiers = english.prefmodifiers local metafamily = metadata.familyname local familyname = english.preffamily or english.family -- cgit v1.2.3 From 532b4ecf5993d5902927e4c6e5db14ff2cd2e5df Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 Jan 2014 20:17:47 +0100 Subject: [tests] include two kinds of tests for Minion Pro --- mktests | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mktests b/mktests index 688e5f8..baa710c 100755 --- a/mktests +++ b/mktests @@ -86,6 +86,11 @@ local infer_regular_style = { { "Garamond Premier Pro", "GaramondPremrPro.otf" }, { "CMU Serif", "cmunrm.otf" }, { "CMU Sans Serif", "cmunss.otf" }, + { "Minion Pro", "MinionPro_Regular.otf" }, + --- Below test will succeed only if we match for the + --- splainname (= sanitized tfmdata.fullname) field + --- explicitly. + { "Minion Pro Italic", "MinionPro_It.otf" }, } local choose_optical_size = { @@ -120,6 +125,25 @@ local choose_style = { { { name = "CMU Sans Serif", style = "italic" }, "cmunsi.otf" }, -- no “italic” but “oblique” { { name = "CMU Sans Serif", style = "bold" }, "cmunsx.otf" }, { { name = "CMU Sans Serif", style = "bolditalic" }, "cmunso.otf" }, + --[[-- + Minion Pro Italic is exceptionally weird regarding identifiers in + that the postscript fontname and both info.fontname and + info.fullname are given as “minionproit”. Now its english fullname + (field 18) is “minionproital”. Only the value “fullname” in the root of + the tfmdata structure (not the one returned by fontloader.info()!) + accurately yields “Minion Pro Italic”. + + To complete the picture, the file naming isn’t very consistent either: + we find the suffixes “Regular” and “Bold”, but “It” and “BoldIt”. What + the hell were the designers smoking? + + Also, the full Minion Pro set comes with different optical sizes which + for monetary reasons cannot considered here. + --]]-- + { { name = "Minion Pro", style = "regular" }, "MinionPro_Regular.otf" }, + { { name = "Minion Pro", style = "italic" }, "MinionPro_It.otf" }, + { { name = "Minion Pro", style = "bold" }, "MinionPro_Bold.otf" }, + { { name = "Minion Pro", style = "bolditalic" }, "MinionPro_BoldIt.otf" }, } --- this needs a database built with --formats=+pfa,pfb,afm -- cgit v1.2.3 From 14e32b836d6b1b5c729c99de2058a6517e8cc29a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 Jan 2014 22:33:19 +0100 Subject: [main] set correct default loglevel when running as tex (seriously, dtx is an abomination) --- luaotfload.dtx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luaotfload.dtx b/luaotfload.dtx index 08f56af..f27b5e0 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1595,7 +1595,7 @@ config.luaotfload = config.luaotfload or { } config.luaotfload.resolver = config.luaotfload.resolver or "cached" config.luaotfload.definer = config.luaotfload.definer or "patch" config.luaotfload.compatibility = config.luaotfload.compatibility or false -config.luaotfload.loglevel = config.luaotfload.loglevel or 1 +config.luaotfload.loglevel = config.luaotfload.loglevel or 2 config.luaotfload.color_callback = config.luaotfload.color_callback or "pre_linebreak_filter" config.luaotfload.prioritize = config.luaotfload.prioritize or "sys" config.luaotfload.names_dir = config.luaotfload.names_dir or "names" -- cgit v1.2.3 From bb99e2c94aaa32cb3635ec6e35a4dc8ca6e309ae Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 Jan 2014 22:43:05 +0100 Subject: [log] fix newline handling of the last status message when imitating texio.*() Issue reported by /u/eg9 on https://github.com/lualatex/luaotfload/issues/164#issuecomment-31551430 --- luaotfload-override.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/luaotfload-override.lua b/luaotfload-override.lua index b1773fa..fe70dcb 100644 --- a/luaotfload-override.lua +++ b/luaotfload-override.lua @@ -166,6 +166,8 @@ if texjob == true then statusln = function (str) if first_status == false then iowrite (kill_line) + else + iowrite "\n" end iowrite (str) end @@ -326,7 +328,9 @@ end local status_stop = function (...) if first_status == false then status_writer(...) - writeln "" + if texjob == false then + writeln "" + end end end -- cgit v1.2.3 From 4edd98f422b10c7f24cab72f0eb9a64c02ab9305 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Fri, 6 Jun 2014 22:45:57 +0100 Subject: Fix issue #218: support XDG_DATA_HOME for nodes --- src/luaotfload-parsers.lua | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/luaotfload-parsers.lua b/src/luaotfload-parsers.lua index 1048e1d..d5f64fc 100644 --- a/src/luaotfload-parsers.lua +++ b/src/luaotfload-parsers.lua @@ -207,17 +207,19 @@ local conf_filter = function (path) end --[[doc-- - read_fonts_conf_indeed() is called with six arguments; the + read_fonts_conf_indeed() is called with seven arguments; the latter three are tables that represent the state and are always returned. - The first three are + The first four are · the path to the file · the expanded $HOME - · the expanded $XDG_CONFIG_DIR + · the expanded $XDG_CONFIG_HOME + · the expanded $XDG_DATA_HOME --doc]]-- --- string -> string -> string -> tab -> tab -> (tab * tab * tab) local read_fonts_conf_indeed -read_fonts_conf_indeed = function (start, home, xdg_home, +read_fonts_conf_indeed = function (start, home, xdg_config_home, + xdg_data_home, acc, done, dirs_done, find_files) @@ -230,12 +232,11 @@ read_fonts_conf_indeed = function (start, home, xdg_home, local pathobj = paths[i] local kind, path = pathobj[1], pathobj[2] local attributes = pathobj.attributes - if attributes and attributes.prefix == "xdg" then - --- this prepends the xdg root (usually ~/.config) - path = filejoin(xdg_home, path) - end if kind == "dir" then + if attributes and attributes.prefix == "xdg" then + path = filejoin(xdg_data_home, path) + end if stringsub(path, 1, 1) == "~" then path = filejoin(home, stringsub(path, 2)) end @@ -252,6 +253,9 @@ read_fonts_conf_indeed = function (start, home, xdg_home, end elseif kind == "include" then + if attributes and attributes.prefix == "xdg" then + path = filejoin(xdg_config_home, path) + end --- here the path can be four things: a directory or a file, --- in absolute or relative path. if stringsub(path, 1, 1) == "~" then @@ -268,14 +272,14 @@ read_fonts_conf_indeed = function (start, home, xdg_home, --- we exclude path with texmf in them, as they should --- be found otherwise acc = read_fonts_conf_indeed( - path, home, xdg_home, + path, home, xdg_config_home, xdg_data_home, acc, done, dirs_done) elseif lfsisdir(path) then --- arrow code ahead local config_files = find_files (path, conf_filter) for _, filename in next, config_files do if not done[filename] then acc = read_fonts_conf_indeed( - filename, home, xdg_home, + filename, home, xdg_config_home, xdg_data_home, acc, done, dirs_done) end end @@ -292,10 +296,10 @@ read_fonts_conf_indeed = function (start, home, xdg_home, read_fonts_conf() sets up an accumulator and two sets for tracking what’s been done. - Also, the environment variables HOME and XDG_CONFIG_HOME -- - which are constants anyways -- are expanded so don’t have to - repeat that over and over again as with the old parser. - Now they’re just passed on to every call of + Also, the environment variables HOME, XDG_DATA_HOME and + XDG_CONFIG_HOME -- which are constants anyways -- are expanded + so we don’t have to repeat that over and over again as with the + old parser. Now they’re just passed on to every call of read_fonts_conf_indeed(). read_fonts_conf() is also the only reference visible outside @@ -306,14 +310,17 @@ read_fonts_conf_indeed = function (start, home, xdg_home, local read_fonts_conf = function (path_list, find_files) local home = kpseexpand_path"~" --- could be os.getenv"HOME" - local xdg_home = kpseexpand_path"$XDG_CONFIG_HOME" - if xdg_home == "" then xdg_home = filejoin(home, ".config") end + local xdg_config_home = kpseexpand_path"$XDG_CONFIG_HOME" + if xdg_config_home == "" then xdg_config_home = filejoin(home, ".config") end + local xdg_data_home = kpseexpand_path"$XDG_DATA_HOME" + if xdg_data_home == "" then xdg_data_home = filejoin(home, ".local/share") end local acc = { } ---> list: paths collected local done = { } ---> set: files inspected local dirs_done = { } ---> set: dirs in list for i=1, #path_list do --- we keep the state between files acc, done, dirs_done = read_fonts_conf_indeed( - path_list[i], home, xdg_home, + path_list[i], home, xdg_config_home, + xdg_data_home, acc, done, dirs_done, find_files) end -- cgit v1.2.3