diff options
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua | 141 |
1 files changed, 119 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua index 0a3ace88037..d3de7313f07 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua @@ -2,9 +2,9 @@ ----------------------------------------------------------------------- -- FILE: luaotfload-auxiliary.lua -- DESCRIPTION: part of luaotfload --- REQUIREMENTS: luaotfload 2.3 +-- REQUIREMENTS: luaotfload 2.4 -- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang --- VERSION: 2.3a +-- VERSION: 2.4 -- CREATED: 2013-05-01 14:40:50+0200 ----------------------------------------------------------------------- -- @@ -234,7 +234,7 @@ local set_capheight = function (fontdata) local shared = fontdata.shared local parameters = fontdata.parameters local capheight - if shared then + if shared 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 @@ -368,35 +368,124 @@ aux.name_of_slot = name_of_slot 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 - “direction” and “mirror” fields of each character defined. + a subset of the fields of each character defined. + + 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 = { } -local chardef = "luaotfload-characters" +characters = characters or { } --- should be created in basics-gen +characters.data = nil +local chardef = "luaotfload-characters" do - local chardata - local index = function (t, k) + 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 () + + log ("Loading character metadata from %s.", chardef) + chardata = dofile (kpse.find_file (chardef, "lua")) + if chardata == nil then - log("Loading character metadata from %s.", chardef) - chardata = dofile(kpse.find_file(chardef, "lua")) - if chardata == nil then - warning("Could not load %s; continuing with empty character table.", + warning ("Could not load %s; continuing \z + with empty character table.", chardef) - chardata = { } - end + chardata = { } + load_failed = true end - return chardata[k] + + 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 mt = getmetatable(characters.data) - if mt then - mt.__index = index - else - setmetatable(characters.data, { __index = index }) + local charindex = function (t, k) + if chardata == nil and load_failed ~= true then + load_chardef () + end + + return characters [k] end + + setmetatableindex (characters, charindex) + end ----------------------------------------------------------------------- @@ -588,6 +677,8 @@ aux.sprint_math_dimension = sprint_math_dimension local namesresolve = fonts.names.resolve local namesscan_dir = fonts.names.scan_dir +--[====[-- TODO -> port this to new db model + --- local directories ------------------------------------------------- --- migrated from luaotfload-database.lua @@ -595,7 +686,7 @@ local namesscan_dir = fonts.names.scan_dir --- string -> (int * int) local scan_external_dir = function (dir) - local old_names, new_names = names.data + local old_names, new_names = names.data() if not old_names then old_names = load_names() end @@ -612,6 +703,12 @@ end aux.scan_external_dir = scan_external_dir +--]====]-- + +aux.scan_external_dir = function () + print "ERROR: scan_external_dir() is not implemented" +end + --- db queries -------------------------------------------------------- --- https://github.com/lualatex/luaotfload/issues/74 |