diff options
| -rwxr-xr-x | fontdbutil.lua | 12 | ||||
| -rw-r--r-- | luaotfload-database.lua | 84 | ||||
| -rw-r--r-- | luaotfload-features.lua | 37 | ||||
| -rw-r--r-- | luaotfload.dtx | 51 | 
4 files changed, 86 insertions, 98 deletions
diff --git a/fontdbutil.lua b/fontdbutil.lua index af9e23c..470d282 100755 --- a/fontdbutil.lua +++ b/fontdbutil.lua @@ -276,14 +276,20 @@ actions.query = function (job)          optsize       = 0,      } -    local foundname, _whatever, success = +    local foundname, subfont, success =          fonts.names.resolve(nil, nil, tmpspec)      if success then          logs.names_report(false, 1,              "resolve", "Font “%s” found!", query) -        logs.names_report(false, 1, -            "resolve", "Resolved file name “%s”", foundname) +        if subfont then +            logs.names_report(false, 1, "resolve", +                "Resolved file name “%s”, subfont nr. “%s”", +                foundname, subfont) +        else +            logs.names_report(false, 1, +                "resolve", "Resolved file name “%s”", foundname) +        end          if job.show_info then              show_font_info(foundname)          end diff --git a/luaotfload-database.lua b/luaotfload-database.lua index eb8271d..e5065bd 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -291,7 +291,7 @@ do      end  end ---- chain: barenames -> [fullnames ->] basenames -> findfile +local type1_formats = { "tfm", "ofm", }  --- string -> (string * bool | int)  crude_file_lookup_verbose = function (filename) @@ -320,26 +320,19 @@ crude_file_lookup_verbose = function (filename)      if found and mappings[found] then          found = mappings[found].filename          report("info", 0, "db", -            "crude file lookup: req=%s; hit=bare; ret=%s", +            "crude file lookup: req=%s; hit=base; ret=%s",              filename, found[1])          return found      end -    --- now look for tfm et al.; will be superseded by proper -    --- format lookup -    found = resolvers.findfile(filename, "tfm") -    if found then -        report("info", 0, "db", -            "crude file lookup: req=tfm; hit=bare; ret=%s", found) -        return { found, false } -    end -    found = resolvers.findfile(filename, "ofm") -    if found then -        report("info", 0, "db", -            "crude file lookup: req=ofm; hit=bare; ret=%s", found) -        return { found, false } +    --- ofm and tfm +    for i=1, #type1_formats do +        local format = type1_formats[i] +        if resolvers.findfile(filename, format) then +            return { file.addsuffix(filename, format), false }, format +        end      end -    return false +    return { filename, false }, nil  end  --- string -> (string * bool | int) @@ -354,11 +347,13 @@ crude_file_lookup = function (filename)          found = data.mappings[found]          if found then return found.filename end      end -    found = resolvers.findfile(filename, "tfm") -    if found then return { found, false } end -    found = resolvers.findfile(filename, "ofm") -    if found then return { found, false } end -    return false +    for i=1, #type1_formats do +        local format = type1_formats[i] +        if resolvers.findfile(filename, format) then +            return { file.addsuffix(filename, format), false }, format +        end +    end +    return { filename, false }, nil  end  --[[doc-- @@ -644,13 +639,14 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con      end      if #found == 1 then -        if kpselookup(found[1].filename[1]) then -            report("log", 0, "resolve", -                "font family='%s', subfamily='%s' found: %s", -                name, style, found[1].filename[1] -            ) -            return found[1].filename[1], found[1].filename[2], true -        end +        --- Since we do the file resolving ourselves, we don’t need the +        --- kpathsea lookup here any longer. +        --- “found” is really synonymous with “registered in the db”. +        report("log", 0, "resolve", +            "font family='%s', subfamily='%s' found: %s", +            name, style, found[1].filename[1] +        ) +        return found[1].filename[1], found[1].filename[2], true      elseif #found > 1 then          -- we found matching font(s) but not in the requested optical          -- sizes, so we loop through the matches to find the one with @@ -665,13 +661,11 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con                  least   = difference              end          end -        if kpselookup(closest.filename[1]) then -            report("log", 0, "resolve", -                "font family='%s', subfamily='%s' found: %s", -                name, style, closest.filename[1] -            ) -            return closest.filename[1], closest.filename[2], true -        end +        report("log", 0, "resolve", +            "font family='%s', subfamily='%s' found: %s", +            name, style, closest.filename[1] +        ) +        return closest.filename[1], closest.filename[2], true      elseif found.fallback then          return found.fallback.filename[1], found.fallback.filename[2], true      end @@ -680,7 +674,7 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con      if not fonts_reloaded then          --- last straw: try reloading the database          return reload_db( -            "unresoled font name: “" .. name .. "”", +            "unresolved font name: “" .. name .. "”",              resolve, nil, nil, specification          )      end @@ -737,9 +731,7 @@ find_closest = function (name, limit)      local name     = sanitize_string(name)      limit          = limit or fuzzy_limit -    if not fonts_loaded then -        names.data = load_names() -    end +    if not fonts_loaded then names.data = load_names() end      local data = names.data @@ -866,10 +858,10 @@ font_fullinfo = function (filename, subfont, texmf)      tfmdata.fontname    = metadata.fontname      tfmdata.fullname    = metadata.fullname      tfmdata.familyname  = metadata.familyname -    tfmdata.filename    = { -        texmf and filebasename(filename) or filename, -        subfont -    } +    if texmf then +        filename = filebasename(filename) +    end +    tfmdata.filename    = { filename, subfont }      tfmdata.weight      = metadata.pfminfo.weight      tfmdata.width       = metadata.pfminfo.width      tfmdata.slant       = metadata.italicangle @@ -1328,9 +1320,9 @@ update_names = function (fontnames, force)      read_blacklist()      local scanned, new -    scanned, new = scan_texmf_fonts(fontnames, newfontnames) -    n_scanned = n_scanned + scanned -    n_new     = n_new     + new +--    scanned, new = scan_texmf_fonts(fontnames, newfontnames) +--    n_scanned = n_scanned + scanned +--    n_new     = n_new     + new      scanned, new = scan_os_fonts(fontnames, newfontnames)      n_scanned = n_scanned + scanned diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 08414f6..de7ff3f 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -419,23 +419,6 @@ local import_values = {      "style", "optsize", "lookup", "sub" --[[‽]], "mode",  } -local handle_tfmofm = function (specname, raw) -    --- FIXME only file: and name: atm -    local name = raw.file or raw.name or specname -    local lookup -    --- why is this here? -    --- TODO should we keep this, check if it applies only to tfm and -    ---      ofm, and test formats by a defined list! -    if resolvers.findfile(name, "tfm") then -        lookup = "file" -        name   = file.addsuffix(name, "tfm") -    elseif resolvers.findfile(name, "ofm") then -        lookup = "file" -        name   = file.addsuffix(name, "ofm") -    end -    return name, lookup -end -  local lookup_types = { "anon", "file", "name", "path" }  local select_lookup = function (request) @@ -455,9 +438,6 @@ local handle_request = function (specification)      local lookup, name = select_lookup(request)      request.features  = set_default_features(request.features) -    --- FIXME what to do about tfm/ofm?? -    --local name, lookup = handle_tfmofm(specification.name, request) -      if name then          specification.name    = name          specification.lookup  = lookup or specification.lookup @@ -467,7 +447,6 @@ local handle_request = function (specification)          local feat       = import_values[n]          local newvalue   = request.features[feat]          if newvalue then -            print(feat, newvalue)              specification[feat]    = request.features[feat]              request.features[feat] = nil          end @@ -495,22 +474,6 @@ fonts.definers.registersplit("",  handle_request, "more cryptic") -- catches \fo  --fonts.definers.registersplit(":",old_behavior,"cryptic")  --fonts.definers.registersplit("", old_behavior,"more cryptic") -- catches \font\text=[names] ---- TODO below section is literally the same in luatex-fonts-def ----      why is it here? ---function fonts.definers.applypostprocessors(tfmdata) ---    local postprocessors = tfmdata.postprocessors ---    if postprocessors then ---        for i=1,#postprocessors do ---            local extrahash = postprocessors[i](tfmdata) -- after scaling etc ---            if type(extrahash) == "string" and extrahash ~= "" then ---                -- e.g. a reencoding needs this ---                extrahash = string.gsub(lower(extrahash),"[^a-z]","-") ---                tfmdata.properties.fullname = format("%s-%s",tfmdata.properties.fullname,extrahash) ---            end ---        end ---    end ---    return tfmdata ---end  ---[[ end included font-ltx.lua ]]  --[[doc-- diff --git a/luaotfload.dtx b/luaotfload.dtx index 0584f07..722a8d2 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1378,8 +1378,9 @@ loadmodule"colors.lua"     --- “font-clr”  %  %    \begin{macrocode} -local resolvers = fonts.definers.resolvers -local formats   = fonts.formats +local request_resolvers   = fonts.definers.resolvers +local formats             = fonts.formats +formats.ofm               = "type1"  %    \end{macrocode}  % \identifier{luaotfload} promises easy access to system fonts. @@ -1398,15 +1399,13 @@ local formats   = fonts.formats  % most cases when looking up font files, only when generating the database.  %  %    \begin{macrocode} -resolvers.file = function (specification) -    --- how would we go about allowing subfonts (ttc)? -    if specification.lookup == "file" then -        local found = fonts.names.crude_file_lookup(specification.name) -        specification.name = found[1] -    end +request_resolvers.file = function (specification) +    --local found = fonts.names.crude_file_lookup(specification.name) +    local found = fonts.names.crude_file_lookup_verbose(specification.name) +    specification.name = found[1] +    --if format then specification.forced = format end  end ---- TODO rewrite this according to the syntax spec  %    \end{macrocode}  % We classify as \verb|anon:| those requests that have neither a  % prefix nor brackets. According to Khaled\footnote{% @@ -1417,7 +1416,35 @@ end  %  %    \begin{macrocode} -resolvers.anon = resolvers.name +--request_resolvers.anon = request_resolvers.name + +%    \end{macrocode} +% There is one drawback, though. +% This syntax is also used for requesting fonts in \identifier{Type1} +% (\abbrev{tfm}, \abbrev{ofm}) format. +% These are essentially \verb|file:| lookups and must be caught before +% the \verb|name:| resolver kicks in, lest they cause the database to +% update. +% Even if we were to require the \verb|file:| prefix for all +% \identifier{Type1} requests, tests have shown that certain fonts still +% include further fonts (e.~g. \fileent{omlgcb.ofm} will ask for +% \fileent{omsecob.tfm}) \emphasis{using the old syntax}. +% For this reason, we introduce an extra check with an early return. +% +%    \begin{macrocode} +local type1_formats = { "tfm", "ofm", } + +request_resolvers.anon = function (specification) +    local name = specification.name +    for i=1, #type1_formats do +        local format = type1_formats[i] +        if resolvers.findfile(name, format) then +            specification.name = file.addsuffix(name, format) +            return +        end +    end +    request_resolvers.name(specification) +end  %    \end{macrocode}  % Prior to version 2.2, \identifier{luaotfload} did not distinguish @@ -1427,10 +1454,10 @@ resolvers.anon = resolvers.name  % system, otherwise we fall back to the \verb|file:| lookup.  %  %    \begin{macrocode} -resolvers.path = function (specification) +request_resolvers.path = function (specification)      local exists, _ = lfsisfile(specification.name)      if not exists then -- resort to file: lookup -        resolvers.file(specification) +        request_resolvers.file(specification)      end  end  | 
