diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-08-15 00:08:30 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-08-15 00:08:30 +0200 |
commit | b2f0a60af9b448c65f70e2f54f37fc837f26dd7a (patch) | |
tree | 4106fb25d4a2275597db0821cb83c73587588289 /tex | |
parent | 3ac1a4bbf84101cca4e80acb31eb7fc5754248d3 (diff) | |
download | context-b2f0a60af9b448c65f70e2f54f37fc837f26dd7a.tar.gz |
2017-08-15 00:03:00
Diffstat (limited to 'tex')
20 files changed, 389 insertions, 160 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 6fe3bf184..152d48973 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.08.13 16:37} +\newcontextversion{2017.08.14 23:57} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 728a2e252..f7c3ebd65 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2017.08.13 16:37} +\edef\contextversion{2017.08.14 23:57} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 4611e5c2f..95b1ebaa0 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.08.13 16:37} +\newcontextversion{2017.08.14 23:57} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 7e80b760a..6c68ae559 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -41,7 +41,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2017.08.13 16:37} +\edef\contextversion{2017.08.14 23:57} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua index 8bf904489..8d6aa5a0b 100644 --- a/tex/context/base/mkiv/grph-inc.lua +++ b/tex/context/base/mkiv/grph-inc.lua @@ -1862,11 +1862,31 @@ end -- end, -- } --- local fig = figures.push { name = pdffile } --- figures.identify() --- figures.check() --- local nofpages = fig.used.pages --- figures.pop() +-- local n = "foo.pdf" +-- local d = figures.getinfo(n) +-- if d then +-- for i=1,d.used.pages do +-- local p = figures.getinfo(n,i) +-- if p then +-- local u = p.used +-- print(u.width,u.height,u.orientation) +-- end +-- end +-- end + +function figures.getinfo(name,page) + if type(name) == "string" then + name = { name = name, page = page } + end + if name.name then + local data = figures.push(name) + figures.identify() + figures.check() + inspect(data) + figures.pop() + return data + end +end -- interfacing diff --git a/tex/context/base/mkiv/lang-url.lua b/tex/context/base/mkiv/lang-url.lua index 93c3c02a8..b682c008d 100644 --- a/tex/context/base/mkiv/lang-url.lua +++ b/tex/context/base/mkiv/lang-url.lua @@ -8,6 +8,7 @@ if not modules then modules = { } end modules ['lang-url'] = { local utfcharacters, utfvalues, utfbyte, utfchar = utf.characters, utf.values, utf.byte, utf.char local min, max = math.min, math.max +local concat = table.concat local context = context @@ -80,13 +81,67 @@ directives.register("hyphenators.urls.packslashes",function(v) urls.packslashes = v end) -local ctx_a = context.a -local ctx_b = context.b -local ctx_d = context.d -local ctx_c = context.c -local ctx_l = context.l -local ctx_C = context.C -local ctx_L = context.L +-- local ctx_a = context.a +-- local ctx_b = context.b +-- local ctx_d = context.d +-- local ctx_c = context.c +-- local ctx_l = context.l +-- local ctx_C = context.C +-- local ctx_L = context.L + +-- local function action(hyphenatedurl,str,left,right,disc) +-- -- +-- left = max( left or urls.lefthyphenmin, 2) +-- right = min(#str-(right or urls.righthyphenmin)+2,#str) +-- disc = disc or urls.discretionary +-- -- +-- local word = nil +-- local prev = nil +-- local pack = urls.packslashes +-- local length = 0 +-- -- +-- for char in utfcharacters(str) do +-- length = length + 1 +-- char = mapping[char] or char +-- local b = utfbyte(char) +-- if prev == char and prev == "/" then +-- ctx_c(b) +-- elseif char == disc then +-- ctx_d() +-- else +-- if prev == "/" then +-- ctx_d() +-- end +-- local how = characters[char] +-- if how == v_before then +-- word = false +-- ctx_b(b) +-- elseif how == v_after then +-- word = false +-- ctx_a(b) +-- else +-- local letter = is_letter[char] +-- if length <= left or length >= right then +-- if word and letter then +-- ctx_L(b) +-- else +-- ctx_C(b) +-- end +-- elseif word and letter then +-- ctx_l(b) +-- else +-- ctx_c(b) +-- end +-- word = letter +-- end +-- end +-- if pack then +-- prev = char +-- else +-- prev = nil +-- end +-- end +-- end local function action(hyphenatedurl,str,left,right,disc) -- @@ -95,48 +150,51 @@ local function action(hyphenatedurl,str,left,right,disc) disc = disc or urls.discretionary -- local word = nil - local prev = nil local pack = urls.packslashes local length = 0 - -- - for char in utfcharacters(str) do - length = length + 1 - char = mapping[char] or char - if prev == char and prev == "/" then - ctx_c(utfbyte(char)) - elseif char == disc then - ctx_d() + local list = utf.split(str) + + for i=1,#list do + local what = nil + local dodi = false + local char = list[i] + length = length + 1 + char = mapping[char] or char + if char == disc then + dodi = true + elseif pack and char == "/" and list[i+1] == "/" then + what = "c" else - if prev == "/" then - ctx_d() - end local how = characters[char] if how == v_before then - word = false - ctx_b(utfbyte(char)) + what = "b" elseif how == v_after then word = false - ctx_a(utfbyte(char)) + what = "a" else local letter = is_letter[char] if length <= left or length >= right then if word and letter then - ctx_L(utfbyte(char)) + what = "L" else - ctx_C(utfbyte(char)) + what = "C" end elseif word and letter then - ctx_l(utfbyte(char)) + what = "l" else - ctx_c(utfbyte(char)) + what = "c" end word = letter end end - if pack then - prev = char + what = "\\" .. what .. "{" .. utfbyte(char) .. "}" + if dodi then + list[i] = "\\d" .. what + else + list[i] = what end end + context(concat(list)) end -- urls.action = function(_,...) action(...) end -- sort of obsolete diff --git a/tex/context/base/mkiv/node-met.lua b/tex/context/base/mkiv/node-met.lua index 2686aa990..12a9256bc 100644 --- a/tex/context/base/mkiv/node-met.lua +++ b/tex/context/base/mkiv/node-met.lua @@ -40,6 +40,11 @@ if not modules then modules = { } end modules ['node-nut'] = { -- As lots of testing and experimenting was part of this project, I could not have -- done without stacks of new \CD s and \DVD s. This time Porcupine Tree, No-Man -- and Archive were came to rescue. +-- +-- It all started with testing performance of: +-- +-- node.getfield = metatable.__index +-- node.setfield = metatable.__newindex local type, select = type, select local setmetatableindex = table.setmetatableindex @@ -118,44 +123,14 @@ nodes.kerning = node.kerning nodes.ligaturing = node.ligaturing nodes.mlist_to_hlist = node.mlist_to_hlist -if not node.getwhd then - local getfield = node.getfield - function node.getwhd(n) - return getfield(n,"width"), getfield(n,"height"), getfield(n,"depth") - end -end - -if not node.setwhd then - local setfield = node.setfield - function node.setwhd(n,w,h,d) - setfield(n,"width",w or 0) - setfield(n,"height",h or 0) - setfield(n,"depth",d or 0) - end -end - -nodes.getwhd = node.getwhd -nodes.setwhd = node.setwhd - nodes.effective_glue = node.effective_glue nodes.getglue = node.getglue nodes.setglue = node.setglue nodes.is_zero_glue = node.is_zero_glue --- if not gonuts or not node.getfield then --- node.getfield = metatable.__index --- node.setfield = metatable.__newindex --- end - nodes.tonode = function(n) return n end nodes.tonut = function(n) return n end -local getfield = node.getfield -local setfield = node.setfield - -local getattr = node.get_attribute -local setattr = setfield - local n_getid = node.getid local n_getlist = node.getlist local n_getnext = node.getnext @@ -163,30 +138,27 @@ local n_getprev = node.getprev local n_getchar = node.getchar local n_getfont = node.getfont local n_getsubtype = node.getsubtype -local n_setfield = node.setfield local n_getfield = node.getfield -local n_setattr = node.setattr -local n_getattr = node.getattr +local n_getattr = node.get_attribute local n_getdisc = node.getdisc local n_getleader = node.getleader +local n_setfield = node.setfield +local n_setattr = n_setfield + local n_setnext = node.setnext or -- always function(c,n) - setfield(c,"next",n) + n_setfield(c,"next",n) end local n_setprev = node.setprev or -- always function(c,p) - setfield(c,"prev",p) + n_setfield(c,"prev",p) end local n_setlist = node.setlist or -- always function(c,l) - setfield(c,"list",l) + n_setfield(c,"list",l) end local n_setlink = node.setlink or -- always --- function(c1,c2) --- if c1 then setfield(c1,"next",c2) end --- if c2 then setfield(c2,"prev",c1) end --- end function(...) -- not that fast but not used often anyway local h = nil @@ -195,8 +167,8 @@ local n_setlink = node.setlink or -- always if not n then -- go on elseif h then - setfield(h,"next",n) - setfield(n,"prev",h) + n_setfield(h,"next",n) + n_setfield(n,"prev",h) else h = n end @@ -205,8 +177,8 @@ local n_setlink = node.setlink or -- always end local n_setboth = node.setboth or -- always function(c,p,n) - setfield(c,"prev",p) - setfield(c,"next",n) + n_setfield(c,"prev",p) + n_setfield(c,"next",n) end nodes.setnext = n_setnext @@ -231,6 +203,23 @@ nodes.getlist = n_getlist nodes.getleader = n_getleader nodes.getdisc = n_getdisc +if not node.getwhd then + function node.getwhd(n) + return n_getfield(n,"width"), n_getfield(n,"height"), n_getfield(n,"depth") + end +end + +if not node.setwhd then + function node.setwhd(n,w,h,d) + n_setfield(n,"width",w or 0) + n_setfield(n,"height",h or 0) + n_setfield(n,"depth",d or 0) + end +end + +nodes.getwhd = node.getwhd +nodes.setwhd = node.setwhd + nodes.is_char = node.is_char nodes.ischar = node.is_char diff --git a/tex/context/base/mkiv/publ-ini.mkiv b/tex/context/base/mkiv/publ-ini.mkiv index 456919b6a..9dd03e40d 100644 --- a/tex/context/base/mkiv/publ-ini.mkiv +++ b/tex/context/base/mkiv/publ-ini.mkiv @@ -1402,7 +1402,7 @@ \let\cite \citation \let\nocite \nocitation -\let\usecitation\citation +\let\usecitation\nocitation \unexpanded\def\publ_entry_citation {\doifelsenextoptionalcs\btxlistcitation \btxdirectlistcite} \unexpanded\def\publ_entry_nocitation{\doifelsenextoptionalcs\btxhiddencitation\btxdirecthiddencite} diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex fa9c777c4..25e1e37c9 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 26c3eb179..3800d42ed 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/tabl-tsp.mkiv b/tex/context/base/mkiv/tabl-tsp.mkiv index eadcda16c..2c4b694b3 100644 --- a/tex/context/base/mkiv/tabl-tsp.mkiv +++ b/tex/context/base/mkiv/tabl-tsp.mkiv @@ -188,7 +188,7 @@ \forcelocalfloats \setuplocalfloats[\c!before=,\c!after=,\c!inbetween=]% \splitfloatcommand{\hbox to #1{\strut}}% dummy line - \setbox\scratchbox\vbox{\flushlocalfloats}% + \setbox\scratchbox\vbox{\flushlocalfloats}% \vpack ? \getnoflines{\ht\scratchbox}% \resetlocalfloats \advance\noflines\minusone % compensate dummy line @@ -307,7 +307,7 @@ {\setbox\scratchbox\vsplit\tsplitcontent to \onepoint % \lineheight \setbox\scratchbox\vbox % \vpack {\unvbox\scratchbox - \setbox\scratchbox\vbox + \setbox\scratchbox\vbox % \vpack {\splitdiscards \ifnum\lastpenalty>-\plustenthousand\else % so that \bTR[before=\page] works @@ -328,7 +328,7 @@ \ifvoid\tsplitcontent \exitloop \fi \else\ifconditional\c_tabl_split_head % we only have a tablehead so far - \setbox\tsplitresult\vbox{\unvbox\tsplitresult\unvbox\scratchbox}% + \setbox\tsplitresult\vbox{\unvbox\tsplitresult\unvbox\scratchbox}% \vpack \exitloop \else\ifconditional\c_tabl_split_full % we have text height available, but the (one) cell is too diff --git a/tex/context/base/mkiv/typo-dir.lua b/tex/context/base/mkiv/typo-dir.lua index 5ecf77a1f..8a9ec978e 100644 --- a/tex/context/base/mkiv/typo-dir.lua +++ b/tex/context/base/mkiv/typo-dir.lua @@ -36,6 +36,8 @@ local trace_textdirections = false trackers.register("typesetters.directions.t local trace_mathdirections = false trackers.register("typesetters.directions.math", function(v) trace_mathdirections = v end) local trace_directions = false trackers.register("typesetters.directions", function(v) trace_textdirections = v trace_mathdirections = v end) +local one_too = false directives.register("typesetters.directions.onetoo", function(v) one_too = v end) + local report_textdirections = logs.reporter("typesetting","text directions") ----- report_mathdirections = logs.reporter("typesetting","math directions") @@ -44,6 +46,9 @@ local hasbit = number.hasbit local texsetattribute = tex.setattribute local unsetvalue = attributes.unsetvalue +local getnext = nodes.getnext +local getattr = nodes.getattr + local enableaction = nodes.tasks.enableaction local tracers = nodes.tracers local setcolor = tracers.colors.set @@ -155,11 +160,18 @@ local enabled = false local starttiming = statistics.starttiming local stoptiming = statistics.stoptiming -function directions.handler(head) -- ,_,_,_,direction) -- nodes not nuts | 5th arg is direction - if not head.next then +-- If we have hbox{!} then the hbox determines the direction but we can consider +-- a fast analysis, not that it matters much because there's nothing to swap in +-- the list unless one glyphs becomes multiple (can that really happen?). +-- +-- \enabledirectives[typesetters.directions.onetoo] + +function directions.handler(head,_,_,_,direction) + local only_one = not getnext(head) + if only_one and not one_too then return head, false end - local attr = head[a_directions] + local attr = getattr(head,a_directions) if not attr or attr == 0 then return head, false end @@ -169,7 +181,7 @@ function directions.handler(head) -- ,_,_,_,direction) -- nodes not nuts | 5th a return head, false end starttiming(directions) - local head, done = handler(head) + local head, done = handler(head,direction,only_one) stoptiming(directions) return head, done end diff --git a/tex/context/base/mkiv/typo-dua.lua b/tex/context/base/mkiv/typo-dua.lua index 3a23f97f1..1e48dfb91 100644 --- a/tex/context/base/mkiv/typo-dua.lua +++ b/tex/context/base/mkiv/typo-dua.lua @@ -57,7 +57,8 @@ if not modules then modules = { } end modules ['typo-dua'] = { -- tood: combine some sweeps -- -- This one wil get frozen (or if needed in sync with basic t-bidi) and I will explore more options --- in typo-dub.lua. There I might also be able to improve performance a bit. +-- in typo-dub.lua. There I might also be able to improve performance a bit. Derived and improved +-- versions will also be sped up local insert, remove, unpack, concat = table.insert, table.remove, table.unpack, table.concat local utfchar = utf.char @@ -678,6 +679,8 @@ local function resolve_levels(list,size,baselevel) end end +-- This is not ok but we keep it as-is: + local function insert_dir_points(list,size) -- L2, but no actual reversion is done, we simply annotate where -- begindir/endddir node will be inserted. diff --git a/tex/context/base/mkiv/typo-dub.lua b/tex/context/base/mkiv/typo-dub.lua index d85caa078..21953bafd 100644 --- a/tex/context/base/mkiv/typo-dub.lua +++ b/tex/context/base/mkiv/typo-dub.lua @@ -812,11 +812,57 @@ local function resolve_levels(list,size,baselevel,analyze_fences) end end +-- local function insert_dir_points(list,size) +-- -- L2, but no actual reversion is done, we simply annotate where +-- -- begindir/endddir node will be inserted. +-- local maxlevel = 0 +-- local finaldir = false +-- for i=1,size do +-- local level = list[i].level +-- if level > maxlevel then +-- maxlevel = level +-- end +-- end +-- for level=0,maxlevel do +-- local started = false +-- local begindir = nil +-- local enddir = nil +-- if level % 2 == 1 then +-- begindir = "+TRT" +-- enddir = "-TRT" +-- else +-- begindir = "+TLT" +-- enddir = "-TLT" +-- end +-- for i=1,size do +-- local entry = list[i] +-- if entry.level >= level then +-- if not started then +-- entry.begindir = begindir +-- started = true +-- end +-- else +-- if started then +-- list[i-1].enddir = enddir +-- started = false +-- end +-- end +-- end +-- -- make sure to close the run at end of line +-- if started then +-- finaldir = enddir +-- end +-- end +-- if finaldir then +-- list[size].enddir = finaldir +-- end +-- end + local function insert_dir_points(list,size) -- L2, but no actual reversion is done, we simply annotate where -- begindir/endddir node will be inserted. local maxlevel = 0 - local finaldir = false + local toggle = true for i=1,size do local level = list[i].level if level > maxlevel then @@ -824,15 +870,18 @@ local function insert_dir_points(list,size) end end for level=0,maxlevel do - local started = false - local begindir = nil - local enddir = nil - if level % 2 == 1 then - begindir = "+TRT" - enddir = "-TRT" - else + local started -- = false + local begindir -- = nil + local enddir -- = nil + local prev -- = nil + if toggle then begindir = "+TLT" enddir = "-TLT" + toggle = false + else + begindir = "+TRT" + enddir = "-TRT" + toggle = true end for i=1,size do local entry = list[i] @@ -843,18 +892,36 @@ local function insert_dir_points(list,size) end else if started then - list[i-1].enddir = enddir - started = false + prev.enddir = enddir + started = false end end - end - -- make sure to close the run at end of line - if started then - finaldir = enddir + prev = entry end end - if finaldir then - list[size].enddir = finaldir + -- make sure to close the run at end of line + local last = list[size] + if not last.enddir then + local s = { } + local n = 0 + for i=1,size do + local entry = list[i] + local e = entry.enddir + local b = entry.begindir + if e then + n = n - 1 + end + if b then + n = n + 1 + s[n] = b + end + end + if n > 0 then + if trace_list and n > 1 then + report_directions("unbalanced list") + end + last.enddir = s[n] == "+TRT" and "-TRT" or "-TLT" + end end end diff --git a/tex/context/base/mkiv/typo-duc.lua b/tex/context/base/mkiv/typo-duc.lua index 53be51aea..9033e6d47 100644 --- a/tex/context/base/mkiv/typo-duc.lua +++ b/tex/context/base/mkiv/typo-duc.lua @@ -105,11 +105,11 @@ local a_directions = attributes.private('directions') local remove_controls = true directives.register("typesetters.directions.removecontrols",function(v) remove_controls = v end) ----- analyze_fences = true directives.register("typesetters.directions.analyzefences", function(v) analyze_fences = v end) -local trace_directions = false trackers .register("typesetters.directions.two", function(v) trace_directions = v end) -local trace_details = false trackers .register("typesetters.directions.two.details", function(v) trace_details = v end) -local trace_list = false trackers .register("typesetters.directions.two.list", function(v) trace_list = v end) +local trace_directions = false trackers.register("typesetters.directions.three", function(v) trace_directions = v end) +local trace_details = false trackers.register("typesetters.directions.three.details", function(v) trace_details = v end) +local trace_list = false trackers.register("typesetters.directions.three.list", function(v) trace_list = v end) -local report_directions = logs.reporter("typesetting","directions two") +local report_directions = logs.reporter("typesetting","directions three") -- strong (old): -- @@ -209,27 +209,28 @@ end local function show_done(list,size) local joiner = utfchar(0x200C) local result = { } + local format = formatters["<%s>"] for i=1,size do local entry = list[i] local character = entry.char local begindir = entry.begindir local enddir = entry.enddir if begindir then - result[#result+1] = formatters["<%s>"](begindir) + result[#result+1] = format(begindir) end if entry.remove then -- continue elseif character == 0xFFFC then - result[#result+1] = formatters["<%s>"]("?") + result[#result+1] = format("?") elseif character == 0x0020 then - result[#result+1] = formatters["<%s>"](" ") + result[#result+1] = format(" ") elseif character >= 0x202A and character <= 0x202C then - result[#result+1] = formatters["<%s>"](entry.original) + result[#result+1] = format(entry.original) else result[#result+1] = utfchar(character) end if enddir then - result[#result+1] = formatters["<%s>"](enddir) + result[#result+1] = format(enddir) end end return concat(result,joiner) @@ -310,7 +311,7 @@ local function build_list(head) -- todo: store node pointer ... saves loop skip = skip + 1 current = getnext(current) list[size] = setmetatable({ id = id, skip = skip },mt_object) - else + else -- disc_code: we assume that these are the same as the surrounding local skip = 0 local last = id current = getnext(current) @@ -350,7 +351,6 @@ end local function resolve_fences(list,size,start,limit) -- N0: funny effects, not always better, so it's an option - -- local stack = { } local nofstack = 0 for i=start,limit do local entry = list[i] @@ -404,27 +404,26 @@ end -- the action -local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for localpar) - local id = getid(head) - if id == localpar_code then - if getdir(head) == "TRT" then +local function get_baselevel(head,list,size,direction) + if not direction and getid(head) == localpar_code then + direction = getdir(head) + end + if direction == "TRT" then + return 1, "TRT", true + elseif direction == "TLT" then + return 0, "TLT", true + end + -- P2, P3: + for i=1,size do + local entry = list[i] + local direction = entry.direction + if direction == "r" or direction == "al" then -- and an ? return 1, "TRT", true - else + elseif direction == "l" then return 0, "TLT", true end - else - -- P2, P3 - for i=1,size do - local entry = list[i] - local direction = entry.direction - if direction == "r" or direction == "al" then -- and an ? - return 1, "TRT", true - elseif direction == "l" then - return 0, "TLT", true - end - end - return 0, "TLT", false end + return 0, "TLT", false end local function resolve_explicit(list,size,baselevel) @@ -432,7 +431,6 @@ local function resolve_explicit(list,size,baselevel) -- X1 local level = baselevel local override = "on" - -- local stack = { } local nofstack = 0 for i=1,size do local entry = list[i] @@ -851,11 +849,67 @@ local function resolve_levels(list,size,baselevel,analyze_fences) end end +-- local function insert_dir_points(list,size) +-- -- L2, but no actual reversion is done, we simply annotate where +-- -- begindir/endddir node will be inserted. +-- local maxlevel = 0 +-- local finaldir = false +-- local toggle = true +-- for i=1,size do +-- local level = list[i].level +-- if level > maxlevel then +-- maxlevel = level +-- end +-- end +-- for level=0,maxlevel do +-- local started -- = false +-- local begindir -- = nil +-- local enddir -- = nil +-- local prev -- = nil +-- if toggle then +-- begindir = "+TLT" +-- enddir = "-TLT" +-- toggle = false +-- else +-- begindir = "+TRT" +-- enddir = "-TRT" +-- toggle = true +-- end +-- for i=1,size do +-- local entry = list[i] +-- if entry.level >= level then +-- if not started then +-- entry.begindir = begindir +-- started = true +-- end +-- else +-- if started then +-- prev.enddir = enddir +-- started = false +-- end +-- end +-- prev = entry +-- end +-- -- make sure to close the run at end of line +-- if started then +-- finaldir = enddir +-- end +-- end +-- if finaldir then +-- list[size].enddir = finaldir +-- end +-- for i=1,size do +-- print("<",i,list[i].level,list[i].begindir,list[i].enddir) +-- end +-- end + +local stack = { } + local function insert_dir_points(list,size) -- L2, but no actual reversion is done, we simply annotate where -- begindir/endddir node will be inserted. local maxlevel = 0 - local finaldir = false + local toggle = true for i=1,size do local level = list[i].level if level > maxlevel then @@ -863,15 +917,18 @@ local function insert_dir_points(list,size) end end for level=0,maxlevel do - local started = false - local begindir = nil - local enddir = nil - if level % 2 == 1 then - begindir = "+TRT" - enddir = "-TRT" - else + local started -- = false + local begindir -- = nil + local enddir -- = nil + local prev -- = nil + if toggle then begindir = "+TLT" enddir = "-TLT" + toggle = false + else + begindir = "+TRT" + enddir = "-TRT" + toggle = true end for i=1,size do local entry = list[i] @@ -882,18 +939,35 @@ local function insert_dir_points(list,size) end else if started then - list[i-1].enddir = enddir - started = false + prev.enddir = enddir + started = false end end - end - -- make sure to close the run at end of line - if started then - finaldir = enddir + prev = entry end end - if finaldir then - list[size].enddir = finaldir + -- make sure to close the run at end of line + local last = list[size] + if not last.enddir then + local n = 0 + for i=1,size do + local entry = list[i] + local e = entry.enddir + local b = entry.begindir + if e then + n = n - 1 + end + if b then + n = n + 1 + stack[n] = b + end + end + if n > 0 then + if trace_list and n > 1 then + report_directions("unbalanced list") + end + last.enddir = stack[n] == "+TRT" and "-TRT" or "-TLT" + end end end @@ -994,18 +1068,24 @@ local function apply_to_list(list,size,head,pardir) return head, done end -local function process(head) +-- If needed we can optimize for only_one. There is no need to do anything +-- when it's not a glyph. Otherwise we only need to check mirror and apply +-- directions when it's different from the surrounding. Paragraphs always +-- have more than one node. Actually, we only enter this function when we +-- do have a glyph! + +local function process(head,direction,only_one) head = tonut(head) -- for the moment a whole paragraph property local attr = getattr(head,a_directions) local analyze_fences = getfences(attr) -- local list, size = build_list(head) - local baselevel, pardir, dirfound = get_baselevel(head,list,size) -- we always have an inline dir node in context - if not dirfound and trace_details then - report_directions("no initial direction found, gambling") - end + local baselevel, pardir, dirfound = get_baselevel(head,list,size,direction) -- we always have an inline dir node in context if trace_details then + if not dirfound then + report_directions("no initial direction found, gambling") + end report_directions("before : %s",show_list(list,size,"original")) end resolve_explicit(list,size,baselevel) diff --git a/tex/context/base/mkiv/typo-krn.lua b/tex/context/base/mkiv/typo-krn.lua index 95b84993b..0a913f8ab 100644 --- a/tex/context/base/mkiv/typo-krn.lua +++ b/tex/context/base/mkiv/typo-krn.lua @@ -104,8 +104,8 @@ local v_auto = interfaces.variables.auto typesetters = typesetters or { } local typesetters = typesetters -typesetters.kerns = typesetters.kerns or { } -local kerns = typesetters.kerns +local kerns = typesetters.kerns or { } +typesetters.kerns = kerns local report = logs.reporter("kerns") local trace_ligatures = false trackers.register("typesetters.kerns.ligatures", function(v) trace_ligatures = v end) diff --git a/tex/context/base/mkiv/unic-ini.mkiv b/tex/context/base/mkiv/unic-ini.mkiv index 13ad4bdb9..9d8574e35 100644 --- a/tex/context/base/mkiv/unic-ini.mkiv +++ b/tex/context/base/mkiv/unic-ini.mkiv @@ -29,7 +29,7 @@ \def\unicodechar#1{\clf_unicodechar{#1}} \unexpanded\def\unknownchar - {\dontleavehmode\hbox{\vrule\s!width.5\emwidth\s!height\exheight\s!depth\zeropoint}} + {\dontleavehmode\hpack{\vrule\s!width.5\emwidth\s!height\exheight\s!depth\zeropoint}} \ifdefined\zwnbsp\else \let\zwnbsp\relax \fi % zerowidthnonbreakablespace diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 29515f75c..0399648d1 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex fdb9f9f2c..cdae41a28 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 08fbc5974..892f42014 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.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 : 08/13/17 16:37:50 +-- merge date : 08/14/17 23:57:26 do -- begin closure to overcome local limits and interference |