diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2011-03-02 20:10:46 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2011-03-02 20:57:11 +0200 |
commit | 654f5f46c8c7bc43b73ce46035f3f6c1d5e9bbe5 (patch) | |
tree | 3df613c3e05ca044d521bfc872f0d28028cb15f8 /otfl-font-xtx.lua | |
parent | a0e1a5594231d9f3789c51f04fdfb24680ca2516 (diff) | |
download | luaotfload-654f5f46c8c7bc43b73ce46035f3f6c1d5e9bbe5.tar.gz |
Sync with ConTeXt 2011.02.25 22:03
This commit overrides all our local modification to ConTeXt file and is
not tested at all.
Diffstat (limited to 'otfl-font-xtx.lua')
-rw-r--r-- | otfl-font-xtx.lua | 142 |
1 files changed, 17 insertions, 125 deletions
diff --git a/otfl-font-xtx.lua b/otfl-font-xtx.lua index 574e161..505e085 100644 --- a/otfl-font-xtx.lua +++ b/otfl-font-xtx.lua @@ -40,155 +40,47 @@ local list = { } specifiers.colonizedpreference = "file" -local function isstyle(s) - local style = string.lower(s):split("/") - for _,v in ipairs(style) do - if v == "b" then - list.style = "bold" - elseif v == "i" then - list.style = "italic" - elseif v == "bi" or v == "ib" then - list.style = "bolditalic" - elseif v:find("^s=") then - list.optsize = v:split("=")[2] - elseif v == "aat" or v == "icu" or v == "gr" then - logs.report("load font", "unsupported font option: %s", v) - elseif not v:is_empty() then - list.style = v:gsub("[^%a%d]", "") - end - end -end - -fonts = fonts or { } -fonts.otf = fonts.otf or { } - -local otf = fonts.otf - -otf.tables = otf.tables or { } - -otf.tables.defaults = { - dflt = { - "ccmp", "locl", "rlig", "liga", "clig", - "kern", "mark", "mkmk", - }, - arab = { - "ccmp", "locl", "isol", "fina", "fin2", - "fin3", "medi", "med2", "init", "rlig", - "calt", "liga", "cswh", "mset", "curs", - "kern", "mark", "mkmk", - }, - deva = { - "ccmp", "locl", "init", "nukt", "akhn", - "rphf", "blwf", "half", "pstf", "vatu", - "pres", "blws", "abvs", "psts", "haln", - "calt", "blwm", "abvm", "dist", "kern", - "mark", "mkmk", - }, - khmr = { - "ccmp", "locl", "pref", "blwf", "abvf", - "pstf", "pres", "blws", "abvs", "psts", - "clig", "calt", "blwm", "abvm", "dist", - "kern", "mark", "mkmk", - }, - thai = { - "ccmp", "locl", "liga", "kern", "mark", - "mkmk", - }, - hang = { - "ccmp", "ljmo", "vjmo", "tjmo", - }, -} - -otf.tables.defaults.beng = otf.tables.defaults.deva -otf.tables.defaults.guru = otf.tables.defaults.deva -otf.tables.defaults.gujr = otf.tables.defaults.deva -otf.tables.defaults.orya = otf.tables.defaults.deva -otf.tables.defaults.taml = otf.tables.defaults.deva -otf.tables.defaults.telu = otf.tables.defaults.deva -otf.tables.defaults.knda = otf.tables.defaults.deva -otf.tables.defaults.mlym = otf.tables.defaults.deva -otf.tables.defaults.sinh = otf.tables.defaults.deva - -otf.tables.defaults.syrc = otf.tables.defaults.arab -otf.tables.defaults.mong = otf.tables.defaults.arab -otf.tables.defaults.nko = otf.tables.defaults.arab - -otf.tables.defaults.tibt = otf.tables.defaults.khmr - -otf.tables.defaults.lao = otf.tables.defaults.thai - -local function parse_script(script) - if otf.tables.scripts[script] then - local dflt - if otf.tables.defaults[script] then - logs.report("load font", "auto-selecting default features for script: %s", script) - dflt = otf.tables.defaults[script] - else - logs.report("load font", "auto-selecting default features for script: dflt (was %s)", script) - dflt = otf.tables.defaults["dflt"] - end - for _,v in next, dflt do - list[v] = "yes" - end - else - logs.report("load font", "unknown script: %s", script) - end -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 iscrap (s) list.crap = string.lower(s) end +local function istrue (s) list[s] = 'yes' end +local function isfalse(s) list[s] = 'no' end +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 function iskey (k,v) - if k == "script" then - parse_script(v) - end - list[k] = v -end 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 crapspec = spaces * P("/") * (((1-P(":"))^0)/iscrap) * spaces +local filename = (P("file:")/isfile * (namespec/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 keyvalue = (C(sometext) * spaces * P("=") * spaces * C(sometext))/iskey local somevalue = sometext/istrue local subvalue = P("(") * (C(P(1-S("()"))^1)/issub) * P(")") -- for Kim local option = spaces * (keyvalue + falsevalue + truevalue + somevalue) * spaces local options = P(":") * spaces * (P(";")^0 * option)^0 -local pattern = (filename + fontname) * subvalue^0 * stylespec^0 * options^0 +local pattern = (filename + fontname) * subvalue^0 * crapspec^0 * options^0 local function colonized(specification) -- xetex mode list = { } lpegmatch(pattern,specification.specification) - if list.style then - specification.style = list.style - list.style = nil - end - if list.optsize then - specification.optsize = list.optsize - list.optsize = nil - end + -- for k, v in next, list do + -- list[k] = is_boolean(v) + -- if type(list[a]) == "nil" then + -- list[k] = v + -- end + -- end + list.crap = nil -- style not supported, maybe some day if list.name then - if resolvers.findfile(list.name, "tfm") then - list.lookup = "file" - list.name = file.addsuffix(list.name, "tfm") - elseif resolvers.findfile(list.name, "ofm") then - list.lookup = "file" - list.name = file.addsuffix(list.name, "ofm") - end - specification.name = list.name list.name = nil end @@ -205,4 +97,4 @@ local function colonized(specification) -- xetex mode return specification end -definers.registersplit(":",colonized) +definers.registersplit(":",colonized,"cryptic") |