From db2e9e6df994386a71d9cca126b55e2676eedfc3 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 3 May 2016 00:09:40 +0200 Subject: [main,tool] reintroduce lost version check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The version check was removed by accident in commit 5ce60cc98a30. This isn’t normally a problem except when people start to run the Pretest version on ancient Luatex binaries … In any case, the check must be present. While we’re at it, make the error messages consistent between the tool and a live TeX run. This can’t cover the fact that there is no (direct) means of determining the Luatex version when not running in TeX mode, so the checks still aren’t equivalent. --- src/luaotfload-main.lua | 23 ++++++++++++++++++++++- src/luaotfload-tool.lua | 30 ++++++++++++------------------ 2 files changed, 34 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 9e8d088..25be3db 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -13,9 +13,30 @@ local luaotfload = luaotfload luaotfload.log = luaotfload.log or { } luaotfload.version = "2.7" luaotfload.loaders = { } -luaotfload.min_luatex_version = 95 --- i. e. 0.95 +luaotfload.min_luatex_version = { 0, 95, 0 } --- i. e. 0.95.0 luaotfload.fontloader_package = "reference" --- default: from current Context +if not tex or not tex.luatexversion then + error "this program must be run in TeX mode" --- or call tex.initialize() =) +else + --- version check + local major = tex.luatexversion / 100 + local minor = tex.luatexversion % 100 + local revision = tex.luatexrevision --[[ : string ]] + local revno = tonumber (revision) + local minimum = luaotfload.min_luatex_version + if major < minimum [1] or minor < minimum [2] + or revno and revno < minimum [3] + then + texio.write_nl ("term and log", + string.format ("\tFATAL ERROR\n\z + \tLuaotfload requires a Luatex version >= %d.%d.%d.\n\z + \tPlease update your TeX distribution!\n\n", + (unpack or table.unpack) (minimum))) + error "version check failed" + end +end + local authors = "\z Hans Hagen,\z Khaled Hosny,\z diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index 376aa39..9ffdbe6 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -7,10 +7,11 @@ -- LICENSE: GPL v2.0 ----------------------------------------------------------------------- -luaotfload = luaotfload or { } -local version = "2.7" -luaotfload.version = version -luaotfload.self = "luaotfload-tool" +luaotfload = luaotfload or { } +local version = "2.7" +luaotfload.version = version +luaotfload.min_luatex_version = { 0, 95, 0 } --- i. e. 0.95.0 +luaotfload.self = "luaotfload-tool" --[[doc-- @@ -33,16 +34,6 @@ see the luaotfload documentation for more info. Report bugs to kpse.set_program_name "luatex" ---[[doc-- - - We test for Lua 5.1 by means of capability detection to see if - we’re running an outdated Luatex. If so, we bail. - - \url{http://lua-users.org/wiki/LuaVersionCompatibility} - ---doc]]-- - - local iowrite = io.write local kpsefind_file = kpse.find_file local mathfloor = math.floor @@ -64,11 +55,14 @@ if _G.getfenv ~= nil then -- 5.1 or LJ if _G.jit ~= nil then runtime = { "jit", jit.version } else + local minimum = luaotfload.min_luatex_version runtime = { "stock", _VERSION } - print "FATAL ERROR" - print "Luaotfload requires a Luatex version >=0.76." - print "Please update your TeX distribution!" - os.exit (-1) + texio.write_nl ("term and log", + string.format ("\tFATAL ERROR\n\z + \tLuaotfload requires a Luatex version >= %d.%d.%d.\n\z + \tPlease update your TeX distribution!\n\n", + (unpack or table.unpack) (minimum))) + error "version check failed" end else -- 5.2 runtime = { "stock", _VERSION } -- cgit v1.2.3 From 664b28e1a6e6ded4240f05b329f754f0144d3f71 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 3 May 2016 08:09:36 +0200 Subject: [tool] check for version info in stats table This could become the common check eventually. --- src/luaotfload-tool.lua | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index 9ffdbe6..547796e 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -50,13 +50,23 @@ local texiowrite = texio.write local tonumber = tonumber local type = type -local runtime -if _G.getfenv ~= nil then -- 5.1 or LJ - if _G.jit ~= nil then - runtime = { "jit", jit.version } - else - local minimum = luaotfload.min_luatex_version - runtime = { "stock", _VERSION } +do + local runtime = _G.jit and { "jit" , jit.version } + or { "stock", _VERSION } + local stats = status and status.list () + local minimum = luaotfload.min_luatex_version + local actual = { 0, 0, 0 } + if stats then + local major = stats.luatex_version / 100 + local minor = stats.luatex_version % 100 + local revision = stats.luatex_revision --[[ : string ]] + local revno = tonumber (revision) + actual = { major, minor, revno or 0 } + end + + if actual [1] < minimum [1] or actual [2] < minimum [2] + or actual [3] < minimum [3] + then texio.write_nl ("term and log", string.format ("\tFATAL ERROR\n\z \tLuaotfload requires a Luatex version >= %d.%d.%d.\n\z @@ -64,8 +74,8 @@ if _G.getfenv ~= nil then -- 5.1 or LJ (unpack or table.unpack) (minimum))) error "version check failed" end -else -- 5.2 - runtime = { "stock", _VERSION } + luaotfload.runtime = runtime + luaotfload.luatex_version = actual end local C, Ct, P, S = lpeg.C, lpeg.Ct, lpeg.P, lpeg.S @@ -330,15 +340,18 @@ local version_msg = function ( ) local out = function (...) texiowrite_nl (stringformat (...)) end local uname = os.uname () local meta = fonts.names.getmetadata () - local info = status.list () + + local runtime = luaotfload.runtime + local actual = luaotfload.luatex_version + local status = config.luaotfload.status + local notes = status and status.notes or { } + out (about, luaotfload.self) out ("%s version: %q", luaotfload.self, version) - out ("Revision: %q", config.luaotfload.status.notes.revision) + out ("Revision: %q", notes.revision) out ("Lua interpreter: %s; version %q", runtime[1], runtime[2]) --[[out ("Luatex SVN revision: %d", info.luatex_svn)]] --> SVN r5624 - out ("Luatex version: %.2f.%d", - info.luatex_version / 100, - info.luatex_revision) + out ("Luatex version: %d.%d", actual [1], actual [2]) out ("Platform: type=%s name=%s", os.type, os.name) local uname_vars = tablesortedkeys (uname) @@ -350,7 +363,7 @@ local version_msg = function ( ) out("No database metadata available.") else out ("Index: version=%q created=%q modified=%q", - config.luaotfload.status.notes.revision, + meta.version or "too old", meta.created or "ages ago", meta.modified or "ages ago") end -- cgit v1.2.3 From 8c0dd0ebbedd93cc476d7dd3fbffc4a6d75c7439 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 3 May 2016 08:27:33 +0200 Subject: [letterspace] fix double free with disc components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adress issue #350 For some reason our stack copy of the current node gets double-freed. Since the “components” field will probably vanish soon, we can get by for now by skipping the explicit free. --- src/luaotfload-letterspace.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/luaotfload-letterspace.lua b/src/luaotfload-letterspace.lua index 40b3015..21a9136 100644 --- a/src/luaotfload-letterspace.lua +++ b/src/luaotfload-letterspace.lua @@ -28,9 +28,6 @@ local setfield = nodedirect.setfield local field_setter = function (name) return function (n, ...) setfield (n, name, ...) end end local field_getter = function (name) return function (n, ...) getfield (n, name, ...) end end ---- As of December 2014 the faster ``node.direct.*`` interface is ---- preferred. - local getfont = nodedirect.getfont local getid = nodedirect.getid @@ -351,7 +348,7 @@ kerncharacters = function (head) end start = c setfield(s, "components", nil) - free_node(s) + --free_node(s) --> double free with multipart components c = getfield (start, "components") end end -- cgit v1.2.3 From 45b6c12f7b08a2fed47263a94fbc76bd4b91302a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 4 May 2016 20:37:14 +0200 Subject: [features] straighten out logspam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to the origin in other parts of Luatex, some messages in this file were logged under the “load” facility; corrected. Also, the combo mechanism still spits debug levels of noise at log level zero; raised to two. --- src/luaotfload-features.lua | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/luaotfload-features.lua b/src/luaotfload-features.lua index 5e9bf7b..cb3849c 100644 --- a/src/luaotfload-features.lua +++ b/src/luaotfload-features.lua @@ -74,7 +74,7 @@ local defined_combos = 0 local handle_combination = function (combo, spec) defined_combos = defined_combos + 1 if not combo [1] then - report ("both", 0, "load", + report ("both", 0, "features", "combo %d: Empty font combination requested.", defined_combos) return false @@ -91,7 +91,7 @@ local handle_combination = function (combo, spec) tablesort (combo, cmp_by_idx) --- pass 1: skim combo and resolve fonts - report ("both", 0, "load", "combo %d: combining %d fonts.", + report ("both", 2, "features", "combo %d: combining %d fonts.", defined_combos, n) for i = 1, n do local cur = combo [i] @@ -101,18 +101,18 @@ local handle_combination = function (combo, spec) if fnt then local chars = cur.chars if chars == true then - report ("both", 0, "load", + report ("both", 2, "features", " *> %.2d: fallback font %d at rank %d.", i, id, idx) else - report ("both", 0, "load", + report ("both", 2, "features", " *> %.2d: include font %d at rank %d (%d items).", i, id, idx, (chars and #chars or 0)) end chain [#chain + 1] = { fnt, chars, idx = idx } fontids [#fontids + 1] = { id = id } else - report ("both", 0, "load", + report ("both", 0, "features", " *> %.2d: font %d at rank %d unknown, skipping.", n, id, idx) --- TODO might instead attempt to define the font at this point @@ -122,14 +122,14 @@ local handle_combination = function (combo, spec) local nc = #chain if nc == 0 then - report ("both", 0, "load", + report ("both", 0, "features", " *> no valid font (of %d) in combination.", n) return false end local basefnt = chain [1] [1] if nc == 1 then - report ("both", 0, "load", + report ("both", 0, "features", " *> combination boils down to a single font (%s) \z of %d initially specified; not pursuing this any \z further.", basefnt.fullname, n) @@ -168,24 +168,24 @@ local handle_combination = function (combo, spec) for j = 1, #def do local this = def [j] if type (this) == "number" then - report ("both", 0, "load", + report ("both", 2, "features", " *> [%d][%d]: import codepoint U+%.4X", i, j, this) pickchr (this) elseif type (this) == "table" then local lo, hi = unpack (this) - report ("both", 0, "load", + report ("both", 2, "features", " *> [%d][%d]: import codepoint range U+%.4X--U+%.4X", i, j, lo, hi) for uc = lo, hi do pickchr (uc) end else - report ("both", 0, "load", + report ("both", 0, "features", " *> item no. %d of combination definition \z %d not processable.", j, i) end end end - report ("both", 0, "load", + report ("both", 2, "features", " *> font %d / %d: imported %d glyphs into combo.", i, nc, cnt) end @@ -1081,7 +1081,7 @@ local apply_default_features = function (speclist) or (scripts[script] and script) or "dflt" if support_incomplete[script] then - report("log", 0, "load", + report("log", 0, "features", "Support for the requested script: " .. "%q may be incomplete.", script) end @@ -1090,13 +1090,13 @@ local apply_default_features = function (speclist) end speclist.script = script - report("log", 1, "load", + report("log", 2, "features", "Auto-selecting default features for script: %s.", script) local requested = default_features.defaults[script] if not requested then - report("log", 1, "load", + report("log", 2, "features", "No default features for script %q, falling back to \"dflt\".", script) requested = default_features.defaults.dflt @@ -1157,8 +1157,7 @@ local handle_slashed = function (modifiers) optsize = tonumber(mod[2]) elseif mod == false then --- ignore - report("log", 0, - "load", "unsupported font option: %s", v) + report("log", 0, "features", "unsupported font option: %s", v) elseif supported[mod] then style = supported[mod] elseif not stringis_empty(mod) then @@ -1189,9 +1188,9 @@ local handle_request = function (specification) --- in an anonymous lookup; --- we try to behave as friendly as possible --- just go with it ... - report("log", 1, "load", "invalid request %q of type anon", + report("log", 1, "features", "invalid request %q of type anon", specification.specification) - report("log", 1, "load", + report("log", 1, "features", "use square bracket syntax or consult the documentation.") --- The result of \fontname must be re-feedable into \font --- which is expected by the Latex font mechanism. Now this @@ -1255,7 +1254,7 @@ end if as_script == true then --- skip the remainder of the file fonts.names.handle_request = handle_request - report ("log", 5, "load", + report ("log", 5, "features", "Exiting early from luaotfload-features.lua.") return else -- cgit v1.2.3 From 109d0b5c76cf614385482b6efd52fca9c76c1cfa Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 4 May 2016 20:44:44 +0200 Subject: [features] prevent database reload upon referencing a combination Defining a combination did not override the default file: lookup so every font defined that way will at font embedding time trigger a reload of the index on account of a missing file. Setting the ``combo:`` lookup will prevent the issue. --- src/luaotfload-features.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/luaotfload-features.lua b/src/luaotfload-features.lua index cb3849c..5152fab 100644 --- a/src/luaotfload-features.lua +++ b/src/luaotfload-features.lua @@ -189,6 +189,7 @@ local handle_combination = function (combo, spec) " *> font %d / %d: imported %d glyphs into combo.", i, nc, cnt) end + spec.lookup = "combo" spec.file = basefnt.filename spec.name = stringformat ("luaotfload<%d>", defined_combos) spec.features = { normal = { spec.specification } } -- cgit v1.2.3 From 766978d24919fef28e12a8c4239c96e92dc349a5 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 4 May 2016 21:06:52 +0200 Subject: [aux] fix units lookup prevent crash with AFM fonts With the new loader, the ``units_per_em`` field resides under the toplevel TFM structure with the key ``units``. For AFM fonts, it is not fount under the metadata table too, which we are currently querying. Thus we prefer the main value, falling back on metadata only in case it is missing. At this occasion, tidy up our unit lookup helper and use that wherever we need access to the values ourselves. --- src/luaotfload-auxiliary.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua index e544dd7..e482aba 100644 --- a/src/luaotfload-auxiliary.lua +++ b/src/luaotfload-auxiliary.lua @@ -100,17 +100,21 @@ luaotfload_callbacks [#luaotfload_callbacks + 1] = { "patch_font", set_sscale_dimens, "set_sscale_dimens", } +local default_units = 1000 + --- fontobj -> int local lookup_units = function (fontdata) - local metadata = fontdata.shared and fontdata.shared.rawdata.metadata - if metadata and metadata.units then - return metadata.units - elseif fontdata.parameters and fontdata.parameters.units then - return fontdata.parameters.units - elseif fontdata.units then --- v1.x - return fontdata.units + local units = fontdata.units + if units and units > 0 then return units end + local shared = fontdata.shared if not shared then return default_units end + local rawdata = shared.rawdata if not rawdata then return default_units end + local metadata = rawdata.metadata if not metadata then return default_units end + local capheight = metadata.capheight if not capheight then return default_units end + local units = metadata.units or fontdata.units + if not units or units == 0 then + return default_units end - return 1000 + return units end --[[doc-- @@ -213,8 +217,9 @@ local query_ascender = function (fontdata) local metadata = rawdata.metadata if not metadata then return false end local ascender = parameters.ascender or metadata.ascender if not ascender then return false end - local units = metadata.units if units == 0 then return false end local size = parameters.size if not size then return false end + local units = lookup_units (fontdata) + if not units or units == 0 then return false end return ascender * size / units end @@ -224,8 +229,9 @@ local query_capheight = function (fontdata) local rawdata = shared.rawdata if not rawdata then return false end local metadata = rawdata.metadata if not metadata then return false end local capheight = metadata.capheight if not capheight then return false end - local units = metadata.units if units == 0 then return false end local size = parameters.size if not size then return false end + local units = lookup_units (fontdata) + if not units or units == 0 then return false end return capheight * size / units end -- cgit v1.2.3 From acd8c47a0c8bda41d1bf57a6bbc9b37b83065f6c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 4 May 2016 21:12:08 +0200 Subject: [letterspace] fix crash in kerning by keeping the default on failed lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With commit 8c0dd0ebbedd kern accesses were fixed but the results never tested for the lookup, which caused the default which is set up before to be nil’ed. Fix this by reusing the value we initialized the kern factor to. --- src/luaotfload-letterspace.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/luaotfload-letterspace.lua b/src/luaotfload-letterspace.lua index 21a9136..78df1d7 100644 --- a/src/luaotfload-letterspace.lua +++ b/src/luaotfload-letterspace.lua @@ -413,7 +413,7 @@ kerncharacters = function (head) else local kern = 0 local kerns = prevchardata.kerns - if kerns then kern = kerns[lastchar] end + if kerns then kern = kerns[lastchar] or kern end krn = kern + quaddata[lastfont]*krn -- here insert_node_before(head,start,kern_injector(fillup,krn)) end @@ -488,7 +488,7 @@ kerncharacters = function (head) --- font doesn’t contain the glyph else local kerns = prevchardata.kerns - if kerns then kern = kerns[lastchar] end + if kerns then kern = kerns[lastchar] or kern end end end krn = kern + quaddata[lastfont]*krn -- here -- cgit v1.2.3 From 0ba71246a7445204a457602806f9cc80c0cbe354 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 4 May 2016 21:49:06 +0200 Subject: [tool] include release tag in --version This info is indeed valuable on top of the commit hash, thanks to @jfbu who complained about its absence. --- src/luaotfload-tool.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index 547796e..35dc9b3 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -348,6 +348,9 @@ local version_msg = function ( ) out (about, luaotfload.self) out ("%s version: %q", luaotfload.self, version) + if notes.description then + out ("Luaotfload: %q", notes.description) + end out ("Revision: %q", notes.revision) out ("Lua interpreter: %s; version %q", runtime[1], runtime[2]) --[[out ("Luatex SVN revision: %d", info.luatex_svn)]] --> SVN r5624 -- cgit v1.2.3