summaryrefslogtreecommitdiff
path: root/src/luaotfload-parsers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/luaotfload-parsers.lua')
-rw-r--r--src/luaotfload-parsers.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/luaotfload-parsers.lua b/src/luaotfload-parsers.lua
index 0349cdc..5ebe8d5 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,35 @@ 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 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 * (asterisk * comborange)^0
+local combodef1 = Ct( Cg(combouint, "idx") --> no chars
+ * slash * Cg(combouint, "id" ))
+local combodef = Ct( Cg(combouint, "idx" )
+ * slash * Cg(combouint, "id" )
+ * slash * Cg(Ct(combochars^1), "chars"))
+local combolist = Ct(combodef1 * (comma * 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 +655,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)