[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Reimplement final font cache (5b4c379)

Marcel Fabian Krüger tex at 2krueger.de
Thu May 26 16:04:43 CEST 2022


Repository : https://github.com/latex3/luaotfload
On branch  : dev
Link       : https://github.com/latex3/luaotfload/commit/5b4c379de00c41048d120a251328d7b3543099e6

>---------------------------------------------------------------

commit 5b4c379de00c41048d120a251328d7b3543099e6
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Tue May 24 02:03:58 2022 +0200

    Reimplement final font cache


>---------------------------------------------------------------

5b4c379de00c41048d120a251328d7b3543099e6
 src/luaotfload-loaders.lua | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/luaotfload-loaders.lua b/src/luaotfload-loaders.lua
index 9643e26..253554a 100644
--- a/src/luaotfload-loaders.lua
+++ b/src/luaotfload-loaders.lua
@@ -104,14 +104,29 @@ local function not_found_msg (specification, size, id)
   logreport ("both", 0, "loaders",
              "--------------------------------------------------------")
 end
---[[doc--
-
-    \subsection{\CONTEXT override}
-    \label{define-font}
-    We provide a simplified version of the original font definition
-    callback.
 
---doc]]--
+do
+  local hashed_cache = {}
+  local tfmdata_cache = fonts.hashes.identifiers
+  local function register(tfmdata, id)
+    if tfmdata and id then
+      local hash = tfmdata.properties.hash
+      if not hash then
+        logreport('both', 3, 'loaders', "Registering font %s with id %s with missing hash.", id, tfmdata.properties.filename or "unknown")
+      elseif not hashed_cache[hash] then
+        hashed_cache[hash] = id
+        logreport('both', 5, 'loaders', "Registering font %s with id %s and hash hash.", id, tfmdata.properties.filename or "unknown", hash)
+      end
+      tfmdata_cache[id] = tfmdata
+    end
+  end
+  function registered(hash)
+   local id = hashed_cache[hash]
+   return id, tfmdata_cache[id]
+  end
+  fonts.definers.register = register
+  fonts.definers.registered = registered
+end
 
 
 local definers --- (string, spec -> size -> id -> tmfdata) hash_t





More information about the latex3-commits mailing list.