From 6c52a85e340761bb03b60564af0b0704d97e31a7 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 11 Jan 2016 07:03:59 +0100 Subject: [fontloader] sync with Context as of 2016-01-11 --- src/fontloader/misc/fontloader-font-otf.lua | 17 +++++++---------- src/fontloader/misc/fontloader-font-otn.lua | 3 --- src/fontloader/misc/fontloader-l-lpeg.lua | 2 +- src/fontloader/runtime/fontloader-reference.lua | 6 ++++-- 4 files changed, 12 insertions(+), 16 deletions(-) (limited to 'src/fontloader') diff --git a/src/fontloader/misc/fontloader-font-otf.lua b/src/fontloader/misc/fontloader-font-otf.lua index 0471c17..e90ec73 100644 --- a/src/fontloader/misc/fontloader-font-otf.lua +++ b/src/fontloader/misc/fontloader-font-otf.lua @@ -287,7 +287,6 @@ local ordered_enhancers = { "check glyphs", "check metadata", --- "check extra features", -- after metadata "prepare tounicode", @@ -296,7 +295,6 @@ local ordered_enhancers = { "expand lookups", -- a temp hack awaiting the lua loader ---[[phg-- PATCH: Next line restores font features --phg]]-- "check extra features", -- after metadata and duplicates "cleanup tables", @@ -601,9 +599,6 @@ function otf.load(filename,sub,featurefile) -- second argument (format) is gone applyruntimefixes(filename,data) end enhance("add dimensions",data,filename,nil,false) ---[[phg-- This was hand-patched to restore the fontloader -enhance("check extra features",data,filename) ---phg]]-- if trace_sequences then showfeatureorder(data,filename) end @@ -2955,11 +2950,13 @@ end otf.coverup = { stepkey = "subtables", actions = { - substitution = justset, - alternate = justset, - multiple = justset, - ligature = justset, - kern = justset, + substitution = justset, + alternate = justset, + multiple = justset, + ligature = justset, + kern = justset, + chainsubstitution = justset, + chainposition = justset, }, register = function(coverage,lookuptype,format,feature,n,descriptions,resources) local name = formatters["ctx_%s_%s_%s"](feature,lookuptype,n) -- we can have a mix of types diff --git a/src/fontloader/misc/fontloader-font-otn.lua b/src/fontloader/misc/fontloader-font-otn.lua index b48aea7..8df01bd 100644 --- a/src/fontloader/misc/fontloader-font-otn.lua +++ b/src/fontloader/misc/fontloader-font-otn.lua @@ -3894,10 +3894,7 @@ local function prepare_contextchains(tfmdata) sequence[nofsequences] = after[n] end end ---[[phg-- Hard patch: This crashes, see https://github.com/lualatex/luaotfload/issues/303 if sequence[1] then ---phg]]-- - if sequence[start] then -- Replacements only happen with reverse lookups as they are single only. We -- could pack them into current (replacement value instead of true) and then -- use sequence[start] instead but it's somewhat ugly. diff --git a/src/fontloader/misc/fontloader-l-lpeg.lua b/src/fontloader/misc/fontloader-l-lpeg.lua index 5be1246..959ca55 100644 --- a/src/fontloader/misc/fontloader-l-lpeg.lua +++ b/src/fontloader/misc/fontloader-l-lpeg.lua @@ -110,7 +110,7 @@ local underscore = P("_") local hexdigit = digit + lowercase + uppercase local cr, lf, crlf = P("\r"), P("\n"), P("\r\n") ----- newline = crlf + S("\r\n") -- cr + lf -local newline = P("\r") * (P("\n") + P(true)) + P("\n") +local newline = P("\r") * (P("\n") + P(true)) + P("\n") -- P("\r")^-1 * P("\n")^-1 local escaped = P("\\") * anything local squote = P("'") local dquote = P('"') diff --git a/src/fontloader/runtime/fontloader-reference.lua b/src/fontloader/runtime/fontloader-reference.lua index 9208e52..b135c44 100644 --- a/src/fontloader/runtime/fontloader-reference.lua +++ b/src/fontloader/runtime/fontloader-reference.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 12/22/15 10:50:54 +-- merge date : 01/08/16 19:09:31 do -- begin closure to overcome local limits and interference @@ -144,7 +144,7 @@ local uppercase=R("AZ") local underscore=P("_") local hexdigit=digit+lowercase+uppercase local cr,lf,crlf=P("\r"),P("\n"),P("\r\n") -local newline=P("\r")*(P("\n")+P(true))+P("\n") +local newline=P("\r")*(P("\n")+P(true))+P("\n") local escaped=P("\\")*anything local squote=P("'") local dquote=P('"') @@ -9571,6 +9571,8 @@ otf.coverup={ multiple=justset, ligature=justset, kern=justset, + chainsubstitution=justset, + chainposition=justset, }, register=function(coverage,lookuptype,format,feature,n,descriptions,resources) local name=formatters["ctx_%s_%s_%s"](feature,lookuptype,n) -- cgit v1.2.3 From 5b0c1656911e5f2d436a8145fd046349ac1cb66f Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 11 Jan 2016 07:31:19 +0100 Subject: [fontloader] re-patch font-otn.lua to avoid crash See issue https://github.com/lualatex/luaotfload/issues/303 --- src/fontloader/misc/fontloader-font-otn.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fontloader') diff --git a/src/fontloader/misc/fontloader-font-otn.lua b/src/fontloader/misc/fontloader-font-otn.lua index 8df01bd..b6f30c3 100644 --- a/src/fontloader/misc/fontloader-font-otn.lua +++ b/src/fontloader/misc/fontloader-font-otn.lua @@ -3894,7 +3894,7 @@ local function prepare_contextchains(tfmdata) sequence[nofsequences] = after[n] end end - if sequence[1] then + if sequence[start] then -- Replacements only happen with reverse lookups as they are single only. We -- could pack them into current (replacement value instead of true) and then -- use sequence[start] instead but it's somewhat ugly. -- cgit v1.2.3 From a65f049165c52ff75de5498983a1d713c773471c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 22 Jan 2016 00:42:10 +0100 Subject: [fontloader] revert features handler temporarily MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address issue #318 This reverts the changes made to font-otn.lua with commit adc43c3c24.. Certain features related to directionality are not handled correctly with the most recent fontloader. As a temporary measure, revert the handling code in font-otn.lua and restore the values it references. While this appears to suppress the issue, we’ll switch back to the upstream code once we have an actual solution. --- src/fontloader/misc/fontloader-basics-nod.lua | 9 ++-- src/fontloader/misc/fontloader-font-otn.lua | 67 ++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 8 deletions(-) (limited to 'src/fontloader') diff --git a/src/fontloader/misc/fontloader-basics-nod.lua b/src/fontloader/misc/fontloader-basics-nod.lua index 78f1b17..95a1744 100644 --- a/src/fontloader/misc/fontloader-basics-nod.lua +++ b/src/fontloader/misc/fontloader-basics-nod.lua @@ -51,15 +51,11 @@ nodes = { } nodes.pool = { } nodes.handlers = { } -local nodecodes = { } +local nodecodes = { } for k,v in next, node.types () do nodecodes[string.gsub(v,"_","")] = k end +local whatcodes = { } for k,v in next, node.whatsits() do whatcodes[string.gsub(v,"_","")] = k end local glyphcodes = node.subtypes("glyph") local disccodes = node.subtypes("disc") -for k, v in next, node.types() do - v = string.gsub(v,"_","") - nodecodes[k] = v - nodecodes[v] = k -end for i=0,#glyphcodes do glyphcodes[glyphcodes[i]] = i end @@ -67,6 +63,7 @@ for i=0,#disccodes do disccodes[disccodes[i]] = i end +nodes.whatcodes = whatcodes nodes.nodecodes = nodecodes nodes.glyphcodes = glyphcodes nodes.disccodes = disccodes diff --git a/src/fontloader/misc/fontloader-font-otn.lua b/src/fontloader/misc/fontloader-font-otn.lua index b6f30c3..081630a 100644 --- a/src/fontloader/misc/fontloader-font-otn.lua +++ b/src/fontloader/misc/fontloader-font-otn.lua @@ -246,6 +246,7 @@ local zwj = 0x200D local wildcard = "*" local default = "dflt" +local whatcodes = nodes.whatcodes local nodecodes = nodes.nodecodes local glyphcodes = nodes.glyphcodes local disccodes = nodes.disccodes @@ -253,9 +254,10 @@ local disccodes = nodes.disccodes local glyph_code = nodecodes.glyph local glue_code = nodecodes.glue local disc_code = nodecodes.disc +local whatsit_code = nodecodes.whatsit local math_code = nodecodes.math -local dir_code = nodecodes.dir -local localpar_code = nodecodes.localpar +local dir_code = nodecodes.dir or whatcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar local discretionary_code = disccodes.discretionary local ligature_code = glyphcodes.ligature @@ -3358,6 +3360,37 @@ local function featuresprocessor(head,font,attr) comprun(start,c_run) start = getnext(start) end + elseif id == whatsit_code then + local subtype = getsubtype(start) + if subtype == dir_code then + local dir = getfield(start,"dir") + if dir == "+TLT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = 1 + elseif dir == "+TRT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = -1 + elseif dir == "-TLT" or dir == "-TRT" then + topstack = topstack - 1 + rlmode = dirstack[topstack] == "+TRT" and -1 or 1 + else + rlmode = rlparmode + end + elseif subtype == localpar_code then + local dir = getfield(start,"dir") + if dir == "TRT" then + rlparmode = -1 + elseif dir == "TLT" then + rlparmode = 1 + else + rlparmode = 0 + end + -- one might wonder if the par dir should be looked at, so we might as well drop the n + rlmode = rlparmode + end + start = getnext(start) elseif id == math_code then start = getnext(end_of_math(start)) elseif id == dir_code then @@ -3628,6 +3661,36 @@ local function featuresprocessor(head,font,attr) comprun(start,c_run) start = getnext(start) end + elseif id == whatsit_code then + local subtype = getsubtype(start) + if subtype == dir_code then + local dir = getfield(start,"dir") + if dir == "+TLT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = 1 + elseif dir == "+TRT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = -1 + elseif dir == "-TLT" or dir == "-TRT" then + topstack = topstack - 1 + rlmode = dirstack[topstack] == "+TRT" and -1 or 1 + else + rlmode = rlparmode + end + elseif subtype == localpar_code then + local dir = getfield(start,"dir") + if dir == "TRT" then + rlparmode = -1 + elseif dir == "TLT" then + rlparmode = 1 + else + rlparmode = 0 + end + rlmode = rlparmode + end + start = getnext(start) elseif id == math_code then start = getnext(end_of_math(start)) elseif id == dir_code then -- cgit v1.2.3