summaryrefslogtreecommitdiff
path: root/src/luaotfload-auxiliary.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-06-04 22:15:12 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2014-06-04 22:15:12 +0200
commit467bddf27f4c158e04cfefa3d68d64b58a290a72 (patch)
tree9c072c02ad478cfb511d41910df3c5326a02a815 /src/luaotfload-auxiliary.lua
parent84619758adf39e49553662b4a5af806c1527001e (diff)
downloadluaotfload-467bddf27f4c158e04cfefa3d68d64b58a290a72.tar.gz
aux: add helpers for accessing the index table/index file
Diffstat (limited to 'src/luaotfload-auxiliary.lua')
-rw-r--r--src/luaotfload-auxiliary.lua41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua
index 14c2ab5..89bf51b 100644
--- a/src/luaotfload-auxiliary.lua
+++ b/src/luaotfload-auxiliary.lua
@@ -20,6 +20,7 @@ local log = luaotfload.log
local report = log.report
local fonthashes = fonts.hashes
local identifiers = fonthashes.identifiers
+local fontnames = fonts.names
local fontid = font.id
local texsprint = tex.sprint
@@ -590,8 +591,8 @@ aux.sprint_math_dimension = sprint_math_dimension
--- extra database functions
-----------------------------------------------------------------------
-local namesresolve = fonts.names.resolve
-local namesscan_dir = fonts.names.scan_dir
+local namesresolve = fontnames.resolve
+local namesscan_dir = fontnames.scan_dir
--[====[-- TODO -> port this to new db model
@@ -663,6 +664,42 @@ end
aux.resolve_fontlist = resolve_fontlist
+--- index access ------------------------------------------------------
+
+--- Based on a discussion on the Luatex mailing list:
+--- http://tug.org/pipermail/luatex/2014-June/004881.html
+
+--[[doc--
+
+ aux.read_font_index -- Read the names index from the canonical
+ location and return its contents. This does not affect the behavior
+ of Luaotfload: The returned table is independent of what the font
+ resolvers use internally. Access is raw: each call to the function
+ will result in the entire table being re-read from disk.
+
+--doc]]--
+
+local load_names = fontnames.load
+local access_font_index = fontnames.access_font_index
+
+local read_font_index = function ()
+ return load_names (true) or { }
+end
+
+--[[doc--
+
+ aux.font_index -- Access Luaotfload’s internal database. If the
+ database hasn’t been loaded yet this will cause it to be loaded, with
+ all the possible side-effects like for instance creating the index
+ file if it doesn’t exist, reading all font files, &c.
+
+--doc]]--
+
+local font_index = function () return access_font_index () end
+
+aux.read_font_index = read_font_index
+aux.font_index = font_index
+
--- loaded fonts ------------------------------------------------------
--- just a proof of concept