summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-04-01 22:33:45 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2010-04-01 22:33:45 +0200
commitaefd8aafbae9531277b95e775b25a257e02a19ef (patch)
tree16e75b0bd0d70d859d3302a202158c54e60b33b9
parent520eba1ac4dbda9d8c4720824777da5b56353f06 (diff)
downloadluaotfload-aefd8aafbae9531277b95e775b25a257e02a19ef.tar.gz
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.
-rw-r--r--otfl-font-nms.lua34
-rw-r--r--tests/opticalsize.tex9
2 files changed, 34 insertions, 9 deletions
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