diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2010-04-02 20:40:24 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2010-04-02 20:40:24 +0200 |
commit | c1eca213a74c2687d7d3a5c4069edcc900934720 (patch) | |
tree | d6503d48b874fded5adc7bc15de481e18d8077f9 /otfl-font-nms.lua | |
parent | 00ac320063ff016aea9f997948aa104d31bc95ff (diff) | |
download | luaotfload-c1eca213a74c2687d7d3a5c4069edcc900934720.tar.gz |
Some cleanup + a bug fix
If the family name is matching but no matching style, we would not
return any thing, we now just return a random match (e.g. the user asks
for XITS Math/Regular but gets XITS Math/Math), I hope in such rare
cases there is only one match, else one is better giving proper style or
fullname.
Diffstat (limited to 'otfl-font-nms.lua')
-rw-r--r-- | otfl-font-nms.lua | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 83b5277..761ff40 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -57,10 +57,11 @@ function names.load() end local loaded = false + local synonyms = { - regular = {"normal", "roman", "plain", "book", "medium"}, - italic = {"regularitalic", "normalitalic", "oblique", "slant"}, - bolditalic = {"boldoblique", "boldslant"}, + regular = {normal=true, roman=true, plain=true, book=true, medium=true}, + italic = {regularitalic=true, normalitalic=true, oblique=true, slant=true}, + bolditalic = {boldoblique=true, boldslant=true}, } function names.resolve(specification) @@ -88,7 +89,7 @@ function names.resolve(specification) maxsize = optsize[2] and optsize[2] / 10 or dsnsize -- can be nil minsize = optsize[3] and optsize[3] / 10 or dsnsize -- can be nil end - if name == family and subfamily then + if name == family then if subfamily == style then if optsize then if dsnsize == size or (size > minsize and size <= maxsize) then @@ -101,27 +102,23 @@ function names.resolve(specification) found[1] = face break end - else - if synonyms[style] then - for _,v in ipairs(synonyms[style]) do - if subfamily == v 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 - end + elseif synonyms[style] and synonyms[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 + else + found[1] = face end else - if name == family or name == fullname or name == psname then + if name == fullname or name == psname then if optsize then if dsnsize == size or (size > minsize and size <= maxsize) then found[1] = face |