summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fontloader/misc/fontloader-font-gbn.lua19
-rw-r--r--src/luaotfload-features.lua58
-rw-r--r--src/luaotfload-loaders.lua5
-rw-r--r--src/luaotfload-parsers.lua50
4 files changed, 92 insertions, 40 deletions
diff --git a/src/fontloader/misc/fontloader-font-gbn.lua b/src/fontloader/misc/fontloader-font-gbn.lua
index 1f8df64..21c6061 100644
--- a/src/fontloader/misc/fontloader-font-gbn.lua
+++ b/src/fontloader/misc/fontloader-font-gbn.lua
@@ -37,6 +37,7 @@ local getdisc = nuts.getdisc
local setchar = nuts.setchar
local setlink = nuts.setlink
local setprev = nuts.setprev
+local nodetail = nuts.tail
-- from now on we apply ligaturing and kerning here because it might interfere with complex
-- opentype discretionary handling where the base ligature pass expect some weird extra
@@ -200,21 +201,15 @@ function nodes.handlers.nodepass(head)
local stop = range[2]
if start then
local front = nuthead == start
- local prev, next
+ if not stop then
+ stop = nodetail(start)
+ end
if stop then
- next = getnext(stop)
start, stop = ligaturing(start,stop)
start, stop = kerning(start,stop)
- else
- prev = getprev(start)
- start = ligaturing(start)
- start = kerning(start)
- end
- if prev then
- setlink(prev,start)
- end
- if next then
- setlink(stop,next)
+ elseif start then -- safeguard
+ start, stop = ligaturing(start,stop)
+ start, stop = kerning(start,stop)
end
if front and nuthead ~= start then
head = tonode(start)
diff --git a/src/luaotfload-features.lua b/src/luaotfload-features.lua
index 5c35031..f11f05b 100644
--- a/src/luaotfload-features.lua
+++ b/src/luaotfload-features.lua
@@ -1274,9 +1274,17 @@ local tlig_specification = {
type = "substitution",
features = everywhere,
data = {
- [0x0022] = 0x201D, -- quotedblright
- [0x0027] = 0x2019, -- quoteleft
- [0x0060] = 0x2018, -- quoteright
+ --- quotedblright:
+ --- " (QUOTATION MARK) → ” (RIGHT DOUBLE QUOTATION MARK)
+ [0x0022] = 0x201D,
+
+ --- quoteleft:
+ --- ' (APOSTROPHE) → ’ (RIGHT SINGLE QUOTATION MARK)
+ [0x0027] = 0x2019,
+
+ --- quoteright:
+ --- ` (GRAVE ACCENT) → ‘ (LEFT SINGLE QUOTATION MARK)
+ [0x0060] = 0x2018,
},
flags = noflags,
order = { "tlig" },
@@ -1286,13 +1294,43 @@ local tlig_specification = {
type = "ligature",
features = everywhere,
data = {
- [0x2013] = {0x002D, 0x002D}, -- endash
- [0x2014] = {0x002D, 0x002D, 0x002D}, -- emdash
- --- next three originate in T1 encoding; Xetex applies
- --- them too
- [0x201E] = {0x002C, 0x002C}, -- quotedblbase
- [0x00AB] = {0x003C, 0x003C}, -- LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- [0x00BB] = {0x003E, 0x003E}, -- RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+
+ --- endash:
+ --- [--] (HYPHEN-MINUS, HYPHEN-MINUS) → – (EN DASH)
+ [0x2013] = {0x002D, 0x002D},
+
+ --- emdash:
+ --- [---] (HYPHEN-MINUS, HYPHEN-MINUS, HYPHEN-MINUS) → — (EM DASH)
+ [0x2014] = {0x002D, 0x002D, 0x002D},
+
+ --- quotedblleft:
+ --- [''] (GRAVE ACCENT, GRAVE ACCENT) → “ (LEFT DOUBLE QUOTATION MARK)
+ [0x201C] = {0x0060, 0x0060},
+
+ --- quotedblright:
+ --- [``] (APOSTROPHE, APOSTROPHE) → ” (RIGHT DOUBLE QUOTATION MARK)
+ [0x201D] = {0x0027, 0x0027},
+
+ --- exclamdown:
+ --- [!'] (EXCLAMATION MARK, GRAVE ACCENT) → ¡ (INVERTED EXCLAMATION MARK)
+ [0x00A1] = {0x0021, 0x0060},
+
+ --- questiondown:
+ --- [?'] (QUESTION MARK, GRAVE ACCENT) → ¡ (INVERTED EXCLAMATION MARK)
+ [0x00BF] = {0x003F, 0x0060},
+
+ --- next three originate in T1 encoding (Xetex applies them too)
+ --- quotedblbase:
+ --- [,,] (COMMA, COMMA) → ¡ (DOUBLE LOW-9 QUOTATION MARK)
+ [0x201E] = {0x002C, 0x002C},
+
+ --- LEFT-POINTING DOUBLE ANGLE QUOTATION MARK:
+ --- [,,] (LESS-THAN SIGN, LESS-THAN SIGN) → ¡ (LEFT-POINTING ANGLE QUOTATION MARK)
+ [0x00AB] = {0x003C, 0x003C},
+
+ --- RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK:
+ --- [,,] (GREATER-THAN SIGN, GREATER-THAN SIGN) → ¡ (RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK)
+ [0x00BB] = {0x003E, 0x003E},
},
flags = noflags,
order = { "tlig" },
diff --git a/src/luaotfload-loaders.lua b/src/luaotfload-loaders.lua
index 87275ef..802776c 100644
--- a/src/luaotfload-loaders.lua
+++ b/src/luaotfload-loaders.lua
@@ -151,6 +151,11 @@ do
logreport ("both", 0, "loaders", " > fontname %q", result.fontname or "<nil>")
logreport ("both", 0, "loaders", " > fullname %q", result.fullname or "<nil>")
logreport ("both", 0, "loaders", " > type %s", result.type or "<nil>")
+ local spec = result.specification
+ if spec then
+ logreport ("both", 0, "loaders", " > file %q", spec.filename or "<nil>")
+ logreport ("both", 0, "loaders", " > subfont %s", spec.sub or "<nil>")
+ end
return result
end
end
diff --git a/src/luaotfload-parsers.lua b/src/luaotfload-parsers.lua
index c2b4f2e..b188bb0 100644
--- a/src/luaotfload-parsers.lua
+++ b/src/luaotfload-parsers.lua
@@ -12,7 +12,8 @@ local traversal_maxdepth = 42 --- prevent stack overflows
local rawset = rawset
local lpeg = require "lpeg"
-local P, R, S = lpeg.P, lpeg.R, lpeg.S
+local patterns = lpeg.patterns
+local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V
local lpegmatch = lpeg.match
local C, Cc, Cf = lpeg.C, lpeg.Cc, lpeg.Cf
local Cg, Cmt, Cs, Ct = lpeg.Cg, lpeg.Cmt, lpeg.Cs, lpeg.Ct
@@ -57,6 +58,7 @@ local equals = P"="
local dash = P"-"
local gartenzaun = P"#"
local lbrk, rbrk = P"[", P"]"
+local brackets = lbrk + rbrk
local squote = P"'"
local dquote = P"\""
@@ -602,6 +604,22 @@ local combodef1 = Ct(comboidx * combomapsep * comboid) --> no chars
local combodef = Ct(comboidx * combomapsep * comboidchars)
local combolist = Ct(combodef1 * (comborowsep * combodef)^1)
+--- subfonts ----------------------------------------------------------
+--- This rule is present in the original parser. It sets the “sub”
+--- field of the specification which allows addressing a specific
+--- font inside a TTC container. Neither in Luatex-Fonts nor in
+--- Luaotfload is this documented, so we might as well silently drop
+--- it. However, as backward compatibility is one of our prime goals we
+--- just insert it here and leave it undocumented until someone cares
+--- to ask. (Note: afair subfonts are numbered, but this rule matches a
+--- string; I won’t mess with it though until someone reports a
+--- problem.)
+--- local subvalue = P("(") * (C(P(1-S("()"))^1)/issub) * P(")") -- for Kim
+--- Note to self: subfonts apparently start at index 0. Tested with
+--- Cambria.ttc that includes “Cambria Math” at 0 and “Cambria” at 1.
+--- Other values cause luatex to segfault.
+local subfont = P"(" * Cg((1 - S"()")^1, "sub") * P")"
+
--- lookups -----------------------------------------------------------
local fontname = C((1-S":(/")^1) --- like luatex-fonts
local unsupported = Cmt((1-S":(")^1, check_garbage)
@@ -618,7 +636,19 @@ local prefixed = P"name:" * ws * Cg(fontname, "name")
+ P"kpse:" * ws * Cg(fontname, "kpse")
+ P"my:" * ws * Cg(fontname, "my")
local unprefixed = Cg(fontname, "anon")
-local path_lookup = lbrk * Cg(C((1-rbrk)^1), "path") * rbrk
+--- Bracketed “path” lookups: These may contain any character except
+--- for unbalanced brackets. A backslash escapes any following
+--- character. Everything inside the outermost brackets is treated as
+--- part of the filename or path to look up. Subfonts may be specified
+--- in parens *after* the closing bracket. Note that this differs from
+--- Xetex whose syntax expects the subfont passed inside the brackets,
+--- separated by a colon.
+local path_escape = backslash / "" * patterns.utf8char
+local path_content = path_escape + (1 - brackets)
+local path_balanced = { (path_content + V(2))^1
+ , lbrk * V(1)^-1 * rbrk }
+local path_lookup = lbrk * Cg(Cs(path_balanced), "path") * rbrk
+ * subfont^-1
--- features ----------------------------------------------------------
local field_char = anum + S"+-.!?" --- sic!
@@ -644,22 +674,6 @@ local feature_list = Cf(Ct""
* (featuresep * option^-1)^0
, rawset)
* featuresep^-1
-
---- other -------------------------------------------------------------
---- This rule is present in the original parser. It sets the “sub”
---- field of the specification which allows addressing a specific
---- font inside a TTC container. Neither in Luatex-Fonts nor in
---- Luaotfload is this documented, so we might as well silently drop
---- it. However, as backward compatibility is one of our prime goals we
---- just insert it here and leave it undocumented until someone cares
---- to ask. (Note: afair subfonts are numbered, but this rule matches a
---- string; I won’t mess with it though until someone reports a
---- problem.)
---- local subvalue = P("(") * (C(P(1-S("()"))^1)/issub) * P(")") -- for Kim
---- Note to self: subfonts apparently start at index 0. Tested with
---- Cambria.ttc that includes “Cambria Math” at 0 and “Cambria” at 1.
---- Other values cause luatex to segfault.
-local subfont = P"(" * Cg((1 - S"()")^1, "sub") * P")"
--- top-level rules ---------------------------------------------------
--- \font\foo=<specification>:<features>
local features = Cg(feature_list, "features")