From aefd8aafbae9531277b95e775b25a257e02a19ef Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 1 Apr 2010 22:33:45 +0200 Subject: Fix optical size with no range_top/bottom Some fonts give only design size with no range, in this case we now will assume range top == range bottom == design size. --- otfl-font-nms.lua | 34 +++++++++++++++++++++++++--------- tests/opticalsize.tex | 9 +++++++++ 2 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 tests/opticalsize.tex diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 130516c..a54724c 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -71,14 +71,24 @@ function names.resolve(specification) for _,v in ipairs(family) do local face = data.mappings[v] local subfamily = sanitize(face.names.subfamily) - local rqssize = tonumber(specification.optsize) or specification.size and specification.size / 65536 - local dsnsize = face.size[1] and face.size[1] / 10 - local maxsize = face.size[2] and face.size[2] / 10 - local minsize = face.size[3] and face.size[3] / 10 local filename = face.filename + local optsize, rqssize, dsnsize, maxsize, minsize + if #face.size > 0 then + optsize = face.size + rqssize = tonumber(specification.optsize) or specification.size and specification.size / 65536 + dsnsize = optsize[1] and optsize[1] / 10 + 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 subfamily then if subfamily == style then - if not dsnsize or dsnsize == rqssize or (rqssize > minsize and rqssize <= maxsize) then + if optsize then + if dsnsize == rqssize or (rqssize > minsize and rqssize <= maxsize) then + found = filename + logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, found) + break + end + else found = filename logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, found) break @@ -87,10 +97,16 @@ function names.resolve(specification) if synonyms[style] then for _,v in ipairs(synonyms[style]) do if subfamily == v then - if not dsnsize or dsnsize == rqssize or (rqssize > minsize and rqssize <= maxsize) then - found = filename - logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, found) - break + if optsize then + if dsnsize == rqssize or (rqssize > minsize and rqssize <= maxsize) then + found = filename + logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, found) + break + end + else + found = filename + logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, found) + break end end end diff --git a/tests/opticalsize.tex b/tests/opticalsize.tex new file mode 100644 index 0000000..d19bb59 --- /dev/null +++ b/tests/opticalsize.tex @@ -0,0 +1,9 @@ +\input luaotfload.sty + +\font\testa={Latin Modern Roman/S=12} at 10pt +\font\testb={Latin Modern Roman} at 5pt +\font\testc={Latin Modern Roman} at 10pt +\testa abcd ABCD \par +\testb abcd ABCD \par +\testc abcd ABCD \par +\bye -- cgit v1.2.3