[latex3-commits] [git/LaTeX3-latex3-luaotfload] xetex: Add aliases for families (d2a5d57)
Marcel Fabian Krüger
tex at 2krueger.de
Sat May 8 22:17:15 CEST 2021
Repository : https://github.com/latex3/luaotfload
On branch : xetex
Link : https://github.com/latex3/luaotfload/commit/d2a5d575a5ce10c38beee9a3f44212bf62e06b74
>---------------------------------------------------------------
commit d2a5d575a5ce10c38beee9a3f44212bf62e06b74
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Sat May 8 22:17:15 2021 +0200
Add aliases for families
>---------------------------------------------------------------
d2a5d575a5ce10c38beee9a3f44212bf62e06b74
src/luaotfload-tool.lua | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua
index c18c200..6a00ae9 100755
--- a/src/luaotfload-tool.lua
+++ b/src/luaotfload-tool.lua
@@ -1401,13 +1401,43 @@ function actions.aliases (job)
local name_index = fonts.names.data() or fonts.names.load()
local mappings = name_index.mappings
local fontnames = name_index.fontnames.texmf
- local formats = { 'ttf', 'otf', }
+ local families = name_index.families.texmf
+ local formats = { 'ttf', 'otf', }
for _, format in ipairs(formats) do
for name, mapping in pairs(fontnames[format]) do
mapping = mappings[mapping]
print(string.format('%s %s', mapping.basename, name))
end
end
+ local function best_match(options, target)
+ if not options then return end
+ if options.default then return mappings[options.default] end
+ local best, best_diff = nil, math.huge
+ for _, option in ipairs(options) do
+ local diff = math.abs(option[1]-target)
+ if diff < best_diff then
+ best, best_diff = option[4], diff
+ end
+ end
+ return mappings[best]
+ end
+ for _, format in ipairs(formats) do
+ for name, family in pairs(families[format]) do
+ local r = best_match(family.r, 655360, mappings)
+ local b = best_match(family.b, 655360, mappings)
+ local i = best_match(family.i, 655360, mappings)
+ local bi = best_match(family.bi, 655360, mappings)
+ r = r or b or i or bi -- Not sure if this is still needed
+ if r then
+ b, i, bi = b or r, i or r, bi or r
+ print(string.format('%s %s\n%s %s-b\n%s %s-i\n%s %s-bi',
+ r.basename, name,
+ b.basename, name,
+ i.basename, name,
+ bi.basename, name))
+ end
+ end
+ end
return true
end
More information about the latex3-commits
mailing list.