summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-02-15 08:26:54 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2016-02-15 08:27:00 +0100
commit0a1b9b746b5ce4cd740af8948f083685879c4eb9 (patch)
tree36933ee515a9d0991dd2afeaeb7bd4a86f60fdb1
parentfdefa722cdbf92c38e02f26a1a7092ef70a14cae (diff)
downloadluaotfload-0a1b9b746b5ce4cd740af8948f083685879c4eb9.tar.gz
[parsers,features] parse combo requests
Highly experimental at this point. The font request parser has been extended to handle combinations of already defined fonts. Nothing else has been implemented yet, so the request handler will simply error out with a message.
-rw-r--r--src/luaotfload-features.lua14
-rw-r--r--src/luaotfload-parsers.lua30
2 files changed, 42 insertions, 2 deletions
diff --git a/src/luaotfload-features.lua b/src/luaotfload-features.lua
index fd43e58..6df04b2 100644
--- a/src/luaotfload-features.lua
+++ b/src/luaotfload-features.lua
@@ -993,7 +993,10 @@ local import_values = {
{ "mode", true },
}
-local lookup_types = { "anon", "file", "kpse", "my", "name", "path" }
+local lookup_types = { "anon" , "file", "kpse"
+ , "my" , "name", "path"
+ , "combo"
+ }
local select_lookup = function (request)
for i=1, #lookup_types do
@@ -1049,6 +1052,7 @@ end
local handle_request = function (specification)
local request = lpegmatch(luaotfload.parsers.font_request,
specification.specification)
+----inspect(request)
if not request then
--- happens when called with an absolute path
--- in an anonymous lookup;
@@ -1077,7 +1081,13 @@ local handle_request = function (specification)
specification.lookup = "path"
return specification
end
+
local lookup, name = select_lookup(request)
+ if lookup == "combo" then
+ report ("both", 0, "load",
+ "‘combo’ lookup not implemented at this stage.")
+ os.exit(-42)
+ end
request.features = apply_default_features(request.features)
if name then
@@ -1749,4 +1759,4 @@ return {
end
}
--- vim:tw=71:sw=4:ts=4:expandtab
+-- vim:tw=79:sw=4:ts=4:expandtab
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)