summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-11-05 18:17:58 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2013-11-05 18:17:58 +0100
commit36129aa2413bf76f7d9663e8de505e00eee5065f (patch)
tree0efb17bd2a73a00e3699da134e53f8b5d861214c
parentbbb62449eb4d64284ec6f9c70663b43cb4945939 (diff)
downloadluaotfload-36129aa2413bf76f7d9663e8de505e00eee5065f.tar.gz
[db] adapt fuzzy matcher
-rw-r--r--luaotfload-database.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index aaba68d..c3256f0 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -1421,12 +1421,13 @@ find_closest = function (name, limit)
local by_distance = { } --- (int, string list) dict
local distances = { } --- int list
local cached = { } --- (string, int) dict
- local mappings = data.mappings
+ local mappings = name_index.mappings
local n_fonts = #mappings
for n = 1, n_fonts do
local current = mappings[n]
- local cnames = current.sanitized
+ local names = current.names
+ local sanitized = names.sanitized
--[[
This is simplistic but surpisingly fast.
Matching is performed against the “fullname” field
@@ -1436,10 +1437,13 @@ find_closest = function (name, limit)
font name categories as well as whatever agrep
does.
--]]
- if cnames then
- local fullname, sfullname = current.fullname, cnames.fullname
+ if names then
+ local fullname = names.fullname
+ local sfullname = sanitized.info.fullname
+ or sanitized.english.fullname
+ or sanitized.metadata.fullname
+ local dist = cached[sfullname]--- maybe already calculated
- local dist = cached[sfullname]--- maybe already calculated
if not dist then
dist = iterative_levenshtein(name, sfullname)
cached[sfullname] = dist
@@ -1589,10 +1593,6 @@ local organize_namedata = function (metadata,
},
}
--- print (fontnames.english.fullname,
--- fontnames.metadata.fullname,
--- fontnames.info.fullname)
-
if metadata.fontstyle_name then
--- not present in all fonts, often differs from the preferred
--- subfamily as well as subfamily fields, e.g. with LMSans10-BoldOblique: