diff options
-rw-r--r-- | doc/luaotfload-main.tex | 61 | ||||
-rw-r--r-- | src/fontloader/misc/fontloader-font-gbn.lua | 19 | ||||
-rw-r--r-- | src/luaotfload-features.lua | 58 | ||||
-rw-r--r-- | src/luaotfload-loaders.lua | 5 | ||||
-rw-r--r-- | src/luaotfload-parsers.lua | 50 |
5 files changed, 139 insertions, 54 deletions
diff --git a/doc/luaotfload-main.tex b/doc/luaotfload-main.tex index c26235e..21e001b 100644 --- a/doc/luaotfload-main.tex +++ b/doc/luaotfload-main.tex @@ -183,7 +183,7 @@ for a more formal description see figure \ref{font-syntax}. \alt <unquoted font request> ; <unquoted font request> ::= <specification>, [`:', <feature list> ] - \alt `[', <path lookup> `]', [ [`:'], <feature list> ] ; + \alt <path lookup>, [ [`:'], <feature list> ] ; <specification> ::= <prefixed spec>, [ <subfont no> ], \{ <modifier> \} \alt <anon lookup>, \{ <modifier> \} ; @@ -218,7 +218,13 @@ for a more formal description see figure \ref{font-syntax}. <anon lookup> ::= {\sc tfmname} | <name lookup> ; - <path lookup> ::= \{ {\sc all_characters} - `]' \} ; + <path lookup> ::= `[', \{ <path content> \}, `]', [ <subfont no> ] ; + + <path content> ::= <path balanced> + \alt `\\', {\sc all_characters} + \alt {\sc all_characters} - `]' + + <path balanced> ::= `[', [ <path content> ], `]' <modifier> ::= `/', (`I' | `B' | `BI' | `IB' | `S=', \{ {\sc digit} \} ) ; @@ -234,6 +240,7 @@ for a more formal description see figure \ref{font-syntax}. <name character> ::= {\sc all_characters} - ( `(' | `/' | `:' ) ; \endsyntaxfloat +%% Below guarded space gets borked in index; why‽ \beginsubsection{Prefix -- the \identifier{luaotfload}{ }Way} In \identifier{luaotfload}, the canonical syntax for font requests @@ -329,13 +336,12 @@ The file names corresponding to the example font names above are \endsubsection -\beginsubsection {Compatibility Layer} - -In addition to the regular prefixed requests, \identifier{luaotfload} -accepts loading fonts the \XETEX way. +\beginsubsection {Bracketed Lookups} +\label{sec:conf} +Bracketed lookups allow for arbitrary character content to be used in a +definition. % -There are again two modes: bracketed and unbracketed. -A bracketed request looks as follows. +A simple bracketed request looks follows the scheme \beginnarrower \nonproportional{\string\font\string\fontname\space = [}% @@ -344,21 +350,41 @@ A bracketed request looks as follows. \endnarrower \noindent -Inside the square brackets, every character except for a closing -bracket is permitted, allowing for specifying paths to a font file. +Inside the square brackets, every character except for a closing bracket is +permitted, allowing for arbitrary paths to a font file -- including Windows +style paths with UNC or drive letter prepended -- to be specified. % +The \identifier{Luaotfload} syntax differs from \XETEX in that the subfont +selector goes \emphasis{after} the closing bracket: + +\beginnarrower + \nonproportional{\string\font\string\fontname\space = [}% + \meta{/path/to/file}% + \nonproportional{]} + \nonproportional{(}n\nonproportional{)} +\endnarrower + Naturally, path-less file names are equally valid and processed the same way as an ordinary \inlinecode {file:} lookup. +\beginsubsection {Compatibility} + +In addition to the regular prefixed requests, \identifier{luaotfload} +accepts loading fonts the \XETEX way. +% +There are again two modes: bracketed and unbracketed. +For the bracketed variety, see above, \ref{sec:conf}. + +Unbracketed (or, for lack of a better word: \emphasis{anonymous}) +font requests resemble the conventional \TEX syntax. + \beginnarrower \nonproportional{\string\font\string\fontname\space= }% \meta{font name} \dots \endnarrower +\endsubsection -Unbracketed (or, for lack of a better word: \emphasis{anonymous}) -font requests resemble the conventional \TEX syntax. -% However, they have a broader spectrum of possible interpretations: before anything else, \identifier{luaotfload} attempts to load a traditional \TEX Font Metric (\abbrev{tfm} or \abbrev{ofm}). @@ -437,6 +463,13 @@ name.\footnote{% \font \cambriamath = "file:cambria.ttc(1)" at 10pt \endlisting +and likewise, requesting subfont inside a TTC container by path: + +\beginlisting + \font \asanamain = "[/home/typesetter/.fonts/math/asana.ttc](0):mode=node;+tlig" at 10pt + \font \asanamath = "[/home/typesetter/.fonts/math/asana.ttc](1):mode=base" at 10pt +\endlisting + \endsubsubsection \beginsubsubsection{Loading by Font Name} @@ -608,7 +641,7 @@ obviously, \inlinecode{random}. For scripts derived from the Latin alphabet the value \inlinecode{latn} is good choice. } - the default value is \inlinecode{dlft}. + the default value is \inlinecode{dflt}. % Some fonts, including very popular ones by foundries like Adobe, do not assign features to the \inlinecode{dflt} script, in 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") |