From a2ea45941a60348f60a312abf8fb01b086dc41a6 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 7 Apr 2016 23:58:55 +0200 Subject: [*] update dates, version --- src/luaotfload-auxiliary.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/luaotfload-auxiliary.lua') diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua index 8292ddd..648c1d3 100644 --- a/src/luaotfload-auxiliary.lua +++ b/src/luaotfload-auxiliary.lua @@ -2,7 +2,7 @@ ----------------------------------------------------------------------- -- FILE: luaotfload-auxiliary.lua -- DESCRIPTION: part of luaotfload --- REQUIREMENTS: luaotfload 2.6 +-- REQUIREMENTS: luaotfload 2.7 -- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang ----------------------------------------------------------------------- -- -- cgit v1.2.3 From a4d0725cce7f78e295491e7e969eff3c0aa07bef Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 8 Apr 2016 23:54:04 +0200 Subject: [init] force preloading of the character table --- src/luaotfload-auxiliary.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/luaotfload-auxiliary.lua') diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua index 648c1d3..2c2624e 100644 --- a/src/luaotfload-auxiliary.lua +++ b/src/luaotfload-auxiliary.lua @@ -301,10 +301,11 @@ aux.name_of_slot = name_of_slot --[[doc-- In Context, characters.data is where the data from char-def.lua - resides. The file is huge (>3.7 MB as of 2013) and not part of the - isolated font loader. Nevertheless, we include a partial version - generated by the mkcharacters script that contains only the - a subset of the fields of each character defined. + resides. The file is huge (>4.4 MB as of 2016) and only a stripped + down version is part of the isolated font loader. Nevertheless, we + include an excerpt generated by the mkcharacters script that contains + a subset of the fields of each character defined and some extra + metadata. Currently, these are (compare the mkcharacters script!) -- cgit v1.2.3 From d9789be6dbd9d77cb4091800f6b50580b25e1868 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 9 Apr 2016 00:30:17 +0200 Subject: [aux,init] move lazy char-def loading code into earlier stage of initialization The fontloader requires parts of the ``characters`` table to be present at load time. This turns out to interfere with our custom of installing the lazy loader for the table components only after the fontloader has been injected. Since inserting the code at the appropriate place in the loading chain would be tedious and unmaintainable due to the various load options, we just preinstall the metatable onto an empty table prior to loading the loader. Some precautions had to be taken regarding the ``classifiers`` subhash of the table that needs to be relocated from the data we received via mkcharacters. --- src/luaotfload-auxiliary.lua | 126 ------------------------------------------- 1 file changed, 126 deletions(-) (limited to 'src/luaotfload-auxiliary.lua') diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua index 2c2624e..6ba21e0 100644 --- a/src/luaotfload-auxiliary.lua +++ b/src/luaotfload-auxiliary.lua @@ -298,132 +298,6 @@ end aux.name_of_slot = name_of_slot ---[[doc-- - - In Context, characters.data is where the data from char-def.lua - resides. The file is huge (>4.4 MB as of 2016) and only a stripped - down version is part of the isolated font loader. Nevertheless, we - include an excerpt generated by the mkcharacters script that contains - a subset of the fields of each character defined and some extra - metadata. - - Currently, these are (compare the mkcharacters script!) - - · "direction" - · "mirror" - · "category" - · "textclass" - - The directional information is required for packages like Simurgh [0] - to work correctly. In an early stage [1] it was necessary to load - further files from Context directly, including the full blown version - of char-def. Since we have no use for most of the so imported - functionality, the required parts have been isolated and are now - instated along with luaotfload-characters.lua. We can extend the set - of imported features easily should it not be enough. - - [0] https://github.com/persian-tex/simurgh - [1] http://tex.stackexchange.com/a/132301/14066 - ---doc]]-- - -characters = characters or { } --- should be created in basics-gen -characters.data = nil -local chardef = "luaotfload-characters" - -do - local setmetatableindex = function (t, f) - local mt = getmetatable (t) - if mt then - mt.__index = f - else - setmetatable (t, { __index = f }) - end - end - - --- there are some special tables for each field that provide access - --- to fields of the character table by means of a metatable - - local mkcharspecial = function (characters, tablename, field) - - local chardata = characters.data - - if chardata then - local newspecial = { } - characters [tablename] = newspecial --> e.g. “characters.data.mirrors” - - local idx = function (t, char) - local c = chardata [char] - if c then - local m = c [field] --> e.g. “mirror” - if m then - t [char] = m - return m - end - end - newspecial [char] = false - return char - end - - setmetatableindex (newspecial, idx) - end - - end - - local mkcategories = function (characters) -- different from the others - - local chardata = characters.data - - setmetatable (characters, { __index = function (t, char) - if char then - local c = chardata [char] - c = c.category or char - t [char] = c - return c - end - end}) - - end - - local load_failed = false - local chardata --> characters.data; loaded on demand - - local load_chardef = function () - - logreport ("both", 1, "aux", "Loading character metadata from %s.", chardef) - chardata = dofile (kpse.find_file (chardef, "lua")) - - if chardata == nil then - warning ("Could not load %s; continuing \z - with empty character table.", - chardef) - chardata = { } - load_failed = true - end - - characters = { } --- nuke metatable - characters.data = chardata - - --- institute some of the functionality from char-ini.lua - - mkcharspecial (characters, "mirrors", "mirror") - mkcharspecial (characters, "directions", "direction") - mkcharspecial (characters, "textclasses", "textclass") - mkcategories (characters) - - end - - local charindex = function (t, k) - if chardata == nil and load_failed ~= true then - load_chardef () - end - - return characters [k] - end - - setmetatableindex (characters, charindex) - -end ----------------------------------------------------------------------- --- features / scripts / languages -- cgit v1.2.3 From 61f0c68e868a58e7f1ddc929a441b3280a571331 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 9 Apr 2016 12:39:25 +0200 Subject: [aux] fix crash in patching code that sets \fontdimen8 Obviously, since Fontforge has been ditched, we need to adapt to the slightly different data structures created by the Lua reader. For the time being, we revise the code so it will not crash instantly due to the lack of a missing ``pfminfo`` table. Hans has been notified of our use of the ``capheight`` data and may add that value grudgingly again. --- src/luaotfload-auxiliary.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/luaotfload-auxiliary.lua') diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua index 6ba21e0..35f8f2b 100644 --- a/src/luaotfload-auxiliary.lua +++ b/src/luaotfload-auxiliary.lua @@ -173,25 +173,30 @@ local set_capheight = function (fontdata) local shared = fontdata.shared local parameters = fontdata.parameters local capheight - if shared and shared.rawdata.metadata.pfminfo then + if shared + and shared.rawdata.metadata + and shared.rawdata.metadata.pfminfo + then local units_per_em = parameters.units local size = parameters.size local os2_capheight = shared.rawdata.metadata.pfminfo.os2_capheight - if os2_capheight > 0 then + if capheight and os2_capheight > 0 then capheight = os2_capheight / units_per_em * size else - local X8 = stringbyte"X" - if fontdata.characters[X8] then - capheight = fontdata.characters[X8].height + local X8_str = stringbyte"X" + local X8_chr = fontdata.characters[X8_str] + if X8_chr then + capheight = X8_chr.height else capheight = parameters.ascender / units_per_em * size end end else - local X8 = stringbyte"X" - if fontdata.characters[X8] then - capheight = fontdata.characters[X8].height + local X8_str = stringbyte "X" + local X8_chr = fontdata.characters[X8_str] + if X8_chr then + capheight = X8_chr.height end end if capheight then -- cgit v1.2.3