From fcdbafd0c86fdba0830c7408409f767f0b75b110 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 1 May 2013 11:25:46 +0200 Subject: perform match on other font names if family but not subfamily matches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit preliminary fix for issue #26 here’s an example that works now but either broke (pre-v1.3) or retrieved the wrong shape with ``/B``: \ifdefined\directlua\input luaotfload.sty\fi %% this should be mono bold \font\libertinemono="Linux Libertine Mono O" at 42pt foo {\libertinemono bar} baz\endgraf %% this should be bold, but isn’t \font\myriadbold="Myriad Pro/B" at 42pt foo {\myriadbold bar} baz\endgraf %% this is bold \font\minionbold="Minion Pro/B" at 42pt foo {\minionbold bar} baz\endgraf \bye also, I refactored parts of the matching function for more clarity --- luaotfload-database.lua | 102 ++++++++++++++++++++++++------------------------ 1 file 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 -- cgit v1.2.3