diff options
Diffstat (limited to 'src/luaotfload-parsers.lua')
| -rw-r--r-- | src/luaotfload-parsers.lua | 44 | 
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) | 
