OSDN Git Service

ltj-jfont.lua: id.filename may be nil in luaotfload v2.7
[luatex-ja/luatexja.git] / src / ltj-jfont.lua
index d357231..16ba9d9 100644 (file)
@@ -31,7 +31,6 @@ local id_glyph = node.id('glyph')
 local id_kern = node.id('kern')
 local cat_lp = luatexbase.catcodetables['latex-package']
 local FROM_JFM     = luatexja.icflag_table.FROM_JFM
-local tokenlib = luatexja.token
 ------------------------------------------------------------------------
 -- LOADING JFM
 ------------------------------------------------------------------------
@@ -368,18 +367,18 @@ do
    end
 
    -- define_font callback
-   local otfl_fdr = fonts.definers.read
+   local otfl_fdr
    local ltjr_font_callback = ltjr.font_callback
    function luatexja.font_callback(name, size, id)
       local new_name = is_def_jfont and extract_metric(name) or name
       is_def_jfont = false
-      --local res =  otfl_fdr(new_name, size, id)
       local res =  ltjr_font_callback(new_name, size, id, otfl_fdr)
       luatexbase.call_callback('luatexja.define_font', res, new_name, size, id)
       -- this callback processes variation selector, so we execute it always
       return res
    end
    luatexbase.create_callback('luatexja.define_font', 'simple', function (n) return n end)
+   otfl_fdr= luatexbase.remove_from_callback('define_font', 'luaotfload.define_font')
    luatexbase.add_to_callback('define_font',luatexja.font_callback,"luatexja.font_callback", 1)
 end
 
@@ -782,8 +781,8 @@ do
    local checksum = file.checksum
 
    local function prepare_extra_data_base(id)
-      if not id then return end
-      local bname = file.nameonly(id.filename or '')
+      if (not id) or (not id.filename) then return end
+      local bname = file.nameonly(id.filename)
       if not font_extra_basename[bname] then
         -- if the cache is present, read it
         local newsum = checksum(id.filename) -- MD5 checksum of the fontfile
@@ -810,7 +809,7 @@ do
       end
    end
    local function prepare_extra_data_font(id, res)
-      if type(res)=='table' and res.shared then
+      if type(res)=='table' and res.shared and res.filename then
         font_extra_info[id] = font_extra_basename[file.nameonly(res.filename)]
       end
    end