diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-06-19 15:50:29 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-06-19 15:50:29 +0200 |
commit | d11a1200ed28c6e0058990a621d7404f821ac7fd (patch) | |
tree | a433002a97225266abf1f925beb0ed699dbee41c /tex/context/base/mkiv/font-oto.lua | |
parent | 008292817580eba8a0f0cf83d8e2d08df8fc8c3f (diff) | |
download | context-d11a1200ed28c6e0058990a621d7404f821ac7fd.tar.gz |
2017-06-19 15:35:00
Diffstat (limited to 'tex/context/base/mkiv/font-oto.lua')
-rw-r--r-- | tex/context/base/mkiv/font-oto.lua | 95 |
1 files changed, 57 insertions, 38 deletions
diff --git a/tex/context/base/mkiv/font-oto.lua b/tex/context/base/mkiv/font-oto.lua index 9c42a54bd..22bb1d74e 100644 --- a/tex/context/base/mkiv/font-oto.lua +++ b/tex/context/base/mkiv/font-oto.lua @@ -67,21 +67,32 @@ local function cref(feature,sequence) return formatters["feature %a, type %a, chain lookup %a"](feature,sequence.type,sequence.name) end - -local function report_alternate(feature,sequence,descriptions,unicode,replacement,value,comment) - report_prepare("%s: base alternate %s => %s (%S => %S)", - cref(feature,sequence), - gref(descriptions,unicode), - replacement and gref(descriptions,replacement), - value, - comment) +local function report_substitution(feature,sequence,descriptions,unicode,substitution) + if unicode == substitution then + report_prepare("%s: base substitution %s maps onto itself", + cref(feature,sequence), + gref(descriptions,unicode)) + else + report_prepare("%s: base substitution %s => %S", + cref(feature,sequence), + gref(descriptions,unicode), + gref(descriptions,substitution)) + end end -local function report_substitution(feature,sequence,descriptions,unicode,substitution) - report_prepare("%s: base substitution %s => %S", - cref(feature,sequence), - gref(descriptions,unicode), - gref(descriptions,substitution)) +local function report_alternate(feature,sequence,descriptions,unicode,replacement,value,comment) + if unicode == replacement then + report_prepare("%s: base alternate %s maps onto itself", + cref(feature,sequence), + gref(descriptions,unicode)) + else + report_prepare("%s: base alternate %s => %s (%S => %S)", + cref(feature,sequence), + gref(descriptions,unicode), + replacement and gref(descriptions,replacement), + value, + comment) + end end local function report_ligature(feature,sequence,descriptions,unicode,ligature) @@ -221,6 +232,9 @@ local function preparesubstitutions(tfmdata,feature,value,validlookups,lookuplis local trace_alternatives = trace_baseinit and trace_alternatives local trace_ligatures = trace_baseinit and trace_ligatures + -- A chain of changes is handled in font-con which is clesner because + -- we can have shared changes and such. + if not changed then changed = { } tfmdata.changed = changed @@ -233,39 +247,44 @@ local function preparesubstitutions(tfmdata,feature,value,validlookups,lookuplis if kind == "gsub_single" then for i=1,#steps do for unicode, data in next, steps[i].coverage do - -- if not changed[unicode] then -- fails for multiple subs in some math fonts - if trace_singles then - report_substitution(feature,sequence,descriptions,unicode,data) - end + if unicode ~= data then changed[unicode] = data - -- end + end + if trace_singles then + report_substitution(feature,sequence,descriptions,unicode,data) + end end end elseif kind == "gsub_alternate" then for i=1,#steps do for unicode, data in next, steps[i].coverage do - if not changed[unicode] then - local replacement = data[alternate] - if replacement then + local replacement = data[alternate] + if replacement then + if unicode ~= replacement then changed[unicode] = replacement - if trace_alternatives then - report_alternate(feature,sequence,descriptions,unicode,replacement,value,"normal") - end - elseif defaultalt == "first" then - replacement = data[1] + end + if trace_alternatives then + report_alternate(feature,sequence,descriptions,unicode,replacement,value,"normal") + end + elseif defaultalt == "first" then + replacement = data[1] + if unicode ~= replacement then changed[unicode] = replacement - if trace_alternatives then - report_alternate(feature,sequence,descriptions,unicode,replacement,value,defaultalt) - end - elseif defaultalt == "last" then - replacement = data[#data] - if trace_alternatives then - report_alternate(feature,sequence,descriptions,unicode,replacement,value,defaultalt) - end - else - if trace_alternatives then - report_alternate(feature,sequence,descriptions,unicode,replacement,value,"unknown") - end + end + if trace_alternatives then + report_alternate(feature,sequence,descriptions,unicode,replacement,value,defaultalt) + end + elseif defaultalt == "last" then + replacement = data[#data] + if unicode ~= replacement then + changed[unicode] = replacement + end + if trace_alternatives then + report_alternate(feature,sequence,descriptions,unicode,replacement,value,defaultalt) + end + else + if trace_alternatives then + report_alternate(feature,sequence,descriptions,unicode,replacement,value,"unknown") end end end |