From 78d506538016cd295d9a84ac62e3e036f23feffc Mon Sep 17 00:00:00 2001
From: Khaled Hosny
We can resolve the filename using the next function:
--ldx]]-- +define.resolvers = resolvers + +function define.resolvers.file(specification) + specification.forced = file.extname(specification.name) + specification.name = file.removesuffix(specification.name) +end + +function define.resolvers.name(specification) + local resolve = fonts.names.resolve + if resolve then + specification.resolved, specification.sub = fonts.names.resolve(specification.name,specification.sub) + if specification.resolved then + specification.forced = file.extname(specification.resolved) + specification.name = file.removesuffix(specification.resolved) + end + else + define.resolvers.file(specification) + end +end + +function define.resolvers.spec(specification) + local resolvespec = fonts.names.resolvespec + if resolvespec then + specification.resolved, specification.sub = fonts.names.resolvespec(specification.name,specification.sub) + if specification.resolved then + specification.forced = file.extname(specification.resolved) + specification.name = file.removesuffix(specification.resolved) + end + else + define.resolvers.name(specification) + end +end + function define.resolve(specification) if not specification.resolved or specification.resolved == "" then -- resolved itself not per se in mapping hash - if specification.lookup == 'name' then - specification.resolved, specification.sub = fonts.names.resolve(specification.name,specification.sub) - if specification.resolved then - specification.forced = file.extname(specification.resolved) - specification.name = file.removesuffix(specification.resolved) - end - elseif specification.lookup == 'file' then - specification.forced = file.extname(specification.name) - specification.name = file.removesuffix(specification.name) + local r = define.resolvers[specification.lookup] + if r then + r(specification) end end if specification.forced == "" then @@ -232,7 +275,6 @@ function define.resolve(specification) else specification.forced = specification.forced end ---~ specification.hash = specification.name .. ' @ ' .. tfm.hash_features(specification) specification.hash = lower(specification.name .. ' @ ' .. tfm.hash_features(specification)) if specification.sub and specification.sub ~= "" then specification.hash = specification.sub .. ' @ ' .. specification.hash @@ -271,15 +313,21 @@ function tfm.read(specification) local reader = sequence[s] if readers[reader] then -- not really needed if trace_defining then - logs.report("define font","trying type %s for %s with file %s",reader,specification.name,specification.filename or "unknown") + logs.report("define font","trying (sequence driven) type %s for %s with file %s",reader,specification.name,specification.filename or "unknown") end tfmtable = readers[reader](specification) - if tfmtable then break end + if tfmtable then + break + else + specification.filename = nil + end end end end if tfmtable then - if tfmtable.filename and fonts.dontembed[tfmtable.filename] then + if directive_embedall then + tfmtable.embedding = "full" + elseif tfmtable.filename and fonts.dontembed[tfmtable.filename] then tfmtable.embedding = "no" else tfmtable.embedding = "subset" @@ -402,16 +450,22 @@ function readers.afm(specification,method) return tfmtable end -local function check_otf(specification,suffix,what) - local fullname, tfmtable = resolvers.findbinfile(specification.name,suffix) or "", nil +-- maybe some day a set of names + +local function check_otf(forced,specification,suffix,what) + local name = specification.name + if forced then + name = file.addsuffix(name,suffix) + end + local fullname, tfmtable = resolvers.findbinfile(name,suffix) or "", nil -- one shot if fullname == "" then - local fb = fonts.names.old_to_new[specification.name] + local fb = fonts.names.old_to_new[name] if fb then fullname = resolvers.findbinfile(fb,suffix) or "" end end if fullname == "" then - local fb = fonts.names.new_to_old[specification.name] + local fb = fonts.names.new_to_old[name] if fb then fullname = resolvers.findbinfile(fb,suffix) or "" end @@ -426,13 +480,11 @@ end function readers.opentype(specification,suffix,what) local forced = specification.forced or "" if forced == "otf" then - return check_otf(specification,forced,"opentype") - elseif forced == "ttf" then - return check_otf(specification,forced,"truetype") - elseif forced == "ttf" then - return check_otf(specification,forced,"truetype") + return check_otf(true,specification,forced,"opentype") + elseif forced == "ttf" or forced == "ttc" or forced == "dfont" then + return check_otf(true,specification,forced,"truetype") else - return check_otf(specification,suffix,what) + return check_otf(false,specification,suffix,what) end end -- cgit v1.2.3