summaryrefslogtreecommitdiff
path: root/luaotfload-database.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-05-01 02:48:17 -0700
committerPhilipp Gesang <phg42.2a@gmail.com>2013-05-01 02:48:17 -0700
commitcabc4adc0619e85a1fd020c2c820bec050f8da30 (patch)
treea381746c1dee2e249f0d4db21ab1f623c058c303 /luaotfload-database.lua
parent6028177d2a5fd2e7c9a84d48af9023e2685b6c05 (diff)
parentfcdbafd0c86fdba0830c7408409f767f0b75b110 (diff)
downloadluaotfload-cabc4adc0619e85a1fd020c2c820bec050f8da30.tar.gz
Merge pull request #29 from phi-gamma/master
fix issue #26
Diffstat (limited to 'luaotfload-database.lua')
-rw-r--r--luaotfload-database.lua102
1 files changed, 52 insertions, 50 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index f78cc67..aaba55a 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -337,13 +337,6 @@ crude_file_lookup_verbose = function (filename)
filename, found[1])
return found
end
--- found = data.fullnames[filename]
--- if found and mappings[found] then
--- found = mappings[found].filename[1]
--- "crude file lookup: req=%s; hit=bare; ret=%s",
--- filename, found[1])
--- return found
--- end
found = data.basenames[filename]
if found and mappings[found] then
found = mappings[found].filename
@@ -369,7 +362,6 @@ crude_file_lookup = function (filename)
local data = names.data
local mappings = data.mappings
local found = data.barenames[filename]
--- or data.fullnames[filename]
or data.basenames[filename]
if found then
found = data.mappings[found]
@@ -477,6 +469,27 @@ resolve_cached = function (_, _, specification)
return filename, subfont, true
end
+--- this used to be inlined; with the lookup cache we don’t
+--- have to be parsimonious wrt function calls anymore
+--- “found” is the match accumulator
+local add_to_match = function (
+ found, optsize, dsnsize, size,
+ minsize, maxsize, face)
+ local continue = true
+ if optsize then
+ if dsnsize == size or (size > minsize and size <= maxsize) then
+ found[1] = face
+ continue = false ---> break
+ else
+ found[#found+1] = face
+ end
+ else
+ found[1] = face
+ continue = false ---> break
+ end
+ return found, continue
+end
+
--[[doc--
Luatex-fonts, the font-loader package luaotfload imports, comes with
@@ -585,54 +598,43 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con
if name == family then
if subfamily == style then
- if optsize then
- if dsnsize == size
- or (size > minsize and size <= maxsize) then
- found[1] = face
- break
- else
- found[#found+1] = face
- end
- else
- found[1] = face
- break
- end
+ local continue
+ found, continue = add_to_match(
+ found, optsize, dsnsize, size,
+ minsize, maxsize, face)
+ if continue == false then break end
elseif synonym_set[style] and
synonym_set[style][subfamily]
then
- if optsize then
- if dsnsize == size
- or (size > minsize and size <= maxsize) then
- found[1] = face
- break
- else
- found[#found+1] = face
- end
- else
- found[1] = face
- break
- end
+ local continue
+ found, continue = add_to_match(
+ found, optsize, dsnsize, size,
+ minsize, maxsize, face)
+ if continue == false then break end
elseif subfamily == "regular" or
- synonym_set.regular[subfamily] then
+ synonym_set.regular[subfamily] then
found.fallback = face
+ elseif name == fullname
+ or name == pfullname
+ or name == fontname
+ or name == psname
+ then
+ local continue
+ found, continue = add_to_match(
+ found, optsize, dsnsize, size,
+ minsize, maxsize, face)
+ if continue == false then break end
end
- end
-
- if name == fullname
- or name == pfullname
- or name == fontname
- or name == psname then
- if optsize then
- if dsnsize == size
- or (size > minsize and size <= maxsize) then
- found[1] = face
- break
- else
- found[#found+1] = face
- end
- else
- found[1] = face
- break
+ else
+ if name == fullname
+ or name == pfullname
+ or name == fontname
+ or name == psname then
+ local continue
+ found, continue = add_to_match(
+ found, optsize, dsnsize, size,
+ minsize, maxsize, face)
+ if continue == false then break end
end
end
end