summaryrefslogtreecommitdiff
path: root/src/luaotfload-parsers.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-02-19 23:05:10 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2016-02-19 23:05:10 +0100
commitfc973a6dde1a78a59e50bc3850dfd0d06e7b2a03 (patch)
treed41348716e437e223fcf30ae636c9bc32e645639 /src/luaotfload-parsers.lua
parent7b982d37f58b36e8d8dd2580893e89430c576ca9 (diff)
parent3447815896954281938500d49bedef715078a140 (diff)
downloadluaotfload-fc973a6dde1a78a59e50bc3850dfd0d06e7b2a03.tar.gz
Merge pull request #324 from phi-gamma/master
lookups, combos, fallbacks
Diffstat (limited to 'src/luaotfload-parsers.lua')
-rw-r--r--src/luaotfload-parsers.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/luaotfload-parsers.lua b/src/luaotfload-parsers.lua
index 0349cdc..b190c2c 100644
--- a/src/luaotfload-parsers.lua
+++ b/src/luaotfload-parsers.lua
@@ -45,6 +45,7 @@ local lfsisdir = lfs.isdir
--- COMMON PATTERNS
-------------------------------------------------------------------------------
+local asterisk = P"*"
local dot = P"."
local colon = P":"
local semicolon = P";"
@@ -72,6 +73,8 @@ local digit = R"09"
local alpha = R("az", "AZ")
local anum = alpha + digit
local decimal = digit^1 * (dot * digit^0)^-1
+local hexdigit = R("09", "af", "AF")
+local hex = P"0x" * hexdigit^1
-------------------------------------------------------------------------------
--- FONTCONFIG
@@ -560,9 +563,49 @@ local modifier = slash * (other_modifier --> ignore
+ garbage_modifier) --> warn
local modifier_list = Cg(Ct(modifier^0), "modifiers")
+--- combining ---------------------------------------------------------
+---
+--- \font \three = combo: 1->42; 2->99,0xdeadbeef; 3->(1,U+2a-U+1337*42)
+--- v +~ v +~ +~~~~~~~~~ v v +~~~ +~~~~~ +~
+--- | | | | | | | | | |
+--- | | | | | | | | | |
+--- idx : ---+--÷---+--÷--÷-----------+ | +----+ |
+--- | | | | | |
+--- id : ------+------+--÷---------------+ +-----------+
+--- | |
+--- chars : ----------------+-----------------+
+---
+local comborowsep = ws * semicolon * ws
+local combomapsep = ws * P"->" * ws
+local combodefsep = ws * comma * ws
+local comborangesep = ws * asterisk * ws
+
+local combohex = hex / tonumber
+local combouint = digit^1 / tonumber
+local tonumber16 = function (s) return tonumber (s, 16) end
+local combouni = P"U+" * (digit^1 / tonumber16)
+local combonum = combohex + combouni + combouint
+local comborange = Ct(combonum * dash * combonum) + combonum
+local combochars = comborange * (comborangesep * comborange)^0
+local parenthesized = function (p) return P"(" * ws * p * ws * P")" end
+
+local comboidxpat = Cg(combouint, "idx")
+local comboidpat = Cg(combouint, "id" )
+local combocharspat = Cg(P"fallback" * Cc(true) + Ct(combochars^1), "chars")
+local comboidcharspat = comboidpat * combodefsep * combocharspat
+
+local comboidx = parenthesized (comboidxpat ) + comboidxpat
+local comboid = parenthesized (comboidpat ) + comboidpat
+local comboidchars = parenthesized (comboidcharspat) + comboidcharspat
+
+local combodef1 = Ct(comboidx * combomapsep * comboid) --> no chars
+local combodef = Ct(comboidx * combomapsep * comboidchars)
+local combolist = Ct(combodef1 * (comborowsep * combodef)^1)
+
--- lookups -----------------------------------------------------------
local fontname = C((1-S":(/")^1) --- like luatex-fonts
local unsupported = Cmt((1-S":(")^1, check_garbage)
+local combo = P"combo:" * ws * Cg(combolist, "combo")
local prefixed = P"name:" * ws * Cg(fontname, "name")
--- initially we intended file: to emulate the behavior of
--- luatex-fonts, i.e. no paths allowed. after all, we do have XeTeX
@@ -626,6 +669,7 @@ local specification = (prefixed + unprefixed)
* subfont^-1
* modifier_list^-1
local font_request = Ct(path_lookup * (colon^-1 * features)^-1
+ + combo --> TODO: feature list needed?
+ specification * (colon * features)^-1)
-- lpeg.print(font_request)