[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Ensure to always set an id mapping (2348cf0)

Marcel Fabian Krüger tex at 2krueger.de
Thu Jan 2 17:28:47 CET 2020


Repository : https://github.com/latex3/luaotfload
On branch  : dev
Link       : https://github.com/latex3/luaotfload/commit/2348cf0673056d386748ea8c0cafb8447e1c239e

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

commit 2348cf0673056d386748ea8c0cafb8447e1c239e
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Thu Jan 2 17:28:47 2020 +0100

    Ensure to always set an id mapping
    
    Also enhances compatibility to certain newer engines.


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

2348cf0673056d386748ea8c0cafb8447e1c239e
 src/luaotfload-loaders.lua | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/luaotfload-loaders.lua b/src/luaotfload-loaders.lua
index 66f085d..341e5be 100644
--- a/src/luaotfload-loaders.lua
+++ b/src/luaotfload-loaders.lua
@@ -120,10 +120,23 @@ end
 
 local definers --- (string, spec -> size -> id -> tmfdata) hash_t
 do
-  local read = fonts.definers.read
+  local ctx_read = fonts.definers.read
+  local register = fonts.definers.register
+  local function read(specification, size, id)
+    local tfmdata = ctx_read(specification, size, id)
+    if tonumber(tfmdata) then
+      return tfmdata
+    end
+    if not id then
+      id = font.define(tfmdata)
+      register(tfmdata, id)
+      return id
+    end
+    return tfmdata
+  end
 
   local patch = function (specification, size, id)
-    local fontdata = read (specification, size, id)
+    local fontdata = ctx_read (specification, size, id)
 ----if not fontdata then not_found_msg (specification, size, id) end
     if type (fontdata) == "table" and fontdata.encodingbytes == 2 then
       --- We need to test for `encodingbytes` to avoid passing
@@ -133,6 +146,14 @@ do
     else
       luatexbase.call_callback ("luaotfload.patch_font_unsafe", fontdata, specification, id)
     end
+    if tonumber(fontdata) then
+      return fontdata
+    end
+    if not id then
+      id = font.define(fontdata)
+      register(fontdata, id)
+      return id
+    end
     return fontdata
   end
 





More information about the latex3-commits mailing list