summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--luaotfload-auxiliary.lua42
1 files changed, 41 insertions, 1 deletions
diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua
index 64fac90..1a48914 100644
--- a/luaotfload-auxiliary.lua
+++ b/luaotfload-auxiliary.lua
@@ -26,6 +26,9 @@ local identifiers = fonts.hashes.identifiers
local fontid = font.id
local texsprint = tex.sprint
+local dofile = dofile
+local getmetatable = getmetatable
+local setmetatable = setmetatable
local utf8 = unicode.utf8
local stringlower = string.lower
local stringformat = string.format
@@ -227,7 +230,7 @@ luatexbase.add_to_callback(
"luaotfload.aux.set_capheight")
-----------------------------------------------------------------------
---- glyphs
+--- glyphs and characters
-----------------------------------------------------------------------
local agl = fonts.encodings.agl
@@ -321,6 +324,43 @@ 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 (>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.
+
+--doc]]--
+
+characters = characters or { } --- should be created in basics-gen
+characters.data = { }
+local chardef = "luaotfload-characters"
+
+do
+ local chardata
+ local index = function (t, k)
+ if chardata == nil then
+ log("Loading character metadata from %s.", chardef)
+ chardata = dofile(kpse.find_file("luaotfload-characters.lua"))
+ if chardata == nil then
+ warning("Could not load %s; continuing with empty character table.",
+ chardef)
+ chardata = { }
+ end
+ end
+ return chardata[k]
+ end
+
+ local mt = getmetatable(characters.data)
+ if mt then
+ mt.__index = index
+ else
+ setmetatable(characters.data, { __index = index })
+ end
+end
+
-----------------------------------------------------------------------
--- features / scripts / languages
-----------------------------------------------------------------------