diff options
Diffstat (limited to 'tex')
31 files changed, 966 insertions, 460 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index fd0516977..146fcbb8c 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{2021.03.17 17:43} +\newcontextversion{2021.03.20 01:03} %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 e04f656a7..f2d2b947f 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{2021.03.17 17:43} +\edef\contextversion{2021.03.20 01:03} %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 095b149a2..e182985f2 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.03.17 17:43} +\newcontextversion{2021.03.20 01:03} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 633060dd1..f0ff9b363 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.03.17 17:43} +\edef\contextversion{2021.03.20 01:03} %D Kind of special: diff --git a/tex/context/base/mkiv/l-url.lua b/tex/context/base/mkiv/l-url.lua index 6f834d778..2e01ad408 100644 --- a/tex/context/base/mkiv/l-url.lua +++ b/tex/context/base/mkiv/l-url.lua @@ -379,53 +379,53 @@ end -- print(url.barepath("/test"),url.barepath("test/"),url.barepath("/test/"),url.barepath("test")) -- print(url.barepath("/x/yz"),url.barepath("x/yz/"),url.barepath("/x/yz/"),url.barepath("x/yz")) ---~ print(url.filename("file:///c:/oeps.txt")) ---~ print(url.filename("c:/oeps.txt")) ---~ print(url.filename("file:///oeps.txt")) ---~ print(url.filename("file:///etc/test.txt")) ---~ print(url.filename("/oeps.txt")) - ---~ from the spec on the web (sort of): - ---~ local function test(str) ---~ local t = url.hashed(str) ---~ t.constructed = url.construct(t) ---~ print(table.serialize(t)) ---~ end - ---~ inspect(url.hashed("http://www.pragma-ade.com/test%20test?test=test%20test&x=123%3d45")) ---~ inspect(url.hashed("http://www.pragma-ade.com/test%20test?test=test%20test&x=123%3d45")) - ---~ test("sys:///./colo-rgb") - ---~ test("/data/site/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733/figuur-cow.jpg") ---~ test("file:///M:/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733") ---~ test("M:/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733") ---~ test("file:///q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733") ---~ test("/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733") - ---~ test("file:///cow%20with%20spaces") ---~ test("file:///cow%20with%20spaces.pdf") ---~ test("cow%20with%20spaces.pdf") ---~ test("some%20file") ---~ test("/etc/passwords") ---~ test("http://www.myself.com/some%20words.html") ---~ test("file:///c:/oeps.txt") ---~ test("file:///c|/oeps.txt") ---~ test("file:///etc/oeps.txt") ---~ test("file://./etc/oeps.txt") ---~ test("file:////etc/oeps.txt") ---~ test("ftp://ftp.is.co.za/rfc/rfc1808.txt") ---~ test("http://www.ietf.org/rfc/rfc2396.txt") ---~ test("ldap://[2001:db8::7]/c=GB?objectClass?one#what") ---~ test("mailto:John.Doe@example.com") ---~ test("news:comp.infosystems.www.servers.unix") ---~ test("tel:+1-816-555-1212") ---~ test("telnet://192.0.2.16:80/") ---~ test("urn:oasis:names:specification:docbook:dtd:xml:4.1.2") ---~ test("http://www.pragma-ade.com/spaced%20name") - ---~ test("zip:///oeps/oeps.zip#bla/bla.tex") ---~ test("zip:///oeps/oeps.zip?bla/bla.tex") - ---~ table.print(url.hashed("/test?test")) +-- print(url.filename("file:///c:/oeps.txt")) +-- print(url.filename("c:/oeps.txt")) +-- print(url.filename("file:///oeps.txt")) +-- print(url.filename("file:///etc/test.txt")) +-- print(url.filename("/oeps.txt")) + +-- from the spec on the web (sort of): + +-- local function test(str) +-- local t = url.hashed(str) +-- t.constructed = url.construct(t) +-- print(table.serialize(t)) +-- end + +-- inspect(url.hashed("http://www.pragma-ade.com/test%20test?test=test%20test&x=123%3d45")) +-- inspect(url.hashed("http://www.pragma-ade.com/test%20test?test=test%20test&x=123%3d45")) + +-- test("sys:///./colo-rgb") + +-- test("/data/site/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733/figuur-cow.jpg") +-- test("file:///M:/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733") +-- test("M:/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733") +-- test("file:///q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733") +-- test("/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733") + +-- test("file:///cow%20with%20spaces") +-- test("file:///cow%20with%20spaces.pdf") +-- test("cow%20with%20spaces.pdf") +-- test("some%20file") +-- test("/etc/passwords") +-- test("http://www.myself.com/some%20words.html") +-- test("file:///c:/oeps.txt") +-- test("file:///c|/oeps.txt") +-- test("file:///etc/oeps.txt") +-- test("file://./etc/oeps.txt") +-- test("file:////etc/oeps.txt") +-- test("ftp://ftp.is.co.za/rfc/rfc1808.txt") +-- test("http://www.ietf.org/rfc/rfc2396.txt") +-- test("ldap://[2001:db8::7]/c=GB?objectClass?one#what") +-- test("mailto:John.Doe@example.com") +-- test("news:comp.infosystems.www.servers.unix") +-- test("tel:+1-816-555-1212") +-- test("telnet://192.0.2.16:80/") +-- test("urn:oasis:names:specification:docbook:dtd:xml:4.1.2") +-- test("http://www.pragma-ade.com/spaced%20name") + +-- test("zip:///oeps/oeps.zip#bla/bla.tex") +-- test("zip:///oeps/oeps.zip?bla/bla.tex") + +-- table.print(url.hashed("/test?test")) diff --git a/tex/context/base/mkiv/mult-fun.lua b/tex/context/base/mkiv/mult-fun.lua index ce94fb3a0..759424f53 100644 --- a/tex/context/base/mkiv/mult-fun.lua +++ b/tex/context/base/mkiv/mult-fun.lua @@ -72,7 +72,7 @@ return { -- "withshading", "withlinearshading", "withcircularshading", "withfromshadecolor", "withtoshadecolor", "shadedinto", "withshadecolors", "withshadedomain", "withshademethod", "withshadefactor", "withshadevector", - "withshadecenter", "withshadedirection", "withshaderadius", "withshadetransform", + "withshadecenter", "withshadedirection", "withshaderadius", "withshadetransform", "withshadecenterone", "withshadecentertwo", "withshadestep", "withshadefraction", "withshadeorigin", "shownshadevector", "shownshadeorigin", "shownshadedirection", "shownshadecenter", "cmyk", "spotcolor", "multitonecolor", "namedcolor", diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index a893d455c..8360ec81f 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -165,7 +165,8 @@ return { "permitgluehyphenationmodecode", "permitallhyphenationmodecode", "permitmathreplacehyphenationmodecode", "forcecheckhyphenationmodecode", "lazyligatureshyphenationmodecode", -- - "normalizelinecode", "parindentskipcode", "swaphangindentcode", "swapparsshapecode", "breakafterdircode", "removemarginkernscode", "clipwidthcode", + "normalizelinecode", "parindentskipcode", "swaphangindentcode", "swapparsshapecode", "breakafterdircode", "removemarginkernscode", + "clipwidthcode", "flattendiscretionariescode", -- "noligaturingcode", "nokerningcode", "noleftligaturecode", "noleftkerncode", "norightligaturecode", "norightkerncode", "noexpansioncode", "noprotrusioncode", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 150b4e1bd..b414d1c97 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 68a481428..097b6cbf0 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-mat.mkiv b/tex/context/base/mkiv/strc-mat.mkiv index 7f5a19154..15b00baae 100644 --- a/tex/context/base/mkiv/strc-mat.mkiv +++ b/tex/context/base/mkiv/strc-mat.mkiv @@ -204,7 +204,10 @@ \relax \relax \relax [\c!name=\v!formula,\s!counter=\v!formula,% \s!hascaption=\v!yes,\s!hastitle=\v!yes,\s!hasnumber=\v!yes,%\s!haslevel=#6,% - \c!reference=#1,\c!title=\namedformulaentry,\c!bookmark=]% + \c!reference=#1,% + \c!title=\namedformulaentry,% + \c!list=\currentplaceformulalist,% + \c!bookmark=\currentplaceformulabookmark]% [#2]% \glet\namedformulaentry\empty % \relax \glet#3\m_strc_counters_last_registered_index @@ -1227,13 +1230,20 @@ %\doifelsenextbgroup\strc_formulas_place_yes\strc_formulas_place_nop} % [ref]{} \strc_formulas_place_nop} +\let\currentplaceformulabookmark\empty +\let\currentplaceformulalist \empty + \def\strc_formulas_start_place_parameters[#1]% {\letdummyparameter\c!title \empty \letdummyparameter\c!reference\empty + \letdummyparameter\c!bookmark \empty + \letdummyparameter\c!list \empty \letdummyparameter\c!suffix \empty \getdummyparameters[#1]% \edef\currentplaceformulatitle {\dummyparameter\c!title}% \edef\currentplaceformulareference{\dummyparameter\c!reference}% + \edef\currentplaceformulareference{\dummyparameter\c!reference}% + \edef\currentplaceformulabookmark {\dummyparameter\c!bookmark}% \edef\currentplaceformulasuffix {\dummyparameter\c!suffix}% \ifx\currentplaceformulatitle\empty\else \normalexpanded{\setformulalistentry{\currentplaceformulatitle}}% diff --git a/tex/context/base/mkiv/task-ini.lua b/tex/context/base/mkiv/task-ini.lua index 8270b9112..84bec0131 100644 --- a/tex/context/base/mkiv/task-ini.lua +++ b/tex/context/base/mkiv/task-ini.lua @@ -131,6 +131,9 @@ appendaction("finalizers", "lists", "typesetters.paragraphs.normalize", end +appendaction("finalizers", "lists", "nodes.handlers.showhyphenation", nil, "nut", "disabled" ) +appendaction("finalizers", "lists", "nodes.handlers.visualizehyphenation", nil, "nut", "disabled" ) + appendaction("finalizers", "lists", "typesetters.margins.localhandler", nil, "nut", "disabled" ) appendaction("finalizers", "lists", "builders.paragraphs.keeptogether", nil, "nut", "disabled" ) appendaction("finalizers", "fonts", "builders.paragraphs.solutions.splitters.optimize", nil, "nonut", "disabled" ) diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 4597309ef..bd37945c2 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.03.17 17:43} +\newcontextversion{2021.03.20 01:03} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 80430f67d..6a211f58c 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.03.17 17:43} +\immutable\edef\contextversion{2021.03.20 01:03} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -523,6 +523,8 @@ \loadmkxlfile{lang-spa} % will become obsolete +\loadmkxlfile{lang-hup} + \loadmkxlfile{typo-ovl} % fuzzy project (tracing) code % old bibtex support: (will be m-oldbibtex.mkiv) diff --git a/tex/context/base/mkxl/font-otj.lmt b/tex/context/base/mkxl/font-otj.lmt index 301b0672f..b454101ba 100644 --- a/tex/context/base/mkxl/font-otj.lmt +++ b/tex/context/base/mkxl/font-otj.lmt @@ -125,7 +125,7 @@ local fontkern = nuts.pool and nuts.pool.fontkern local italickern = nuts.pool and nuts.pool.italickern local function somekern(makekern,amount,current) - local kern = makekern(leftkern,amount) + local kern = makekern(amount) setattrlist(kern,current) return kern end diff --git a/tex/context/base/mkxl/lang-hup.lmt b/tex/context/base/mkxl/lang-hup.lmt new file mode 100644 index 000000000..cde677102 --- /dev/null +++ b/tex/context/base/mkxl/lang-hup.lmt @@ -0,0 +1,249 @@ +if not modules then modules = { } end modules ['lang-hup'] = { + version = 1.001, + comment = "companion to lang-hup.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local utfchar = utf.char +local concat, sortedhash = table.concat, table.sortedhash + +local specialskips = nodes.specialskipcodes +local nodecodes = nodes.nodecodes +local disc_code = nodecodes.disc +local glyph_code = nodecodes.glyph +local glue_code = nodecodes.glue +local hlist_code = nodecodes.hlist +local kern_code = nodecodes.kern +local par_code = nodecodes.par +local line_code = nodes.listcodes.line +local fontkern_code = nodes.kerncodes.fontkern +local nuts = nodes.nuts +local findtail = nuts.tail +local getlist = nuts.getlist +local getnext = nuts.getnext +local getprev = nuts.getprev +local getid = nuts.getid +local getsubtype = nuts.getsubtype +local getreplace = nuts.getreplace +local getdiscpart = nuts.getdiscpart +local isglyph = nuts.isglyph +local nexthlist = nuts.traversers.list +local nextglyph = nuts.traversers.glyph + +local setcolor = nodes.tracers.colors.set +local setaction = nodes.tasks.setaction + +local hash = table.setmetatableindex("number") + +local report = logs.reporter("hyphenated") +local trace_detail = false + +-- local nexthlist = nuts.traversers.list +-- local nextglyph = nuts.traversers.glyph +-- +-- local setcolor = nodes.tracers.colors.set +-- +-- function nodes.handlers.showhyphenation(head) +-- for current, id, subtype, list in nexthlist, head do +-- if subtype == line_code then +-- for n in nextglyph, list do +-- local d = getdiscpart(n) +-- if d == 0 then +-- -- nothing +-- elseif d == 1 then +-- setcolor(n,"red") -- pre +-- elseif d == 2 then +-- setcolor(n,"blue") -- post +-- elseif d == 3 then +-- setcolor(n,"green") -- replace +-- end +-- end +-- end +-- end +-- return head +-- end + +local hash = table.setmetatableindex("number") + +local characters = fonts.hashes.characters + +local function collect(t,head) + local last = nil + while head do + local char, id = isglyph(head) + if char then + local u = characters[id][char].unicode + if u then + if type(u) == "table" then + for i=1,#u do + t[#t+1] = utfchar(u[i]) + end + else + t[#t+1] = utfchar(u) + end + else + t[#t+1] = utfchar(char) + end + last = head + elseif id == disc_code then + collect(t,getreplace(head)) + elseif id == kern_code and getsubtype(head,fontkern_code) then + -- we're ok + else + break + end + head = getnext(head) + end + return last and getdiscpart(last) == 1 +end + +local function getpostpart(current) + local first = nil + while current do + local id = getid(current) + if id == glue_code then + if not specialskips[getsubtype(current)] then + break + end + elseif id == glyph_code or id == disc_code then + return current + elseif id ~= par_code then + break + end + current = getnext(current) + end +end + +local function findprepart(current) + local tail = findtail(current) + while tail do + local id = getid(tail) + if id == glue_code then + if not specialskips[getsubtype(tail)] then + break + end + elseif id == glyph_code and getdiscpart(tail) == 1 then + return tail + else + break + end + tail = getprev(tail) + end +end + +local function getprepart(disc) + local back = getprev(disc) + local okay = back + while okay do + local id = getid(okay) + if id == glyph_code or id == disc_code or (id == kern_code and getsubtype(okay,fontkern_code)) then + back = okay + else + break + end + okay = getprev(okay) + end + return back +end + +function nodes.handlers.showhyphenation(head) + local current = head + local word = { } + while current do + if getid(current) == hlist_code and getsubtype(current) == line_code then + local list = getlist(current) + if list then + if #word > 0 then + local after = getpostpart(list) + local more = collect(word,after) + if more then + goto skip + else + word = concat(word) + if trace_detail then + local r = status.readstate + report("around line %s in file %s: %s",r.linenumber or "-",file.basename(r.filename),word) + end + hash[word] = hash[word] + 1 + word = { } + end + end + local last = findprepart(list) + if last then + local before = getprepart(last) + collect(word,before) + + end + ::skip:: + end + end + current = getnext(current) + end + return head +end + +local initialize ; initialize = function() + logs.registerfinalactions(function() + logs.startfilelogging(report,"hyphenated words") + if hash and next(hash) then + for word, count in sortedhash(hash) do + report("%4i : %s",count,word) + end + else + report("nothing hyphenated") + end + logs.stopfilelogging() + end) + -- + statistics.register("hyphenation",function() + local n = 0 + local m = 0 + for k, v in sortedhash(hash) do + n = n + 1 + m = m + v + end + return string.format("%i hyphenated words, %i unique words",m,n) + end) + initialize = false +end + +trackers.register("hyphenation.applied", function(v) + setaction("finalizers","nodes.handlers.showhyphenation",v) + if v and initialize then + initialize() + end +end) + +trackers.register("hyphenation.applied.console", function(v) + setaction("finalizers","nodes.handlers.showhyphenation",v) + trace_detail = v + if v and initialize then + initialize() + end +end) + +function nodes.handlers.visualizehyphenation(head) + for current, id, subtype, list in nexthlist, head do + if subtype == line_code then + for n in nextglyph, list do + local d = getdiscpart(n) + if d == 0 then + -- nothing + elseif d == 1 then + setcolor(n,"red") -- pre + elseif d == 2 then + setcolor(n,"blue") -- post + elseif d == 3 then + setcolor(n,"green") -- replace + end + end + end + end + return head +end + +trackers.register("hyphenation.applied.visualize", function(v) + setaction("finalizers","nodes.handlers.visualizehyphenation",v) +end) diff --git a/tex/context/base/mkxl/lang-hup.mkxl b/tex/context/base/mkxl/lang-hup.mkxl new file mode 100644 index 000000000..b7bebce52 --- /dev/null +++ b/tex/context/base/mkxl/lang-hup.mkxl @@ -0,0 +1,34 @@ +%D \module +%D [ file=lang-hup, +%D version=2021.03.19, +%D title=\CONTEXT\ Language Macros, +%D subtitle=Hyphenation tracing, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Language Macros / hyphenation tracing} + +\unprotect + +\registerctxluafile{lang-hup}{autosuffix} + +%D \starttyping +%D \starttext +%D +%D \enabletrackers[hyphenation.applied] +%D \enabletrackers[hyphenation.applied.console] +%D +%D \dontcomplain \dostepwiserecurse{0}{15}{1}{ +%D {\advance\hsize -#1cm \input tufte \par} +%D } +%D +%D \stoptext +%D \stoptyping + +\protect \endinput + diff --git a/tex/context/base/mkxl/math-ali.mkxl b/tex/context/base/mkxl/math-ali.mkxl index 2007ed83c..decf8c655 100644 --- a/tex/context/base/mkxl/math-ali.mkxl +++ b/tex/context/base/mkxl/math-ali.mkxl @@ -658,7 +658,8 @@ \setupmathcases [\c!distance=\emwidth, \c!strut=\v!yes, % new - \c!numberdistance=2.5\emwidth, + %\c!numberdistance=2.5\emwidth, + \c!numberdistance=\zeropoint, % pending an extension wrt placement (Aditya/Hans) \c!left={\left\{\mskip\thinmuskip}, \c!right={\right.}] @@ -667,36 +668,126 @@ \frozen\instance \defcsname \e!stop \currentmathcases\endcsname{\math_cases_stop}% \to \everydefinemathcases -\permanent\protected\def\math_cases_NC_zero - {\math_cases_NC} +% \permanent\protected\def\math_cases_NC_zero +% {\math_cases_NC} +% +% \permanent\protected\def\math_cases_MC_zero +% {\math_cases_NC +% \ifmmode\else +% \startimath +% \enforced\let\math_cases_end_math\stopimath +% \fi} +% +% \let\math_cases_end_math\relax +% +% \permanent\protected\def\math_cases_NR_zero +% {\unskip +% \math_cases_end_math +% \aligntab +% \global\enforced\let\math_cases_NC\math_cases_NC_first +% \dodirectdoubleempty\math_cases_NR} +% +% \permanent\protected\def\math_cases_NC_first +% {\global\enforced\let\math_cases_NC\math_cases_NC_second} +% +% \permanent\protected\def\math_cases_NC_second +% {\math_cases_end_math\aligntab} +% +% \let\math_cases_NR\math_align_NR_generic +% +% \installmacrostack\math_cases_NC +% +% \let\math_cases_strut\relax +% +% \permanent\tolerant\protected\def\math_cases_start[#1]#*[#2]% +% {\begingroup +% \edef\currentmathcases{#1}% +% \ifarguments\or\or +% \setupcurrentmathcases[#2]% +% \fi +% \edef\p_strut{\mathcasesparameter\c!strut}% +% \ifx\p_strut\v!yes +% \enforced\let\math_cases_strut\strut +% \else +% \enforced\let\math_cases_strut\relax +% \fi +% \mathcasesparameter\c!left +% \vcenter\bgroup +% \push_macro_math_cases_NC +% \enforced\let\MC\math_cases_MC_zero +% \enforced\let\NR\math_cases_NR_zero +% \enforced\let\TB\math_common_TB +% \enforced\glet\math_cases_NC\math_cases_NC_first +% \normalbaselines +% \mathsurround\zeropoint +% \everycr\emptytoks +% \tabskip\zeropoint +% \global\c_math_eqalign_column\plusone +% \halign\bgroup +% \startimath +% \mathcasesparameter\c!style +% \alignmark\alignmark +% \stopimath +% \hfil +% \aligntab +% \hskip\mathcasesparameter\c!distance\relax +% \pop_macro_math_cases_NC +% \math_cases_strut % looks better +% \alignmark\alignmark +% \hfil +% \aligntab +% \hskip\mathcasesparameter\c!numberdistance\relax +% % \let\formuladistance\!!zeropoint +% \span\math_text_in_eqalign{\alignmark\alignmark}% +% \crcr} % todo: number +% +% % When we have just protected we get an extra row but we can no flag +% % this as a proper alignment related command which means that uit gets +% % expanded. +% +% \noaligned\permanent\protected\def\math_cases_stop +% {\crcr +% \egroup +% \pop_macro_math_cases_NC +% \egroup +% \mathcasesparameter\c!right +% \endgroup} -\permanent\protected\def\math_cases_MC_zero - {\math_cases_NC - \ifmmode\else - \startimath - \enforced\let\math_cases_end_math\stopimath - \fi} +\let\math_cases_strut\relax -\let\math_cases_end_math\relax +\newcount\c_math_cases_nc -\permanent\protected\def\math_cases_NR_zero - {\unskip - \math_cases_end_math - \aligntab - \global\enforced\let\math_cases_NC\math_cases_NC_first - \dodirectdoubleempty\math_cases_NR} +\def\math_cases_NC_zero + {\ifmmode\else\startimath\fi} -\permanent\protected\def\math_cases_NC_first - {\global\enforced\let\math_cases_NC\math_cases_NC_second} +\def\math_cases_NC_one + {\ifmmode\stopimath\fi + \aligntab + \ifmmode\else\startimath\fi} -\permanent\protected\def\math_cases_NC_second - {\math_cases_end_math\aligntab} +\def\math_cases_NC_two + {\ifmmode\stopimath\fi} -\let\math_cases_NR\math_align_NR_generic +\permanent\protected\def\math_cases_NC + {\ifcase\c_math_cases_nc + \expandafter\math_cases_NC_zero + \or + \expandafter\math_cases_NC_one + \or + \expandafter\math_cases_NC_two + \else + % error + \fi + \global\advance\c_math_cases_nc\plusone} -\installmacrostack\math_cases_NC +\noaligned\tolerant\permanent\protected\def\math_cases_NR[#1]#*[#2]% + {\unskip + \ifmmode\stopimath\fi + \aligntab + \global\c_math_cases_nc\zerocount + \math_align_NR_generic[#1][#2]} -\let\math_cases_strut\relax +\installglobalmacrostack\c_math_cases_nc \permanent\tolerant\protected\def\math_cases_start[#1]#*[#2]% {\begingroup @@ -710,48 +801,41 @@ \else \enforced\let\math_cases_strut\relax \fi + \push_macro_c_math_cases_nc \mathcasesparameter\c!left \vcenter\bgroup - \push_macro_math_cases_NC - % \enforced\let\endmath\relax - \enforced\let\NC\math_cases_NC_zero - \enforced\let\MC\math_cases_MC_zero - \enforced\let\NR\math_cases_NR_zero + \enforced\let\MC\math_cases_NC + \enforced\let\NC\math_cases_NC + \enforced\let\NR\math_cases_NR \enforced\let\TB\math_common_TB - \global\enforced\let\math_cases_NC\math_cases_NC_first \normalbaselines \mathsurround\zeropoint \everycr\emptytoks \tabskip\zeropoint \global\c_math_eqalign_column\plusone + \global\c_math_cases_nc\zerocount \halign\bgroup - \startimath + \ifmmode\else\startimath\fi \mathcasesparameter\c!style \alignmark\alignmark - \stopimath + \ifmmode\stopimath\fi \hfil \aligntab \hskip\mathcasesparameter\c!distance\relax - \pop_macro_math_cases_NC \math_cases_strut % looks better \alignmark\alignmark \hfil \aligntab \hskip\mathcasesparameter\c!numberdistance\relax - % \let\formuladistance\!!zeropoint \span\math_text_in_eqalign{\alignmark\alignmark}% \crcr} % todo: number -% When we have just protected we get an extra row but we can no flag -% this as a proper alignment related command which means that uit gets -% expanded. - \noaligned\permanent\protected\def\math_cases_stop {\crcr \egroup - \pop_macro_math_cases_NC \egroup \mathcasesparameter\c!right + \pop_macro_c_math_cases_nc \endgroup} \definemathcases[cases] diff --git a/tex/context/base/mkxl/math-frc.mkxl b/tex/context/base/mkxl/math-frc.mkxl index dfdb7144f..d02a3b865 100644 --- a/tex/context/base/mkxl/math-frc.mkxl +++ b/tex/context/base/mkxl/math-frc.mkxl @@ -489,9 +489,7 @@ \appendtoks \edef\p_distance{\rootmathfractionparameter\c!distance}% \ifempty\p_distance\else - \ifcsname\??mathfractiondistance\p_distance\endcsname - \lastnamedcs - \fi + \begincsname\??mathfractiondistance\p_distance\endcsname \fi \to \everymathematics diff --git a/tex/context/base/mkxl/meta-tex.mkxl b/tex/context/base/mkxl/meta-tex.mkxl index 00ad3a58b..17dc788ef 100644 --- a/tex/context/base/mkxl/meta-tex.mkxl +++ b/tex/context/base/mkxl/meta-tex.mkxl @@ -45,10 +45,10 @@ \permanent\def\getTeXtext#1% {\begincsname\??graphictextext#1\endcsname} -\letvalue{\??graphictexdepth d}\syst_boxes_lower_nextbox_dp -\letvalue{\??graphictexdepth \s!depth}\syst_boxes_lower_nextbox_dp -\letvalue{\??graphictexdepth n}\donothing -\letvalue{\??graphictexdepth\s!nodepth}\donothing +\letcsname\??graphictexdepth d\endcsname\syst_boxes_lower_nextbox_dp +\letcsname\??graphictexdepth \s!depth\endcsname\syst_boxes_lower_nextbox_dp +\letcsname\??graphictexdepth n\endcsname\donothing +\letcsname\??graphictexdepth\s!nodepth\endcsname\donothing % old hackery, slightly modernized @@ -176,16 +176,16 @@ \permanent\protected\def\svghashed#1% {\clf_svghashed#1\relax} -\permanent\protected\def\svg_normal_poscode#1#2#3% +\permanent\protected\def\svg_normal_pcode#1#2#3% {\glyph xoffset #1\onebasepoint yoffset #2\onebasepoint #3\relax} -\permanent\protected\def\svg_normal_poschar#1#2#3% +\permanent\protected\def\svg_normal_pchar#1#2#3% {\glyph xoffset #1\onebasepoint yoffset #2\onebasepoint `#3\relax} -\permanent\protected\def\svg_normal_posspace#1#2% +\permanent\protected\def\svg_normal_pspace#1#2% {\space} -\permanent\protected\def\svg_normal_space#1% +\permanent\protected\def\svg_normal_space {\space} \permanent\protected\def\svg_normal_code#1% @@ -194,42 +194,56 @@ \permanent\protected\def\svg_normal_char#1% {#1\relax} -\permanent\protected\def\svg_normal_startlayer +\permanent\protected\def\svg_normal_start {\resetlayer[svgmps]% \setlayer[svgmps]\bgroup} -\permanent\protected\def\svg_normal_stoplayer +\permanent\protected\def\svg_normal_stop {\egroup \flushlayer[svgmps]} -\permanent\protected\def\svg_normal_colored#1#2#3#4% +\permanent\protected\def\svg_normal_color#1#2#3#4% {\colored[r=#1,g=#2,b=#3]{#4}} -\permanent\protected\def\svg_normal_setlayer#1#2#3% +\permanent\protected\def\svg_normal_set#1#2#3% {\setlayer[svgmps]{\hbox xoffset #1\onebasepoint yoffset #2\onebasepoint to 10sp{#3}}} -\permanent\protected\def\svg_normal_scaled#1#2#3#4#5% +% \permanent\protected\def\svg_normal_font#1#2#3#4#5% +% {\hbox\bgroup +% \iftok{#2}\emptytoks\else +% \edef\p_font{\ifcsname\??svgfamily#2\endcsname\lastnamedcs\else#2\fi-#3-#4}% +% \predefinedfont[\s!spec:\p_font*\s!default\space @ 10bp]% +% \fi +% \glyphscale\numericscale#1\relax % we need a period ! +% #5% +% \egroup} + +\permanent\protected\def\svg_normal_font#1#2#3#4#5% {\hbox\bgroup - \edef\p_family{#2}% - \ifempty\p_family\else + \iftok{#2}\emptytoks\else \edef\p_font{\ifcsname\??svgfamily#2\endcsname\lastnamedcs\else#2\fi-#3-#4}% - \predefinedfont[\s!spec:\p_font*\s!default\space @ 10bp]% + \ifcsname svg:\p_font\endcsname + \lastnamedcs + \else + \predefinefont[svg:\p_font][\s!spec:\p_font*\s!default\space @ 10bp]% + \csname svg:\p_font\endcsname + \fi \fi \glyphscale\numericscale#1\relax % we need a period ! #5% \egroup} -\permanent\protected\def\svg_traced_poscode#1#2#3% +\permanent\protected\def\svg_traced_pcode#1#2#3% {\writestatus{SVG TEXT}{....[poscode #1 #2 \Uchar #3]}% - \svg_normal_poscode{#1}{#2}{#3}} + \svg_normal_pcode{#1}{#2}{#3}} -\permanent\protected\def\svg_traced_poschar#1#2#3% +\permanent\protected\def\svg_traced_pchar#1#2#3% {\writestatus{SVG TEXT}{....[poschar #1 #2 #3]}% - \svg_normal_poschar{#1}{#2}{#3}} + \svg_normal_pchar{#1}{#2}{#3}} -\permanent\protected\def\svg_traced_posspace#1#2% +\permanent\protected\def\svg_traced_pspace#1#2% {\writestatus{SVG TEXT}{....[posspace #1 #2]}% - \svg_normal_posspace{#1}{#2}} + \svg_normal_pspace{#1}{#2}} \permanent\protected\def\svg_traced_code#1% {\writestatus{SVG TEXT}{....[char \Uchar #1]}% @@ -243,54 +257,54 @@ {\writestatus{SVG TEXT}{....[space]}% \svg_normal_space} -\permanent\protected\def\svg_traced_startlayer +\permanent\protected\def\svg_traced_start {\writestatus{SVG TEXT}{[start layer]}% - \svg_normal_startlayer} + \svg_normal_start} -\permanent\protected\def\svg_traced_stoplayer - {\svg_normal_stoplayer +\permanent\protected\def\svg_traced_stop + {\svg_normal_stop \writestatus{SVG TEXT}{[stop layer]}} -\permanent\protected\def\svg_traced_colored#1#2#3#4% +\permanent\protected\def\svg_traced_color#1#2#3#4% {\writestatus{SVG TEXT}{.[start color #1 #2 #3]}% - \svg_normal_colored{#1}{#2}{#3}{#4}% + \svg_normal_color{#1}{#2}{#3}{#4}% \writestatus{SVG TEXT}{.[stop color]}} -\permanent\protected\def\svg_traced_setlayer#1#2#3% +\permanent\protected\def\svg_traced_set#1#2#3% {\writestatus{SVG TEXT}{...[start set layer #1 #2]}% - \svg_normal_setlayer{#1}{#2}{#3}% + \svg_normal_set{#1}{#2}{#3}% \writestatus{SVG TEXT}{...[stop set setlayer]}} -\permanent\protected\def\svg_traced_scaled#1#2#3#4#5% +\permanent\protected\def\svg_traced_font#1#2#3#4#5% {\writestatus{SVG TEXT}{..[start scaled font #1 #2 #3 #4]}% - \svg_normal_scaled{#1}{#2}{#3}{#4}{#5}% + \svg_normal_font{#1}{#2}{#3}{#4}{#5}% \writestatus{SVG TEXT}{..[stop scaled font]}} \permanent\protected\def\svg_normal_text - {\let\svgposcode \svg_normal_poscode - \let\svgposchar \svg_normal_poschar - \let\svgposspace \svg_normal_posspace - \let\svgcode \svg_normal_code - \let\svgchar \svg_normal_char - \let\svgspace \svg_normal_space - \let\svgstartlayer\svg_normal_startlayer - \let\svgstoplayer \svg_normal_stoplayer - \let\svgcolored \svg_normal_colored - \let\svgsetlayer \svg_normal_setlayer - \let\svgscaled \svg_normal_scaled} + {\let\svgpcode \svg_normal_pcode + \let\svgpchar \svg_normal_pchar + \let\svgpspace\svg_normal_pspace + \let\svgcode \svg_normal_code + \let\svgchar \svg_normal_char + \let\svgspace \svg_normal_space + \let\svgstart \svg_normal_start + \let\svgstop \svg_normal_stop + \let\svgcolor \svg_normal_color + \let\svgset \svg_normal_set + \let\svgfont \svg_normal_font} \permanent\protected\def\svg_traced_text - {\let\svgposcode \svg_traced_poscode - \let\svgposchar \svg_traced_poschar - \let\svgposspace \svg_traced_posspace - \let\svgcode \svg_traced_code - \let\svgchar \svg_traced_char - \let\svgspace \svg_traced_space - \let\svgstartlayer\svg_traced_startlayer - \let\svgstoplayer \svg_traced_stoplayer - \let\svgcolored \svg_traced_colored - \let\svgsetlayer \svg_traced_setlayer - \let\svgscaled \svg_traced_scaled} + {\let\svgpcode \svg_traced_pcode + \let\svgpchar \svg_traced_pchar + \let\svgpspace\svg_traced_pspace + \let\svgcode \svg_traced_code + \let\svgchar \svg_traced_char + \let\svgspace \svg_traced_space + \let\svgstart \svg_traced_start + \let\svgstop \svg_traced_stop + \let\svgcolor \svg_traced_color + \let\svgset \svg_traced_set + \let\svgfont \svg_traced_font} \installtextracker {svg.text} diff --git a/tex/context/base/mkxl/mlib-lmt.lmt b/tex/context/base/mkxl/mlib-lmt.lmt index b7c869c3b..651a98be5 100644 --- a/tex/context/base/mkxl/mlib-lmt.lmt +++ b/tex/context/base/mkxl/mlib-lmt.lmt @@ -168,8 +168,8 @@ registerscript("scrutenized", function() local t = { p[1], cycle = p.cycle } for i=2,m-1 do local pi = p[i] - local x2 = r(pi[1]) - local y2 = r(pi[2]) + local x2 = round(pi[1]) + local y2 = round(pi[2]) if x1 ~= x2 or y1 ~= y2 then n = n + 1 t[n] = p[i] @@ -177,16 +177,16 @@ registerscript("scrutenized", function() y1 = y2 end end - local x1 = r(p[1][1]) - local y1 = r(p[1][2]) - local x2 = r(p[m][1]) - local y2 = r(p[m][2]) + local x1 = round(p[1][1]) + local y1 = round(p[1][2]) + local x2 = round(p[m][1]) + local y2 = round(p[m][2]) if x1 ~= x2 or y1 ~= y2 then n = n + 1 t[n] = p[m] end - mp.path(t) - -- injectpath(t) + -- mp.path(t) + injectpath(t) end) -- A goodie, mostly a side effect of updating the metafun manual. diff --git a/tex/context/base/mkxl/mlib-pps.lmt b/tex/context/base/mkxl/mlib-pps.lmt index d668d1b10..45ae9bf24 100644 --- a/tex/context/base/mkxl/mlib-pps.lmt +++ b/tex/context/base/mkxl/mlib-pps.lmt @@ -761,6 +761,10 @@ end local tx_reset, tx_process do + -- The dilemma is that we need to process the text in order to know the + -- dimensions but afterwards also need to apply color and such. So, we need + -- two passes, one immediately and one when we use it. + local eol = S("\n\r")^1 local cleaner = Cs((P("@@")/"@" + P("@")/"%%" + P(1))^0) local splitter = Ct( @@ -1015,6 +1019,8 @@ local tx_reset, tx_process do end end + local fasttrack = false directives.register("metapost.text.fasttrack", function(v) fasttrack = v end) + tx_process = function(object,prescript,before,after) local data = top.texdata[metapost.properties.number] -- the current figure number, messy local index = tonumber(prescript.tx_index) @@ -1040,9 +1046,14 @@ local tx_reset, tx_process do local mp_text = top.texstrings[mp_index] local mp_hash = prescript.tx_cache local box +local donebox = fasttrack and top.textexts[mp_index] if mp_hash == "no" then +if donebox then + box = copy_list(donebox) +else texrunlocal("mptexttoks") box = textakebox("mptextbox") +end else local cache = data.texhash if mp_hash then @@ -1074,8 +1085,12 @@ local tx_reset, tx_process do if box then box = copy_list(box) else +if donebox then + box = copy_list(donebox) +else texrunlocal("mptexttoks") box = textakebox("mptextbox") +end cache[mp_hash] = box end end diff --git a/tex/context/base/mkxl/mlib-svg.lmt b/tex/context/base/mkxl/mlib-svg.lmt index e405eaa8d..496d4ed0d 100644 --- a/tex/context/base/mkxl/mlib-svg.lmt +++ b/tex/context/base/mkxl/mlib-svg.lmt @@ -7,6 +7,10 @@ if not modules then modules = { } end modules ['mlib-svg'] = { license = "see context related readme files", } +-- todo: svg stripper + +-- todo: when opacity is 1 don't flush it + -- Just a few notes: -- -- There is no real need to boost performance here .. we can always make a fast @@ -335,6 +339,7 @@ do * (P("e") * S("+-")^0 * p_digit^1)^-1 local function convert (n) n = tonumber(n) return n end + local function convert_p (n,u) n = tonumber(n) if u == true then return n / 100 else return n end end local function convert_r (n,u) n = tonumber(n) if u == true then return percentage_r * n elseif u then return u * n else return n end end local function convert_x (n,u) n = tonumber(n) if u == true then return percentage_x * n elseif u then return u * n else return n end end local function convert_y (n,u) n = tonumber(n) if u == true then return percentage_y * n elseif u then return u * n else return n end end @@ -345,7 +350,7 @@ do local p_percent = P("%") * Cc(true) local c_number_n = C(p_number) - local c_number_u = C(p_number) * (p_unit + p_percent)^-1 + local c_number_u = C(p_number) * (p_percent + p_unit)^-1 p_number_n = c_number_n / convert p_number_x = c_number_u / convert_x @@ -353,9 +358,11 @@ do p_number_y = c_number_u / convert_y p_number_vy = c_number_u / convert_vy p_number_r = c_number_u / convert_r + p_number_p = c_number_u / convert_p asnumber = function(s) return s and lpegmatch(p_number, s) or 0 end asnumber_r = function(s) return s and lpegmatch(p_number_r, s) or 0 end + asnumber_p = function(s) return s and lpegmatch(p_number_p, s) or 0 end asnumber_x = function(s) return s and lpegmatch(p_number_x, s) or 0 end asnumber_y = function(s) return s and lpegmatch(p_number_y, s) or 0 end asnumber_vx = function(s) return s and lpegmatch(p_number_vx,s) or 0 end @@ -483,8 +490,8 @@ local colorcomponents, withcolor, thecolor, usedcolors do local f_rgb = formatters[' withcolor svgcolor(%.3N,%.3N,%.3N)'] local f_cmyk = formatters[' withcolor svgcmyk(%.3N,%.3N,%.3N,%.3N)'] local f_gray = formatters[' withcolor svggray(%.3N)'] - local f_rgba = formatters[' withcolor svgcolor(%.3N,%.3N,%.3N) withtransparency (2,1-%.3N)'] - local f_graya = formatters[' withcolor svggray(%.3N) withtransparency (2,1-%.3N)'] + local f_rgba = formatters[' withcolor svgcolor(%.3N,%.3N,%.3N) withopacity %.3N'] + local f_graya = formatters[' withcolor svggray(%.3N) withopacity %.3N'] local f_name = formatters[' withcolor "%s"'] local f_svgrgb = formatters['svgcolor(%.3N,%.3N,%.3N)'] local f_svgcmyk = formatters['svgcmyk(%.3N,%.3N,%.3N,%.3N)'] @@ -513,6 +520,13 @@ local colorcomponents, withcolor, thecolor, usedcolors do local p_left = P("(") local p_right = P(")") local p_a = P("a")^-1 + local p_r_a_color = p_left + * (p_fraction * p_separator^-1)^-3 + * p_absolute^0 + * p_right + local p_c_k_color = p_left + * (p_absolute + p_separator^-1)^-4 + * p_right local p_h_a_color = p_left * p_angle * p_separator * p_percent @@ -541,11 +555,11 @@ local colorcomponents, withcolor, thecolor, usedcolors do end end + P("rgb") * p_a - * p_left * (p_fraction + p_separator)^-3 * (p_absolute + p_separator)^0 * p_right / function(r,g,b,a) + * p_r_a_color / function(r,g,b,a) return "rgb", r or 0, g or 0, b or 0, a or false end + P("cmyk") - * p_left * (p_absolute + p_separator)^0 * p_right / function(c,m,y,k) + * p_c_k_color / function(c,m,y,k) return "cmyk", c or 0, m or 0, y or 0, k or 0 end + P("hsl") * p_a @@ -634,7 +648,7 @@ local colorcomponents, withcolor, thecolor, usedcolors do if not what then local t = triplets[color] if t then - s1, s3, s3 = t[1], t[2], t[3] + s1, s2, s3 = t[1], t[2], t[3] what = "rgb" end end @@ -648,7 +662,6 @@ local colorcomponents, withcolor, thecolor, usedcolors do withcolor = function(color) local what, s1, s2, s3, s4 = validcolor(color) - -- print(color,what, s1, s2, s3, s4) if what == "rgb" then if s4 then if s1 == s2 and s1 == s3 then @@ -1296,6 +1309,14 @@ local handletransform, handleviewbox do end end + handletransformstring = function(t) + if t then + noftransforms = 0 + lpegmatch(p_transform,t) + return noftransforms > 0 and concat(transforms,"",1,noftransforms) + end + end + handleviewbox = function(v) if v then local x, y, w, h = lpegmatch(p_fournumbers,v) @@ -1398,6 +1419,20 @@ do -- ["vkern"] = true, } + local usetags = { + ["circle"] = true, + ["ellipse"] = true, + ["g"] = true, + ["image"] = true, + ["line"] = true, + ["path"] = true, + ["polygon"] = true, + ["polyline"] = true, + ["rect"] = true, + -- ["text"] = true, + -- ["tspan"] = true, + } + local pathtracer = { ["stroke"] = "darkred", ["stroke-opacity"] = ".5", @@ -1505,17 +1540,42 @@ do -- We can have root in definitions and then do a metatable lookup but use -- is not used that often I guess. - local function locate(id) + local function locate(id,c) + if id == none then + return + end local res = definitions[id] + local ref if res then return res end - local ref = gsub(id,"^url%(#(.-)%)$","%1") - local ref = gsub(ref,"^#","") + ref = gsub(id,"^url%(#(.-)%)$","%1") + ref = gsub(ref,"^#","") -- we can make a fast id lookup - local res = xmlfirst(root,"**[@id='"..ref.."']") + res = xmlfirst(root,"**[@id='"..ref.."']") if res then definitions[id] = res + return res + end + -- we expect resource paths to be specified but for now we want + -- them on the same path .. we could use the url splitter .. todo + ref = url.hashed(id) + if not ref.nosheme and ref.scheme == "file" then + local filename = ref.filename + local fragment = ref.fragment + if filename and filename ~= "" then + if lfs.isfile(filename) then + report("loading use file: %s",filename) + local root = xml.load(filename) + res = xmlfirst(root,"**[@id='"..fragment.."']") + if res then + xmlinheritattributes(res,c) -- tricky + setmetatableindex(res.at,c.at) + definitions[id] = res + return res + end + end + end end return res end @@ -1531,7 +1591,7 @@ do local spec = definitions[clippath] or locate(clippath) - -- do we really need thsi crap + -- do we really need this crap if not spec then local index = match(clippath,"(%d+)") if index then @@ -1577,12 +1637,16 @@ do -- break elseif tg == "path" then local ca = c.at - local d = ca.d + local d = rawget(ca,"d") if d then local p = grabpath(d) p.evenodd = ca["clip-rule"] == "evenodd" p.close = true - return p, clippath +local transform = rawget(ca,"transform") +if transform then + transform = handletransformstring(transform) +end + return p, clippath, transform else return end @@ -1592,19 +1656,36 @@ do end end - local s_shade_linear = ' withshademethod "linear" ' - local s_shade_circular = ' withshademethod "circular" ' - local f_shade_step = formatters['withshadestep ( withshadefraction %N withshadecolors(%s,%s) )'] - local f_shade_one = formatters['withprescript "sh_center_a=%N %N"'] - local f_shade_two = formatters['withprescript "sh_center_b=%N %N"'] - - local f_color = formatters[' withcolor "%s"'] - local f_opacity = formatters[' withtransparency (2,%N)'] - local f_pen = formatters[' withpen pencircle scaled %N'] + local s_shade_linear = ' withshademethod "linear" ' + local s_shade_circular = ' withshademethod "circular" ' + local f_color = formatters[' withcolor "%s"'] + local f_opacity = formatters[' withopacity %N'] + local f_pen = formatters[' withpen pencircle scaled %N'] + + local f_shade_step = formatters['withshadestep ( withshadefraction %N withshadecolors (%s,%s) )'] + local f_shade_step_opacity = formatters['withshadestep ( withshadefraction %N withshadecolors (%s,%s) withshadeopacity %N )'] + local f_shade_radius = formatters['withshaderadius (%N,%N) '] + local f_shade_center_one = formatters['withshadecenterone (%N,%N)'] + local f_shade_center_two = formatters['withshadecentertwo (%N,%N)'] + local f_shade_center_one_f = formatters['withshadecenteronefraction (%N,%N)'] + local f_shade_center_two_f = formatters['withshadecentertwofraction (%N,%N)'] + local f_shade_center_f = formatters['withshadecenterfraction (%N,%N)'] + local f_shade_radius_f = formatters['withshaderadiusfraction %N'] -- todo: gradient unfinished -- todo: opacity but first we need groups in mp + -- this is rather hard to deal with because browsers differ (at the time of writing) + -- and what they show on screen comes out different (or not at all) in print + + -- todo: gradientUnits = "userSpaceOnUse" : use units instead of ratios + + -- spreadMethod = "pad" : default + -- spreadMethod = "repeat" : crap + -- spreadMethod = "reflect" : crap + + -- stop-opacity = "0" : strange, just use steps for that + local function gradient(id) local spec = definitions[id] -- no locate ! if spec then @@ -1620,10 +1701,10 @@ do local x2 = rawget(a,"x2") local y2 = rawget(a,"y2") if x1 and y1 then - n = n + 1 ; shade[n] = f_shade_one(asnumber_vx(x1),asnumber_vy(y1)) + n = n + 1 ; shade[n] = f_shade_center_one_f(asnumber_p(x1),1-asnumber_p(y1)) end if x2 and y2 then - n = n + 1 ; shade[n] = f_shade_one(asnumber_vx(x2),asnumber_vy(y2)) + n = n + 1 ; shade[n] = f_shade_center_two_f(asnumber_p(x2),1-asnumber_p(y2)) end -- elseif kind == "radialGradient" then @@ -1636,10 +1717,13 @@ do local fy = rawget(a,"fy") -- focal points -- if cx and cy then - -- todo + n = n + 1 ; shade[n] = f_shade_center_f(asnumber_p(cx),1-asnumber_p(cy)) + end + if fx and fy then + n = n + 1 ; shade[n] = f_shade_center_one_f(asnumber_p(fx),1-asnumber_p(fy)) end if r then - -- todo + n = n + 1 ; shade[n] = f_shade_radius_f(asnumber_p(r)) end if fx and fy then -- todo @@ -1657,29 +1741,30 @@ do local a = c.at local offset = rawget(a,"offset") local colorb = rawget(a,"stop-color") - local opacity = rawget(a,"stop-opacity") - if colorb then - colorb = thecolor(colorb) - end + -- local opacity = rawget(a,"stop-opacity") -- not in pdf for steps if not colora then colora = colorb end -- what if no percentage - - local fraction = offset and asnumber_r(offset) + local fraction = offset and asnumber_r(offset) -- asnumber_p ? if not fraction then -- offset = tonumber(offset) -- for now - fraction = xmlcount(spec,"/stop")/100 + fraction = xmlcount(spec,"/stop")/100 -- asnumber_p ? end - if colora and colorb and color_a ~= "" and color_b ~= "" then - n = n + 1 ; shade[n] = f_shade_step(fraction,colora,colorb) + if colora and colorb and colora ~= "" and colorb ~= "" then + n = n + 1 + -- if opacity then + -- shade[n] = f_shade_step_opacity(fraction,thecolor(colora),thecolor(colorb),asnumber(o)) + -- else + shade[n] = f_shade_step(fraction,thecolor(colora),thecolor(colorb)) + -- end end colora = colorb end - return concat(shade," ") + return concat(shade,"\n ") end end @@ -1706,8 +1791,9 @@ do o = nil elseif o then o = asnumber_r(o) - if o and o ~= 1 then - o = f_opacity(1-o) +-- if o and o ~= 0 then + if o then + o = f_opacity(o) else o = nil end @@ -1716,29 +1802,35 @@ do end local s_opacity_start = s_draw_image_start - local f_opacity_content = formatters["setgroup currentpicture to boundingbox currentpicture withtransparency (1,%N);"] + local f_opacity_content = formatters["setgroup currentpicture to boundingbox currentpicture withopacity %N;"] local s_opacity_stop = s_draw_image_stop local function sharedopacity(at) local o = at["opacity"] if o and o ~= "none" then o = asnumber_r(o) - if o and o ~= 1 then - return s_opacity_start, f_opacity_content(1-o), s_opacity_stop +-- if o and o ~= 1 then + if o then + return s_opacity_start, f_opacity_content(o), s_opacity_stop end end end + -- it looks like none and transparent are both used (mozilla examples) + local function fillproperties(fill,at,opacity) local c = c ~= "none" and (gradient(fill) or withcolor(fill)) or nil local o = at["fill-opacity"] or (opacity and at["opacity"]) if o and o ~= "none" then o = asnumber_r(o) - if o == 1 then - return c - elseif o then - return c, f_opacity(1-o), o == 0 +-- if o == 1 then +-- return c +-- else + if o then + return c, f_opacity(o), o == 0 -- hm this check should be: o == 1 end + elseif fill == "transparent" then + return nil, f_opacity(1), false -- o == 1 -- hm this check should be: o == 1 end return c end @@ -1817,7 +1909,7 @@ do function handlers.use(c) local at = c.at local id = rawget(at,"href") or rawget(at,"xlink:href") -- better a rawget - local res = locate(id) + local res = locate(id,c) if res then -- width height ? uselevel = uselevel + 1 @@ -1839,7 +1931,12 @@ do at["transform"] = false -- at["clip-path"] = false - process(res,"/*") + local tg = res.tg + if usetags[tg] then + process(res,".") + else + process(res,"/*") + end at["transform"] = _transform -- at["clip-path"] = _clippath @@ -1869,26 +1966,19 @@ do local f_do_fill = f_do_fill_c local f_eo_fill = f_eo_fill_c local f_no_fill = f_no_fill_c --- local s_clip_start = 'draw image (' --- local f_clip_stop_c = formatters[') ; clip currentpicture to (%s..cycle) ;'] --- local f_clip_stop_l = formatters[') ; clip currentpicture to (%s--cycle) ;'] --- local f_clip_stop = f_clip_stop_c --- local f_eoclip_stop_c = formatters[') ; eoclip currentpicture to (%s..cycle) ;'] --- local f_eoclip_stop_l = formatters[') ; eoclip currentpicture to (%s--cycle) ;'] --- local f_eoclip_stop = f_eoclip_stop_c local s_clip_start = 'save p ; picture p ; p := image (' - local f_clip_stop_c = formatters[') ; clip p to (%s..cycle) ; draw p ;'] - local f_clip_stop_l = formatters[') ; clip p to (%s--cycle) ; draw p ;'] + local f_clip_stop_c = formatters[') ; clip p to closedcurve(%s) %s ; draw p ;'] + local f_clip_stop_l = formatters[') ; clip p to closedlines(%s) %s ; draw p ;'] local f_clip_stop = f_clip_stop_c - local f_eoclip_stop_c = formatters[') ; eoclip p to (%s..cycle) ; draw p ;'] - local f_eoclip_stop_l = formatters[') ; eoclip p to (%s--cycle) ; draw p ;'] + local f_eoclip_stop_c = formatters[') ; eoclip p to closedcurve(%s) %s ; draw p ;'] + local f_eoclip_stop_l = formatters[') ; eoclip p to closedlines(%s) %s ; draw p ;'] local f_eoclip_stop = f_eoclip_stop_c -- could be shared and then beginobject | endobject local function flushobject(object,at,c,o) local btransform, etransform = handletransform(at) - local cpath = handleclippath(at) + local cpath, _, ctransform = handleclippath(at) if cpath then r = r + 1 ; result[r] = s_clip_start @@ -1921,7 +2011,7 @@ do else f_done = f_done and f_eoclip_stop_l or f_clip_stop_l end - r = r + 1 ; result[r] = f_done(cpath[1]) + r = r + 1 ; result[r] = f_done(cpath[1],ctransform or "") end end @@ -1985,10 +2075,11 @@ do local refy = rawget(at,"refY") local width = rawget(at,"markerWidth") local height = rawget(at,"markerHeight") + local units = rawget(at,"markerUnits") -- no parentat["stroke-width"], bad for m4mbo local view = rawget(at,"viewBox") local orient = rawget(at,"orient") -- local ratio = rawget(at,"preserveAspectRatio") - local units = asnumber(at["markerUnits"] or parentat["stroke-width"]) or 1 + local units = units and asnumber(units) or 1 local angx = 0 local angy = 0 @@ -2148,7 +2239,7 @@ do local stroke = at["stroke"] or "none" local btransform, etransform = handletransform(at) - local cpath = handleclippath(at) + local cpath, _, ctransform = handleclippath(at) if cpath then r = r + 1 ; result[r] = s_clip_start @@ -2218,7 +2309,7 @@ do end if cpath then - r = r + 1 ; result[r] = (cpath.evenodd and f_eoclip_stop or f_clip_stop)(cpath[1]) + r = r + 1 ; result[r] = (cpath.evenodd and f_eoclip_stop or f_clip_stop)(cpath[1],ctransform) end end @@ -2446,7 +2537,7 @@ do end if cpath then - r = r + 1 ; result[r] = f_clip_stop(cpath[1]) + r = r + 1 ; result[r] = f_clip_stop(cpath[1],"") end end @@ -2492,7 +2583,7 @@ do y = y and asnumber_vy(y) or 0 nofimages = nofimages + 1 local name = "temp-svg-image-" .. nofimages .. "." .. kind - local data = mime.decode("base64")(data) + local data = basexx.decode64(data) io.savedata(name,data) if not w or not h then local info = graphics.identifiers[kind](data,"string") @@ -2538,7 +2629,7 @@ do local at = c.at local btransform, etransform, transform = handletransform(at) - local cpath, clippath = handleclippath(at) + local cpath, clippath, ctransform = handleclippath(at) if cpath then r = r + 1 ; result[r] = s_clip_start @@ -2569,7 +2660,7 @@ do else f_done = f_done and f_eoclip_stop_l or f_clip_stop_l end - r = r + 1 ; result[r] = f_done(cpath[1]) + r = r + 1 ; result[r] = f_done(cpath[1],ctransform or "") end end @@ -2590,31 +2681,31 @@ do do - local s_startlayer = "\\svgstartlayer " - local s_stoplayer = "\\svgstoplayer " - local f_setlayer = formatters["\\svgsetlayer{%N}{%N}"] -- we need a period - local f_colored = formatters["\\svgcolored{%.3N}{%.3N}{%.3N}{"] - local f_poscode = formatters["\\svgposcode{%N}{%N}{%s}"] - local f_poschar = formatters["\\svgposchar{%N}{%N}{%s}"] - local f_posspace = formatters["\\svgposspace{%N}{%N}"] - local f_coder = formatters["\\svgcode{%s}"] - local f_char = formatters["\\svgchar{%s}"] - local s_space = "\\svgspace " - local f_scaled = formatters["\\svgscaled{%0.6f}{%s}{%s}{%s}"] -- we need a period - local f_hashed = formatters["\\svghashed{%s}"] - - local p_texescape = lpegpatterns.texescape + local s_start = "\\svgstart " + local s_stop = "\\svgstop " + local f_set = formatters["\\svgset{%N}{%N}"] -- we need a period + local f_colored = formatters["\\svgcolor{%.3N}{%.3N}{%.3N}{"] + local f_poscode = formatters["\\svgpcode{%N}{%N}{%s}"] + local f_poschar = formatters["\\svgpchar{%N}{%N}{%s}"] + local f_posspace = formatters["\\svgpspace{%N}{%N}"] + local f_code = formatters["\\svgcode{%s}"] + local f_char = formatters["\\svgchar{%s}"] + local s_space = "\\svgspace " + local f_scaled = formatters["\\svgfont{%0.6f}{%s}{%s}{%s}"] -- we need a period + local f_hashed = formatters["\\svghashed{%s}"] + + ----- p_texescape = lpegpatterns.texescape local anchors = { ["start"] = "drt", - ["end"] = "dflt", + ["end"] = "dlft", ["middle"] = "d", } -- we can now just use the lmt maptext feature - local f_text_normal_svg = formatters['(textext.%s("%s") shifted (%N,%N))'] - local f_text_simple_svg = formatters['textext.%s("%s")'] + local f_text_normal_svg = formatters['(onetimetextext.%s("%s") shifted (%N,%N))'] + local f_text_simple_svg = formatters['onetimetextext.%s("%s")'] local f_mapped_normal_svg = formatters['(svgtext("%s") shifted (%N,%N))'] local f_mapped_simple_svg = formatters['svgtext("%s")'] @@ -2690,17 +2781,18 @@ do if c.special then return nil end - local dt = c.dt - local nt = #dt - local at = c.at - local tg = c.tg - local ax = rawget(at,"x") - local ay = rawget(at,"y") - local v_fill = at["fill"] - local v_family = at["font-family"] - local v_style = at["font-style"] - local v_weight = at["font-weight"] - local v_size = at["font-size"] + local dt = c.dt + local nt = #dt + local at = c.at + local tg = c.tg + local ax = rawget(at,"x") + local ay = rawget(at,"y") + local v_fill = at["fill"] + local v_family = at["font-family"] + local v_style = at["font-style"] + local v_weight = at["font-weight"] + local v_size = at["font-size"] + local v_lineheight = at["line-height"] -- ax = ax and asnumber_vx(ax) or x ay = ay and asnumber_vy(ay) or y @@ -2721,12 +2813,23 @@ do -- usedfonts[v_family][v_weight][v_style] = true -- + local lh = v_lineheight and asnumber_vx(v_lineheight) or false + -- ax = ax - x ay = ay - y -- local usedsize = v_size or defaultsize local usedscale = usedsize / defaultsize -- +-- todo: rotate : list of numbers +-- todo: lengthAdjust : spacing|spacingAndGlyphs +-- todo: textLength : scale to width +-- toto: font-size-adjust +-- toto: font-stretch +-- letter-spacing +-- word-spacing +-- writing-mode:lr-tb + -- -- local useddelta = d_x ~= 0 or d_y ~= 0 or false -- if useddelta then -- dx = validdelta(usedscale,dx) @@ -2758,20 +2861,18 @@ do end end -- + local hasa = ax ~= 0 or ay ~= 0 + if hasa then + -- we abuse the fact that flushing layers can be nested + t[#t+1] = f_set(ax or 0,ay or 0) + t[#t+1] = "{" + end for i=1,nt do local di = dt[i] if type(di) == "table" then -- when x or y then absolute else inline if #di.dt > 0 then - t[#t+1] = f_setlayer(ax,ay) - t[#t+1] = "{" - local ok = collect(tg,t,di,x,y,usedsize,usedscale,v_family) - if not ok then - t[#t] = nil - t[#t] = nil - else - t[#t+1] = "}" - end + collect(tg,t,di,x,y,usedsize,usedscale,v_family) end else -- check for preserve @@ -2785,44 +2886,57 @@ do if svghash then -- dx dy di = f_hashed(svghash[di]) - elseif tx or ty or tdx or tdy then - local txi, tyi, tdxi, tdyi - for i=1,#chars do - txi = tx and (tx [i] or txi ) - tyi = ty and (ty [i] or tyi ) - tdxi = tdx and (tdx[i] or tdxi) or 0 - tdyi = tdy and (tdy[i] or tdyi) or 0 - local dx = (txi and (txi - x) or 0) + tdxi - local dy = (tyi and (tyi - y) or 0) + tdyi - local ci = chars[i] - if ci == " " then - chars[i] = f_posspace(dx, dy) - elseif sensitive[ci] then - chars[i] = f_poscode(dx, dy, utfbyte(ci)) - else - chars[i] = f_poschar(dx, dy, ci) - end - end - di = "{" .. concat(chars) .. "}" else - -- this needs to be texescaped ! and even quotes and newlines - -- or we could register it but that's a bit tricky as we nest - -- and don't know what we can expect here - -- di = lpegmatch(p_texescape,di) or di - for i=1,#chars do - local ci = chars[i] - if ci == " " then - chars[i] = s_space - elseif sensitive[ci] then - chars[i] = f_code(utfbyte(chars[i])) - else - chars[i] = f_char(ci) + if tx or ty or tdx or tdy then + local txi, tyi, tdxi, tdyi + for i=1,#chars do + txi = tx and (tx [i] or txi ) + tyi = ty and (ty [i] or tyi ) + tdxi = tdx and (tdx[i] or tdxi) or 0 + tdyi = tdy and (tdy[i] or tdyi) or 0 + local dx = (txi and (txi - x) or 0) + tdxi + local dy = (tyi and (tyi - y) or 0) + tdyi + local ci = chars[i] + if ci == " " then + chars[i] = f_posspace(dx, dy) + elseif sensitive[ci] then + chars[i] = f_poscode(dx, dy, utfbyte(ci)) + else + chars[i] = f_poschar(dx, dy, ci) + end end + di = "{" .. concat(chars) .. "}" + t[#t+1] = di + else + -- this needs to be texescaped ! and even quotes and newlines + -- or we could register it but that's a bit tricky as we nest + -- and don't know what we can expect here + -- di = lpegmatch(p_texescape,di) or di + for i=1,#chars do + local ci = chars[i] + if ci == " " then + chars[i] = s_space + elseif sensitive[ci] then + chars[i] = f_code(utfbyte(chars[i])) + else + chars[i] = f_char(ci) + -- chars[i] = ci + end + end + di = concat(chars) + t[#t+1] = di end - di = concat(chars) end - t[#t+1] = di end + if hasa then + if t[#t] == "{" then + t[#t] = nil + t[#t] = nil + else + t[#t+1] = "}" + end + end + end -- if ecolored then @@ -2892,13 +3006,13 @@ do local ndy = #tdy -- local t = { } - t[#t+1] = s_startlayer + t[#t+1] = s_start if nx > 1 or ny > 1 or ndx > 1 or ndy > 1 then collect(tg,t,c,x,y,defaultsize,1,"serif",tx,ty,tdx,tdy) else collect(tg,t,c,x,y,defaultsize,1,"serif") end - t[#t+1] = s_stoplayer + t[#t+1] = s_stop t = concat(t) if x == 0 and y == 0 then t = f_text_simple_svg(anchor,t) @@ -3093,7 +3207,12 @@ do normalize, specification.remap ) - if trace_result then + if trace_result == "file" then + io.savedata( + tex.jobname .. "-svg-to-mp.tex", + "\\startMPpage[instance=doublefun]\n" .. concat(result,"\n") .. "\n\\stopMPpage\n" + ) + elseif trace_result then report("result graphic:\n %\n t",result) end if usedcolors and next(usedcolors) then diff --git a/tex/context/base/mkxl/node-aux.lmt b/tex/context/base/mkxl/node-aux.lmt index d952ec41b..27f248c58 100644 --- a/tex/context/base/mkxl/node-aux.lmt +++ b/tex/context/base/mkxl/node-aux.lmt @@ -56,6 +56,7 @@ local nextglyph = traversers.glyph local flush_node = nuts.flush local flush_list = nuts.flush_list local hpack_nodes = nuts.hpack +local vpack_nodes = nuts.vpack local unset_attribute = nuts.unset_attribute local first_glyph = nuts.first_glyph local copy_node = nuts.copy @@ -394,3 +395,6 @@ do end end + +function nodes.hpack(h,...) return tonode(hpack_nodes(tonut(h),...)) end +function nodes.vpack(h,...) return tonode(vpack_nodes(tonut(h),...)) end diff --git a/tex/context/base/mkxl/node-met.lmt b/tex/context/base/mkxl/node-met.lmt index a3f02d709..0186f2860 100644 --- a/tex/context/base/mkxl/node-met.lmt +++ b/tex/context/base/mkxl/node-met.lmt @@ -65,81 +65,57 @@ end -- We start with some helpers and provide all relevant basic functions in the -- node namespace as well. -nodes = nodes or { } -local nodes = nodes - -local nodecodes = nodes.nodecodes - -nodes.tostring = node.tostring or tostring -nodes.copy = node.copy -nodes.copy_node = node.copy -nodes.copy_list = node.copy_list -nodes.delete = node.delete -nodes.dimensions = node.dimensions -nodes.rangedimensions = node.rangedimensions -nodes.end_of_math = node.end_of_math -nodes.flush = node.flush_node -nodes.flush_node = node.flush_node -nodes.flush_list = node.flush_list -nodes.free = node.free -nodes.insert_after = node.insert_after -nodes.insert_before = node.insert_before -nodes.hpack = node.hpack -nodes.new = node.new -nodes.tail = node.tail -nodes.traverse = node.traverse -nodes.traverse_id = node.traverse_id -nodes.traverse_char = node.traverse_char -nodes.traverse_glyph = node.traverse_glyph -nodes.traverse_list = node.traverse_list -nodes.slide = node.slide -nodes.vpack = node.vpack -nodes.fields = node.fields -nodes.is_node = node.is_node -nodes.setglue = node.setglue -nodes.uses_font = node.uses_font - -nodes.first_glyph = node.first_glyph -nodes.has_glyph = node.has_glyph or node.first_glyph - -nodes.current_attributes = node.current_attributes or node.current_attr -nodes.has_field = node.has_field -nodes.last_node = node.last_node -nodes.usedlist = node.usedlist -nodes.protrusion_skippable = node.protrusion_skippable -nodes.check_discretionaries = node.check_discretionaries -nodes.write = node.write -nodes.flatten_discretionaries = node.flatten_discretionaries - -nodes.count = node.count -nodes.length = node.length - -nodes.has_attribute = node.has_attribute -nodes.set_attribute = node.set_attribute -nodes.find_attribute = node.find_attribute -nodes.unset_attribute = node.unset_attribute - -nodes.protect_glyph = node.protect_glyph -nodes.protect_glyphs = node.protect_glyphs -nodes.unprotect_glyph = node.unprotect_glyph -nodes.unprotect_glyphs = node.unprotect_glyphs -nodes.kerning = node.kerning -nodes.ligaturing = node.ligaturing -nodes.hyphenating = node.hyphenating -nodes.mlist_to_hlist = node.mlist_to_hlist - -nodes.effective_glue = node.effective_glue -nodes.getglue = node.getglue -nodes.setglue = node.setglue -nodes.is_zero_glue = node.is_zero_glue - -nodes.tonode = function(n) return n end -nodes.tonut = function(n) return n end +nodes = nodes or { } +local nodes = nodes + +local nodecodes = nodes.nodecodes + +nodes.copy = node.copy +nodes.copy_list = node.copy_list +nodes.copy_node = node.copy +nodes.current_attributes = node.current_attributes +nodes.remove = node.remove +nodes.fields = node.fields +nodes.flush = node.flush_node +nodes.flush_list = node.flush_list +nodes.flush_node = node.flush_node +nodes.get_attribute = node.get_attribute +nodes.has_attribute = node.has_attribute +nodes.has_field = node.has_field +nodes.insert_after = node.insert_after +nodes.insert_before = node.insert_before +nodes.is_node = node.is_node +nodes.new = node.new +nodes.set_attribute = node.set_attribute +nodes.tail = node.tail +nodes.tostring = node.tostring or tostring +nodes.traverse = node.traverse +nodes.traverse_id = node.traverse_id +nodes.unset_attribute = node.unset_attribute +nodes.write = node.write +nodes.usedlist = node.usedlist + +nodes.get_properties_table = node.get_properties_table +nodes.getproperty = node.getproperty +nodes.setproperty = node.setproperty + +-- nodes.usedlist", +-- nodes.inuse", +-- nodes.instock", +-- nodes.type", +-- nodes.types", +-- nodes.subtypes", +-- nodes.values", +-- nodes.id", +-- nodes.show", + +-- nodes.tonode = function(n) return n end +-- nodes.tonut = function(n) return n end -- These are never used in \CONTEXT, only as a gimmick in node operators -- so we keep them around. -- --- Fro nwo I keep them in \LMTX\ but they will go away! +-- Fot now I keep them in \LMTX\ but they will go away! local n_getfield = node.getfield local n_getattr = node.get_attribute @@ -324,10 +300,6 @@ function nodes.concat(list) -- consider tail instead of slide return head, tail end -function nodes.reference(n) - return n and tonut(n) or "<none>" -end - -- Here starts an experiment with metatables. Of course this only works with nodes -- wrapped in userdata with a metatable. -- @@ -559,29 +531,9 @@ metatable.__unm = function(head) return first end --- see node-nut.lua for more info on going nuts - --- if not gonuts then --- --- local nuts = { } --- nodes.nuts = nuts --- --- local function dummy(f) return f end --- --- nodes.vianuts = dummy --- nodes.vianodes = dummy --- --- for k, v in next, nodes do --- if type(v) == "function" then --- nuts[k] = v --- end --- end --- --- end - --- also handy +-- also handy n.. do we still need this ... needs an update anyway -local tonode = nodes.tonode +local tonode = node.direct.tonode local whatsit_code = nodecodes.whatsit local getfields = node.fields local sort = table.sort diff --git a/tex/context/base/mkxl/node-nut.lmt b/tex/context/base/mkxl/node-nut.lmt index 7ef087178..b9af5551d 100644 --- a/tex/context/base/mkxl/node-nut.lmt +++ b/tex/context/base/mkxl/node-nut.lmt @@ -82,6 +82,7 @@ local nuts = { getdirection = direct.getdirection, getdisc = direct.getdisc, getdiscretionary = direct.getdisc, + getdiscpart = direct.getdiscpart, getexpansion = direct.getexpansion, getfam = direct.getfam, getfield = direct.getfield, @@ -179,6 +180,7 @@ local nuts = { setdirection = direct.setdirection, setdisc = direct.setdisc, setdiscretionary = direct.setdisc, + setdiscpart = direct.setdiscpart, setexpansion = direct.setexpansion, setfam = direct.setfam, setfield = direct.setfield, diff --git a/tex/context/base/mkxl/spac-hor.mkxl b/tex/context/base/mkxl/spac-hor.mkxl index f64207a2c..25f469fc5 100644 --- a/tex/context/base/mkxl/spac-hor.mkxl +++ b/tex/context/base/mkxl/spac-hor.mkxl @@ -22,6 +22,7 @@ \bitwiseflip \normalizelinemode \parindentskipcode \bitwiseflip \normalizelinemode \normalizelinecode \bitwiseflip \normalizelinemode \clipwidthcode +\bitwiseflip \normalizelinemode \flattendiscretionariescode \let\v_spac_indentation_current\empty % amount/keyword diff --git a/tex/context/base/mkxl/strc-lst.mklx b/tex/context/base/mkxl/strc-lst.mklx index 049a0370e..2046be727 100644 --- a/tex/context/base/mkxl/strc-lst.mklx +++ b/tex/context/base/mkxl/strc-lst.mklx @@ -116,17 +116,6 @@ \installcorenamespace {listlocations} -% \permanent\protected\def\doifelseinlistentry#1% -% {\ifcsname\??listlocations#1\endcsname -% \ifnum\lastnamedcs=\structurelistlocation\relax -% \doubleexpandafter\firstoftwoarguments -% \else -% \doubleexpandafter\secondoftwoarguments -% \fi -% \else -% \expandafter\secondoftwoarguments -% \fi} - \permanent\protected\def\doifelseinlistentry#1% {\unless\ifcsname\??listlocations#1\endcsname \expandafter\secondoftwoarguments @@ -236,6 +225,22 @@ \tolerant\def\strc_lists_write_to_nop[#settings]#:#first#second% {\endgroup} % \strc_lists_inject_nop[][] +% \starttyping +% \installstructurelistprocessor{chapter:userdata} +% {\startlinecorrection[blank] +% \hfill \inframed{you really need to look at \structurelistuservariable{pagenumber}}% +% \stoplinecorrection} +% +% \starttext +% \placelist[chapter] +% \chapter{one} +% \writebetweenlist[chapter][location=here]{\blank page 4\blank} +% \writedatatolist[chapter][location=here][pagenumber=4] +% \writetolist[chapter]{}{It's a test} +% \chapter{two} +% \stoptext +% \stoptyping + %D When placing a list either one or a set can be giving. This makes it possible to %D flush for instance an nested (or merged) table of contents. Keep in mind that %D placing a list is what we do most (think of tables of contents, figures, etc.\ @@ -320,9 +325,9 @@ \permanent\tolerant\protected\def\definecombinedlist[#tag]#spacer[#list]#spacer[#settings]% {\definelist[#tag][\c!criterium=\v!local,\c!reference=,\c!alternative=,\c!list={#list},#settings]% inherits from root - \frozen\instance\setvalue{\e!setup#tag\e!endsetup}{\setupcombinedlist[#tag]}% - \frozen\instance\setvalue{\e!place#tag}{\placecombinedlist[#tag]}% - \frozen\instance\setvalue{\e!complete#tag}{\strc_lists_combined_complete[#tag]}} + \frozen\instance\defcsname\e!setup#tag\e!endsetup\endcsname{\setupcombinedlist[#tag]}% + \frozen\instance\defcsname\e!place#tag\endcsname{\placecombinedlist[#tag]}% + \frozen\instance\defcsname\e!complete#tag\endcsname{\strc_lists_combined_complete[#tag]}} \permanent\tolerant\protected\def\setupcombinedlist[#tag]#spacer[#settings]% {\ifarguments\or\or @@ -352,9 +357,9 @@ \installcorenamespace {listpagenumber} -\setvalue{\??listpagenumber\v!always }{\settrue\c_lists_show_page\settrue\c_lists_has_page} -\setvalue{\??listpagenumber\v!yes }{\settrue\c_lists_show_page} -\setvalue{\??listpagenumber\s!realpage}{\settrue\c_lists_show_page\settrue\c_lists_show_realpage} +\defcsname\??listpagenumber\v!always \endcsname{\settrue\c_lists_show_page\settrue\c_lists_has_page} +\defcsname\??listpagenumber\v!yes \endcsname{\settrue\c_lists_show_page} +\defcsname\??listpagenumber\s!realpage\endcsname{\settrue\c_lists_show_page\settrue\c_lists_show_realpage} \def\strc_lists_process_pagenumber#1% {\begincsname\??listpagenumber#1\endcsname} @@ -493,7 +498,7 @@ {\expandafter\normaldef\csname\??structurelistprocessor#tag\endcsname{#meaning}} \permanent\def\usestructurelistprocessor#tag% - {\csname\??structurelistprocessor#tag\endcsname} + {\begincsname\??structurelistprocessor#tag\endcsname} \aliased\let\dotaglistlocation\relax @@ -549,7 +554,7 @@ % example of usage elsewhere: % -% \installstructcurelistprocessor{pubs:userdata} +% \installstructurelistprocessor{pubs:userdata} % {\clf_listuserdata{\currentlist}\currentlistindex{bibref}} %D List symbols are used in interactive documents where no numbers are used but @@ -631,22 +636,22 @@ \fi \endgroup} -\letvalue{\??listsymbollabels\s!unknown}\strc_lists_symbol_default +\letcsname\??listsymbollabels\s!unknown\endcsname\strc_lists_symbol_default -\setvalue{\??listsymbollabels}% default (empty) +\defcsname\??listsymbollabels\endcsname % default (empty) {\listparameter\c!starter \currentlistentrynumber \listparameter\c!stopper} -\setvalue{\??listsymbollabels\v!no}% also default +\defcsname\??listsymbollabels\v!no\endcsname % also default {\listparameter\c!starter \currentlistentrynumber \listparameter\c!stopper} -\setvalue{\??listsymbollabels\v!none}% real minimal (as suggested by WS) +\defcsname\??listsymbollabels\v!none\endcsname % real minimal (as suggested by WS) {\currentlistentrynumber} -\setvalue{\??listsymbollabels\v!yes}% auto (use value stored in tuc file) +\defcsname\??listsymbollabels\v!yes\endcsname % auto (use value stored in tuc file) {\edef\currentlistlabel{\clf_listlabel\currentlistindex{\currentlistlabel}}% \leftlabeltext\currentlistlabel \listparameter\c!starter @@ -1418,14 +1423,14 @@ \installcorenamespace{listinteractions} -\letvalue{\??listinteractions\v!number }\v!number -\letvalue{\??listinteractions\v!sectionnumber}\v!number -\letvalue{\??listinteractions\v!text }\v!text -\letvalue{\??listinteractions\v!title }\v!text -\letvalue{\??listinteractions\v!page }\v!pagenumber -\letvalue{\??listinteractions\v!pagenumber }\v!pagenumber -\letvalue{\??listinteractions\v!all }\v!all -\letvalue{\??listinteractions\v!yes }\v!all +\letcsname\??listinteractions\v!number \endcsname\v!number +\letcsname\??listinteractions\v!sectionnumber\endcsname\v!number +\letcsname\??listinteractions\v!text \endcsname\v!text +\letcsname\??listinteractions\v!title \endcsname\v!text +\letcsname\??listinteractions\v!page \endcsname\v!pagenumber +\letcsname\??listinteractions\v!pagenumber \endcsname\v!pagenumber +\letcsname\??listinteractions\v!all \endcsname\v!all +\letcsname\??listinteractions\v!yes \endcsname\v!all \permanent\def\listboxproperties {\strc_lists_get_reference_attribute} \permanent\def\listrenderingsetup {\the\t_lists_every_renderingtext} diff --git a/tex/context/base/mkxl/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl index 0b90eecba..5399da133 100644 --- a/tex/context/base/mkxl/strc-mat.mkxl +++ b/tex/context/base/mkxl/strc-mat.mkxl @@ -195,13 +195,17 @@ \protected\def\strc_formulas_store_number#1#2#3#4#5% ref, todo:str, \sync % todo: title etc (like float) {\settrue\c_strc_formulas_handle_number + \edef\xx{\formulaparameter\c!list}% \strc_counters_register_component {formula}% \setupcurrentformula \formulaparameter \detokenizedformulaparameter \relax \relax \relax [\c!name=\v!formula,\s!counter=\v!formula,% \s!hascaption=\v!yes,\s!hastitle=\v!yes,\s!hasnumber=\v!yes,%\s!haslevel=#6,% - \c!reference=#1,\c!title=\namedformulaentry,\c!bookmark=]% + \c!reference=#1,% + \c!title=\namedformulaentry, + \c!list=\currentplaceformulalist, + \c!bookmark=\currentplaceformulabookmark]% [#2]% \glet\namedformulaentry\empty % \relax \glet#3\m_strc_counters_last_registered_index @@ -615,14 +619,14 @@ \installcorenamespace{mathdisplayspacemodel} -\setvalue{\??mathdisplayspacemodel\v!before:1}% old +\defcsname\??mathdisplayspacemodel\v!before:1\endcsname % old {\ifx\p_spacebefore\v!none % nothing \else \directvspacing\p_spacebefore \fi} -\setvalue{\??mathdisplayspacemodel\v!after:1}% old +\defcsname\??mathdisplayspacemodel\v!after:1\endcsname % old {\prevdepth .5\strutdp \edef\p_spaceafter{\formulaparameter\c!spaceafter}% \ifx\p_spaceafter\v!none @@ -631,7 +635,7 @@ \directvspacing\p_spaceafter \fi} -\setvalue{\??mathdisplayspacemodel\v!before:2}% old +\defcsname\??mathdisplayspacemodel\v!before:2\endcsname % old {\ifx\p_spacebefore\v!none % nothing \else @@ -639,7 +643,7 @@ \fi \prevdepth-\maxdimen} % texbook pagina 79-80 -\setvalue{\??mathdisplayspacemodel\v!after:2}% old +\defcsname\??mathdisplayspacemodel\v!after:2\endcsname % old {\prevdepth\lineheight \edef\p_spaceafter{\formulaparameter\c!spaceafter}% \ifx\p_spaceafter\v!none @@ -648,7 +652,7 @@ \directvspacing\p_spaceafter \fi} -\setvalue{\??mathdisplayspacemodel\v!before:3}% +\defcsname\??mathdisplayspacemodel\v!before:3\endcsname {% not ok, try \stopformula\par\startformula vs \stopformula\startformula \let\m_spacebefore\empty \ifvmode @@ -684,7 +688,7 @@ \fi \fi} -\setvalue{\??mathdisplayspacemodel\v!after:3}% +\defcsname\??mathdisplayspacemodel\v!after:3\endcsname {\prevdepth\strutdp % \directvspacing\v!depth \ifx\p_spaceafter\v!none % nothing @@ -696,7 +700,7 @@ \newconditional\c_math_model_four_indeed -\setvalue{\??mathdisplayspacemodel\v!before:4}% +\defcsname\??mathdisplayspacemodel\v!before:4\endcsname {% not ok, try \stopformula\par\startformula vs \stopformula\startformula \ifvmode \ifinner @@ -717,7 +721,7 @@ \csname\??mathdisplayspacemodel\v!before:3\endcsname \fi} -\setvalue{\??mathdisplayspacemodel\v!after:4}% +\defcsname\??mathdisplayspacemodel\v!after:4\endcsname {\ifconditional\c_math_model_four_indeed \setfalse\c_math_model_four_indeed \forcestrutdepth @@ -785,9 +789,6 @@ \relax \hsize\displaywidth} % new, else overfull in itemize -\protected\def\strc_formulas_start_formula#1% - {\dodoubleempty\strc_formulas_start_formula_indeed[#1]} - % \newskip\formulastrutht % \newskip\formulastrutdp @@ -798,35 +799,35 @@ %D %D \typebuffer \getbuffer -\setvalue{\??formulaoption\v!packed}% +\defcsname\??formulaoption\v!packed\endcsname {\c_strc_formulas_space_model\zerocount} -\setvalue{\??formulaoption\v!tight}% +\defcsname\??formulaoption\v!tight\endcsname {\settrue\c_strc_formulas_tight} -\setvalue{\??formulaoption\v!middle}% +\defcsname\??formulaoption\v!middle\endcsname {\d_strc_formulas_display_skip_left \zeropoint \d_strc_formulas_display_skip_right\zeropoint} -\setvalue{\??formulaoption\v!depth}% +\defcsname\??formulaoption\v!depth\endcsname {\c_strc_formulas_space_model\plusfour} -\setvalue{\??formulaoption\v!line}% +\defcsname\??formulaoption\v!line\endcsname {\ifgridsnapping \setformulaparameter\c!grid{\v!math:\v!line}% \fi} -\setvalue{\??formulaoption\v!halfline}% +\defcsname\??formulaoption\v!halfline\endcsname {\ifgridsnapping \setformulaparameter\c!grid{\v!math:\v!halfline}% \fi} -\setvalue{\??formulaoption-\v!line}% +\defcsname\??formulaoption-\v!line\endcsname {\ifgridsnapping \setformulaparameter\c!grid{\v!math:-\v!line}% \fi} -\setvalue{\??formulaoption-\v!halfline}% +\defcsname\??formulaoption-\v!halfline\endcsname {\ifgridsnapping \setformulaparameter\c!grid{\v!math:-\v!halfline}% \fi} @@ -885,7 +886,12 @@ \enforced\let\breakhere\strc_math_break_here \to \everymathematics -\protected\def\strc_formulas_start_formula_indeed[#1][#2]% setting leftskip adaption is slow ! +% \protected\def\strc_formulas_start_formula#1% +% {\strc_formulas_start_formula_indeed[#1]} +% +% \tolerant\protected\def\strc_formulas_start_formula[#1]#*[#2]% setting leftskip adaption is slow ! + +\tolerant\protected\def\strc_formulas_start_formula#1#:#*[#2]% setting leftskip adaption is slow ! {\ifhmode \par \fi @@ -1207,7 +1213,7 @@ \expandafter\strc_formulas_start_place_nop \fi[#1]} -\def\strc_formulas_start_place_yes[#1]% +\def\strc_formulas_start_place_yes[#1]% todo {\doifassignmentelse{#1}\strc_formulas_start_place_parameters\strc_formulas_start_place_reference[#1]} \def\strc_formulas_start_place_nop[#1]% @@ -1221,13 +1227,20 @@ %\doifelsenextbgroup\strc_formulas_place_yes\strc_formulas_place_nop} % [ref]{} \strc_formulas_place_nop} -\def\strc_formulas_start_place_parameters[#1]% +\mutable\let\currentplaceformulabookmark\empty +\mutable\let\currentplaceformulalist \empty + +\def\strc_formulas_start_place_parameters[#1]% maybe a dedicated setup handler {\letdummyparameter\c!title \empty \letdummyparameter\c!reference\empty + \letdummyparameter\c!bookmark \empty + \letdummyparameter\c!list \empty \letdummyparameter\c!suffix \empty \getdummyparameters[#1]% \edef\currentplaceformulatitle {\dummyparameter\c!title}% \edef\currentplaceformulareference{\dummyparameter\c!reference}% + \edef\currentplaceformulabookmark {\dummyparameter\c!bookmark}% + \edef\currentplaceformulalist {\dummyparameter\c!list}% \edef\currentplaceformulasuffix {\dummyparameter\c!suffix}% \ifempty\currentplaceformulatitle\else \normalexpanded{\setformulalistentry{\currentplaceformulatitle}}% diff --git a/tex/context/base/mkxl/typo-hid.lmt b/tex/context/base/mkxl/typo-hid.lmt index 9cc77ffac..e3b7567d9 100644 --- a/tex/context/base/mkxl/typo-hid.lmt +++ b/tex/context/base/mkxl/typo-hid.lmt @@ -1,6 +1,6 @@ -if not modules then modules = { } end modules ['typo-krn'] = { +if not modules then modules = { } end modules ['typo-hid'] = { version = 1.001, - comment = "companion to typo-krn.mkiv", + comment = "companion to typo-hid.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/tex/context/base/mkxl/typo-hid.mkxl b/tex/context/base/mkxl/typo-hid.mkxl index cf9759c85..8ee953cc1 100644 --- a/tex/context/base/mkxl/typo-hid.mkxl +++ b/tex/context/base/mkxl/typo-hid.mkxl @@ -1,5 +1,5 @@ %D \module -%D [ file=typo-krn, +%D [ file=typo-hid, %D version=2021.03.15, % based on old code lying around %D title=\CONTEXT\ Typesetting Macros, %D subtitle=Hiding, diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index b7ee64864..8987234fe 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 : 2021-03-17 17:43 +-- merge date : 2021-03-20 01:03 do -- begin closure to overcome local limits and interference |