From 868e6b8d73fc2e9d75d39507ff261c7b34b78002 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 1 Apr 2010 22:59:58 +0200 Subject: Support loading fonts by fullname Now, if we didn't find a matching family name, we then try fullname. --- otfl-font-nms.lua | 31 +++++++++++++++---------------- tests/fullname.tex | 7 +++++++ 2 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 tests/fullname.tex diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index a54724c..3cedaa2 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -84,14 +84,12 @@ function names.resolve(specification) if subfamily == style 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 + logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, filename) + return filename, false end else - found = filename - logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, found) - break + logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, filename) + return filename, false end else if synonyms[style] then @@ -99,14 +97,12 @@ function names.resolve(specification) if subfamily == v 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 + logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, filename) + return filename, false end else - found = filename - logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, found) - break + logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, filename) + return filename, false end end end @@ -114,12 +110,15 @@ function names.resolve(specification) end end end - if found then - return found, false - else - return name, false -- fallback to filename + else + for i,v in ipairs(data.mappings) do + if sanitize(v.fullname) == sanitize(name) or sanitize(v.names.fullname) == sanitize(name) then + logs.report("load font", "font fullname='%s' found: %s", name, v.filename) + return v.filename, false + end end end + return name, false -- fallback to filename end else logs.report("load font", "no font names database loaded") diff --git a/tests/fullname.tex b/tests/fullname.tex new file mode 100644 index 0000000..ec73cb3 --- /dev/null +++ b/tests/fullname.tex @@ -0,0 +1,7 @@ +\input luaotfload.sty + +\font\testa={LM Roman Slanted 10 Regular} at 10pt +\font\testb={LM Roman 9 Italic} at 10pt +\testa abcd ABCD\par +\testb abcd ABCD\par +\bye -- cgit v1.2.3