diff options
Diffstat (limited to 'tex')
28 files changed, 324 insertions, 671 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 78b1530af..3ad3147ce 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{2018.12.28 11:01} +\newcontextversion{2018.12.30 19:28} %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 48a2834fc..eb7d5d402 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{2018.12.28 11:01} +\edef\contextversion{2018.12.30 19:28} %D For those who want to use this: diff --git a/tex/context/base/mkiv/back-exp.lua b/tex/context/base/mkiv/back-exp.lua index 86c29966e..71e2b89f8 100644 --- a/tex/context/base/mkiv/back-exp.lua +++ b/tex/context/base/mkiv/back-exp.lua @@ -2897,11 +2897,8 @@ local collectresults do -- too many locals otherwise local nuts = nodes.nuts local getnext = nuts.getnext - local getsubtype = nuts.getsubtype - local getfont = nuts.getfont - local getchar = nuts.getchar local getdisc = nuts.getdisc - local getcomponents = nuts.getcomponents + ----- getcomponents = nuts.getcomponents local getlist = nuts.getlist local getid = nuts.getid local getattr = nuts.getattr @@ -2956,24 +2953,24 @@ local collectresults do -- too many locals otherwise showdetail(n,id,subtype) end if id == glyph_code then - local c = getchar(n) - local at = getattr(n,a_tagged) or pat + local c, f = isglyph(n) + local at = getattr(n,a_tagged) or pat if not at then -- we need to tag the pagebody stuff as being valid skippable -- -- report_export("skipping character: %C (no attribute)",n.char) else -- we could add tonunicodes for ligatures (todo) - local components = getcomponents(n) - if components and (not characterdata[c] or overloads[c]) then -- we loose data - collectresults(components,nil,at) -- this assumes that components have the same attribute as the glyph ... we should be more tolerant (see math) - else + -- local components = getcomponents(n) + -- if components and (not characterdata[c] or overloads[c]) then -- we loose data + -- collectresults(components,nil,at) -- this assumes that components have the same attribute as the glyph ... we should be more tolerant (see math) + -- else if last ~= at then local tl = taglist[at] local ap = getattr(n,a_taggedpar) or pap -if localparagraph and (not ap or ap < localparagraph) then - maybewrong = addtomaybe(maybewrong,c,1) -end + if localparagraph and (not ap or ap < localparagraph) then + maybewrong = addtomaybe(maybewrong,c,1) + end pushcontent() currentnesting = tl currentparagraph = ap @@ -3007,9 +3004,9 @@ end currentattribute = last currentparagraph = ap end -if localparagraph and (not ap or ap < localparagraph) then - maybewrong = addtomaybe(maybewrong,c,2) -end + if localparagraph and (not ap or ap < localparagraph) then + maybewrong = addtomaybe(maybewrong,c,2) + end if trace_export then report_export("%w<!-- processing glyph %C tagged %a -->",currentdepth,c,last) end @@ -3038,7 +3035,7 @@ end currentcontent[nofcurrentcontent] = " " end else - local fc = fontchar[getfont(n)] + local fc = fontchar[f] if fc then fc = fc and fc[c] if fc then @@ -3068,7 +3065,7 @@ end -- we can have -1 as side effect of an explicit hyphen (unless we expand) end end - end + -- end end elseif id == disc_code then -- probably too late local pre, post, replace = getdisc(n) @@ -3240,8 +3237,11 @@ end local kern = getkern(n) if kern > 0 then local limit = threshold - if p and getid(p) == glyph_code then - limit = fontquads[getfont(p)] / 4 + if p then + local c, f = isglyph(p) + if c then + limit = fontquads[f] / 4 + end end if kern > limit then if last and not somespace[currentcontent[nofcurrentcontent]] then diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 1c6ba3dde..0a456e591 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{2018.12.28 11:01} +\newcontextversion{2018.12.30 19:28} %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 4425ac476..a8a81ecef 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -42,7 +42,7 @@ %D has to match \type {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2018.12.28 11:01} +\edef\contextversion{2018.12.30 19:28} \edef\contextkind {beta} %D For those who want to use this: @@ -138,6 +138,8 @@ % needs more checking for clashes: % +% no need to register, just execute once, slightly faster +% % \doifelsefileexists{l-macro-imp-codes.lua}{\registerctxluafile{l-macro-imp-codes}{}}{} \loadmarkfile{supp-dir} diff --git a/tex/context/base/mkiv/core-lmt.lua b/tex/context/base/mkiv/core-lmt.lua index 2f4f43116..ae8c02ea5 100644 --- a/tex/context/base/mkiv/core-lmt.lua +++ b/tex/context/base/mkiv/core-lmt.lua @@ -30,7 +30,5 @@ end implement { name = "textdir", public = true, protected = true, actions = function() scandir(settextdir) end } implement { name = "linedir", public = true, protected = true, actions = function() scandir(setlinedir) end } -implement { name = "pagedir", public = true, protected = true, actions = function() scandir(setpagedir) end } implement { name = "pardir", public = true, protected = true, actions = function() scandir(setpardir) end } -implement { name = "bodydir", public = true, protected = true, actions = function() scandir(setbodydir) end } implement { name = "boxdir", public = true, protected = true, actions = function() scandir(setboxdir) end } diff --git a/tex/context/base/mkiv/font-nod.lua b/tex/context/base/mkiv/font-nod.lua index 69c1d34dd..33bd6408b 100644 --- a/tex/context/base/mkiv/font-nod.lua +++ b/tex/context/base/mkiv/font-nod.lua @@ -65,7 +65,7 @@ local getsubtype = nuts.getsubtype local getchar = nuts.getchar local getlist = nuts.getlist local getdisc = nuts.getdisc -local getcomponents = nuts.getcomponents +----- getcomponents = nuts.getcomponents local isglyph = nuts.isglyph local getkern = nuts.getkern local getdirection = nuts.getdirection @@ -501,10 +501,10 @@ local function toutf(list,result,nofresult,stopcriterium,nostrip) for n, id in nextnode, tonut(list) do if id == glyph_code then local c = getchar(n) - local components = getcomponents(n) - if components then - result, nofresult = toutf(components,result,nofresult,false,true) - elseif c > 0 then + -- local components = getcomponents(n) + -- if components then + -- result, nofresult = toutf(components,result,nofresult,false,true) + -- elseif c > 0 then local fc = fontcharacters[getfont(n)] if fc then local fcc = fc[c] @@ -530,10 +530,10 @@ local function toutf(list,result,nofresult,stopcriterium,nostrip) nofresult = nofresult + 1 result[nofresult] = f_unicode(c) end - else - nofresult = nofresult + 1 - result[nofresult] = f_badcode(c) - end + -- else + -- nofresult = nofresult + 1 + -- result[nofresult] = f_badcode(c) + -- end elseif id == disc_code then result, nofresult = toutf(getfield(n,"replace"),result,nofresult,false,true) -- needed? elseif id == hlist_code or id == vlist_code then diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua index a0dab10cb..5c64ab8e5 100644 --- a/tex/context/base/mkiv/font-ots.lua +++ b/tex/context/base/mkiv/font-ots.lua @@ -82,7 +82,7 @@ mechanisms. Both put some constraints on the code here.</p> -- Todo: check if we copy attributes to disc nodes if needed. -- -- Todo: it would be nice if we could get rid of components. In other places we can use --- the unicode properties. +-- the unicode properties. We can just keep a lua table. -- -- Remark: We do some disc juggling where we need to keep in mind that the pre, post and -- replace fields can have prev pointers to a nesting node ... I wonder if that is still @@ -213,13 +213,6 @@ local find_node_tail = nuts.tail local flush_node_list = nuts.flush_list local flush_node = nuts.flush_node local end_of_math = nuts.end_of_math ------ traverse_nodes = nuts.traverse ------ traverse_id = nuts.traverse_id -local set_components = nuts.set_components -local take_components = nuts.take_components -local count_components = nuts.count_components -local copy_no_components = nuts.copy_no_components -local copy_only_glyphs = nuts.copy_only_glyphs local setmetatable = setmetatable local setmetatableindex = table.setmetatableindex @@ -458,26 +451,50 @@ end -- start is a mark and we need to keep that one -local take_components = getcomponents -- we overload here (for now) -local set_components = setcomponents -- we overload here (for now) ------ get_components = getcomponents -- we overload here (for now) +local copy_no_components = nuts.copy_no_components +local copy_only_glyphs = nuts.copy_only_glyphs + +local set_components = setcomponents +local take_components = getcomponents + +local isglyph = nuts.isglyph + +-- local function count_components(start,marks) +-- print("!") +-- if getid(start) ~= glyph_code then +-- return 0 +-- elseif getsubtype(start) == ligatureglyph_code then +-- local i = 0 +-- local components = getcomponents(start) +-- while components do +-- i = i + count_components(components,marks) +-- components = getnext(components) +-- end +-- return i +-- elseif not marks[getchar(start)] then +-- print("YES") +-- return 1 +-- else +-- return 0 +-- end +-- end local function count_components(start,marks) - if getid(start) ~= glyph_code then - return 0 - elseif getsubtype(start) == ligatureglyph_code then - local i = 0 - local components = getcomponents(start) - while components do - i = i + count_components(components,marks) - components = getnext(components) + local char = isglyph(start) + if char then + if getsubtype(start) == ligatureglyph_code then + local i = 0 + local components = getcomponents(start) + while components do + i = i + count_components(components,marks) + components = getnext(components) + end + return i + elseif not marks[char] then + return 1 end - return i - elseif not marks[getchar(start)] then - return 1 - else - return 0 end + return 0 end local function markstoligature(head,start,stop,char) @@ -3645,14 +3662,11 @@ local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,datase end end --- to be checked, nowadays we probably can assume properly matched directions --- so maybe we no longer need a stack - local txtdirstate, pardirstate do local getdirection = nuts.getdirection local lefttoright = 0 - local rightoleft = 1 + local righttoleft = 1 txtdirstate = function(start,stack,top,rlparmode) local nxt = getnext(start) @@ -3670,11 +3684,11 @@ local txtdirstate, pardirstate do end elseif dir == lefttoright then top = top + 1 - stack[top] = 0 + stack[top] = lefttoright return nxt, top, 1 elseif dir == righttoleft then top = top + 1 - stack[top] = 1 + stack[top] = righttoleft return nxt, top, -1 else return nxt, top, rlparmode @@ -3686,13 +3700,12 @@ local txtdirstate, pardirstate do local dir = getdirection(start) if dir == lefttoright then return nxt, 1, 1 - end - if dir == righttoleft then + elseif dir == righttoleft then return nxt, -1, -1 -- for old times sake we we handle strings too - elseif dir == "TRT" then - return nxt, 1, 1 elseif dir == "TLT" then + return nxt, 1, 1 + elseif dir == "TRT" then return nxt, -1, -1 else return nxt, 0, 0 diff --git a/tex/context/base/mkiv/lang-hyp.lua b/tex/context/base/mkiv/lang-hyp.lua index 15d4ca458..1684c0dac 100644 --- a/tex/context/base/mkiv/lang-hyp.lua +++ b/tex/context/base/mkiv/lang-hyp.lua @@ -1610,16 +1610,25 @@ featureset.hyphenonly = hyphenonly == v_yes -- local replaceaction = nodes.tasks.replaceaction -- no longer overload this way (too many local switches) - local hyphenate = lang.hyphenate - local methods = { } - local usedmethod = false - local stack = { } + local hyphenate = lang.hyphenate + local has_language = lang.has_language + local methods = { } + local usedmethod = false + local stack = { } - local function original(head) + local function original(head) -- kernel.hyphenation(head) hyphenate(tonode(head)) return head end + -- local function original(head) -- kernel.hyphenation(head) + -- local h = tonode(head) + -- if has_language(h) then + -- hyphenate(h) + -- end + -- return head + -- end + local getcount = tex.getcount hyphenators.methods = methods diff --git a/tex/context/base/mkiv/math-tag.lua b/tex/context/base/mkiv/math-tag.lua index 97495002a..72de3e660 100644 --- a/tex/context/base/mkiv/math-tag.lua +++ b/tex/context/base/mkiv/math-tag.lua @@ -31,9 +31,11 @@ local getsubtype = nuts.getsubtype local getattr = nuts.getattr local getattrlist = nuts.getattrlist local setattr = nuts.setattr -local getcomponents = nuts.getcomponents +local getcomponents = nuts.getcomponents -- not really needed local getwidth = nuts.getwidth +local isglyph = nuts.isglyph + local getnucleus = nuts.getnucleus local getsub = nuts.getsub local getsup = nuts.getsup @@ -156,12 +158,18 @@ local fencesstack = { } -- glyph nodes and such can happen in under and over stuff +-- local function getunicode(n) -- instead of getchar +-- local char = getchar(n) +-- -- local font = font_of_family(getfield(n,"fam")) -- font_of_family +-- local font = getfont(n) +-- local data = fontcharacters[font][char] +-- return data.unicode or char +-- end + local function getunicode(n) -- instead of getchar - local char = getchar(n) - -- local font = font_of_family(getfield(n,"fam")) -- font_of_family - local font = getfont(n) + local char, font = isglyph(n) local data = fontcharacters[font][char] - return data.unicode or char + return data.unicode or char -- can be a table but unlikely for math characters end ------------------- @@ -197,7 +205,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer local mtexttag = nil while start do local id = getid(start) --- showtag(start,id,true) + -- showtag(start,id,true) if id == glyph_code or id == disc_code then if not mtexttag then mtexttag = start_tagged("mtext") @@ -234,7 +242,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer setattr(start,a_tagged,start_tagged(tag)) -- todo: a_mathcategory end stop_tagged() --- showtag(start,id,false) + -- showtag(start,id,false) break -- okay? elseif id == mathtextchar_code then -- or id == glyph_code -- check for code @@ -245,18 +253,18 @@ process = function(start) -- we cannot use the processor as we have no finalizer setattr(start,a_tagged,start_tagged("ms")) -- mtext end stop_tagged() --- showtag(start,id,false) + -- showtag(start,id,false) break elseif id == delim_code then -- check for code setattr(start,a_tagged,start_tagged("mo")) stop_tagged() --- showtag(start,id,false) + -- showtag(start,id,false) break elseif id == style_code then -- has a next elseif id == noad_code then --- setattr(start,a_tagged,tags.current()) + -- setattr(start,a_tagged,tags.current()) processsubsup(start) elseif id == dubbox_code or id == hlist_code or id == vlist_code then -- keep an eye on subbox_code and see what ends up in there @@ -335,12 +343,21 @@ process = function(start) -- we cannot use the processor as we have no finalizer runner(getlist(n),depth+1) elseif id == glyph_code then -- this should not be needed (todo: use tounicode info) - runner(getcomponents(n),depth+1) + local components = getcomponents(n) + if components then + runner(getcomponent,depth+1) + end elseif id == disc_code then local pre, post, replace = getdisc(n) - runner(pre,depth+1) -- idem - runner(post,depth+1) -- idem - runner(replace,depth+1) -- idem + if pre then + runner(pre,depth+1) -- idem + end + if post then + runner(post,depth+1) -- idem + end + if replace then + runner(replace,depth+1) -- idem + end end if mth == 1 then stop_tagged() @@ -382,7 +399,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer end elseif tag == "mstacker" then -- or tag == "mstackertop" or tag == "mstackermid" or tag == "mstackerbot" then -- looks like it gets processed twice --- do we still end up here ? + -- do we still end up here ? setattr(start,a_tagged,restart_tagged(attr)) -- so we just reuse the attribute process(list) stop_tagged() diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index 874492d68..f6b142d46 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -915,6 +915,8 @@ local function splitprescript(script) return hash end +metapost.splitprescript = splitprescript + -- -- not used: -- -- local function splitpostscript(script) diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index bc6c50fb2..6cdbc61d7 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -448,7 +448,8 @@ return { -- "nospace", "nospacing", "dospacing", -- - "naturalhbox", "naturalvbox", "naturalvtop", "naturalhpack", "naturalvpack", + "naturalhbox", "naturalvbox", "naturalvtop", "naturalhpack", "naturalvpack", "naturaltpack", + "reversehbox", "reversevbox", "reversevtop", "reversehpack", "reversevpack", "reversetpack", -- "frule", -- diff --git a/tex/context/base/mkiv/node-aux.lua b/tex/context/base/mkiv/node-aux.lua index cdd3403ac..cb969bc1d 100644 --- a/tex/context/base/mkiv/node-aux.lua +++ b/tex/context/base/mkiv/node-aux.lua @@ -488,87 +488,6 @@ end -- end -- end --- these component helpers might move to another module - --- nodemode helper: here we also flatten components, no check for disc here - -function nuts.set_components(target,start,stop) - local head = getcomponents(target) - if head then - flush_list(head) - head = nil - end - if start then - setprev(start) - else - return nil - end - if stop then - setnext(stop) - end - local tail = nil - while start do - local c = getcomponents(start) - local n = getnext(start) - if c then - if head then - setlink(tail,c) - else - head = c - end - tail = find_tail(c) - setcomponents(start) - flush_node(start) - else - if head then - setlink(tail,start) - else - head = start - end - tail = start - end - start = n - end - setcomponents(target,head) - -- maybe also upgrade the subtype but we don't use it anyway - return head -end - -function nuts.get_components(target) - return getcomponents(target) -end - -nuts.get_components = getcomponents - -function nuts.take_components(target) - local c = getcomponents(target) - setcomponents(target) - -- maybe also upgrade the subtype but we don't use it anyway - return c -end - --- nodemode helper: we assume a glyph and a flat components list (basemode can --- have nested components) - -function nuts.count_components(n,marks) - local components = getcomponents(n) - if components then - if marks then - local i = 0 - for g in nextglyph, components do - if not marks[getchar(g)] then - i = i + 1 - end - end - return i - else - return count(glyph_code,components) - end - else - return 0 - end -end - -- nodemode helper: the next and prev pointers are untouched function nuts.copy_no_components(g,copyinjection) diff --git a/tex/context/base/mkiv/node-fin.lua b/tex/context/base/mkiv/node-fin.lua index 03f0d83bb..f75c948c5 100644 --- a/tex/context/base/mkiv/node-fin.lua +++ b/tex/context/base/mkiv/node-fin.lua @@ -24,7 +24,7 @@ local getleader = nuts.getleader local getattr = nuts.getattr local getwidth = nuts.getwidth local getwhd = nuts.getwhd -local gettransform = nuts.gettransform +local getorientation = nuts.getorientation local setlist = nuts.setlist local setleader = nuts.setleader @@ -194,7 +194,7 @@ local function process(attribute,head,inheritance,default) -- one attribute if content then -- tricky checking local outer - if gettransform(stack) then + if getorientation(stack) then outer = getattr(stack,attribute) if outer then if default and outer == inheritance then @@ -321,7 +321,7 @@ local function selective(attribute,head,inheritance,default) -- two attributes if content then -- tricky checking local outer - if gettransform(stack) then + if getorientation(stack) then outer = getattr(stack,attribute) if outer then if default and outer == inheritance then diff --git a/tex/context/base/mkiv/node-ltp.lua b/tex/context/base/mkiv/node-ltp.lua index 97eb62ea2..6279fac82 100644 --- a/tex/context/base/mkiv/node-ltp.lua +++ b/tex/context/base/mkiv/node-ltp.lua @@ -253,7 +253,6 @@ local getattr = nuts.getattr local getdisc = nuts.getdisc local getglue = nuts.getglue local getwhd = nuts.getwhd -local getcomponents = nuts.getcomponents local getkern = nuts.getkern local getpenalty = nuts.getpenalty local getdirection = nuts.getdirection @@ -280,8 +279,6 @@ local setkern = nuts.setkern local setdirection = nuts.setdirection local setshift = nuts.setshift local setwidth = nuts.setwidth ------ setheight = nuts.setheight ------ setdepth = nuts.setdepth local setexpansion = nuts.setexpansion local slide_node_list = nuts.slide -- get rid of this, probably ok > 78.2 @@ -2575,16 +2572,18 @@ do while a do local char, id = isglyph(a) if char then - local font = getfont(a) - if font ~= font_in_short_display then - write(target,tex.fontidentifier(font) .. ' ') - font_in_short_display = font + if id ~= font_in_short_display then + write(target,tex.fontidentifier(id) .. ' ') + font_in_short_display = id end - -- todo: instead of components the split tounicode string - if getsubtype(a) == ligatureglyph_code then - font_in_short_display = short_display(target,getcomponents(a),font_in_short_display) + local u = chardata[id][char] + local u = u.unicode or char + if type(u) == "table" then + for i=1,#u do + write(target,utfchar(u[i])) + end else - write(target,utfchar(char)) + write(target,utfchar(u)) end elseif id == disc_code then local pre, post, replace = getdisc(a) diff --git a/tex/context/base/mkiv/node-nut.lua b/tex/context/base/mkiv/node-nut.lua index 867d79a65..54de799da 100644 --- a/tex/context/base/mkiv/node-nut.lua +++ b/tex/context/base/mkiv/node-nut.lua @@ -257,8 +257,8 @@ nuts.getdepth = direct.getdepth nuts.setdepth = direct.setdepth nuts.getshift = direct.getshift nuts.setshift = direct.setshift -nuts.gettransform = direct.gettransform or function() end -nuts.settransform = direct.settransform or function() end +nuts.getorientation = direct.getorientation or function() end +nuts.setorientation = direct.setorientation or function() end nuts.getnucleus = direct.getnucleus nuts.setnucleus = direct.setnucleus diff --git a/tex/context/base/mkiv/node-tra.lua b/tex/context/base/mkiv/node-tra.lua index 7c2a93af0..01616c2e4 100644 --- a/tex/context/base/mkiv/node-tra.lua +++ b/tex/context/base/mkiv/node-tra.lua @@ -21,69 +21,68 @@ local report_nodes = logs.reporter("nodes","tracing") local nodes, node, context = nodes, node, context -local texgetattribute = tex.getattribute - -local tracers = nodes.tracers or { } -nodes.tracers = tracers - -local tasks = nodes.tasks or { } -nodes.tasks = tasks - -local handlers = nodes.handlers or {} -nodes.handlers = handlers - -local injections = nodes.injections or { } -nodes.injections = injections - -local nuts = nodes.nuts -local tonut = nuts.tonut -local tonode = nuts.tonode - -local getnext = nuts.getnext -local getprev = nuts.getprev -local getid = nuts.getid -local getchar = nuts.getchar -local getsubtype = nuts.getsubtype -local getlist = nuts.getlist -local getdisc = nuts.getdisc -local setattr = nuts.setattr -local getglue = nuts.getglue -local isglyph = nuts.isglyph -local getcomponents = nuts.getcomponents -local getdirection = nuts.getdirection -local getwidth = nuts.getwidth - -local flush_list = nuts.flush_list -local count_nodes = nuts.countall -local used_nodes = nuts.usedlist - -local nextnode = nuts.traversers.node -local nextglyph = nuts.traversers.glyph - -local d_tostring = nuts.tostring - -local nutpool = nuts.pool -local new_rule = nutpool.rule - -local nodecodes = nodes.nodecodes -local whatsitcodes = nodes.whatsitcodes -local fillcodes = nodes.fillcodes - -local subtypes = nodes.subtypes - -local glyph_code = nodecodes.glyph -local hlist_code = nodecodes.hlist -local vlist_code = nodecodes.vlist -local disc_code = nodecodes.disc -local glue_code = nodecodes.glue -local kern_code = nodecodes.kern -local rule_code = nodecodes.rule -local dir_code = nodecodes.dir -local localpar_code = nodecodes.localpar -local whatsit_code = nodecodes.whatsit - -local dimenfactors = number.dimenfactors -local formatters = string.formatters +local texgetattribute = tex.getattribute + +local tracers = nodes.tracers or { } +nodes.tracers = tracers + +local tasks = nodes.tasks or { } +nodes.tasks = tasks + +local handlers = nodes.handlers or {} +nodes.handlers = handlers + +local injections = nodes.injections or { } +nodes.injections = injections + +local nuts = nodes.nuts +local tonut = nuts.tonut +local tonode = nuts.tonode + +local getnext = nuts.getnext +local getprev = nuts.getprev +local getid = nuts.getid +local getchar = nuts.getchar +local getsubtype = nuts.getsubtype +local getlist = nuts.getlist +local getdisc = nuts.getdisc +local setattr = nuts.setattr +local getglue = nuts.getglue +local isglyph = nuts.isglyph +local getdirection = nuts.getdirection +local getwidth = nuts.getwidth + +local flush_list = nuts.flush_list +local count_nodes = nuts.countall +local used_nodes = nuts.usedlist + +local nextnode = nuts.traversers.node +local nextglyph = nuts.traversers.glyph + +local d_tostring = nuts.tostring + +local nutpool = nuts.pool +local new_rule = nutpool.rule + +local nodecodes = nodes.nodecodes +local whatsitcodes = nodes.whatsitcodes +local fillcodes = nodes.fillcodes + +local subtypes = nodes.subtypes + +local glyph_code = nodecodes.glyph +local hlist_code = nodecodes.hlist +local vlist_code = nodecodes.vlist +local disc_code = nodecodes.disc +local glue_code = nodecodes.glue +local kern_code = nodecodes.kern +local rule_code = nodecodes.rule +local dir_code = nodecodes.dir +local localpar_code = nodecodes.localpar +local whatsit_code = nodecodes.whatsit + +local dimenfactors = number.dimenfactors +local formatters = string.formatters -- this will be reorganized: @@ -128,44 +127,51 @@ function nodes.handlers.checkforleaks(sparse) end end +local fontcharacters -- = fonts.hashes.descriptions + local function tosequence(start,stop,compact) if start then + if not fontcharacters then + fontcharacters = fonts.hashes.descriptions + if not fontcharacters then + return "[no char data]" + end + end local f_sequence = formatters["U+%04X:%s"] local f_subrange = formatters["[[ %s ][ %s ][ %s ]]"] start = tonut(start) stop = stop and tonut(stop) local t = { } + local n = 0 while start do local c, id = isglyph(start) if c then - if compact then - local components = getcomponents(start) - if components then - t[#t+1] = tosequence(components,nil,compact) - else - t[#t+1] = utfchar(c) + local u = fontcharacters[id][c] -- id == font id + u = u and u.unicode or c + if type(u) == "table" then + local tt = { } + for i=1,#u do + local c = u[i] + tt[i] = compact and utfchar(c) or f_sequence(c,utfchar(c)) end + n = n + 1 ; t[n] = "(" .. concat(tt," ") .. ")" else - t[#t+1] = f_sequence(c,utfchar(c)) + n = n + 1 ; t[n] = compact and utfchar(c) or f_sequence(c,utfchar(c)) end elseif id == disc_code then local pre, post, replace = getdisc(start) t[#t+1] = f_subrange(pre and tosequence(pre),post and tosequence(post),replace and tosequence(replace)) elseif id == rule_code then - if compact then - t[#t+1] = "|" - else - t[#t+1] = nodecodes[id] - end + n = n + 1 ; t[n] = compact and "|" or nodecodes[id] or "?" elseif id == dir_code then local d, p = getdirection(start) - t[#t+1] = "[<" .. (p and "-" or "+") .. d .. ">]" -- todo l2r etc + n = n + 1 ; t[n] = "[<" .. (p and "-" or "+") .. d .. ">]" -- todo l2r etc elseif id == localpar_code then - t[#t+1] = "[<" .. getdirection(start) .. ">]" -- todo l2r etc + n = n + 1 ; t[n] = "[<" .. getdirection(start) .. ">]" -- todo l2r etc elseif compact then - t[#t+1] = "[]" + n = n + 1 ; t[n] = "[]" else - t[#t+1] = nodecodes[id] + n = n + 1 ; t[n] = nodecodes[id] end if start == stop then break diff --git a/tex/context/base/mkiv/page-mul.mkiv b/tex/context/base/mkiv/page-mul.mkiv index 69771bf78..ad9f75871 100644 --- a/tex/context/base/mkiv/page-mul.mkiv +++ b/tex/context/base/mkiv/page-mul.mkiv @@ -480,7 +480,7 @@ \page_mul_calculate_column_result_dimensions \overlaycolumnfootnotes \setbox\columnpagebox\vpack % \vbox - {\hpack \ifconditional\c_page_mul_reverse bdir \plusone \fi to \makeupwidth + {\ifconditional\c_page_mul_reverse\reversehpack\else\naturalhpack\fi to \makeupwidth {\hskip\ifconditional\c_page_mul_reverse\d_page_mul_rightskip\else\d_page_mul_leftskip\fi\relax \dohandleallcolumns {\finishcolumnbox diff --git a/tex/context/base/mkiv/spac-ali.mkiv b/tex/context/base/mkiv/spac-ali.mkiv index 7e3b24197..cc56f4069 100644 --- a/tex/context/base/mkiv/spac-ali.mkiv +++ b/tex/context/base/mkiv/spac-ali.mkiv @@ -67,15 +67,12 @@ \chardef\directionlefttoright\zerocount \chardef\directionrighttoleft\plusone -\unexpanded\def\syst_fatal_dir_error#1% - {\writestatus{fatal error}{\string#1\space is forbidden}% - \wait} - -\def\pagedir {\syst_fatal_dir_error\pagedir} \let\normalpagedir\pagedir -\def\bodydir {\syst_fatal_dir_error\bodydir} \let\normalbodydir\bodydir - -\def\pagedirection{\syst_fatal_dir_error\pagedirection} \let\normalpagedirection\pagedirection -\def\bodydirection{\syst_fatal_dir_error\bodydirection} \let\normalbodydirection\bodydirection +\ifdefined\pagedir + \let\pagedir \undefined \let\normalpagedir \undefined + \let\bodydir \undefined \let\normalbodydir \undefined + \let\pagedirection\undefined \let\normalpagedirection\undefined + \let\bodydirection\undefined \let\normalbodydirection\undefined +\fi % This will become a more advanced layout controller soon: @@ -185,12 +182,12 @@ inline: \ifconditional\inlinelefttoright l2r\else r2l\fi\space ]\endgroup} -\unexpanded\def\righttolefthbox#1#{\hbox bdir\plusone #1\bgroup\righttoleft\let\next} \let\rtlhbox\righttolefthbox -\unexpanded\def\lefttorighthbox#1#{\hbox bdir\zerocount#1\bgroup\lefttoright\let\next} \let\ltrhbox\lefttorighthbox -\unexpanded\def\righttoleftvbox#1#{\vbox bdir\plusone #1\bgroup\righttoleft\let\next} \let\rtlvbox\righttoleftvbox -\unexpanded\def\lefttorightvbox#1#{\vbox bdir\zerocount#1\bgroup\lefttoright\let\next} \let\ltrvbox\lefttorightvbox -\unexpanded\def\righttoleftvtop#1#{\vtop bdir\plusone #1\bgroup\righttoleft\let\next} \let\rtlvtop\righttoleftvtop -\unexpanded\def\lefttorightvtop#1#{\vtop bdir\zerocount#1\bgroup\lefttoright\let\next} \let\ltrvtop\lefttorightvtop +\unexpanded\def\righttolefthbox#1#{\reversehbox#1\bgroup\righttoleft\let\next} \let\rtlhbox\righttolefthbox +\unexpanded\def\lefttorighthbox#1#{\naturalhbox#1\bgroup\lefttoright\let\next} \let\ltrhbox\lefttorighthbox +\unexpanded\def\righttoleftvbox#1#{\reversevbox#1\bgroup\righttoleft\let\next} \let\rtlvbox\righttoleftvbox +\unexpanded\def\lefttorightvbox#1#{\naturalvbox#1\bgroup\lefttoright\let\next} \let\ltrvbox\lefttorightvbox +\unexpanded\def\righttoleftvtop#1#{\reversevtop#1\bgroup\righttoleft\let\next} \let\rtlvtop\righttoleftvtop +\unexpanded\def\lefttorightvtop#1#{\naturalvtop#1\bgroup\lefttoright\let\next} \let\ltrvtop\lefttorightvtop \unexpanded\def\autodirhbox#1#{\hbox#1\bgroup\synchronizeinlinedirection\let\next} \unexpanded\def\autodirvbox#1#{\vbox#1\bgroup\synchronizeinlinedirection\let\next} % maybe also pardir or maybe just a \vbox diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 9d01c3a8a..138c84361 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 ae17faf97..5609dc05a 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv index a74aeab2e..d3c74f725 100644 --- a/tex/context/base/mkiv/supp-box.mkiv +++ b/tex/context/base/mkiv/supp-box.mkiv @@ -2770,12 +2770,41 @@ %D And even rawer: - \let\naturalvtop \normalvtop - \let\naturalvcenter\normalvtop -\unexpanded\def\naturalhbox {\hbox bdir\directionlefttoright} -\unexpanded\def\naturalvbox {\vbox bdir\directionlefttoright} -\unexpanded\def\naturalhpack {\hpack bdir\directionlefttoright} -\unexpanded\def\naturalvpack {\vpack bdir\directionlefttoright} + \let\naturalvcenter\normalvtop % will go away + +\ifdefined\bodydir + + \unexpanded\def\naturalhbox {\hbox bdir\directionlefttoright} + \unexpanded\def\naturalvbox {\vbox bdir\directionlefttoright} + \unexpanded\def\naturalvtop {\vtop bdir\directionlefttoright} + \unexpanded\def\naturalhpack {\hpack bdir\directionlefttoright} + \unexpanded\def\naturalvpack {\vpack bdir\directionlefttoright} + \unexpanded\def\naturaltpack {\tpack bdir\directionlefttoright} + + \unexpanded\def\reversehbox {\hbox bdir\directionrighttoleft} + \unexpanded\def\reversevbox {\vbox bdir\directionrighttoleft} + \unexpanded\def\reversevtop {\vtop bdir\directionrighttoleft} + \unexpanded\def\reversehpack {\hpack bdir\directionrighttoleft} + \unexpanded\def\reversevpack {\vpack bdir\directionrighttoleft} + \unexpanded\def\reversetpack {\tpack bdir\directionrighttoleft} + +\else + + \unexpanded\def\naturalhbox {\hbox direction\directionlefttoright} + \unexpanded\def\naturalvbox {\vbox direction\directionlefttoright} + \unexpanded\def\naturalvtop {\vtop direction\directionlefttoright} + \unexpanded\def\naturalhpack {\hpack direction\directionlefttoright} + \unexpanded\def\naturalvpack {\vpack direction\directionlefttoright} + \unexpanded\def\naturaltpack {\tpack direction\directionlefttoright} + + \unexpanded\def\reversehbox {\hbox direction\directionrighttoleft} + \unexpanded\def\reversevbox {\vbox direction\directionrighttoleft} + \unexpanded\def\reversevtop {\vtop direction\directionrighttoleft} + \unexpanded\def\reversehpack {\hpack direction\directionrighttoleft} + \unexpanded\def\reversevpack {\vpack direction\directionrighttoleft} + \unexpanded\def\reversetpack {\tpack direction\directionrighttoleft} + +\fi %D \macros %D {vcenter} diff --git a/tex/context/base/mkiv/supp-dir.mkiv b/tex/context/base/mkiv/supp-dir.mkiv index 073d32aa7..3447a83a3 100644 --- a/tex/context/base/mkiv/supp-dir.mkiv +++ b/tex/context/base/mkiv/supp-dir.mkiv @@ -11,33 +11,15 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D We no longer have the \ETEX\ direction primitives. - \unprotect -% \expanded{\defineactivecharacter \number"2000E} {\textdir TRT\relax} -% \expanded{\defineactivecharacter \number"2000F} {\textdir TLT\relax} - -%D As we have less directions now we can use something +% \expanded{\defineactivecharacter \number"2000E} {\textdirection TRT\relax} +% \expanded{\defineactivecharacter \number"2000F} {\textdirection TLT\relax} -% \chardef\@@D@@TLT0 -% \chardef\@@D@@TRT1 -% \chardef\@@D@@RTT0 -% \chardef\@@D@@LRL1 -% -% \def\thetextdir{\csname @@D@@\the\textdir\endcsname} -% -% \ifnum\thetextdir=0 L\else R\fi \textdir TRT \ifnum\thetextdir=0 L\else R\fi +\def\syst_direction_string#1{\ifcase#1=\plusone r2l\else l2r\fi} \unexpanded\def\showdirsinmargin - {\inleft{\normalexpanded{\noexpand\hbox bdir\directionlefttoright{\ttxx[\the\pardir,\the\textdir]}}}} - -% this will become: - -% \def\syst_direction_string#1{\ifnum#1=\plusone r2l\else l2r\fi} -% -% \unexpanded\def\showdirsinmargin -% {\inleft{\normalexpanded{\noexpand\hbox bdir\directionlefttoright -% {\ttxx[\syst_direction_string\pardirection,\syst_direction_string\textdirection]}}}} + {\normalexpanded{\inleft{\naturalhbox + {\ttxx[\syst_direction_string\pardirection,\syst_direction_string\textdirection]}}}} \protect \endinput diff --git a/tex/context/base/mkiv/syst-aux.mkiv b/tex/context/base/mkiv/syst-aux.mkiv index 9c959a105..63def7f7a 100644 --- a/tex/context/base/mkiv/syst-aux.mkiv +++ b/tex/context/base/mkiv/syst-aux.mkiv @@ -7891,6 +7891,12 @@ \unexpanded\def\signalcharacter{\char\zerocount} % \zwj +% \unexpanded\def\signalcharacter +% {\scratchcounter\normallanguage +% \normallanguage\zerocount +% \char\zerocount +% \normallanguage\scratchcounter} + %D A few secial variants of commands defined here. Some more will be moved here (e.g. %D from table modules. diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 36541a927..4d99b4f4d 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 0127ead24..f4672bd0c 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-basics-nod.lua b/tex/generic/context/luatex/luatex-basics-nod.lua index c3b467a11..53414a009 100644 --- a/tex/generic/context/luatex/luatex-basics-nod.lua +++ b/tex/generic/context/luatex/luatex-basics-nod.lua @@ -62,7 +62,7 @@ end for k, v in next, glyphcodes do glyphcodes[v] = k end -for k, v in next, glyphcodes do +for k, v in next, disccodes do disccodes[v] = k end @@ -77,17 +77,6 @@ local traverse_id = node.traverse_id nodes.handlers.protectglyphs = node.protect_glyphs -- beware: nodes! nodes.handlers.unprotectglyphs = node.unprotect_glyphs -- beware: nodes! -local math_code = nodecodes.math -local end_of_math = node.end_of_math - -function node.end_of_math(n) - if n.id == math_code and n.subtype == 1 then - return n - else - return end_of_math(n) - end -end - function nodes.remove(head, current, free_too) local t = current head, current = remove_node(head,current) @@ -190,7 +179,7 @@ nuts.setprev = direct.setprev nuts.getboth = direct.getboth nuts.setboth = direct.setboth nuts.getid = direct.getid -nuts.getattr = direct.get_attribute or direct.has_attribute or getfield +nuts.getattr = direct.get_attribute nuts.setattr = setfield nuts.getfont = direct.getfont nuts.setfont = direct.setfont @@ -204,64 +193,8 @@ nuts.setlink = direct.setlink nuts.setsplit = direct.setsplit nuts.getlist = direct.getlist nuts.setlist = direct.setlist - -nuts.getoffsets = direct.getoffsets or - function(n) - return getfield(n,"xoffset"), getfield(n,"yoffset") - end -nuts.setoffsets = direct.setoffsets or - function(n,x,y) - if x then setfield(n,"xoffset",x) end - if y then setfield(n,"xoffset",y) end - end - -nuts.getleader = direct.getleader or function(n) return getfield(n,"leader") end -nuts.setleader = direct.setleader or function(n,l) setfield(n,"leader",l) end -nuts.getcomponents = direct.getcomponents or function(n) return getfield(n,"components") end -nuts.setcomponents = direct.setcomponents or function(n,c) setfield(n,"components",c) end -nuts.getkern = direct.getkern or function(n) return getfield(n,"kern") end -nuts.setkern = direct.setkern or function(n,k) setfield(n,"kern",k) end -nuts.getdir = direct.getdir or function(n) return getfield(n,"dir") end -nuts.setdir = direct.setdir or function(n,d) setfield(n,"dir",d) end -nuts.getwidth = direct.getwidth or function(n) return getfield(n,"width") end -nuts.setwidth = direct.setwidth or function(n,w) return setfield(n,"width",w) end -nuts.getheight = direct.getheight or function(n) return getfield(n,"height") end -nuts.setheight = direct.setheight or function(n,h) return setfield(n,"height",h) end -nuts.getdepth = direct.getdepth or function(n) return getfield(n,"depth") end -nuts.setdepth = direct.setdepth or function(n,d) return setfield(n,"depth",d) end - -if not direct.is_glyph then - local getchar = direct.getchar - local getid = direct.getid - local getfont = direct.getfont - local glyph_code = nodes.nodecodes.glyph - function direct.is_glyph(n,f) - local id = getid(n) - if id == glyph_code then - if f and getfont(n) == f then - return getchar(n) - else - return false - end - else - return nil, id - end - end - function direct.is_char(n,f) - local id = getid(n) - if id == glyph_code then - if getsubtype(n) >= 256 then - return false - elseif f and getfont(n) == f then - return getchar(n) - else - return false - end - else - return nil, id - end - end -end +nuts.getoffsets = direct.getoffsets +nuts.setoffsets = direct.setoffsets nuts.ischar = direct.is_char nuts.is_char = direct.is_char @@ -343,76 +276,6 @@ local copy_node = nuts.copy_node local glyph_code = nodes.nodecodes.glyph -function nuts.set_components(target,start,stop) - local head = getcomponents(target) - if head then - flush_list(head) - head = nil - end - if start then - setprev(start) - else - return nil - end - if stop then - setnext(stop) - end - local tail = nil - while start do - local c = getcomponents(start) - local n = getnext(start) - if c then - if head then - setlink(tail,c) - else - head = c - end - tail = find_tail(c) - setcomponents(start) - flush_node(start) - else - if head then - setlink(tail,start) - else - head = start - end - tail = start - end - start = n - end - setcomponents(target,head) - -- maybe also upgrade the subtype but we don't use it anyway - return head -end - -nuts.get_components = nuts.getcomponents - -function nuts.take_components(target) - local c = getcomponents(target) - setcomponents(target) - -- maybe also upgrade the subtype but we don't use it anyway - return c -end - -function nuts.count_components(n,marks) - local components = getcomponents(n) - if components then - if marks then - local i = 0 - for g in traverse_id(glyph_code,components) do - if not marks[getchar(g)] then - i = i + 1 - end - end - return i - else - return count(glyph_code,components) - end - else - return 0 - end -end - function nuts.copy_no_components(g,copyinjection) local components = getcomponents(g) if components then @@ -450,38 +313,6 @@ end nuts.uses_font = direct.uses_font -if not nuts.uses_font then - local getdisc = nuts.getdisc - local getfont = nuts.getfont - function nuts.uses_font(n,font) - local pre, post, replace = getdisc(n) - if pre then - -- traverse_char - for n in traverse_id(glyph_code,pre) do - if getfont(n) == font then - return true - end - end - end - if post then - for n in traverse_id(glyph_code,post) do - if getfont(n) == font then - return true - end - end - end - if replace then - for n in traverse_id(glyph_code,replace) do - if getfont(n) == font then - return true - end - end - end - return false - end -end - --- do -- another poor mans substitute ... i will move these to a more protected diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index b3afbafa1..9ae2c4882 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 : 12/28/18 11:01:18 +-- merge date : 12/30/18 19:28:22 do -- begin closure to overcome local limits and interference @@ -4748,7 +4748,7 @@ end for k,v in next,glyphcodes do glyphcodes[v]=k end -for k,v in next,glyphcodes do +for k,v in next,disccodes do disccodes[v]=k end nodes.nodecodes=nodecodes @@ -4759,15 +4759,6 @@ local remove_node=node.remove local traverse_id=node.traverse_id nodes.handlers.protectglyphs=node.protect_glyphs nodes.handlers.unprotectglyphs=node.unprotect_glyphs -local math_code=nodecodes.math -local end_of_math=node.end_of_math -function node.end_of_math(n) - if n.id==math_code and n.subtype==1 then - return n - else - return end_of_math(n) - end -end function nodes.remove(head,current,free_too) local t=current head,current=remove_node(head,current) @@ -4844,7 +4835,7 @@ nuts.setprev=direct.setprev nuts.getboth=direct.getboth nuts.setboth=direct.setboth nuts.getid=direct.getid -nuts.getattr=direct.get_attribute or direct.has_attribute or getfield +nuts.getattr=direct.get_attribute nuts.setattr=setfield nuts.getfont=direct.getfont nuts.setfont=direct.setfont @@ -4858,61 +4849,8 @@ nuts.setlink=direct.setlink nuts.setsplit=direct.setsplit nuts.getlist=direct.getlist nuts.setlist=direct.setlist -nuts.getoffsets=direct.getoffsets or - function(n) - return getfield(n,"xoffset"),getfield(n,"yoffset") - end -nuts.setoffsets=direct.setoffsets or - function(n,x,y) - if x then setfield(n,"xoffset",x) end - if y then setfield(n,"xoffset",y) end - end -nuts.getleader=direct.getleader or function(n) return getfield(n,"leader") end -nuts.setleader=direct.setleader or function(n,l) setfield(n,"leader",l) end -nuts.getcomponents=direct.getcomponents or function(n) return getfield(n,"components") end -nuts.setcomponents=direct.setcomponents or function(n,c) setfield(n,"components",c) end -nuts.getkern=direct.getkern or function(n) return getfield(n,"kern") end -nuts.setkern=direct.setkern or function(n,k) setfield(n,"kern",k) end -nuts.getdir=direct.getdir or function(n) return getfield(n,"dir") end -nuts.setdir=direct.setdir or function(n,d) setfield(n,"dir",d) end -nuts.getwidth=direct.getwidth or function(n) return getfield(n,"width") end -nuts.setwidth=direct.setwidth or function(n,w) return setfield(n,"width",w) end -nuts.getheight=direct.getheight or function(n) return getfield(n,"height") end -nuts.setheight=direct.setheight or function(n,h) return setfield(n,"height",h) end -nuts.getdepth=direct.getdepth or function(n) return getfield(n,"depth") end -nuts.setdepth=direct.setdepth or function(n,d) return setfield(n,"depth",d) end -if not direct.is_glyph then - local getchar=direct.getchar - local getid=direct.getid - local getfont=direct.getfont - local glyph_code=nodes.nodecodes.glyph - function direct.is_glyph(n,f) - local id=getid(n) - if id==glyph_code then - if f and getfont(n)==f then - return getchar(n) - else - return false - end - else - return nil,id - end - end - function direct.is_char(n,f) - local id=getid(n) - if id==glyph_code then - if getsubtype(n)>=256 then - return false - elseif f and getfont(n)==f then - return getchar(n) - else - return false - end - else - return nil,id - end - end -end +nuts.getoffsets=direct.getoffsets +nuts.setoffsets=direct.setoffsets nuts.ischar=direct.is_char nuts.is_char=direct.is_char nuts.isglyph=direct.is_glyph @@ -4976,70 +4914,6 @@ local flush_node=nuts.flush_node local traverse_id=nuts.traverse_id local copy_node=nuts.copy_node local glyph_code=nodes.nodecodes.glyph -function nuts.set_components(target,start,stop) - local head=getcomponents(target) - if head then - flush_list(head) - head=nil - end - if start then - setprev(start) - else - return nil - end - if stop then - setnext(stop) - end - local tail=nil - while start do - local c=getcomponents(start) - local n=getnext(start) - if c then - if head then - setlink(tail,c) - else - head=c - end - tail=find_tail(c) - setcomponents(start) - flush_node(start) - else - if head then - setlink(tail,start) - else - head=start - end - tail=start - end - start=n - end - setcomponents(target,head) - return head -end -nuts.get_components=nuts.getcomponents -function nuts.take_components(target) - local c=getcomponents(target) - setcomponents(target) - return c -end -function nuts.count_components(n,marks) - local components=getcomponents(n) - if components then - if marks then - local i=0 - for g in traverse_id(glyph_code,components) do - if not marks[getchar(g)] then - i=i+1 - end - end - return i - else - return count(glyph_code,components) - end - else - return 0 - end -end function nuts.copy_no_components(g,copyinjection) local components=getcomponents(g) if components then @@ -5073,35 +4947,6 @@ function nuts.copy_only_glyphs(current) return head end nuts.uses_font=direct.uses_font -if not nuts.uses_font then - local getdisc=nuts.getdisc - local getfont=nuts.getfont - function nuts.uses_font(n,font) - local pre,post,replace=getdisc(n) - if pre then - for n in traverse_id(glyph_code,pre) do - if getfont(n)==font then - return true - end - end - end - if post then - for n in traverse_id(glyph_code,post) do - if getfont(n)==font then - return true - end - end - end - if replace then - for n in traverse_id(glyph_code,replace) do - if getfont(n)==font then - return true - end - end - end - return false - end -end do local dummy=tonut(node.new("glyph")) nuts.traversers={ @@ -25683,11 +25528,6 @@ local find_node_tail=nuts.tail local flush_node_list=nuts.flush_list local flush_node=nuts.flush_node local end_of_math=nuts.end_of_math -local set_components=nuts.set_components -local take_components=nuts.take_components -local count_components=nuts.count_components -local copy_no_components=nuts.copy_no_components -local copy_only_glyphs=nuts.copy_only_glyphs local setmetatable=setmetatable local setmetatableindex=table.setmetatableindex local nextnode=nuts.traversers.node @@ -25863,24 +25703,27 @@ local function appenddisc(disc,list) end setdisc(disc,pre,post,replace) end -local take_components=getcomponents +local copy_no_components=nuts.copy_no_components +local copy_only_glyphs=nuts.copy_only_glyphs local set_components=setcomponents +local take_components=getcomponents +local isglyph=nuts.isglyph local function count_components(start,marks) - if getid(start)~=glyph_code then - return 0 - elseif getsubtype(start)==ligatureglyph_code then - local i=0 - local components=getcomponents(start) - while components do - i=i+count_components(components,marks) - components=getnext(components) - end - return i - elseif not marks[getchar(start)] then - return 1 - else - return 0 + local char=isglyph(start) + if char then + if getsubtype(start)==ligatureglyph_code then + local i=0 + local components=getcomponents(start) + while components do + i=i+count_components(components,marks) + components=getnext(components) + end + return i + elseif not marks[char] then + return 1 + end end + return 0 end local function markstoligature(head,start,stop,char) if start==stop and getchar(start)==char then @@ -28567,7 +28410,7 @@ end local txtdirstate,pardirstate do local getdirection=nuts.getdirection local lefttoright=0 - local rightoleft=1 + local righttoleft=1 txtdirstate=function(start,stack,top,rlparmode) local nxt=getnext(start) local dir,pop=getdirection(start) @@ -28584,11 +28427,11 @@ local txtdirstate,pardirstate do end elseif dir==lefttoright then top=top+1 - stack[top]=0 + stack[top]=lefttoright return nxt,top,1 elseif dir==righttoleft then top=top+1 - stack[top]=1 + stack[top]=righttoleft return nxt,top,-1 else return nxt,top,rlparmode @@ -28599,12 +28442,11 @@ local txtdirstate,pardirstate do local dir=getdirection(start) if dir==lefttoright then return nxt,1,1 - end - if dir==righttoleft then + elseif dir==righttoleft then return nxt,-1,-1 - elseif dir=="TRT" then - return nxt,1,1 elseif dir=="TLT" then + return nxt,1,1 + elseif dir=="TRT" then return nxt,-1,-1 else return nxt,0,0 |