diff options
Diffstat (limited to 'otfl-font-xtx.lua')
-rw-r--r-- | otfl-font-xtx.lua | 81 |
1 files changed, 30 insertions, 51 deletions
diff --git a/otfl-font-xtx.lua b/otfl-font-xtx.lua index 8237851..574e161 100644 --- a/otfl-font-xtx.lua +++ b/otfl-font-xtx.lua @@ -31,36 +31,14 @@ well and that does not work too well with the general design of the specifier.</p> --ldx]]-- ---~ function fonts.define.specify.colonized(specification) -- xetex mode ---~ local list = { } ---~ if specification.detail and specification.detail ~= "" then ---~ for v in gmatch(specification.detail,"%s*([^;]+)%s*") do ---~ local a, b = match(v,"^(%S*)%s*=%s*(%S*)$") ---~ if a and b then ---~ list[a] = b:is_boolean() ---~ if type(list[a]) == "nil" then ---~ list[a] = b ---~ end ---~ else ---~ local a, b = match(v,"^([%+%-]?)%s*(%S+)$") ---~ if a and b then ---~ list[b] = a ~= "-" ---~ end ---~ end ---~ end ---~ end ---~ specification.features.normal = list ---~ return specification ---~ end - ---~ check("oeps/BI:+a;-b;c=d") ---~ check("[oeps]/BI:+a;-b;c=d") ---~ check("file:oeps/BI:+a;-b;c=d") ---~ check("name:oeps/BI:+a;-b;c=d") +local fonts = fonts +local definers = fonts.definers +local specifiers = definers.specifiers +local normalize_meanings = fonts.otf.meanings.normalize local list = { } -fonts.define.specify.colonized_default_lookup = "file" +specifiers.colonizedpreference = "file" local function isstyle(s) local style = string.lower(s):split("/") @@ -157,11 +135,15 @@ local function parse_script(script) end end -local function issome () list.lookup = fonts.define.specify.colonized_default_lookup end +specifiers.colonizedpreference = "file" + +local function issome () list.lookup = specifiers.colonizedpreference end local function isfile () list.lookup = 'file' end local function isname () list.lookup = 'name' end local function thename(s) list.name = s end local function issub (v) list.sub = v end +local function istrue (s) list[s] = true end +local function isfalse(s) list[s] = false end local function iskey (k,v) if k == "script" then parse_script(v) @@ -169,28 +151,25 @@ local function iskey (k,v) list[k] = v end -local function istrue (s) list[s] = true end -local function isfalse(s) list[s] = false end - -local spaces = lpeg.P(" ")^0 -local namespec = (1-lpeg.S("/:("))^0 -- was: (1-lpeg.S("/: ("))^0 -local filespec = (lpeg.R("az", "AZ") * lpeg.P(":"))^-1 * (1-lpeg.S(":("))^1 -local crapspec = spaces * lpeg.P("/") * (((1-lpeg.P(":"))^0)/isstyle) * spaces -local filename = (lpeg.P("file:")/isfile * (filespec/thename)) + (lpeg.P("[") * lpeg.P(true)/isfile * (((1-lpeg.P("]"))^0)/thename) * lpeg.P("]")) -local fontname = (lpeg.P("name:")/isname * (namespec/thename)) + lpeg.P(true)/issome * (namespec/thename) -local sometext = (lpeg.R("az","AZ","09") + lpeg.S("+-."))^1 -local truevalue = lpeg.P("+") * spaces * (sometext/istrue) -local falsevalue = lpeg.P("-") * spaces * (sometext/isfalse) -local keyvalue = lpeg.P("+") + (lpeg.C(sometext) * spaces * lpeg.P("=") * spaces * lpeg.C(sometext))/iskey +local P, S, R, C = lpeg.P, lpeg.S, lpeg.R, lpeg.C + +local spaces = P(" ")^0 +local namespec = (1-S("/:("))^0 -- was: (1-S("/: ("))^0 +local filespec = (R("az", "AZ") * P(":"))^-1 * (1-S(":("))^1 +local stylespec = spaces * P("/") * (((1-P(":"))^0)/isstyle) * spaces +local filename = (P("file:")/isfile * (filespec/thename)) + (P("[") * P(true)/isname * (((1-P("]"))^0)/thename) * P("]")) +local fontname = (P("name:")/isname * (namespec/thename)) + P(true)/issome * (namespec/thename) +local sometext = (R("az","AZ","09") + S("+-."))^1 +local truevalue = P("+") * spaces * (sometext/istrue) +local falsevalue = P("-") * spaces * (sometext/isfalse) +local keyvalue = P("+") + (C(sometext) * spaces * P("=") * spaces * C(sometext))/iskey local somevalue = sometext/istrue -local subvalue = lpeg.P("(") * (lpeg.C(lpeg.P(1-lpeg.S("()"))^1)/issub) * lpeg.P(")") -- for Kim +local subvalue = P("(") * (C(P(1-S("()"))^1)/issub) * P(")") -- for Kim local option = spaces * (keyvalue + falsevalue + truevalue + somevalue) * spaces -local options = lpeg.P(":") * spaces * (lpeg.P(";")^0 * option)^0 -local pattern = (filename + fontname) * subvalue^0 * crapspec^0 * options^0 - -local normalize_meanings = fonts.otf.meanings.normalize +local options = P(":") * spaces * (P(";")^0 * option)^0 +local pattern = (filename + fontname) * subvalue^0 * stylespec^0 * options^0 -function fonts.define.specify.colonized(specification) -- xetex mode +local function colonized(specification) -- xetex mode list = { } lpegmatch(pattern,specification.specification) if list.style then @@ -202,10 +181,10 @@ function fonts.define.specify.colonized(specification) -- xetex mode list.optsize = nil end if list.name then - if resolvers.find_file(list.name, "tfm") then + if resolvers.findfile(list.name, "tfm") then list.lookup = "file" list.name = file.addsuffix(list.name, "tfm") - elseif resolvers.find_file(list.name, "ofm") then + elseif resolvers.findfile(list.name, "ofm") then list.lookup = "file" list.name = file.addsuffix(list.name, "ofm") end @@ -221,9 +200,9 @@ function fonts.define.specify.colonized(specification) -- xetex mode specification.sub = list.sub list.sub = nil end --- specification.features.normal = list + -- specification.features.normal = list specification.features.normal = normalize_meanings(list) return specification end -fonts.define.register_split(":", fonts.define.specify.colonized) +definers.registersplit(":",colonized) |