diff options
| -rw-r--r-- | luaotfload-database.lua | 20 | ||||
| -rwxr-xr-x | luaotfload-tool.lua | 10 | 
2 files changed, 23 insertions, 7 deletions
| diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 4e7d5fb..d5e2a7b 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -611,9 +611,11 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con          return specification.name, false, false      end -    local found = { } +    local found      = { } --> collect results +    local candidates = { } --> secondary results, incomplete matches +      local synonym_set = style_synonyms.set -    for _, face in next, data.mappings do +    for n, face in next, data.mappings do          local family, subfamily, fullname, psname, fontname, pfullname          local facenames = face.sanitized @@ -653,6 +655,7 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con                      minsize, maxsize, face)                  if continue == false then break end              elseif subfamily == "regular" or +                --- TODO this match should be performed when building the db                     synonym_set.regular[subfamily] then                  found.fallback = face              elseif name == fullname @@ -665,6 +668,8 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con                      found,   optsize, dsnsize, size,                      minsize, maxsize, face)                  if continue == false then break end +            else --- mark as last straw but continue +                candidates[#candidates+1] = face              end          else              if name == fullname @@ -717,6 +722,17 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con          return found.fallback.filename[1],                 found.fallback.filename[2],                 true +    elseif next(candidates) then +        --- pick the first candidate encountered +        local entry     = candidates[1] +        local filename  = entry.filename[1] +        if is_file(filename, entry.texmf) then +            report("log", 0, "resolve", +                "font family='%s', subfamily='%s' found: %s", +                name, style, filename +            ) +            return filename, entry.filename[2], true +        end      end      --- no font found so far diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index a379633..25cc9fa 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -354,24 +354,24 @@ actions.query = function (job)          fonts.names.resolve(nil, nil, tmpspec)      if success then -        logs.names_report(false, 1, +        logs.names_report(false, 0,              "resolve", "Font “%s” found!", query)          if subfont then -            logs.names_report(false, 1, "resolve", +            logs.names_report(false, 0, "resolve",                  "Resolved file name “%s”, subfont nr. “%s”",                  foundname, subfont)          else -            logs.names_report(false, 1, +            logs.names_report(false, 0,                  "resolve", "Resolved file name “%s”", foundname)          end          if job.show_info then              show_font_info(foundname)          end      else -        logs.names_report(false, 1, +        logs.names_report(false, 0,              "resolve", "Cannot find “%s”.", query)          if job.fuzzy == true then -            logs.names_report(false, 1, +            logs.names_report(false, 0,                  "resolve", "Looking for close matches, this may take a while ...")              local success = fonts.names.find_closest(query, job.fuzzy_limit)          end | 
