diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-05-31 09:46:19 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-05-31 09:46:19 +0200 |
commit | a274872832cdd1e71ce4b019858c61c5a77c6b98 (patch) | |
tree | 31aac20468007968eb094db54e530a00a7fec5ff | |
parent | 66f653890a45d1275826d56798071a97468d88be (diff) | |
download | context-a274872832cdd1e71ce4b019858c61c5a77c6b98.tar.gz |
2016-05-31 09:07:00
65 files changed, 1355 insertions, 716 deletions
diff --git a/doc/context/documents/general/manuals/luatex.pdf b/doc/context/documents/general/manuals/luatex.pdf Binary files differindex 23464f212..8a178e0b2 100644 --- a/doc/context/documents/general/manuals/luatex.pdf +++ b/doc/context/documents/general/manuals/luatex.pdf diff --git a/doc/context/sources/general/manuals/luatex/luatex-languages.tex b/doc/context/sources/general/manuals/luatex/luatex-languages.tex index 19e3f7b14..83969acef 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-languages.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-languages.tex @@ -147,6 +147,38 @@ hyphenation happens is (normally) when the paragraph or a horizontal box is constructed. When \type {\savinghyphcodes} was zero when the language got initialized you start out with nothing, otherwise you already have a set. +When a \type {\hjcode} is larger than $0$ but smaller than $32$ is indicates the +to be used length. In the following example we map a character (\type {x}) onto +another one in the patterns and tell the engine that \type {œ} counts as one +character. Because traditionally zero itself is reserved for inhibiting +hyphenation, a value of $32$ counts as zero. + +\starttyping +% assuming french patterns: +foobar % foo-bar + +\hjcode`x=`o + +fxxbar % fxx-bar + +\lefthyphenmin3 + +œdipus % œdi-pus + +\lefthyphenmin4 + +œdipus % œdipus + +\hjcode`œ=2 + +œdipus % œdi-pus + +\hjcode`i=32 +\hjcode`d=32 + +œdipus % œdipus +\stoptyping + Carrying all this information with each glyph would give too much overhead and also make the process of setting up thee codes more complex. A solution with \type {hjcode} sets was considered but rejected because in practice the current diff --git a/doc/context/sources/general/manuals/luatex/luatex-nodes.tex b/doc/context/sources/general/manuals/luatex/luatex-nodes.tex index b7b81b5a6..32e641789 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-nodes.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-nodes.tex @@ -595,7 +595,7 @@ Whatsit nodes come in many subtypes that you can ask for by running \stopluacode . % period -\subsubsection{front|-|end whatits} +\subsubsection{front|-|end whatsits} \subsubsubsection{open whatsits} @@ -625,7 +625,7 @@ Whatsit nodes come in many subtypes that you can ask for by running \NC stream \NC number \NC \TEX's stream id number \NC \NR \stoptabulate -\subsubsubsection{user_defined whatits} +\subsubsubsection{user_defined whatsits} User|-|defined whatsit nodes can only be created and handled from \LUA\ code. In effect, they are an extension to the extension mechanism. The \LUATEX\ engine @@ -677,9 +677,9 @@ The difference between \type {data} and \type {string} is that on assignment, th \type {data} field is converted to a token list, cf. use as \type {\latelua}. The \type {string} version is treated as a literal string. -\subsubsection{\DVI\ backend whatits} +\subsubsection{\DVI\ backend whatsits} -\subsubsection{special whatits} +\subsubsection{special whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -687,9 +687,9 @@ The difference between \type {data} and \type {string} is that on assignment, th \NC data \NC string \NC the \type {\special} information \NC \NR \stoptabulate -\subsubsection{\PDF\ backend whatits} +\subsubsection{\PDF\ backend whatsits} -\subsubsubsection{pdf_literal whatits} +\subsubsubsection{pdf_literal whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -707,7 +707,7 @@ Possible mode values are: \NC 2 \NC direct \NC \NR \stoptabulate -\subsubsubsection{pdf_refobj whatits} +\subsubsubsection{pdf_refobj whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -715,7 +715,7 @@ Possible mode values are: \NC objnum \NC number \NC the referenced \PDF\ object number \NC \NR \stoptabulate -\subsubsubsection{pdf_annot whatits} +\subsubsubsection{pdf_annot whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -727,7 +727,7 @@ Possible mode values are: \NC data \NC string \NC the annotation data \NC \NR \stoptabulate -\subsubsubsection{pdf_start_link whatits} +\subsubsubsection{pdf_start_link whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -740,14 +740,14 @@ Possible mode values are: \NC action \NC node \NC the action to perform \NC \NR \stoptabulate -\subsubsubsection{pdf_end_link whatits} +\subsubsubsection{pdf_end_link whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR \NC attr \NC node \NC \NC \NR \stoptabulate -\subsubsubsection{pdf_dest whatits} +\subsubsubsection{pdf_dest whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -763,7 +763,7 @@ Possible mode values are: \NC objnum \NC number \NC the \PDF\ object number \NC \NR \stoptabulate -\subsubsubsection{pdf_action whatits} +\subsubsubsection{pdf_action whatsits} These are a special kind of item that only appears inside \PDF\ start link objects. @@ -795,7 +795,7 @@ Valid window types are: \NC 2 \NC nonew \NC \NR \stoptabulate -\subsubsubsection{pdf_thread whatits} +\subsubsubsection{pdf_thread whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -809,7 +809,7 @@ Valid window types are: \NC thread_attr \NC number \NC extra thread information \NC \NR \stoptabulate -\subsubsubsection{pdf_start_thread whatits} +\subsubsubsection{pdf_start_thread whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -823,14 +823,14 @@ Valid window types are: \NC thread_attr \NC number \NC extra thread information \NC \NR \stoptabulate -\subsubsubsection{pdf_end_thread whatits} +\subsubsubsection{pdf_end_thread whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR \NC attr \NC node \NC \NC \NR \stoptabulate -\subsubsubsection{pdf_colorstack whatits} +\subsubsubsection{pdf_colorstack whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -840,7 +840,7 @@ Valid window types are: \NC data \NC string \NC data \NC \NR \stoptabulate -\subsubsubsection{pdf_setmatrix whatits} +\subsubsubsection{pdf_setmatrix whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR @@ -848,14 +848,14 @@ Valid window types are: \NC data \NC string \NC data \NC \NR \stoptabulate -\subsubsubsection{pdf_save whatits} +\subsubsubsection{pdf_save whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR \NC attr \NC node \NC list of attributes \NC \NR \stoptabulate -\subsubsubsection{pdf_restore whatits} +\subsubsubsection{pdf_restore whatsits} \starttabulate[|lT|l|p|] \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR diff --git a/metapost/context/base/mpiv/mp-abck.mpiv b/metapost/context/base/mpiv/mp-abck.mpiv index abd7d8848..68706b1d9 100644 --- a/metapost/context/base/mpiv/mp-abck.mpiv +++ b/metapost/context/base/mpiv/mp-abck.mpiv @@ -267,3 +267,41 @@ enddef ; def anchor_box (expr n,x,y,w,h,d) = currentpicture := currentpicture shifted (-x,-y) ; enddef ; + +vardef shaped (suffix p) = + save l ; pair l[] ; + save r ; pair r[] ; + save i ; i := 1 ; + save n ; n := 0 ; + forever : + exitif unknown p[i] ; + n := n + 1 ; + l[n] := ulcorner p[i] ; + r[n] := urcorner p[i] ; + n := n + 1 ; + l[n] := llcorner p[i] ; + r[n] := lrcorner p[i] ; + i := i + 1 ; + endfor ; + for i = 3 upto n : + if xpart r[i] < xpart r[i-1] : + r[i] := (xpart r[i],ypart r[i-1]) ; + elseif xpart r[i] > xpart r[i-1] : + r[i] := (xpart r[i],ypart r[i-1]) ; + fi ; + if xpart l[i] < xpart l[i-1] : + l[i] := (xpart l[i],ypart l[i-1]) ; + elseif xpart l[i] > xpart l[i-1] : + l[i] := (xpart l[i],ypart l[i-1]) ; + fi ; + endfor ; + if n > 0 : + simplified ( + for i = 1 upto n : r[i] -- endfor + for i = n downto 1 : l[i] -- endfor + cycle + ) + else : + origin -- cycle + fi +enddef ; diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index 326342b70..c4f447d41 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -842,7 +842,7 @@ vardef mfun_do_outline_text_f (expr n, x, y) (text t) = for i=t : mfun_do_outline_n := mfun_do_outline_n + 1 ; if mfun_do_outline_n = n : - fill i shifted(x,y) mfun_do_outline_options_f + fill i shifted(x,y) mfun_do_outline_options_f withpen pencircle scaled 0 else : nofill i shifted(x,y) fi ; diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua index 0c3224fe0..995fb6634 100644 --- a/scripts/context/lua/mtx-fonts.lua +++ b/scripts/context/lua/mtx-fonts.lua @@ -14,8 +14,8 @@ local suffix, addsuffix, removesuffix, replacesuffix = file.suffix, file.addsuff local nameonly, basename, joinpath, collapsepath = file.nameonly, file.basename, file.join, file.collapsepath local lower = string.lower -local otfversion = 2.825 -local otlversion = 3.020 +local otfversion = 2.826 +local otlversion = 3.021 local helpinfo = [[ <?xml version="1.0"?> diff --git a/scripts/context/lua/mtx-patterns.lua b/scripts/context/lua/mtx-patterns.lua index e8d4d3e65..d16912e4f 100644 --- a/scripts/context/lua/mtx-patterns.lua +++ b/scripts/context/lua/mtx-patterns.lua @@ -694,16 +694,37 @@ end -- -- use this call: -- --- mtxrun --script pattern --convert --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns/txt --destination=e:/tmp/patterns - --- copy /Y *.hyp e:\tex-context\tex\texmf-context\tex\context\patterns --- copy /Y *.pat e:\tex-context\tex\texmf-context\tex\context\patterns --- copy /Y *.rme e:\tex-context\tex\texmf-context\tex\context\patterns --- copy /Y *.lua e:\tex-context\tex\texmf-context\tex\context\patterns - --- move /Y *.hyp e:\tex-context\tex\texmf-mine\tex\context\patterns --- move /Y *.pat e:\tex-context\tex\texmf-mine\tex\context\patterns --- move /Y *.rme e:\tex-context\tex\texmf-mine\tex\context\patterns --- move /Y *.lua e:\tex-context\tex\texmf-mine\tex\context\patterns - +-- setlocal +-- +-- rem tugsvn checkout: +-- +-- set patternsroot=c:/data/develop/svn-hyphen/trunk +-- +-- rem github checkout: +-- +-- set patternsroot=c:/data/repositories/tex-hyphen +-- +-- del /q c:\data\develop\tex-context\tex\texmf-local\tex\context\patterns\* +-- del /q c:\data\develop\tex-context\tex\texmf-mine\tex\context\patterns\* +-- del /q c:\data\develop\tex-context\tex\texmf-context\tex\context\patterns\* +-- +-- mtxrun --script pattern --convert --path=%patternsroot%/hyph-utf8/tex/generic/hyph-utf8/patterns/txt --destination=c:/data/develop/tmp/patterns +-- +-- copy /Y lang*.hyp c:\data\develop\tex-context\tex\texmf-context\tex\context\patterns +-- copy /Y lang*.pat c:\data\develop\tex-context\tex\texmf-context\tex\context\patterns +-- copy /Y lang*.rme c:\data\develop\tex-context\tex\texmf-context\tex\context\patterns +-- copy /Y lang*.lua c:\data\develop\tex-context\tex\texmf-context\tex\context\patterns +-- +-- move /Y lang*.hyp c:\data\develop\tex-context\tex\texmf-mine\tex\context\patterns +-- move /Y lang*.pat c:\data\develop\tex-context\tex\texmf-mine\tex\context\patterns +-- move /Y lang*.rme c:\data\develop\tex-context\tex\texmf-mine\tex\context\patterns +-- move /Y lang*.lua c:\data\develop\tex-context\tex\texmf-mine\tex\context\patterns +-- -- mtxrun --script pattern --words --update word-th.lua --compress +-- +-- copy /Y word*.lua c:\data\develop\tex-context\tex\texmf-context\tex\context\patterns +-- move /Y word*.lua c:\data\develop\tex-context\tex\texmf-mine\tex\context\patterns +-- +-- mtxrun --generate +-- +-- endlocal diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 3f6357149..11024640d 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkiv/anch-bar.mkiv b/tex/context/base/mkiv/anch-bar.mkiv index b5df21a07..c58d48abd 100644 --- a/tex/context/base/mkiv/anch-bar.mkiv +++ b/tex/context/base/mkiv/anch-bar.mkiv @@ -15,8 +15,10 @@ \unprotect -%D We will implement a sidebar mechanism using the -%D functionality from \type {core-pos}. +%D This can be done better now ... + +%D We will implement a sidebar mechanism using the functionality from +%D \type {core-pos}. %D %D \starttyping %D \definesidebar[whow][rulecolor=green,distance=0pt] diff --git a/tex/context/base/mkiv/anch-pos.lua b/tex/context/base/mkiv/anch-pos.lua index d59a91cad..77816111d 100644 --- a/tex/context/base/mkiv/anch-pos.lua +++ b/tex/context/base/mkiv/anch-pos.lua @@ -448,7 +448,7 @@ local function markregionbox(n,tag,correct) -- correct needs checking -- local push = new_latelua(f_b_region(tag)) -- local pop = new_latelua(f_e_region(tostring(correct))) local push = new_latelua(function() b_region(tag) end) - local pop = new_latelua(function() e_region(tostring(correct)) end) + local pop = new_latelua(function() e_region(correct) end) -- maybe we should construct a hbox first (needs experimenting) so that we can avoid some at the tex end local head = getlist(box) if head then diff --git a/tex/context/base/mkiv/buff-ini.lua b/tex/context/base/mkiv/buff-ini.lua index 499e43f87..80272c1bf 100644 --- a/tex/context/base/mkiv/buff-ini.lua +++ b/tex/context/base/mkiv/buff-ini.lua @@ -494,7 +494,9 @@ local function runbuffer(name,encapsulate) registertempfile(addsuffix(tag,"tmp")) -- to be sure registertempfile(addsuffix(tag,"pdf")) end - newhashes = { } + newhashes = { + version = environment.version, + } job.datasets.setdata { name = "typeset buffers", tag = "hashes", @@ -518,7 +520,7 @@ local function runbuffer(name,encapsulate) -- if newhashes[hash] then -- done - elseif not oldhashes[hash] or not lfs.isfile(resultname) then + elseif not oldhashes[hash] or oldhashes.version ~= newhashes.version or not lfs.isfile(resultname) then if trace_run then report_typeset("changes in %a, processing forced",name) end diff --git a/tex/context/base/mkiv/char-def.lua b/tex/context/base/mkiv/char-def.lua index f112f2b67..98882b561 100644 --- a/tex/context/base/mkiv/char-def.lua +++ b/tex/context/base/mkiv/char-def.lua @@ -227051,4 +227051,4 @@ characters.data={ linebreak="cm", unicodeslot=0xE007F, }, -}
\ No newline at end of file +} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 8a4d05a05..4c62d968e 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{2016.05.22 15:18} +\newcontextversion{2016.05.31 09:02} %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-todo.tex b/tex/context/base/mkiv/context-todo.tex index 0cbd94814..0e69b3df8 100644 --- a/tex/context/base/mkiv/context-todo.tex +++ b/tex/context/base/mkiv/context-todo.tex @@ -26,9 +26,6 @@ {texlang.w} and also store the \type {*mins} \stopitem \startitem - get rid of \type {temp} node in hyphenator i.e. postpone to when needed - \stopitem - \startitem remove local par in head of line when done with linebreak \stopitem \startitem @@ -66,7 +63,7 @@ reorganize position data (more subtables) \stopitem \startitem - use \type {\matheqnogapstep}, \type {\Ustack}, \type {\mathscriptsmode}, \ + use \type {\matheqnogapstep}, \type {\Ustack}, \type {\mathscriptsmode}, \type {\mathdisplayskipmode} and other new math primitives \stopitem \stopitemize diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index c2a0d9e43..66946af45 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.05.22 15:18} +\edef\contextversion{2016.05.31 09:02} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-con.lua b/tex/context/base/mkiv/font-con.lua index 45ecdd6c8..367f8078e 100644 --- a/tex/context/base/mkiv/font-con.lua +++ b/tex/context/base/mkiv/font-con.lua @@ -337,6 +337,20 @@ function constructors.enhanceparameters(parameters) } end +local function mathkerns(v,vdelta) + local k = { } + for i=1,#v do + local entry = v[i] + local height = entry.height + local kern = entry.kern + k[i] = { + height = height and vdelta*height or 0, + kern = kern and vdelta*kern or 0, + } + end + return k +end + function constructors.scale(tfmdata,specification) local target = { } -- the new table -- @@ -748,22 +762,15 @@ function constructors.scale(tfmdata,specification) chr.top_accent = vdelta*va end if stackmath then - local mk = character.mathkerns -- not in math ? + local mk = character.mathkerns if mk then - local kerns = { } - local v = mk.top_right if v then local k = { } for i=1,#v do local vi = v[i] - k[i] = { height = vdelta*vi.height, kern = vdelta*vi.kern } - end kerns.top_right = k end - local v = mk.top_left if v then local k = { } for i=1,#v do local vi = v[i] - k[i] = { height = vdelta*vi.height, kern = vdelta*vi.kern } - end kerns.top_left = k end - local v = mk.bottom_left if v then local k = { } for i=1,#v do local vi = v[i] - k[i] = { height = vdelta*vi.height, kern = vdelta*vi.kern } - end kerns.bottom_left = k end - local v = mk.bottom_right if v then local k = { } for i=1,#v do local vi = v[i] - k[i] = { height = vdelta*vi.height, kern = vdelta*vi.kern } - end kerns.bottom_right = k end - chr.mathkern = kerns -- singular -> should be patched in luatex ! + local tr, tl, br, bl = mk.topright, mk.topleft, mk.bottomright, mk.bottomleft + chr.mathkern = { -- singular -> should be patched in luatex ! + top_right = tr and mathkerns(tr,vdelta) or nil, + top_left = tl and mathkerns(tl,vdelta) or nil, + bottom_right = br and mathkerns(br,vdelta) or nil, + bottom_left = bl and mathkerns(bl,vdelta) or nil, + } end end if hasitalics then diff --git a/tex/context/base/mkiv/font-dsp.lua b/tex/context/base/mkiv/font-dsp.lua index e35d6da11..37ae16657 100644 --- a/tex/context/base/mkiv/font-dsp.lua +++ b/tex/context/base/mkiv/font-dsp.lua @@ -715,6 +715,8 @@ function gsubhandlers.single(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofg end end +-- we see coverage format 0x300 in some old ms fonts + local function sethandler(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,what) local tableoffset = lookupoffset + offset setposition(f,tableoffset) @@ -1598,6 +1600,14 @@ do local reported = { } + local function report_issue(i,what,sequence,kind) + local name = sequence.name + if not reported[name] then + report("rule %i in %s lookup %a has %s lookups",i,what,name,kind) + reported[name] = true + end + end + for i=lastsequence+1,nofsequences do local sequence = sequences[i] local steps = sequence.steps @@ -1609,18 +1619,10 @@ do local rule = rules[i] local rlookups = rule.lookups if not rlookups then - local name = sequence.name - if not reported[name] then - report("rule %i in %s lookup %a has %s lookups",i,what,name,"no") - reported[name] = true - end + report_issue(i,what,sequence,"no") elseif not next(rlookups) then - local name = sequence.name - if not reported[name] then - -- can be ok as it aborts a chain sequence - report("rule %i in %s lookup %a has %s lookups",i,what,name,"empty") - reported[name] = true - end + -- can be ok as it aborts a chain sequence + report_issue(i,what,sequence,"empty") rule.lookups = nil else for index, lookupid in sortedhash(rlookups) do -- nicer @@ -1628,23 +1630,36 @@ do if not h then -- here we have a lookup that is used independent as well -- as in another one - nofsublookups = nofsublookups + 1 - -- report("registering %i as sublookup %i",lookupid,nofsublookups) - local d = lookups[lookupid].done - h = { - index = nofsublookups, -- handy for tracing - name = f_lookupname(lookupprefix,"d",lookupid+lookupidoffset), - derived = true, -- handy for tracing - steps = d.steps, - nofsteps = d.nofsteps, - type = d.lookuptype, - markclass = d.markclass or nil, - flags = d.flags, - -- chain = d.chain, - } - sublookuplist[nofsublookups] = h - sublookuphash[lookupid] = nofsublookups - sublookupcheck[lookupid] = 1 + local lookup = lookups[lookupid] + if lookup then + local d = lookup.done + if d then + nofsublookups = nofsublookups + 1 + -- report("registering %i as sublookup %i",lookupid,nofsublookups) + h = { + index = nofsublookups, -- handy for tracing + name = f_lookupname(lookupprefix,"d",lookupid+lookupidoffset), + derived = true, -- handy for tracing + steps = d.steps, + nofsteps = d.nofsteps, + type = d.lookuptype, + markclass = d.markclass or nil, + flags = d.flags, + -- chain = d.chain, + } + sublookuplist[nofsublookups] = h + sublookuphash[lookupid] = nofsublookups + sublookupcheck[lookupid] = 1 + else + report_issue(i,what,sequence,"missing") + rule.lookups = nil + break + end + else + report_issue(i,what,sequence,"bad") + rule.lookups = nil + break + end else sublookupcheck[lookupid] = sublookupcheck[lookupid] + 1 end @@ -2014,16 +2029,15 @@ local function readmathglyphinfo(f,fontdata,offset) local function get(offset) setposition(f,kernoffset+offset) local n = readushort(f) - if n > 0 then + if n == 0 then + local k = readmathvalue(f) + if k == 0 then + -- no need for it (happens sometimes) + else + return { { kern = k } } + end + else local l = { } - -- for i=1,n do - -- l[i] = { readushort(f), 0 } -- height, kern - -- skipshort(f) - -- end - -- for i=1,n do - -- l[i][2] = readushort(f) - -- skipshort(f) - -- end for i=1,n do l[i] = { height = readmathvalue(f) } end @@ -2058,10 +2072,10 @@ local function readmathglyphinfo(f,fontdata,offset) if next(kernset) then local glyph = glyphs[coverage[i]] local math = glyph.math - if not math then - glyph.math = { kerns = kernset } - else + if math then math.kerns = kernset + else + glyph.math = { kerns = kernset } end end end diff --git a/tex/context/base/mkiv/font-gds.lua b/tex/context/base/mkiv/font-gds.lua index 184a002dd..c24bef315 100644 --- a/tex/context/base/mkiv/font-gds.lua +++ b/tex/context/base/mkiv/font-gds.lua @@ -173,7 +173,7 @@ end fontgoodies.prepare_features = prepare_features -local function initialize(goodies,tfmdata) +local function initialize(goodies) local featuresets = goodies.featuresets if featuresets then if trace_goodies then @@ -586,46 +586,48 @@ local function initialize(tfmdata) local shared = tfmdata.shared for i=1,#goodies do local mathgoodies = goodies[i].mathematics - local mathitalics = mathgoodies and mathgoodies.italics - if mathitalics then - local properties = tfmdata.properties - if properties.setitalics then - mathitalics = mathitalics[file.nameonly(properties.name)] or mathitalics - if mathitalics then - if trace_goodies then - report_goodies("loading mathitalics for font %a",properties.name) - end - local corrections = mathitalics.corrections - local defaultfactor = mathitalics.defaultfactor - -- properties.mathitalic_defaultfactor = defaultfactor -- we inherit outer one anyway (name will change) - if corrections then - fontgoodies.registerpostprocessor(tfmdata, function(tfmdata) -- this is another tfmdata (a copy) - -- better make a helper so that we have less code being defined - local properties = tfmdata.properties - local parameters = tfmdata.parameters - local characters = tfmdata.characters - properties.mathitalic_defaultfactor = defaultfactor - properties.mathitalic_defaultvalue = defaultfactor * parameters.quad - if trace_goodies then - report_goodies("assigning mathitalics for font %a",properties.name) - end - local quad = parameters.quad - local hfactor = parameters.hfactor - for k, v in next, corrections do - local c = characters[k] - if c then - if v > -1 and v < 1 then - c.italic = v * quad + if mathgoodies then + local mathitalics = mathgoodies.italics + if mathitalics then + local properties = tfmdata.properties + if properties.setitalics then + mathitalics = mathitalics[file.nameonly(properties.name)] or mathitalics + if mathitalics then + if trace_goodies then + report_goodies("loading mathitalics for font %a",properties.name) + end + local corrections = mathitalics.corrections + local defaultfactor = mathitalics.defaultfactor + -- properties.mathitalic_defaultfactor = defaultfactor -- we inherit outer one anyway (name will change) + if corrections then + fontgoodies.registerpostprocessor(tfmdata, function(tfmdata) -- this is another tfmdata (a copy) + -- better make a helper so that we have less code being defined + local properties = tfmdata.properties + local parameters = tfmdata.parameters + local characters = tfmdata.characters + properties.mathitalic_defaultfactor = defaultfactor + properties.mathitalic_defaultvalue = defaultfactor * parameters.quad + if trace_goodies then + report_goodies("assigning mathitalics for font %a",properties.name) + end + local quad = parameters.quad + local hfactor = parameters.hfactor + for k, v in next, corrections do + local c = characters[k] + if c then + if v > -1 and v < 1 then + c.italic = v * quad + else + c.italic = v * hfactor + end else - c.italic = v * hfactor + report_goodies("invalid mathitalics entry %U for font %a",k,properties.name) end - else - report_goodies("invalid mathitalics entry %U for font %a",k,properties.name) end - end - end) + end) + end + return -- maybe not as these can accumulate end - return -- maybe not as these can accumulate end end end @@ -855,12 +857,53 @@ registerotffeature { } } +local enabled = false directives.register("fontgoodies.mathkerning",function(v) enabled = v end) + +local function initialize(tfmdata) + if enabled and tfmdata.mathparameters then -- funny, cambria text has this + local goodies = tfmdata.goodies + if goodies then + local characters = tfmdata.characters + if characters[0x1D44E] then -- 119886 + -- we have at least an italic a + for i=1,#goodies do + local mathgoodies = goodies[i].mathematics + if mathgoodies then + local kerns = mathgoodies.kerns + if kerns then + for unicode, specification in next, kerns do + local chardata = characters[unicode] + if chardata and (not chardata.mathkerns or specification.force) then + chardata.mathkerns = specification + end + end + return + end + end + end + else + return -- no proper math font anyway + end + end + end +end + +registerotffeature { + name = "mathkerns", + description = "math kerns", + default = true, + initializers = { + base = initialize, + node = initialize, + } +} + -- kern hackery: -- -- yes : use goodies table -- auto : assume features to be set (often ccmp only) -local function setkeepligatures(tfmdata,value) +local function setkeepligatures(tfmdata) if not tfmdata.properties.keptligatures then local goodies = tfmdata.goodies if goodies then diff --git a/tex/context/base/mkiv/font-ini.mkvi b/tex/context/base/mkiv/font-ini.mkvi index 7e5851b26..edf9e688e 100644 --- a/tex/context/base/mkiv/font-ini.mkvi +++ b/tex/context/base/mkiv/font-ini.mkvi @@ -2332,7 +2332,6 @@ %D Handy for manuals: - %D The \type {\tochar} commmand takes a specification: %D %D \starttabulate[|l|l|l|] diff --git a/tex/context/base/mkiv/font-mis.lua b/tex/context/base/mkiv/font-mis.lua index d359e2132..5d0d5af7a 100644 --- a/tex/context/base/mkiv/font-mis.lua +++ b/tex/context/base/mkiv/font-mis.lua @@ -21,7 +21,7 @@ local readers = otf.readers if readers then - otf.version = otf.version or 3.020 + otf.version = otf.version or 3.021 otf.cache = otf.cache or containers.define("fonts", "otl", otf.version, true) function fonts.helpers.getfeatures(name,save) diff --git a/tex/context/base/mkiv/font-mps.lua b/tex/context/base/mkiv/font-mps.lua index 2f9fd1c1d..42e8e704b 100644 --- a/tex/context/base/mkiv/font-mps.lua +++ b/tex/context/base/mkiv/font-mps.lua @@ -23,9 +23,9 @@ fonts.metapost = metapost local trace_skips = false trackers.register("metapost.outlines.skips",function(v) trace_skips = v end) -local f_moveto = formatters["(%.4F,%.4F)"] -local f_lineto = formatters["--(%.4F,%.4F)"] -local f_curveto = formatters["..controls(%.4F,%.4F)and(%.4F,%.4F)..(%.4F,%.4F)"] +local f_moveto = formatters["(%F,%F)"] +local f_lineto = formatters["--(%F,%F)"] +local f_curveto = formatters["..controls(%F,%F)and(%F,%F)..(%F,%F)"] local s_cycle = "--cycle" local f_nofill = formatters["nofill %s;"] @@ -34,8 +34,8 @@ local f_dofill = formatters["fill %s;"] local f_draw_trace = formatters["drawpathonly %s;"] local f_draw = formatters["draw %s;"] -local f_boundingbox = formatters["((%.4F,%.4F)--(%.4F,%.4F)--(%.4F,%.4F)--(%.4F,%.4F)--cycle)"] -local f_vertical = formatters["((%.4F,%.4F)--(%.4F,%.4F))"] +local f_boundingbox = formatters["((%F,%F)--(%F,%F)--(%F,%F)--(%F,%F)--cycle)"] +local f_vertical = formatters["((%F,%F)--(%F,%F))"] function metapost.boundingbox(d,factor) local bounds = d.boundingbox @@ -256,16 +256,17 @@ local find_tail = nodes.tail ----- metapost = fonts.glyphs.metapost local characters = fonts.hashes.characters +local parameters = fonts.hashes.parameters local shapes = fonts.hashes.shapes local topaths = metapost.paths -local f_code = formatters["mfun_do_outline_text_flush(%q,%i,%.4F,%.4F)(%,t);"] +local f_code = formatters["mfun_do_outline_text_flush(%q,%i,%F,%F)(%,t);"] local s_nothing = "(origin scaled 10)" -local f_trace_rule = formatters["draw rule(%6F,%6F,%6F) shifted (%6F,%6F) withcolor .5white;"] -local f_strut = formatters["strut(%6F,%6F);"] -local f_hrule = formatters["draw rule(%6F,%6F,%6F);"] -local f_vrule = formatters["draw rule(%6F,%6F,%6F) shifted (%6F,%6F);"] -local f_bounds = formatters["checkbounds(%6F,%6F,%6F,%6F);"] +local f_trace_rule = formatters["draw rule(%F,%F,%F) shifted (%F,%F) withcolor .5white;"] +local f_strut = formatters["strut(%F,%F);"] +local f_hrule = formatters["draw rule(%F,%F,%F);"] +local f_vrule = formatters["draw rule(%F,%F,%F) shifted (%F,%F);"] +local f_bounds = formatters["checkbounds(%F,%F,%F,%F);"] local sc = 10 local fc = number.dimenfactors.bp * sc / 10 @@ -284,6 +285,7 @@ function metapost.output(kind,font,char,advance,shift,ex) if glyf then local units = shapedata.units or 1000 local yfactor = sc/units +yfactor = yfactor * parameters[font].factor / 655.36 local xfactor = yfactor local shift = shift or 0 local advance = advance or 0 diff --git a/tex/context/base/mkiv/font-otf.lua b/tex/context/base/mkiv/font-otf.lua index 17d3b34ad..4fec73989 100644 --- a/tex/context/base/mkiv/font-otf.lua +++ b/tex/context/base/mkiv/font-otf.lua @@ -57,7 +57,7 @@ local otf = fonts.handlers.otf otf.glists = { "gsub", "gpos" } -otf.version = 2.825 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 2.826 -- beware: also sync font-mis.lua and in mtx-fonts otf.cache = containers.define("fonts", "otf", otf.version, true) local hashes = fonts.hashes @@ -1907,18 +1907,16 @@ actions["analyze math"] = function(data,filename,raw) math.accent = accent end if mathkerns then - for k, v in next, mathkerns do - if not next(v) then - mathkerns[k] = nil - else - for k, v in next, v do - if v == 0 then - k[v] = nil -- height / kern can be zero - end - end - end - end - math.kerns = mathkerns + local topright = mathkerns.top_right + local topleft = mathkerns.top_left + local bottomright = mathkerns.bottom_right + local bottomleft = mathkerns.bottom_left + math.kerns = { + topright = topright and next(topright) and topright or nil, + topleft = topleft and next(topleft) and topleft or nil, + bottomright = bottomright and next(bottomright) and bottomright or nil, + bottomleft = bottomleft and next(bottomleft) and bottomleft or nil, + } end if hvariants then math.hvariants, math.hparts, math.hitalic = check_variants(unicode,hvariants,splitter,unicodes) diff --git a/tex/context/base/mkiv/font-otj.lua b/tex/context/base/mkiv/font-otj.lua index 61baf931d..0db30c646 100644 --- a/tex/context/base/mkiv/font-otj.lua +++ b/tex/context/base/mkiv/font-otj.lua @@ -753,7 +753,7 @@ local function inject_pairs_only(head,where) end local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - insert_node_before(head,current,newkern(leftkern)) + head = insert_node_before(head,current,newkern(leftkern)) end local rightkern = i.rightkern if rightkern and rightkern ~= 0 then @@ -1521,10 +1521,19 @@ function injections.handler(head,where) head = injectspaces(head) end if nofregisteredmarks > 0 or nofregisteredcursives > 0 then + if trace_injections then + report_injections("injection variant %a","everything") + end return inject_everything(head,where) elseif nofregisteredpairs > 0 then + if trace_injections then + report_injections("injection variant %a","pairs") + end return inject_pairs_only(head,where) elseif nofregisteredkerns > 0 then + if trace_injections then + report_injections("injection variant %a","kerns") + end return inject_kerns_only(head,where) else return head, false diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua index 304b6b989..73e3df9c0 100644 --- a/tex/context/base/mkiv/font-otl.lua +++ b/tex/context/base/mkiv/font-otl.lua @@ -53,7 +53,7 @@ local report_otf = logs.reporter("fonts","otf loading") local fonts = fonts local otf = fonts.handlers.otf -otf.version = 3.020 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 3.021 -- beware: also sync font-mis.lua and in mtx-fonts otf.cache = containers.define("fonts", "otl", otf.version, true) local otfreaders = otf.readers diff --git a/tex/context/base/mkiv/font-sel.lua b/tex/context/base/mkiv/font-sel.lua index a2323ad0b..02dc9e686 100644 --- a/tex/context/base/mkiv/font-sel.lua +++ b/tex/context/base/mkiv/font-sel.lua @@ -70,6 +70,7 @@ local report_selectfont = logs.reporter("selectfont") local report_files = logs.reporter("selectfont","files") local report_features = logs.reporter("selectfont","features") local report_goodies = logs.reporter("selectfont","goodies") +local report_alternatives = logs.reporter("selectfont","alternatives") local report_typescript = logs.reporter("selectfont","typescripts") defaults["rm"] = { features = { ["sc"] = "*,f:smallcaps" } } @@ -81,6 +82,7 @@ defaults["dejavumath"] = { options = { extras = "dejavu", defaults["neoeuler"] = { options = { extras = "euler-math", features = "math\\mathsizesuffix" } } defaults["latinmodernmath"] = { options = { extras = "lm,lm-math", features = "math\\mathsizesuffix,lm-math", goodies = "lm" } } defaults["lucidabrightmathot"] = { options = { extras = "lucida-opentype-math", features = "math\\mathsizesuffix", goodies = "lucida-opentype-math" } } +defaults["texgyredejavumath"] = { options = { extras = "dejavu", features = "math\\mathsizesuffix" } } defaults["texgyrepagellamath"] = { options = { extras = "texgyre", features = "math\\mathsizesuffix" } } defaults["texgyrebonummath"] = { options = { extras = "texgyre", features = "math\\mathsizesuffix" } } defaults["texgyrescholamath"] = { options = { extras = "texgyre", features = "math\\mathsizesuffix" } } @@ -678,8 +680,8 @@ end function selectfont.fontfallback(data,class,style,alternative,index) local range = data.options.range local scale = data.options.rscale ~= "" and data.options.rscale or 1 - local check = data.options.check ~= "" and data.options.check or "yes" - local force = data.options.force ~= "" and data.options.force or "no" + local check = data.options.check ~= "" and data.options.check or "" + local force = data.options.force ~= "" and data.options.force or "" local fontfeature = data.features and data.features[alternative] or data.options.features local fontsynonym = formatters["synonym-%s-%s-%s-%s"](class,style,alternative,index) local fontfallback = formatters["fallback-%s-%s-%s"] (class,style,alternative) @@ -812,11 +814,7 @@ function selectfont.typeface(data) --~ if trace_typescript then --~ report_typescript("Class: '%s', Style: '%s', Size: '%s', Scale: '%s'",fontclass,fontstyle,size,scale) --~ end - if fontstyle == "mm" then -- math uses the default bodyfont settings because it uses 'ma' and 'mb' as alternative names - ctx_definetypeface( { fontclass }, { fontstyle }, { style }, { "" }, { "default" }, { designsize = size, rscale = scale } ) - else - ctx_definetypeface( { fontclass }, { fontstyle }, { "" }, { "" }, { "" }, { designsize = size, rscale = scale } ) - end + ctx_definetypeface( { fontclass }, { fontstyle }, { style }, { "" }, { "default" }, { designsize = size, rscale = scale } ) end function selectfont.default(data) @@ -921,4 +919,4 @@ implement { name = "definefontfamilypreset", actions = selectfont.definefontfamilypreset, arguments = { "string", "string" } -} +}
\ No newline at end of file diff --git a/tex/context/base/mkiv/lang-hyp.lua b/tex/context/base/mkiv/lang-hyp.lua index ac1d5cb7e..7864220e3 100644 --- a/tex/context/base/mkiv/lang-hyp.lua +++ b/tex/context/base/mkiv/lang-hyp.lua @@ -48,6 +48,8 @@ if not modules then modules = { } end modules ['lang-hyp'] = { -- In the procecess of wrapping up (for the ctx conference proceedings) I cleaned up -- and extended the code a bit. +-- todo: hjcodes (<32 == length) if i really want it + local type, rawset, tonumber, next = type, rawset, tonumber, next local P, R, S, Cg, Cf, Ct, Cc, C, Carg, Cs = lpeg.P, lpeg.R, lpeg.S, lpeg.Cg, lpeg.Cf, lpeg.Ct, lpeg.Cc, lpeg.C, lpeg.Carg, lpeg.Cs diff --git a/tex/context/base/mkiv/math-ali.mkiv b/tex/context/base/mkiv/math-ali.mkiv index ebb20e33e..ca282aceb 100644 --- a/tex/context/base/mkiv/math-ali.mkiv +++ b/tex/context/base/mkiv/math-ali.mkiv @@ -38,7 +38,7 @@ \dorecurse{\mathalignmentparameter\c!m}\math_build_eqalign_step \normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_c}}} -\def\math_build_eqalign_step +\unexpanded\def\math_build_eqalign_step % make sure no expansion in tracing {\ifnum\recurselevel>\plusone \scratchtoks\expandafter{\the\scratchtoks\tabskip\mathalignmentparameter\c!distance\aligntab\tabskip\zeropoint}% \fi @@ -83,8 +83,6 @@ % use zeroskipplusfill -% i really need to redo this eqno mess ... in lua - \def\math_prepare_r_eqalign_no {\c_math_align_a{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{\alignmark\alignmark}\math_right_of_eqalign\tabskip\zeropoint}% \c_math_align_b{\aligntab\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{\alignmark\alignmark}\math_right_of_eqalign\tabskip\zeropoint}% @@ -118,7 +116,7 @@ \def\math_both_eqalign_no_normal#1#2% {\ifmmode - \the\mathdisplayaligntweaks % \let\strc_formulas_place_number\relax % strange hack + \the\mathdisplayaligntweaks \vcenter\bgroup \let\math_finish_eqalign_no\egroup \else @@ -145,8 +143,8 @@ \def\math_rlap#1% {\setbox\scratchbox\hbox{#1}% - \ifdim\wd\scratchbox>\mathnumbercorrection - \xdef\mathnumbercorrection{\the\wd\scratchbox}% + \ifdim\wd\scratchbox>\d_math_number_correction + \global\d_math_number_correction\wd\scratchbox \fi \box\scratchbox \global\mathnumberstatus\plustwo} @@ -1052,26 +1050,13 @@ \newconstant\mathraggedstatus % normal left center right \newconstant\mathnumberstatus % nothing normal shift_right -\let\mathnumbercorrection\!!zeropoint - -\let\math_the_r_eq_no\empty -\let\math_the_l_eq_no\empty +\newdimen\d_math_number_correction \unexpanded\def\startmathbox#1% {\hsize\displaywidth % \checkeddisplaymath \global\mathnumberstatus\plusone \mathraggedstatus#1\relax - \let\mathnumbercorrection\!!zeropoint - \global\let\math_the_r_eq_no\empty - \global\let\math_the_l_eq_no\empty - \def\reqno{\gdef\math_the_r_eq_no}% - \def\leqno{\gdef\math_the_l_eq_no}% - \let\eqno\reqno - % added - \let\normalreqno\reqno - \let\normalleqno\leqno - \let\normaleqno \eqno - % added + \global\d_math_number_correction\zeropoint \strc_formulas_place_number \setbox\scratchbox\math_hbox to \displaywidth\bgroup % \checkeddisplaymath \mathinnerstrut @@ -1080,57 +1065,113 @@ \def\math_box_llapped_math_no {\ifcase\mathraggedstatus\or - \math_the_r_eq_no + \box\b_strc_formulas_number \or - \llap{\math_the_r_eq_no}% + \llap{\box\b_strc_formulas_number}% \or - \llap{\math_the_r_eq_no}% + \llap{\box\b_strc_formulas_number}% \fi} \def\math_box_rlapped_math_no {\ifcase\mathraggedstatus\or - \rlap{\math_the_l_eq_no}% + \rlap{\box\b_strc_formulas_number}% \or - \rlap{\math_the_l_eq_no}% + \rlap{\box\b_strc_formulas_number}% \or - \math_the_l_eq_no + \box\b_strc_formulas_number \fi} +% \unexpanded\def\stopmathbox +% {\stopforceddisplaymath +% \ifcase\mathraggedstatus\or\or\hfill\or\hfill\fi +% \egroup +% \setbox0\hbox{\unhcopy\scratchbox}% +% \scratchdimen\wd0 +% % to be tested: \scratchdimen\naturalwd\scratchbox +% \ifdim\scratchdimen>\displaywidth % \checkeddisplaymath +% \donetrue +% \else +% \donefalse +% \fi +% % is number correction still needed ? +% \dontcomplain +% \dontleavehmode +% \kern\d_strc_formulas_display_margin_left +% \hbox to \displaywidth\bgroup +% \ifcase\mathnumberstatus +% \box\scratchbox +% \or +% \ifzeropt\wd\b_strc_formulas_number +% \box\scratchbox +% \else\ifx\p_location\v!left +% \ifdone +% \vpack{\hpack to \displaywidth{\math_box_rlapped_math_no\hss}\box\scratchbox}% \checkeddisplaymath +% \else +% \math_box_rlapped_math_no\box\scratchbox\hss % hss makes room for number +% \fi +% \else +% \ifdone +% \vpack{\box\scratchbox\hpack to \displaywidth{\hss\math_box_llapped_math_no}}% \checkeddisplaymath +% \else +% \hss\box\scratchbox\math_box_llapped_math_no % hss makes room for number +% \fi +% \fi\fi +% \or +% \hskip\d_math_number_correction +% \box\scratchbox +% \hss +% \else +% \box\scratchbox +% \fi +% \egroup} + \unexpanded\def\stopmathbox {\stopforceddisplaymath \ifcase\mathraggedstatus\or\or\hfill\or\hfill\fi \egroup - \setbox0\hbox{\unhcopy\scratchbox}% - \scratchdimen\wd0 - % to be tested: \scratchdimen\naturalwd\scratchbox - \ifdim\scratchdimen>\displaywidth % \checkeddisplaymath - \donetrue + \ifconditional\c_strc_formulas_tight + \setnaturalwd\scratchbox + \scratchdimen\wd\scratchbox + \ifdim\scratchdimen>\displaywidth % \checkeddisplaymath + \donetrue + \else + \displaywidth\scratchdimen + \donefalse + \fi \else - \donefalse + \scratchdimen\getnaturalwd\scratchbox + \ifdim\scratchdimen>\displaywidth % \checkeddisplaymath + \donetrue + \else + \donefalse + \fi \fi - \hbox to \displaywidth\bgroup + % is number correction still needed ? + \dontcomplain + \noindentation + % \dontleavehmode + \kern\d_strc_formulas_display_margin_left + \hbox to \displaywidth \bgroup \ifcase\mathnumberstatus \box\scratchbox \or - \ifx\math_the_l_eq_no\empty - \ifx\math_the_r_eq_no\empty - \box\scratchbox + \ifzeropt\wd\b_strc_formulas_number + \box\scratchbox + \else\ifx\p_location\v!left + \ifdone + \vpack{\hpack to \displaywidth{\math_box_rlapped_math_no\hss}\box\scratchbox}% \checkeddisplaymath \else - \ifdone - \vpack{\box\scratchbox\hpack to \displaywidth{\hss\math_box_llapped_math_no}}% \checkeddisplaymath - \else - \hss\box\scratchbox\math_box_llapped_math_no % hss makes room for number - \fi + \math_box_rlapped_math_no\box\scratchbox\hss % hss makes room for number \fi \else \ifdone - \vpack{\hpack to \displaywidth{\math_box_rlapped_math_no\hss}\box\scratchbox}% \checkeddisplaymath + \vpack{\box\scratchbox\hpack to \displaywidth{\hss\math_box_llapped_math_no}}% \checkeddisplaymath \else - \math_box_rlapped_math_no\box\scratchbox\hss % hss makes room for number + \hss\box\scratchbox\math_box_llapped_math_no % hss makes room for number \fi - \fi + \fi\fi \or - \hskip\mathnumbercorrection + \hskip\d_math_number_correction \box\scratchbox \hss \else @@ -1144,131 +1185,9 @@ \defineinnermathhandler\v!flushleft {\startmathbox\plusthree}{\stopmathbox} \defineinnermathhandler\v!center {\startmathbox\plustwo }{\stopmathbox} \defineinnermathhandler\v!flushright{\startmathbox\plusone }{\stopmathbox} -\defineinnermathhandler\v!normal {} {} +\defineinnermathhandler\v!normal {\startmathbox\plustwo }{\stopmathbox} -%defineinnermathhandler\v!normal {\startmathbox\plustwo }{\stopmathbox} - -%D [The examples below are in english and don't process in the -%D documentation style, which will be english some day.] -%D -%D Normally a formula is centered, but in case you want to -%D align it left or right, you can set up formulas to behave -%D that way. Normally a formula will adapt is left indentation -%D to the environment: -%D -%D \startbuffer -%D \fakewords{20}{40}\epar -%D \startitemize -%D \item \fakewords{20}{40}\epar -%D \placeformula \startformula \fakeformula \stopformula -%D \item \fakewords{20}{40}\epar -%D \stopitemize -%D \fakewords{20}{40}\epar -%D \stopbuffer -%D -%D % \getbuffer -%D -%D In the next examples we explicitly align formulas to the -%D left (\type {\raggedleft}), center and right (\type -%D {\raggedright}): -%D -%D \startbuffer -%D \setupformulas[align=left] -%D \startformula\fakeformula\stopformula -%D \setupformulas[align=middle] -%D \startformula\fakeformula\stopformula -%D \setupformulas[align=right] -%D \startformula\fakeformula\stopformula -%D \stopbuffer -%D -%D \typebuffer -%D -%D Or in print: -%D -%D % {\getbuffer} -%D -%D With formula numbers these formulas look as follows: -%D -%D \startbuffer -%D \setupformulas[align=left] -%D \placeformula \startformula\fakeformula\stopformula -%D \setupformulas[align=middle] -%D \placeformula \startformula\fakeformula\stopformula -%D \setupformulas[align=right] -%D \placeformula \startformula\fakeformula\stopformula -%D \stopbuffer -%D -%D % {\getbuffer} -%D -%D This was keyed in as: -%D -%D \typebuffer -%D -%D When tracing is turned on (\type {\tracemathtrue}) you can -%D visualize the bounding box of the formula, -%D -%D % {\tracemathtrue\getbuffer} -%D -%D As you can see, the dimensions are the natural ones, but if -%D needed you can force a normalized line: -%D -%D \startbuffer -%D \setupformulas[strut=yes] -%D \placeformula \startformula \fakeformula \stopformula -%D \stopbuffer -%D -%D \typebuffer -%D -%D This time we get a more spacy result. -%D -%D % {\tracemathtrue\getbuffer} -%D -%D We will now show a couple of more settings and combinations -%D of settings. In centered formulas, the number takes no space -%D -%D \startbuffer -%D \setupformulas[align=middle] -%D \startformula \fakeformula \stopformula -%D \placeformula \startformula \fakeformula \stopformula -%D \stopbuffer -%D -%D \typebuffer % {\tracemathtrue\getbuffer} -%D -%D You can influence the placement of the whole box with the -%D parameters \type {leftmargin} and \type {rightmargin}. -%D -%D \startbuffer -%D \setupformulas[align=right,leftmargin=3em] -%D \startformula \fakeformula \stopformula -%D \placeformula \startformula \fakeformula \stopformula -%D -%D \setupformulas[align=left,rightmargin=1em] -%D \startformula \fakeformula \stopformula -%D \placeformula \startformula \fakeformula \stopformula -%D \stopbuffer -%D -%D \typebuffer % {\tracemathtrue\getbuffer} -%D -%D You can also inherit the margin from the environment. -%D -%D \startbuffer -%D \setupformulas[align=right,margin=standard] -%D \startformula \fakeformula \stopformula -%D \placeformula \startformula \fakeformula \stopformula -%D \stopbuffer -%D -%D \typebuffer % {\tracemathtrue\getbuffer} -%D -%D The distance between the formula and the number is only -%D applied when the formula is left or right aligned. -%D -%D \startbuffer -%D \setupformulas[align=left,distance=2em] -%D \startformula \fakeformula \stopformula -%D \placeformula \startformula \fakeformula \stopformula -%D \stopbuffer -%D -%D \typebuffer % {\tracemathtrue\getbuffer} +%D For documentation, see \type {math-mkiv.tex}. \protect \endinput diff --git a/tex/context/base/mkiv/math-ini.mkiv b/tex/context/base/mkiv/math-ini.mkiv index 2e7831d75..777af412f 100644 --- a/tex/context/base/mkiv/math-ini.mkiv +++ b/tex/context/base/mkiv/math-ini.mkiv @@ -2159,6 +2159,8 @@ \resetdisplaymatheq % moved to here \to \mathdisplayaligntweaks +% this can become an option: + \unexpanded\def\math_display_align_hack % I don't like the global, maybe we should push and pop {\global\let\math_display_align_hack_indeed\math_display_align_hack_remove_skip \math_openup\displayopenupvalue % was \math_openup\jot diff --git a/tex/context/base/mkiv/node-rul.lua b/tex/context/base/mkiv/node-rul.lua index 033539062..63d5da853 100644 --- a/tex/context/base/mkiv/node-rul.lua +++ b/tex/context/base/mkiv/node-rul.lua @@ -11,6 +11,12 @@ if not modules then modules = { } end modules ['node-rul'] = { -- -- todo: make robust for layers ... order matters +-- todo: collect successive bit and pieces and combine them +-- +-- path s ; s := shaped(p) ; % p[] has rectangles +-- fill s withcolor .5white ; +-- draw boundingbox s withcolor yellow; + local attributes, nodes, node = attributes, nodes, node local nuts = nodes.nuts @@ -93,6 +99,7 @@ local n_tostring = nodes.idstostring local n_tosequence = nodes.tosequence local a_ruled = attributes.private('ruled') +local a_runningtext = attributes.private('runningtext') local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') local a_colorspace = attributes.private('colormodel') @@ -161,16 +168,16 @@ local checkdir = true -- handlers -local function processwords(attribute,data,flush,head,parent) -- we have hlistdir and local dir +local function processwords(attribute,data,flush,head,parent,skip) -- we have hlistdir and local dir local n = head if n then local f, l, a, d, i, class local continue, leaders, done, strip, level = false, false, false, true, -1 while n do local id = getid(n) - if id == glyph_code or id == rule_code then + if id == glyph_code or id == rule_code or (id == hlist_code and getattr(n,a_runningtext) == 1) then local aa = getattr(n,attribute) - if aa then + if aa and aa ~= skip then if aa == a then if not f then -- ? f = n @@ -200,6 +207,12 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi end f, l, a = nil, nil, nil end + if id == hlist_code then + local list = getlist(n) + if list then + setlist(n,(processwords(attribute,data,flush,list,n,aa))) -- watch () + end + end elseif id == disc_code or id == boundary_code then if f then l = n @@ -215,7 +228,7 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi end local list = getlist(n) if list then - setlist(n,(processwords(attribute,data,flush,list,n))) -- watch () + setlist(n,(processwords(attribute,data,flush,list,n,skip))) -- watch () end -- elseif checkdir and id == dir_code then -- only changes in dir, we assume proper boundaries -- if f and a then @@ -317,7 +330,14 @@ end local a_viewerlayer = attributes.private("viewerlayer") local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but acceptable for this purpose - if getid(f) ~= glyph_code then + local font = nil + local id = getid(f) + if id == glyph_code then + font = getfont(f) + elseif id == hlist_code then + font = getattr(f,a_runningtext) + end + if not font then -- saveguard ... we need to deal with rules and so (math) return head end @@ -353,14 +373,14 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a local transparency = ta > 0 and ta or getattr(f,a_transparency) local foreground = order == v_foreground local layer = getattr(f,a_viewerlayer) - local e = dimenfactor(unit,getfont(f)) -- what if no glyph node + local e = dimenfactor(unit,font) -- what if no glyph node local rt = tonumber(rulethickness) if rt then rulethickness = e * rulethickness / 2 else local n, u = splitdimen(rulethickness) if n and u then -- we need to intercept ex and em and % and ... - rulethickness = n * dimenfactor(u,fontdata[getfont(f)]) / 2 + rulethickness = n * dimenfactor(u,fontdata[font]) / 2 else rulethickness = 1/5 end diff --git a/tex/context/base/mkiv/pack-rul.lua b/tex/context/base/mkiv/pack-rul.lua index 427a2d11d..e85e42200 100644 --- a/tex/context/base/mkiv/pack-rul.lua +++ b/tex/context/base/mkiv/pack-rul.lua @@ -26,6 +26,7 @@ local hlist_code = nodes.nodecodes.hlist local vlist_code = nodes.nodecodes.vlist local box_code = nodes.listcodes.box local line_code = nodes.listcodes.line +local equation_code = nodes.listcodes.equation local texsetdimen = tex.setdimen local texsetcount = tex.setcount @@ -49,9 +50,16 @@ local traverse_id = nuts.traverse_id local node_dimensions = nuts.dimensions local free_node = nuts.free +local checkformath = false + +directives.register("framed.checkmath",function(v) checkformath = v end) -- experiment + +-- beware: dir nodes and pseudostruts can end up on lines of their own + local function doreshapeframedbox(n) local box = getbox(n) local noflines = 0 + local nofnonzero = 0 local firstheight = nil local lastdepth = nil local lastlinelength = 0 @@ -74,7 +82,6 @@ local function doreshapeframedbox(n) if repack then local subtype = getsubtype(n) if subtype == box_code or subtype == line_code then - -- used to be: hpack(copy(l)).width lastlinelength = node_dimensions(l,getfield(n,"dir")) else lastlinelength = getfield(n,"width") @@ -88,6 +95,9 @@ local function doreshapeframedbox(n) if lastlinelength < minwidth or minwidth == 0 then minwidth = lastlinelength end + if lastlinelength > 0 then + nofnonzero = nofnonzero + 1 + end totalwidth = totalwidth + lastlinelength end end @@ -111,16 +121,15 @@ local function doreshapeframedbox(n) local subtype = getsubtype(h) if subtype == box_code or subtype == line_code then local p = hpack(l,maxwidth,'exactly',getfield(h,"dir")) -- multiple return value - if false then - setlist(h,p) - setfield(h,"shift",0) -- needed for display math, so no width check possible - -- setfield(p,"attr",getfield(h,"attr")) - else - setfield(h,"glue_set",getfield(p,"glue_set")) - setfield(h,"glue_order",getfield(p,"glue_order")) - setfield(h,"glue_sign",getfield(p,"glue_sign")) - setlist(p) - free_node(p) + setfield(h,"glue_set",getfield(p,"glue_set")) + setfield(h,"glue_order",getfield(p,"glue_order")) + setfield(h,"glue_sign",getfield(p,"glue_sign")) + setlist(p) + free_node(p) + elseif checkformath and subtype == equation_code then + -- display formulas use a shift + if nofnonzero == 1 then + setfield(h,"shift",0) end end setfield(h,"width",maxwidth) @@ -138,7 +147,7 @@ local function doreshapeframedbox(n) setfield(box,"width",maxwidth) averagewidth = noflines > 0 and totalwidth/noflines or 0 else -- e.g. empty math {$ $} or \hbox{} or ... -setfield(box,"width",0) + setfield(box,"width",0) end end end diff --git a/tex/context/base/mkiv/pack-rul.mkiv b/tex/context/base/mkiv/pack-rul.mkiv index 635863302..cf8fe4941 100644 --- a/tex/context/base/mkiv/pack-rul.mkiv +++ b/tex/context/base/mkiv/pack-rul.mkiv @@ -809,12 +809,13 @@ \newconditional\c_framed_has_width \newconditional\c_framed_has_height \newconditional\c_framed_has_format -\newconditional\c_framed_has_strut \newconditional\c_framed_is_overlaid \newconditional\c_framed_has_frame \newconditional\c_framed_has_extra_offset \newconditional\c_framed_text_location_none +\newconstant \c_framed_has_strut % 0=relaxes 1=pseudostruts 2=realstruts + %D \macros %D {framed, setupframed} %D @@ -1226,18 +1227,18 @@ \framed_offset_alternative_unknown \fi % the next check could move to strutalternative - \ifconditional\c_framed_has_strut + \ifcase\c_framed_has_strut % none (not even noindent) + \let\localbegstrut\relax + \let\localendstrut\relax + \let\localstrut \relax + \or % no / overlay + \let\localbegstrut\pseudobegstrut + \let\localendstrut\pseudoendstrut + \let\localstrut \pseudostrut + \else \let\localbegstrut\begstrut \let\localendstrut\endstrut \let\localstrut \strut - \else - \let\localbegstrut\pseudobegstrut % was: \relax - \let\localendstrut\pseudoendstrut % was: \relax - \let\localstrut \pseudostrut % was: \relax - %\ifconditional\c_framed_has_height\ifdim\d_framed_height<\strutht % saveguard - % \let\localbegstrut\relax % but not that - % \let\localstrut \relax % save after all - %\fi\fi \fi \ifx\p_framed_autostrut\v!yes \let\delayedbegstrut\relax @@ -1390,7 +1391,7 @@ % struts (use let instead?) \setvalue{\??framedstrutalternative\v!no}% - {\setfalse\c_framed_has_strut} + {\c_framed_has_strut\plusone} \setvalue{\??framedstrutalternative\v!global}% {\setstrut} @@ -1407,49 +1408,47 @@ \def\framed_strut_alternative_unknown {\setstrut} +\setvalue{\??framedstrutalternative\v!none}% not even pseudo struts + {\c_framed_has_strut\zerocount} + % offsets \setvalue{\??framedoffsetalternative\v!none}% {\setfalse\c_framed_has_offset - \setfalse\c_framed_has_strut + \c_framed_has_strut\plusone \setfalse\c_framed_is_overlaid \d_framed_local_offset\d_framed_linewidth} \setvalue{\??framedoffsetalternative\v!overlay}% {% \ifx\p_framed_frame\v!no \setfalse\c_framed_has_frame \fi % test first \setfalse\c_framed_has_offset - \setfalse\c_framed_has_strut - \settrue \c_framed_is_overlaid + \c_framed_has_strut\plusone + \settrue\c_framed_is_overlaid \d_framed_local_offset\zeropoint} % \setvalue{\??framedoffsetalternative\v!strut}% % {\setfalse\c_framed_has_offset -% \settrue \c_framed_has_strut -% \settrue \c_framed_is_overlaid +% \c_framed_has_strut\plustwo +% \settrue\c_framed_is_overlaid % \d_framed_local_offset\zeropoint} \setvalue{\??framedoffsetalternative\v!default}% new per 2-6-2000 {\settrue \c_framed_has_offset - \settrue \c_framed_has_strut + \c_framed_has_strut\plustwo \setfalse\c_framed_is_overlaid \let\localoffset\defaultframeoffset \letframedparameter\c!offset\defaultframeoffset % brrr \d_framed_local_offset\dimexpr\localoffset+\d_framed_linewidth\relax} -\setvalue{\??framedoffsetalternative\s!unknown}% - {\settrue \c_framed_has_offset - \settrue \c_framed_has_strut - \setfalse\c_framed_is_overlaid - \let\defaultframeoffset\localoffset - \d_framed_local_offset\dimexpr\localoffset+\d_framed_linewidth\relax} - \def\framed_offset_alternative_unknown {\settrue \c_framed_has_offset - \settrue \c_framed_has_strut + \c_framed_has_strut\plustwo \setfalse\c_framed_is_overlaid \let\defaultframeoffset\localoffset \d_framed_local_offset\dimexpr\localoffset+\d_framed_linewidth\relax} +\letvalue{\??framedoffsetalternative\s!unknown}\framed_offset_alternative_unknown + % so far for alternatives \let\pack_framed_stop_orientation\relax @@ -1952,12 +1951,13 @@ % \inheritedmathframedframed{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}% % \endgroup} -\newcount\c_pack_framed_mc +\newcount\c_pack_framed_mathframed +\newtoks \t_pack_framed_mathframed \def\pack_framed_math_pos - {\global\advance\c_pack_framed_mc\plusone - \xdef\pack_framed_mc_one{mcf:1:\number\c_pack_framed_mc}% - \xdef\pack_framed_mc_two{mcf:2:\number\c_pack_framed_mc}% + {\global\advance\c_pack_framed_mathframed\plusone + \xdef\pack_framed_mc_one{mcf:1:\number\c_pack_framed_mathframed}% + \xdef\pack_framed_mc_two{mcf:2:\number\c_pack_framed_mathframed}% \xypos\pack_framed_mc_two} \def\pack_framed_mathframed_indeed[#1]#2% no fancy nesting supported here @@ -1971,9 +1971,20 @@ \else\ifx\m_framed_location\v!low\else \let\normalstrut\pack_framed_math_strut \fi\fi - \inheritedmathframedframed{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}% + \inheritedmathframedframed\bgroup + \Ustartmath + \triggermathstyle\c_framed_mstyle + \the\t_pack_framed_mathframed + #2% + \Ustopmath + \egroup \endgroup} +\appendtoks + \mathraggedstatus\plustwo % makes \startalign work + \eqalignmode \zerocount % makes \startalign fit +\to \t_pack_framed_mathframed + \installframedlocator \v!mathematics {} {\lower\dimexpr\MPy\pack_framed_mc_two-\MPy\pack_framed_mc_one\relax @@ -3007,6 +3018,7 @@ \ifx\currentframedcontent\v!off \let\stopframedcontent\egroup \else + \checkframedcontentparent \let\stopframedcontent\pack_framed_stop_content_indeed \expandafter\pack_framed_start_content_indeed \fi} diff --git a/tex/context/base/mkiv/page-mix.lua b/tex/context/base/mkiv/page-mix.lua index 2252d365d..5ff1abf09 100644 --- a/tex/context/base/mkiv/page-mix.lua +++ b/tex/context/base/mkiv/page-mix.lua @@ -340,8 +340,8 @@ local function preparesplit(specification) -- a rather large function if trace_state then report_state("backtracking over %s in column %s","glue",column) end - elseif id == penalty_code then current = getprev(current) + elseif id == penalty_code then if trace_state then report_state("backtracking over %s in column %s","penalty",column) end diff --git a/tex/context/base/mkiv/spac-adj.mkiv b/tex/context/base/mkiv/spac-adj.mkiv index ad0f92a1f..936e00624 100644 --- a/tex/context/base/mkiv/spac-adj.mkiv +++ b/tex/context/base/mkiv/spac-adj.mkiv @@ -23,7 +23,7 @@ \definesystemattribute [graphicvadjust] [public] \unexpanded\def\enablegraphicvadjust - {\writestatus\m!systems{graphicvadjusting is no longer needed!} + {\writestatus\m!system{graphicvadjusting is no longer needed!} \clf_enablegraphicvadjust %once anyway \glet\enablegraphicvadjust\relax} diff --git a/tex/context/base/mkiv/spac-hor.mkiv b/tex/context/base/mkiv/spac-hor.mkiv index 08e5f6343..38ba7281e 100644 --- a/tex/context/base/mkiv/spac-hor.mkiv +++ b/tex/context/base/mkiv/spac-hor.mkiv @@ -782,15 +782,19 @@ \newskip\leftskipadaption \newskip\rightskipadaption -\setvalue{\??skipadaptionleft \v!standard}{\ifdim\d_spac_indentation_par=\zeropoint\narrowerparameter\c!left\else\d_spac_indentation_par\fi} -\setvalue{\??skipadaptionleft \v!yes }{\ifdim\d_spac_indentation_par=\zeropoint\narrowerparameter\c!left\else\d_spac_indentation_par\fi} +\setvalue{\??skipadaptionleft \v!yes }{\ifzeropt\d_spac_indentation_par\narrowerparameter\c!left\else\d_spac_indentation_par\fi} \letvalue{\??skipadaptionleft \v!no }\zeropoint \letvalue{\??skipadaptionleft \empty }\zeropoint -\setvalue{\??skipadaptionright\v!standard}{\narrowerparameter\c!right} \setvalue{\??skipadaptionright\v!yes }{\narrowerparameter\c!right} \letvalue{\??skipadaptionright\v!no }\zeropoint \letvalue{\??skipadaptionright\empty }\zeropoint +% \setvalue{\??skipadaptionleft \v!standard}{\ifdim\d_spac_indentation_par=\zeropoint\narrowerparameter\c!left\else\d_spac_indentation_par\fi} +% \setvalue{\??skipadaptionright\v!standard}{\narrowerparameter\c!right} + +\letcsnamecsname\csname\??skipadaptionleft \v!standard\endcsname\csname\??skipadaptionleft \v!yes\endcsname +\letcsnamecsname\csname\??skipadaptionright\v!standard\endcsname\csname\??skipadaptionright\v!yes\endcsname + % \unexpanded\def\dosetleftskipadaption #1{\leftskipadaption \ifcsname\??skipadaptionleft #1\endcsname\csname\??skipadaptionleft #1\endcsname\else#1\fi\relax} % \unexpanded\def\dosetrightskipadaption#1{\rightskipadaption\ifcsname\??skipadaptionright#1\endcsname\csname\??skipadaptionright#1\endcsname\else#1\fi\relax} diff --git a/tex/context/base/mkiv/spac-lin.mkiv b/tex/context/base/mkiv/spac-lin.mkiv index c4c6eb6d9..6558cb111 100644 --- a/tex/context/base/mkiv/spac-lin.mkiv +++ b/tex/context/base/mkiv/spac-lin.mkiv @@ -61,7 +61,7 @@ \appendtoks \setuevalue{\e!start\currentlines}{\spac_lines_start[\currentlines]}% - \setuevalue{\e!stop \currentlines}{\spac_lines_stop}% + \letvalue {\e!stop \currentlines }\spac_lines_stop \to \everydefinelines \unexpanded\def\spac_lines_start[#1]% @@ -107,14 +107,17 @@ \def\spac_lines_after_first_obeyed_line_a % tzt two pass, like itemize {\linesparameter\c!command + \linesparameter\c!left \glet\spac_after_first_obeyed_line\spac_lines_after_first_obeyed_line_b} \def\spac_lines_after_first_obeyed_line_b {\spac_lines_break - \linesparameter\c!command} + \linesparameter\c!command + \linesparameter\c!left} \def\spac_lines_obeyed_line - {\dostoptagged + {\ifdone\linesparameter\c!right\fi + \dostoptagged % can be a dummy one as we don't look ahead \par \dostarttagged\t!line\empty \futurelet\next\spac_lines_between} @@ -128,9 +131,13 @@ \egroup} \def\spac_lines_between - {\doifelsemeaning\next\obeyedline % brrr - {\linesparameter\c!inbetween} - {\spac_after_first_obeyed_line}} + {\ifx\next\spac_lines_stop + \donefalse + \else + \doifelsemeaning\next\obeyedline % brrr + {\donefalse\linesparameter\c!inbetween} + {\donetrue\spac_after_first_obeyed_line}% + \fi} \definelines[\v!lines] diff --git a/tex/context/base/mkiv/spac-ver.lua b/tex/context/base/mkiv/spac-ver.lua index d31067a25..1887501b7 100644 --- a/tex/context/base/mkiv/spac-ver.lua +++ b/tex/context/base/mkiv/spac-ver.lua @@ -66,6 +66,8 @@ local trace_vspacing = false trackers.register("vspacing.spacing", fun local trace_vsnapping = false trackers.register("vspacing.snapping", function(v) trace_vsnapping = v end) local trace_specials = false trackers.register("vspacing.specials", function(v) trace_specials = v end) +local remove_math_skips = true directives.register("vspacing.removemathskips", function(v) remnove_math_skips = v end) + local report_vspacing = logs.reporter("vspacing","spacing") local report_collapser = logs.reporter("vspacing","collapsing") local report_snapper = logs.reporter("vspacing","snapping") @@ -647,7 +649,7 @@ vspacingdata.skip = vspacingdata.skip or { } -- allocate ? storage.register("builders/vspacing/data/map", vspacingdata.map, "builders.vspacing.data.map") storage.register("builders/vspacing/data/skip", vspacingdata.skip, "builders.vspacing.data.skip") -do -- todo: interface.variables +do -- todo: interface.variables and properties vspacing.fixed = false @@ -1377,11 +1379,11 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also if sv then -- check if already snapped if list and already_done(id,list,a_snapmethod) then - local ht = getfield(current,"height") - local dp = getfield(current,"depth") -- assume that the box is already snapped if trace_vsnapping then - report_snapper("mvl list already snapped at (%p,%p): %s",ht,dp,listtoutf(list)) + local h = getfield(current,"height") + local d = getfield(current,"depth") + report_snapper("mvl list already snapped at (%p,%p): %s",h,d,listtoutf(list)) end else local h, d, ch, cd, lines = snap_hlist("mvl",current,sv) @@ -1686,18 +1688,18 @@ end end head, current = remove_node(head, current, true) elseif glue_data then - local wp = getfield(current,"width") or 0 + local w = getfield(current,"width") or 0 if ((w ~= 0) and (w > (getfield(glue_data,"width") or 0))) then glue_data = current - head, current = remove_node(head, current) if trace then trace_natural("taking parskip",current) end + head, current = remove_node(head, current) else - head, current = remove_node(head, current, true) if trace then trace_natural("removed parskip",current) end + head, current = remove_node(head, current, true) end else if trace then @@ -1732,7 +1734,7 @@ end flush("topskip") end current = getnext(current) - elseif subtype == abovedisplayskip_code then + elseif subtype == abovedisplayskip_code and remove_math_skips then -- if trace then trace_skip("above display skip (normal)",sc,so,sp,current) @@ -1740,7 +1742,7 @@ end flush("above display skip (normal)") current = getnext(current) -- - elseif subtype == belowdisplayskip_code then + elseif subtype == belowdisplayskip_code and remove_math_skips then -- if trace then trace_skip("below display skip (normal)",sc,so,sp,current) @@ -1748,7 +1750,7 @@ end flush("below display skip (normal)") current = getnext(current) -- - elseif subtype == abovedisplayshortskip_code then + elseif subtype == abovedisplayshortskip_code and remove_math_skips then -- if trace then trace_skip("above display skip (short)",sc,so,sp,current) @@ -1756,7 +1758,7 @@ end flush("above display skip (short)") current = getnext(current) -- - elseif subtype == belowdisplayshortskip_code then + elseif subtype == belowdisplayshortskip_code and remove_math_skips then -- if trace then trace_skip("below display skip (short)",sc,so,sp,current) diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 528062af9..d80b8b645 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 d7c4635ae..e5c33fd93 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 85870d547..c1b5c5824 100644 --- a/tex/context/base/mkiv/strc-mat.mkiv +++ b/tex/context/base/mkiv/strc-mat.mkiv @@ -40,6 +40,7 @@ \c!expansion=\v!yes, % maybe automatically \c!spacebefore=\v!big, \c!spaceafter=\formulaparameter\c!spacebefore, + \c!width=\hsize, \c!leftmargin=\zeropoint, \c!rightmargin=\zeropoint, \c!indentnext=\v!no, @@ -230,12 +231,6 @@ \global\setfalse\c_strc_formulas_inside_place_sub \to \everyresetformulas -% \def\strc_formulas_place_numbering % place formula -% {\settrue\c_strc_formulas_handle_number -% \strc_formulas_check_reference\c_strc_formulas_place_number_mode\currentplaceformulareference -% \glet\strc_formulas_place_number\strc_formulas_place_number_indeed -% \glet\strc_formulas_place_number_nested\strc_formulas_place_number_nested_indeed} - \def\strc_formulas_place_numbering % place formula {\settrue\c_strc_formulas_handle_number \strc_formulas_check_reference\c_strc_formulas_place_number_mode\currentplaceformulareference @@ -271,21 +266,6 @@ \let\strc_formulas_reference_trace\relax \let\strc_formulas_reference_show \relax -% \def\strc_formulas_reference_trace -% {\rlap{\hbox{\quad\tt\txx[% -% \number\c_strc_formulas_place_number_mode,% -% \number\c_strc_formulas_number_mode,% -% \number\c_strc_formulas_sub_number_mode,% -% \number\c_strc_formulas_nested_number_mode -% ]}}} - -% \def\strc_formulas_reference_show -% {\writestatus{\v!formula}% -% {place: \number\c_strc_formulas_place_number_mode,\space -% formula: \number\c_strc_formulas_number_mode,\space -% subformula: \number\c_strc_formulas_sub_number_mode,\space -% nested: \number\c_strc_formulas_nested_number_mode]}} - \unexpanded\def\placecurrentformulanumber {\begingroup \rm % determines the distance and main font @@ -313,9 +293,6 @@ {\strc_formulas_handle_current_references \labeltexts\currentformula{\convertedcounter[\v!formula][]}} -% \def\theboxdestinationattribute#1{\iflocation\ifx#1\relax\else\ifx#1\empty\else attr \destinationattribute#1\fi\fi\fi} -% \def\thedestinationattribute #1{\iflocation\ifx#1\relax\else\ifx#1\empty\else \attribute\destinationattribute#1\fi\fi\fi} - \def\theformuladestinationattribute#1% {\iflocation\ifx#1\relax\else\ifx#1\empty\else \attribute\destinationattribute#1% @@ -501,12 +478,22 @@ %D %D Otherwise we get a missing \type {$$} error reported. -\let\reqno\eqno +\let\reqno\eqno % no longer valid as we just nil it + +\let\math_native_leqno\leqno +\let\math_native_reqno\reqno + +\unexpanded\def\resetdisplaymatheq + {\let\strc_formulas_place_number\relax} + +\unexpanded\def\normaleqno#1{\writestatus\m!system{no native (l)eqno equation number support}} + +\let\normalleqno\normaleqno +\let\normalreqno\normaleqno -\unexpanded\def\resetdisplaymatheq % when used? - {\let\normalleqno\gobbleoneargument \let\leqno\gobbleoneargument - \let\normalreqno\gobbleoneargument \let\eqno \gobbleoneargument - \let\strc_formulas_place_number\relax} +\let\leqno\normaleqno +\let\reqno\normaleqno +\let\eqno \normaleqno %D \macros %D {startsubformulas} @@ -537,41 +524,157 @@ \belowdisplayshortskip \zeropoint % evt. 0pt minus 3pt \predisplaypenalty \zerocount -\postdisplaypenalty \zerocount % -5000 gaat mis, zie penalty bij \paragraaf - -% we don't use the skip's +\postdisplaypenalty \zerocount % -5000 goes wrong, see penalty at \section +\mathdisplayskipmode \plusthree % because align also adds \unexpanded\def\strc_formulas_forget_display_skips - {\abovedisplayskip \zeropoint + {\mathdisplayskipmode \plusthree + \abovedisplayskip \zeropoint \belowdisplayskip \zeropoint \abovedisplayshortskip\zeropoint \belowdisplayshortskip\zeropoint} -% \def\predisplaysizethreshhold{2\emwidth} % was 3\emwidth - \newdimen\d_strc_formulas_display_skip_left \newdimen\d_strc_formulas_display_skip_right \newdimen\d_strc_formulas_display_margin_left \newdimen\d_strc_formulas_display_margin_right \newdimen\d_strc_formulas_display_pre_threshold -\newskip \d_strc_formulas_display_skip_par +\newdimen\d_strc_formulas_display_width + +\newconstant\c_strc_formulas_mode +\newconstant\c_strc_formulas_space_model + +\c_strc_formulas_mode \plustwo % 0=native 1=simple (old) 2=align (new) +\c_strc_formulas_space_model\plusthree % replaces \plusone + +\newconditional\c_strc_formulas_tight + +\newbox\b_strc_formulas_number +\newbox\b_strc_formulas_content + +\def\strc_formulas_flush_content_and_number + {\noindentation + % \dontleavehmode + \kern\d_strc_formulas_display_margin_left + \ifcase\wd\b_strc_formulas_number + \hbox to \displaywidth \bgroup + \hfill + \box\b_strc_formulas_content + \hfill + \egroup + \else\ifdim\dimexpr\wd\b_strc_formulas_content+\wd\b_strc_formulas_number\relax>\displaywidth + \vbox \bgroup + \hsize\displaywidth + \box\b_strc_formulas_content + \par + \ifx\p_location\v!left + \box\b_strc_formulas_number\hfill + \else + \hfill\box\b_strc_formulas_number + \fi + \egroup + \else + \hbox to \displaywidth \bgroup + \ifx\p_location\v!left + \rlap{\box\b_strc_formulas_number}% + \hfill\box\b_strc_formulas_content\hfill + \else + \hfill\box\b_strc_formulas_content\hfill + \llap{\box\b_strc_formulas_number}% + \fi + \egroup + \fi\fi} + +\installcorenamespace{mathdisplayspacemodel} + +\setvalue{\??mathdisplayspacemodel\v!before:1}% old + {\ifx\p_spacebefore\v!none + % nothing + \else + \directvspacing\p_spacebefore + \fi} + +\setvalue{\??mathdisplayspacemodel\v!after:1}% old + {\prevdepth .5\strutdp + \edef\p_spaceafter{\formulaparameter\c!spaceafter}% + \ifx\p_spaceafter\v!none + % nothing + \else + \directvspacing\p_spaceafter + \fi} + +\setvalue{\??mathdisplayspacemodel\v!before:2}% old + {\ifx\p_spacebefore\v!none + % nothing + \else + \directvspacing\p_spacebefore + \fi + \prevdepth-\maxdimen} % texbook pagina 79-80 + +\setvalue{\??mathdisplayspacemodel\v!after:2}% old + {\prevdepth\lineheight + \edef\p_spaceafter{\formulaparameter\c!spaceafter}% + \ifx\p_spaceafter\v!none + % nothing + \else + \directvspacing\p_spaceafter + \fi} + +\setvalue{\??mathdisplayspacemodel\v!before:3}% + {\ifdim\lastskip>\zeropoint + % bah + \else + \obeydepth + \nointerlineskip + \fi + \ifx\p_spacebefore\v!none + % nothing + \else\ifx\p_spaceafter\empty + \directvspacing\currentvspacing + \else + \directvspacing\p_spacebefore + \fi\fi} + +\setvalue{\??mathdisplayspacemodel\v!after:3}% + {\prevdepth\strutdp + \ifx\p_spaceafter\v!none + % nothing + \else\ifx\p_spaceafter\empty + \directvspacing\currentvspacing + \else + \directvspacing\p_spaceafter + \fi\fi} \unexpanded\def\beforedisplayspace - {\edef\p_spacebefore{\formulaparameter\c!spacebefore}% - \ifx\p_spacebefore\v!none \else - \blank[\p_spacebefore]% + {\ifhmode + \par + \fi + \ifvmode + \edef\p_spacebefore{\formulaparameter\c!spacebefore}% + \begincsname\??mathdisplayspacemodel\v!before:\number\c_strc_formulas_space_model\endcsname + \fi + \ifhmode + \par \fi} \unexpanded\def\afterdisplayspace - {\edef\p_spaceafter{\formulaparameter\c!spaceafter}% - \ifx\p_spaceafter\v!none \else - \blank[\p_spaceafter]% + {\ifhmode + \par + \fi + \ifvmode + \edef\p_spaceafter{\formulaparameter\c!spaceafter}% + \begincsname\??mathdisplayspacemodel\v!after:\number\c_strc_formulas_space_model\endcsname + \fi + \ifhmode + \par \fi} \unexpanded\def\setdisplaydimensions - {\displayindent\d_strc_formulas_display_skip_left - \advance\displayindent\d_strc_formulas_display_margin_left - \displaywidth\hsize + {\displayindent\dimexpr + \d_strc_formulas_display_skip_left + +\d_strc_formulas_display_margin_left + \relax + \displaywidth\d_strc_formulas_display_width %\setlocalhsize %\displaywidth\localhsize \ifdim\hangindent>\zeropoint @@ -579,7 +682,11 @@ \else \advance\displaywidth\hangindent \fi - \advance\displaywidth\dimexpr-\displayindent-\d_strc_formulas_display_skip_right-\d_strc_formulas_display_margin_right\relax + \advance\displaywidth\dimexpr + -\displayindent + -\d_strc_formulas_display_skip_right + -\d_strc_formulas_display_margin_right + \relax \hsize\displaywidth} % new, else overfull in itemize \unexpanded\def\strc_formulas_start_formula#1% @@ -595,39 +702,49 @@ %D %D \typebuffer \getbuffer +\installcorenamespace{formulaoption} + +\def\strc_formulas_option#1% + {\ifcsname\??formulaoption#1\endcsname + \lastnamedcs + \else + \font_basics_switchtobodyfont{#1}% for old time sake, might go away, only pt so maybe dimension and small test + \fi} + +\setvalue{\??formulaoption\v!packed}% + {\c_strc_formulas_space_model\zerocount} + +\setvalue{\??formulaoption\v!tight}% + {\settrue\c_strc_formulas_tight} + +\setvalue{\??formulaoption\v!middle}% + {\d_strc_formulas_display_skip_left \zeropoint + \d_strc_formulas_display_skip_right\zeropoint} + \unexpanded\def\strc_formulas_start_formula_indeed[#1][#2]% setting leftskip adaption is slow ! {\bgroup % HERE \def\currentformula{#1}% \dostarttaggedchained\t!formula\currentformula\??formula \the\everybeforedisplayformula - \d_strc_formulas_display_skip_par\parskip\relax + \setfalse\c_strc_formulas_tight %\formulastrutdp\strutdepth %\formulastrutht\strutheight - \edef\p_option {\formulaparameter\c!option}% - \edef\p_margin {\formulaparameter\c!margin}% - \edef\p_bodyfont{#2}% - %\ifx\p_bodyfont\empty - % \edef\p_bodyfont{\formulaparameter\c!bodyfont}% - %\fi - \ifx\p_bodyfont\empty \else - \switchtoformulabodyfont[#2]% - \fi - \parskip\d_strc_formulas_display_skip_par\relax - \ifx\p_option\v!middle - \d_strc_formulas_display_skip_left \zeropoint - \d_strc_formulas_display_skip_right\zeropoint - \else - \d_strc_formulas_display_skip_left \leftskip - \d_strc_formulas_display_skip_right\rightskip - \fi + \d_strc_formulas_display_skip_left \leftskip + \d_strc_formulas_display_skip_right \rightskip + \d_strc_formulas_display_width \formulaparameter\c!width\relax \d_strc_formulas_display_margin_left \formulaparameter\c!leftmargin \relax \d_strc_formulas_display_margin_right\formulaparameter\c!rightmargin\relax + \edef\p_option{\formulaparameter\c!option}% + \edef\p_option{\ifx\p_option\empty\else\p_option,\fi#2}% + \ifx\p_option\empty \else + \rawprocesscommacommand[\p_option]\strc_formulas_option + \fi + \edef\p_margin{\formulaparameter\c!margin}% \ifx\p_margin\empty \else \dosetleftskipadaption\p_margin \d_strc_formulas_display_margin_left\leftskipadaption \fi \let\strc_formulas_start_formula\strc_formulas_start_formula_nested - %\freezedimenmacro\predisplaysizethreshhold \strc_formulas_forget_display_skips \csname\e!start\formulaparameter\c!alternative\v!formula\endcsname} @@ -643,9 +760,8 @@ % tagging of formulanumbers is not ok (we get two display maths blobs) \unexpanded\def\strc_formulas_stop_formula - {\dostarttagged\t!formulacaption\empty - \strc_formulas_place_number - \dostoptagged + {\strc_formulas_place_number % in case it hasn't happened yet + \strc_formulas_flush_number % in case we are in native mode \dostarttagged\t!formulacontent\empty \csname\e!stop\formulaparameter\c!alternative\v!formula\endcsname \dostoptagged @@ -668,16 +784,16 @@ \fi \to \everybeforedisplayformula -\unexpanded\def\switchtoformulabodyfont - {\switchtobodyfont} +% \unexpanded\def\switchtoformulabodyfont +% {\switchtobodyfont} \setuvalue{\v!formula}{\dosingleempty\strc_formulas_formula} \def\strc_formulas_formula[#1]#2% todo: tagged {\begingroup - \edef\p_bodyfont{#1}% - \ifx\p_bodyfont\empty \else - \switchtoformulabodyfont[\p_bodyfont]% + \edef\p_direct{#1}% + \ifx\p_direct\empty \else + \rawprocesscommalist[\p_direct]\strc_formulas_option \fi % not : \def\strc_formulas_formula[##1]##2{\mathematics{##2}}% \mathematics{#2}% @@ -711,47 +827,71 @@ % \afterdisplayspace % \par % \egroup} - -\newconstant\c_strc_formulas_space_model - -\c_strc_formulas_space_model\plusone -%c_strc_formulas_space_model\plustwo % needs chdcking with spac-ver +% +% \unexpanded\def\startdisplaymath +% {\bgroup +% \par +% \informulatrue +% \beforedisplayspace +% \par +% \ifvmode +% \ifcase\c_strc_formulas_space_model +% % nothing +% \or +% % nothing yet +% \or +% \prevdepth-\maxdimen % texbook pagina 79-80 +% \fi +% \fi +% \noindent % else funny hlist with funny baselineskip +% \Ucheckedstartdisplaymath +% \setdisplaydimensions +% \startinnermath} +% +% \unexpanded\def\stopdisplaymath +% {\stopinnermath +% \Ucheckedstopdisplaymath +% \par +% \ifvmode +% \ifcase\c_strc_formulas_space_model +% % nothing +% \or +% \prevdepth .5\strutdp +% \or +% \prevdepth\lineheight +% \fi +% \fi +% \afterdisplayspace +% \par +% \egroup} \unexpanded\def\startdisplaymath {\bgroup - \par \informulatrue \beforedisplayspace - \par - \ifvmode - \ifcase\c_strc_formulas_space_model - % nothing - \or - % nothing yet - \or - \prevdepth-\maxdimen % texbook pagina 79-80 - \fi - \fi - \noindent % else funny hlist with funny baselineskip - \Ucheckedstartdisplaymath \setdisplaydimensions - \startinnermath} + \ifcase\c_strc_formulas_mode + \noindent % prevents that tex injects empty line (when using native display mechanism) + \Ucheckedstartdisplaymath + \or + \setbox\b_strc_formulas_content\hbox\bgroup + \normalUstartmath + \displaystyle + \else + \expandafter\startinnermath + \fi} \unexpanded\def\stopdisplaymath - {\stopinnermath - \Ucheckedstopdisplaymath - \par - \ifvmode - \ifcase\c_strc_formulas_space_model - % nothing - \or - \prevdepth .5\strutdp - \or - \prevdepth\lineheight - \fi + {\ifcase\c_strc_formulas_mode + \Ucheckedstopdisplaymath + \or + \normalUstopmath + \egroup + \strc_formulas_flush_content_and_number + \else + \expandafter\stopinnermath \fi \afterdisplayspace - \par \egroup} % already defined @@ -821,47 +961,49 @@ \unexpanded\def\startformulas {\dosingleempty\strc_formulas_start_formulas} +\unexpanded\def\startformulas + {\dosingleempty\strc_formulas_start_formulas} + \def\strc_formulas_start_formulas[#1]#2\stopformulas % new / to be internationalized - {\bgroup + {\startformula \dostarttagged\t!formulaset\empty \global\settrue\c_strc_formulas_inside_formulas \edef\currentformulasreference{#1}% \strc_formulas_handle_number \let\currentformula\empty \strc_formulas_forget_display_skips - \startdisplaymath - \setlocalhsize \unexpanded\def\startformula##1\stopformula {\advance\scratchcounter\plusone}% \scratchcounter\zerocount #2% preroll - \ifcase\scratchcounter\else - \divide \hsize \scratchcounter - \fi - \hbox to \localhsize \bgroup + \hbox to \displaywidth \bgroup + \divide\displaywidth\scratchcounter \hss \let\startformula\strc_formulas_nested_formula_start \let\stopformula \strc_formulas_nested_formula_stop #2% - \egroup - \stopdisplaymath + \egroup \global\setfalse\c_strc_formulas_inside_formulas \dostoptagged - \egroup + \stopformula \the\everyresetformulas \hangafter\minusone % added for side floats \hangindent\zeropoint} % added for side floats \unexpanded\def\strc_formulas_nested_formula_start - {\Ustartmath - \vcenter\bgroup + {\hbox to \displaywidth \bgroup + \hsize\displaywidth + \Ustartmath + \vcenter\bgroup % not optimal \vskip-\strutdepth \Ustartdisplaymath} \unexpanded\def\strc_formulas_nested_formula_stop {\Ustopdisplaymath + \obeydepth \egroup \Ustopmath + \egroup \hss} % place @@ -998,10 +1140,23 @@ \fi} \def\strc_formulas_place_number_indeed - {\glet\strc_formulas_place_number\relax - \doifelse{\formulaparameter\c!location}\v!left - {\normalleqno{\strc_formulas_number_indeed}} - {\normalreqno{\strc_formulas_number_indeed}}} + {\dostarttagged\t!formulacaption\empty + \glet\strc_formulas_place_number\relax + \global\setbox\b_strc_formulas_number\hbox{\strc_formulas_number_indeed}% + \dostoptagged} + +\def\strc_formulas_flush_number + {\ifcase\c_strc_formulas_mode + \ifzeropt\wd\b_strc_formulas_number + % nothing to be done + \else + \ifx\p_location\v!left + \math_native_leqno{\box\b_strc_formulas_number}% + \else + \math_native_reqno{\box\b_strc_formulas_number}% + \fi + \fi + \fi} % todo diff --git a/tex/context/base/mkiv/supp-box.lua b/tex/context/base/mkiv/supp-box.lua index 98d0e0474..bf41899bf 100644 --- a/tex/context/base/mkiv/supp-box.lua +++ b/tex/context/base/mkiv/supp-box.lua @@ -38,6 +38,7 @@ local getid = nuts.getid local getlist = nuts.getlist local getattribute = nuts.getattribute local getbox = nuts.getbox +local takebox = nuts.takebox local setfield = nuts.setfield local setlink = nuts.setlink @@ -54,6 +55,7 @@ local find_tail = nuts.tail local traverse_id = nuts.traverse_id local link_nodes = nuts.linked local dimensions = nuts.dimensions +local hpack = nuts.hpack local listtoutf = nodes.listtoutf @@ -389,6 +391,35 @@ interfaces.implement { end } +interfaces.implement { + name = "getnaturalwd", + arguments = "integer", + actions = function(n) + local w, h, d = 0, 0, 0 + local l = getlist(getbox(n)) + if l then + w, h, d = dimensions(l) + end + context("\\dimexpr%i\\scaledpoint\\relax",w) + end +} + +local function setboxtonaturalwd(n) + local old = takebox(n) + local new = hpack(getlist(old)) + setlist(old,nil) + free_node(old) + setbox(n,new) +end + +interfaces.implement { + name = "setnaturalwd", + arguments = "integer", + actions = setboxtonaturalwd +} + +nodes.setboxtonaturalwd = setboxtonaturalwd + local function firstdirinbox(n) local b = getbox(n) if b then diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv index 9f4c58ad7..bb7e2b709 100644 --- a/tex/context/base/mkiv/supp-box.mkiv +++ b/tex/context/base/mkiv/supp-box.mkiv @@ -2620,7 +2620,7 @@ \unexpanded\def\obeydepth {\par - \ifvmode + \ifvmode \ifdim\prevdepth>\zeropoint \kern-\prevdepth \fi @@ -2885,10 +2885,20 @@ \let\getnaturaldimensions\clf_getnaturaldimensions % sets three dimensions \let\naturalwd \clf_naturalwd % calculates and returns wd +\let\getnaturalwd\clf_getnaturalwd % no intermediate +\let\setnaturalwd\clf_setnaturalwd % no intermediate + \unexpanded\def\doifelserighttoleftinbox{\clf_doifelserighttoleftinbox} \let\doifrighttoleftinboxelse\doifelserighttoleftinbox +%D New, used in high/low: + +\definesystemattribute [runningtext] [public] + +\unexpanded\def\runninghbox{\hbox attr \runningtextattribute \plusone} % not yet in i-* +\unexpanded\def\runninghbox{\hbox attr \runningtextattribute \fontid\font} % not yet in i-* + \protect \endinput % a bit of test code: diff --git a/tex/context/base/mkiv/tabl-xtb.lua b/tex/context/base/mkiv/tabl-xtb.lua index 4eaa29ad3..937e2d816 100644 --- a/tex/context/base/mkiv/tabl-xtb.lua +++ b/tex/context/base/mkiv/tabl-xtb.lua @@ -26,7 +26,7 @@ this mechamism will be improved so that it can replace its older cousin. -- todo: use linked list instead of r/c array -- todo: we can use the sum of previously forced widths for column spans -local tonumber, next = tonumber, next +local tonumber, next, rawget = tonumber, next, rawget local commands = commands local context = context @@ -1187,9 +1187,17 @@ function xtables.next_row(specification) end function xtables.finish_row() - local n = data.nofcolumns - data.currentcolumn + local c = data.currentcolumn + local r = data.currentrow + local d = data.rows[r][c] + local n = data.nofcolumns - c + if d then + local nx = d.nx + if nx > 0 then + n = n - nx + 1 + end + end if n > 0 then - -- message for i=1,n do context_dummyxcell() end diff --git a/tex/context/base/mkiv/trac-vis.lua b/tex/context/base/mkiv/trac-vis.lua index 803bfdde0..080b72673 100644 --- a/tex/context/base/mkiv/trac-vis.lua +++ b/tex/context/base/mkiv/trac-vis.lua @@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['trac-vis'] = { local string, number, table = string, number, table local node, nodes, attributes, fonts, tex = node, nodes, attributes, fonts, tex local type = type -local format = string.format +local gmatch = string.gmatch local formatters = string.formatters -- This module started out in the early days of mkiv and luatex with @@ -166,6 +166,7 @@ local modes = { vtop = 4, kern = 8, glue = 16, + -- skip = 16, penalty = 32, fontkern = 64, strut = 128, @@ -237,7 +238,7 @@ local function enable() tex.setcount("global","c_syst_visualizers_state",1) -- so that we can optimize at the tex end end -local function setvisual(n,a,what) -- this will become more efficient when we have the bit lib linked in +local function setvisual(n,a,what,list) -- this will become more efficient when we have the bit lib linked in if not n or n == "reset" then return unsetvalue elseif n == "makeup" then @@ -261,22 +262,15 @@ local function setvisual(n,a,what) -- this will become more efficient when we ha a = setbit(a,preset_all) end else - local m = modes[n] - if not m then - -- go on - elseif a == unsetvalue then - if what == false then - return unsetvalue - else - -- a = setbit(0,m) + for s in gmatch(n,"[a-z]+") do + local m = modes[s] + if not m then + -- go on + elseif not a or a == 0 or a == unsetvalue then a = m + else + a = setbit(a,m) end - elseif what == false then - a = clearbit(a,m) - elseif not a or a == 0 then - a = m - else - a = setbit(a,m) end end if not a or a == 0 or a == unsetvalue then @@ -291,6 +285,10 @@ function nuts.setvisual(n,mode) setattr(n,a_visual,setvisual(mode,getattr(n,a_visual),true)) end +function nuts.setvisuals(n,mode) + setattr(n,a_visual,setvisual(mode,getattr(n,a_visual),true,true)) +end + function nuts.copyvisual(n,m) setattr(n,a_visual,getattr(m,a_visual)) end @@ -1072,7 +1070,7 @@ end statistics.register("visualization time",function() if enabled then -- cleanup() -- in case we don't don't do it each time - return format("%s seconds",statistics.elapsedtime(visualizers)) + return formatters["%s seconds"](statistics.elapsedtime(visualizers)) end end) @@ -1080,9 +1078,38 @@ end) local implement = interfaces.implement -implement { name = "setvisual", arguments = "string", actions = visualizers.setvisual } -implement { name = "getvisual", arguments = "string", actions = { setvisual, context } } -implement { name = "setvisuallayer", arguments = "string", actions = visualizers.setlayer } -implement { name = "markvisualfonts", arguments = "integer", actions = visualizers.markfonts } -implement { name = "setvisualfont", arguments = "integer", actions = visualizers.setfont } +implement { + name = "setvisual", + arguments = "string", + actions = visualizers.setvisual +} + +implement { + name = "setvisuals", + arguments = "string", + actions = visualizers.setvisual +} +implement { + name = "getvisual", + arguments = "string", + actions = { setvisual, context } +} + + implement { + name = "setvisuallayer", + arguments = "string", + actions = visualizers.setlayer +} + +implement { + name = "markvisualfonts", + arguments = "integer", + actions = visualizers.markfonts +} + +implement { + name = "setvisualfont", + arguments = "integer", + actions = visualizers.setfont +} diff --git a/tex/context/base/mkiv/typo-fln.lua b/tex/context/base/mkiv/typo-fln.lua index 848c7ccf6..c45836437 100644 --- a/tex/context/base/mkiv/typo-fln.lua +++ b/tex/context/base/mkiv/typo-fln.lua @@ -31,6 +31,9 @@ local tonut = nuts.tonut local tonode = nuts.tonode local getnext = nuts.getnext +local getprev = nuts.getprev +local getboth = nuts.getboth +local setboth = nuts.setboth local getid = nuts.getid local getfield = nuts.getfield local setfield = nuts.setfield @@ -39,6 +42,10 @@ local setlist = nuts.setlist local getattr = nuts.getattr local setattr = nuts.setattr local getbox = nuts.getbox +local getdisc = nuts.getdisc +local setdisc = nuts.setdisc +local getdimensions = nuts.dimensions +local setlink = nuts.setlink local nodecodes = nodes.nodecodes local glyph_code = nodecodes.glyph @@ -50,7 +57,6 @@ local free_node_list = nuts.flush_list local free_node = nuts.flush_node local copy_node_list = nuts.copy_list local insert_node_after = nuts.insert_after -local hpack_node_list = nuts.hpack local remove_node = nuts.remove local nodepool = nuts.pool @@ -119,12 +125,31 @@ actions[v_line] = function(head,setting) local n = 0 local temp = copy_node_list(head) local linebreaks = { } - for g in traverse_id(glyph_code,temp) do - if dynamic > 0 then - setattr(g,0,dynamic) + + local function set(head) + for g in traverse_id(glyph_code,head) do + if dynamic > 0 then + setattr(g,0,dynamic) + end + setfield(g,"font",font) + end + end + + set(temp) + + for g in traverse_id(disc_code,temp) do + local pre, post, replace = getdisc(g) + if pre then + set(pre) + end + if post then + set(post) + end + if replace then + set(replace) end - setfield(g,"font",font) end + local start = temp local list = temp local prev = temp @@ -136,25 +161,37 @@ actions[v_line] = function(head,setting) if i <= - hangafter then hsize = hsize - hangindent end + + local function try(extra) + local width = getdimensions(list,start) + if extra then + width = width + getdimensions(extra) + end + if width > hsize then + list = prev + return true + else + linebreaks[i] = n + prev = start + nofchars = n + end + end + while start do local id = getid(start) if id == glyph_code then n = n + 1 elseif id == disc_code then -- this could be an option + n = n + 1 + if try(getfield(start,"pre")) then + break + end elseif id == kern_code then -- todo: fontkern -- this could be an option elseif n > 0 then - local pack = hpack_node_list(copy_node_list(list,start)) - if getfield(pack,"width") > hsize then - free_node_list(pack) - list = prev + if try() then break - else - linebreaks[i] = n - prev = start - free_node_list(pack) - nofchars = n end end start = getnext(start) @@ -165,23 +202,69 @@ actions[v_line] = function(head,setting) end local start = head local n = 0 + + local function update(start) + if dynamic > 0 then + setattr(start,0,dynamic) + end + setfield(start,"font",font) + if ca and ca > 0 then + setattr(start,a_colorspace,ma == 0 and 1 or ma) + setattr(start,a_color,ca) + end + if ta and ta > 0 then + setattr(start,a_transparency,ta) + end + end + for i=1,noflines do local linebreak = linebreaks[i] while start and n < nofchars do local id = getid(start) - if id == glyph_code then -- or id == disc_code then - if dynamic > 0 then - setattr(start,0,dynamic) - end - setfield(start,"font",font) - if ca and ca > 0 then - setattr(start,a_colorspace,ma == 0 and 1 or ma) - setattr(start,a_color,ca) - end - if ta and ta > 0 then - setattr(start,a_transparency,ta) - end + if id == glyph_code then n = n + 1 + update(start) + elseif id == disc_code then + n = n + 1 + local disc = start + local pre, post, replace, pretail, posttail, replacetail = getdisc(disc,true) + if linebreak == n then + local p, n = getboth(start) + if pre then + for current in traverse_id(glyph_code,pre) do + update(current) + end + setlink(pretail,n) + setlink(p,pre) + start = pretail + pre = nil + else + setlink(p,n) + start = p + end + if post then + local p, n = getboth(start) + setlink(posttail,n) + setlink(start,post) + post = nil + end + else + local p, n = getboth(start) + if replace then + for current in traverse_id(glyph_code,replace) do + update(current) + end + setlink(replacetail,n) + setlink(p,replace) + start = replacetail + replace = nil + else + setlink(p,n) + start = p + end + end + setdisc(disc,pre,post,replace) + free_node(disc) end if linebreak == n then if trace_firstlines then diff --git a/tex/context/base/mkiv/typo-itc.lua b/tex/context/base/mkiv/typo-itc.lua index a54098bdf..38d4968df 100644 --- a/tex/context/base/mkiv/typo-itc.lua +++ b/tex/context/base/mkiv/typo-itc.lua @@ -8,6 +8,7 @@ if not modules then modules = { } end modules ['typo-itc'] = { local trace_italics = false trackers.register("typesetters.italics", function(v) trace_italics = v end) + local report_italics = logs.reporter("nodes","italics") local threshold = 0.5 trackers.register("typesetters.threshold", function(v) threshold = v == true and 0.5 or tonumber(v) end) @@ -61,6 +62,7 @@ local fonthashes = fonts.hashes local fontdata = fonthashes.identifiers local italicsdata = fonthashes.italics local exheights = fonthashes.exheights +local chardata = fonthashes.characters local is_punctuation = characters.is_punctuation @@ -193,12 +195,37 @@ local function domath(head,current, done) else a = a + 100 end - if getfield(next,"height") < 1.25*ex then - if trace_italics then - report_italics("removing italic between math %C and punctuation %C",getchar(glyph),char) + local i = getfield(kern,"kern") + local f = getfont(glyph) + local c = getchar(glyph) + if getfield(next,"height") < 1.25*exheights[f] then + if i == 0 then + if trace_italics then + report_italics("%s italic %p between math %C and punctuation %C","ignoring",i,c,char) + end + else + if trace_italics then + report_italics("%s italic between math %C and punctuation %C","removing",i,c,char) + end + setfield(kern,"kern",0) -- or maybe a small value or half the ic + done = true + end + elseif i == 0 then + local d = chardata[f][c] + local i = d.italic + if i == 0 then + if trace_italics then + report_italics("%s italic %p between math %C and punctuation %C","ignoring",i,c,char) + end + else + setfield(kern,"kern",i) + if trace_italics then + report_italics("%s italic %p between math %C and punctuation %C","setting",i,c,char) + end + done = true end - setfield(kern,"kern",0) -- or maybe a small value or half the ic - done = true + elseif trace_italics then + report_italics("%s italic %p between math %C and punctuation %C","keeping",k,c,char) end end end diff --git a/tex/context/base/mkiv/typo-scr.mkiv b/tex/context/base/mkiv/typo-scr.mkiv index 6249c390a..7b8d62dfb 100644 --- a/tex/context/base/mkiv/typo-scr.mkiv +++ b/tex/context/base/mkiv/typo-scr.mkiv @@ -53,7 +53,7 @@ \begingroup \edef\currentlow{#1}% \kern\lowparameter\c!distance\relax - \setbox\scratchbox\hbox\bgroup + \setbox\scratchbox\runninghbox\bgroup \lower\lowparameter\c!down\hbox\bgroup \ifx\fontsize\empty \ifmmode @@ -79,7 +79,7 @@ \begingroup \edef\currenthigh{#1}% \kern\highparameter\c!distance\relax - \setbox\scratchbox\hbox\bgroup + \setbox\scratchbox\runninghbox\bgroup \raise\highparameter\c!up\hbox\bgroup \ifx\fontsize\empty \ifmmode @@ -136,7 +136,7 @@ \unexpanded\def\typo_scripts_lowhigh#1% #2 {\dontleavehmode - \hbox\bgroup + \runninghbox\bgroup \edef\currentlowhigh{#1}% \dosingleempty} % #2 @@ -228,7 +228,8 @@ \to \everydefinelowmidhigh \unexpanded\def\typo_scripts_lowmidhigh#1#2#3#4% - {\dontleavehmode \hbox \bgroup + {\dontleavehmode + \runninghbox\bgroup \edef\currentlowmidhigh{#1}% \dostarttagged\t!subsup\currentlowmidhigh \uselowmidhighstyleandcolor\c!style\c!color diff --git a/tex/context/fonts/mkiv/bonum-math.lfg b/tex/context/fonts/mkiv/bonum-math.lfg new file mode 100644 index 000000000..00576aaef --- /dev/null +++ b/tex/context/fonts/mkiv/bonum-math.lfg @@ -0,0 +1,19 @@ +local kern_200 = { bottomright = { { kern = -200 } } } +local kern_100 = { bottomright = { { kern = -100 } } } + +return { + name = "bonum-math", + version = "1.00", + comment = "Goodies that complement bonum.", + author = "Hans Hagen", + copyright = "ConTeXt development team", + mathematics = { + kerns = { + [0x1D449] = kern_200, -- + [0x1D44A] = kern_100, -- 𝑊 + }, + alternates = { + dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, + }, + }, +} diff --git a/tex/context/fonts/mkiv/dejavu-math.lfg b/tex/context/fonts/mkiv/dejavu-math.lfg new file mode 100644 index 000000000..d28c69060 --- /dev/null +++ b/tex/context/fonts/mkiv/dejavu-math.lfg @@ -0,0 +1,18 @@ +local kern_250 = { bottomright = { { kern = -250 } } } + +return { + name = "dejavu-math", + version = "1.00", + comment = "Goodies that complement dejavu.", + author = "Hans Hagen", + copyright = "ConTeXt development team", + mathematics = { + kerns = { + [0x1D449] = kern_250, -- + [0x1D44A] = kern_250, -- 𝑊 + }, + alternates = { + dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, + }, + }, +} diff --git a/tex/context/fonts/mkiv/lm.lfg b/tex/context/fonts/mkiv/lm.lfg index 546d18def..7ea5059e9 100644 --- a/tex/context/fonts/mkiv/lm.lfg +++ b/tex/context/fonts/mkiv/lm.lfg @@ -1,6 +1,9 @@ -- In order to be able to use beta math fonts, we use our own file name and -- always remap. +local kern_150 = { bottomright = { { kern = -150 } } } +local kern_200 = { bottomright = { { kern = -200 } } } + return { name = "latin modern", version = "1.00", @@ -14,6 +17,10 @@ return { -- mathematics.tweaks.fixoverline, }, }, + kerns = { + [0x1D449] = kern_150, -- + [0x1D44A] = kern_200, -- 𝑊 + }, dimensions = { -- always applied -- default = { diff --git a/tex/context/fonts/mkiv/lucida-opentype-math.lfg b/tex/context/fonts/mkiv/lucida-opentype-math.lfg index 946458dea..29206da1a 100644 --- a/tex/context/fonts/mkiv/lucida-opentype-math.lfg +++ b/tex/context/fonts/mkiv/lucida-opentype-math.lfg @@ -1,3 +1,5 @@ +----- kern_250 = { bottomright = { { kern = -250 } }, force = true } + return { name = "lucida-opentype-math", version = "1.00", @@ -13,6 +15,10 @@ return { zero = { feature = 'ss05', value = 1, comment = "Mathematical Alternative Zero" }, partial = { feature = 'ss20', value = 1, comment = "Mathematical Alternative Upright Partial Differential" }, }, + -- kerns = { + -- [0x1D449] = kern_250, -- + -- [0x1D44A] = kern_250, -- 𝑊 + -- }, dimensions = { default = { -- experimental values [0x2044] = { xoffset = 275, width = 600 }, diff --git a/tex/context/fonts/mkiv/pagella-math.lfg b/tex/context/fonts/mkiv/pagella-math.lfg new file mode 100644 index 000000000..40d50383b --- /dev/null +++ b/tex/context/fonts/mkiv/pagella-math.lfg @@ -0,0 +1,19 @@ +local kern_200 = { bottomright = { { kern = -200 } } } +local kern_100 = { bottomright = { { kern = -100 } } } + +return { + name = "pagella-math", + version = "1.00", + comment = "Goodies that complement pagella.", + author = "Hans Hagen", + copyright = "ConTeXt development team", + mathematics = { + kerns = { + [0x1D449] = kern_200, -- + [0x1D44A] = kern_100, -- 𝑊 + }, + alternates = { + dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, + }, + }, +} diff --git a/tex/context/fonts/mkiv/schola-math.lfg b/tex/context/fonts/mkiv/schola-math.lfg new file mode 100644 index 000000000..9787c18a9 --- /dev/null +++ b/tex/context/fonts/mkiv/schola-math.lfg @@ -0,0 +1,19 @@ +local kern_200_050 = { bottomright = { { kern = -200 } }, topright = { { kern = 50 } } } +local kern_100_050 = { bottomright = { { kern = -100 } }, topright = { { kern = 50 } } } + +return { + name = "schola-math", + version = "1.00", + comment = "Goodies that complement schola.", + author = "Hans Hagen", + copyright = "ConTeXt development team", + mathematics = { + kerns = { + [0x1D449] = kern_200_050, -- + [0x1D44A] = kern_100_050, -- 𝑊 + }, + alternates = { + dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, + }, + }, +} diff --git a/tex/context/fonts/mkiv/termes-math.lfg b/tex/context/fonts/mkiv/termes-math.lfg new file mode 100644 index 000000000..557216cb1 --- /dev/null +++ b/tex/context/fonts/mkiv/termes-math.lfg @@ -0,0 +1,19 @@ +local kern_200 = { bottomright = { { kern = -200 } } } +local kern_100 = { bottomright = { { kern = -100 } } } + +return { + name = "termes-math", + version = "1.00", + comment = "Goodies that complement termes.", + author = "Hans Hagen", + copyright = "ConTeXt development team", + mathematics = { + kerns = { + [0x1D449] = kern_200, -- + [0x1D44A] = kern_100, -- 𝑊 + }, + alternates = { + dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, + }, + }, +} diff --git a/tex/context/fonts/mkiv/type-imp-dejavu.mkiv b/tex/context/fonts/mkiv/type-imp-dejavu.mkiv index 41cf1f701..6ae26e0a7 100644 --- a/tex/context/fonts/mkiv/type-imp-dejavu.mkiv +++ b/tex/context/fonts/mkiv/type-imp-dejavu.mkiv @@ -40,15 +40,16 @@ \stoptypescript \starttypescript [\s!math][dejavu][\s!name] - %\loadfontgoodies[dejavu] - \definefontsynonym[\s!MathRoman][file:dejavu-math.otf][\s!features=\s!math\mathsizesuffix] + \loadfontgoodies[dejavu-math] + % \definefontsynonym[\s!MathRoman][file:dejavu-math.otf][\s!features=\s!math\mathsizesuffix] + \definefontsynonym[\s!MathRoman][file:texgyredejavu-math][\s!features=\s!math\mathsizesuffix,\s!goodies=dejavu-math] \stoptypescript \starttypescript[dejavu] \definetypeface [dejavu] [\s!rm] [\s!serif] [dejavu] [\s!default] \definetypeface [dejavu] [\s!ss] [\s!sans] [dejavu] [\s!default] \definetypeface [dejavu] [\s!tt] [\s!mono] [dejavu] [\s!default] -% \definetypeface [dejavu] [\s!mm] [\s!math] [xits] [\s!default] [\s!rscale=1.2] + % \definetypeface [dejavu] [\s!mm] [\s!math] [xits] [\s!default] [\s!rscale=1.2] \definetypeface [dejavu] [\s!mm] [\s!math] [dejavu] [\s!default] \stoptypescript @@ -99,7 +100,7 @@ \definetypeface [dejavu-condensed] [\s!rm] [\s!serif] [dejavu-condensed] [\s!default] \definetypeface [dejavu-condensed] [\s!ss] [\s!sans] [dejavu-condensed] [\s!default] \definetypeface [dejavu-condensed] [\s!tt] [\s!mono] [dejavu-condensed] [\s!default] -% \definetypeface [dejavu-condensed] [\s!mm] [\s!math] [xits] [\s!default] [\s!rscale=1.2] + % \definetypeface [dejavu-condensed] [\s!mm] [\s!math] [xits] [\s!default] [\s!rscale=1.2] \definetypeface [dejavu-condensed] [\s!mm] [\s!math] [dejavu] [\s!default] \stoptypescript diff --git a/tex/context/fonts/mkiv/type-imp-texgyre.mkiv b/tex/context/fonts/mkiv/type-imp-texgyre.mkiv index 86db8c603..e617a2505 100644 --- a/tex/context/fonts/mkiv/type-imp-texgyre.mkiv +++ b/tex/context/fonts/mkiv/type-imp-texgyre.mkiv @@ -215,54 +215,28 @@ \stoptypescriptcollection -\startmode[txmath] - - \starttypescriptcollection[texgyre-math-times] - - \starttypescript [\s!math][times,termes][\s!all] - \loadfontgoodies[tx-math] - \definefontsynonym[\s!MathRoman][txmath@tx-math] - % \definefontsynonym[\s!MathRomanBold][MathRoman] - \stoptypescript - - \stoptypescriptcollection - -\stopmode - \startnotmode[txmath] \starttypescriptcollection[texgyre-math-times] \starttypescript [\s!math][times,termes][\s!all] - \loadfontgoodies[texgyre] - \definefontsynonym[\s!MathRoman][file:texgyre-termes-math-regular.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=texgyre] + % \loadfontgoodies[texgyre] + % \definefontsynonym[\s!MathRoman][file:texgyre-termes-math-regular.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=texgyre] + \definefontsynonym[\s!MathRoman][file:texgyretermes-math.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=termes-math] \stoptypescript \stoptypescriptcollection \stopnotmode -\startmode[pxmath] - - \starttypescriptcollection[texgyre-math-pagella] - - \starttypescript [\s!math][palatino,pagella][\s!all] - \loadfontgoodies[px-math] - \definefontsynonym[\s!MathRoman][pxmath@px-math] - % \definefontsynonym[\s!MathRomanBold][MathRoman] - \stoptypescript - - \stoptypescriptcollection - -\stopmode - \startnotmode[pxmath] \starttypescriptcollection[texgyre-math-pagella] \starttypescript [\s!math][palatino,pagella][\s!all] - \loadfontgoodies[texgyre] - \definefontsynonym[\s!MathRoman][file:texgyre-pagella-math-regular.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=texgyre] + % \loadfontgoodies[texgyre] + % \definefontsynonym[\s!MathRoman][file:texgyre-pagella-math-regular.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=texgyre] + \definefontsynonym[\s!MathRoman][file:texgyrepagella-math.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=pagella-math] \stoptypescript \stoptypescriptcollection @@ -272,8 +246,9 @@ \starttypescriptcollection[texgyre-math-bonum] \starttypescript [\s!math][bookman,bonum][\s!all] - \loadfontgoodies[texgyre] - \definefontsynonym[\s!MathRoman][file:texgyre-bonum-math-regular.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=texgyre] + % \loadfontgoodies[texgyre] + % \definefontsynonym[\s!MathRoman][file:texgyre-bonum-math-regular.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=texgyre] + \definefontsynonym[\s!MathRoman][file:texgyrebonum-math.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=bonum-math] \stoptypescript \stoptypescriptcollection @@ -281,8 +256,38 @@ \starttypescriptcollection[texgyre-math-schola] \starttypescript [\s!math][schoolbook,schola][\s!all] - \loadfontgoodies[texgyre] - \definefontsynonym[\s!MathRoman][file:texgyre-schola-math-regular.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=texgyre] + % \loadfontgoodies[texgyre] + % \definefontsynonym[\s!MathRoman][file:texgyre-schola-math-regular.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=texgyre] + \definefontsynonym[\s!MathRoman][file:texgyreschola-math.otf][\s!features=\s!math\mathsizesuffix,\s!goodies=schola-math] \stoptypescript \stoptypescriptcollection + +\startmode[txmath] + + \starttypescriptcollection[texgyre-math-times] + + \starttypescript [\s!math][times,termes][\s!all] + \loadfontgoodies[tx-math] + \definefontsynonym[\s!MathRoman][txmath@tx-math] + % \definefontsynonym[\s!MathRomanBold][MathRoman] + \stoptypescript + + \stoptypescriptcollection + +\stopmode + +\startmode[pxmath] + + \starttypescriptcollection[texgyre-math-pagella] + + \starttypescript [\s!math][palatino,pagella][\s!all] + \loadfontgoodies[px-math] + \definefontsynonym[\s!MathRoman][pxmath@px-math] + % \definefontsynonym[\s!MathRomanBold][MathRoman] + \stoptypescript + + \stoptypescriptcollection + +\stopmode + diff --git a/tex/context/interface/mkiv/i-common-argument.xml b/tex/context/interface/mkiv/i-common-argument.xml index 9e7429800..f197481e7 100644 --- a/tex/context/interface/mkiv/i-common-argument.xml +++ b/tex/context/interface/mkiv/i-common-argument.xml @@ -494,4 +494,15 @@ </cd:keywords> </cd:define> -</cd:interface>
\ No newline at end of file + <!-- math formula directives --> + + <cd:define name="argument-formula"> + <cd:keywords list="yes" optional="yes"> + <cd:constant type="packed"/> + <cd:constant type="tight"/> + <cd:constant type="middle"/> + <cd:inherit name="setupbodyfont"/> + </cd:keywords> + </cd:define> + +</cd:interface> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex fcb1f5bd1..39a841a19 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-fontfamily.xml b/tex/context/interface/mkiv/i-fontfamily.xml index c069a4c17..648bef6a2 100644 --- a/tex/context/interface/mkiv/i-fontfamily.xml +++ b/tex/context/interface/mkiv/i-fontfamily.xml @@ -146,8 +146,8 @@ <cd:constant type="no" default="yes"/> </cd:parameter> <cd:parameter name="force"> - <cd:constant type="yes" default="yes"/> - <cd:constant type="no"/> + <cd:constant type="yes"/> + <cd:constant type="no" default="yes"/> </cd:parameter> <cd:parameter name="features"> <cd:constant type="cd:name"/> @@ -209,9 +209,9 @@ <cd:command name="definefontfamilypreset" variant="1" file="font-sel.mkvi"> <cd:arguments> <cd:resolve name="keyword-name"/> - <cd:assignment list="yes"> + <cd:assignments list="yes"> <cd:inherit name="definefontfamily"/> - </cd:assignment> + </cd:assignments> </cd:arguments> </cd:command> @@ -222,4 +222,4 @@ </cd:arguments> </cd:command> -</cd:interface>
\ No newline at end of file +</cd:interface> diff --git a/tex/context/interface/mkiv/i-formula.xml b/tex/context/interface/mkiv/i-formula.xml index da1d1c0cf..ea0dcb52f 100644 --- a/tex/context/interface/mkiv/i-formula.xml +++ b/tex/context/interface/mkiv/i-formula.xml @@ -126,55 +126,45 @@ --> + <!-- todo: make definition for keywords --> + <cd:command name="formula" type="environment" generated="yes" variant="generated" file="strc-mat.mkiv"> <cd:sequence> <cd:variable value="formula"/> <cd:string value="formula"/> </cd:sequence> <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:inherit name="setupbodyfont"/> - </cd:keywords> + <cd:resolve name="argument-formula"/> </cd:arguments> </cd:command> <cd:command name="formula" type="environment" file="strc-mat.mkiv"> <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:inherit name="setupbodyfont"/> - </cd:keywords> + <cd:resolve name="argument-formula"/> </cd:arguments> </cd:command> <cd:command name="spformula" type="environment" file="strc-mat.mkiv"> <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:inherit name="setupbodyfont"/> - </cd:keywords> + <cd:resolve name="argument-formula"/> </cd:arguments> </cd:command> <cd:command name="sdformula" type="environment" file="strc-mat.mkiv"> <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:inherit name="setupbodyfont"/> - </cd:keywords> + <cd:resolve name="argument-formula"/> </cd:arguments> </cd:command> <cd:command name="mpformula" type="environment" file="strc-mat.mkiv"> <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:inherit name="setupbodyfont"/> - </cd:keywords> + <cd:resolve name="argument-formula"/> </cd:arguments> </cd:command> <cd:command name="mdformula" type="environment" file="strc-mat.mkiv"> <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:inherit name="setupbodyfont"/> - </cd:keywords> + <cd:resolve name="argument-formula"/> </cd:arguments> </cd:command> @@ -188,9 +178,7 @@ <cd:command name="formula" file="strc-mat.mkiv"> <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:inherit name="setupbodyfont"/> - </cd:keywords> + <cd:resolve name="argument-formula"/> <cd:content/> </cd:arguments> </cd:command> @@ -295,4 +283,4 @@ <cd:command name="placecurrentformulanumber" file="strc-mat"/> -</cd:interface>
\ No newline at end of file +</cd:interface> diff --git a/tex/context/interface/mkiv/i-framed.xml b/tex/context/interface/mkiv/i-framed.xml index 1c214322a..07bdd5de4 100644 --- a/tex/context/interface/mkiv/i-framed.xml +++ b/tex/context/interface/mkiv/i-framed.xml @@ -142,6 +142,7 @@ <cd:parameter name="strut"> <cd:constant type="yes" default="yes"/> <cd:constant type="no"/> + <cd:constant type="none"/> <cd:constant type="local"/> <cd:constant type="global"/> </cd:parameter> diff --git a/tex/context/interface/mkiv/i-lines.xml b/tex/context/interface/mkiv/i-lines.xml index e43945e4d..fc8032448 100644 --- a/tex/context/interface/mkiv/i-lines.xml +++ b/tex/context/interface/mkiv/i-lines.xml @@ -78,6 +78,12 @@ <cd:parameter name="color"> <cd:constant type="cd:color"/> </cd:parameter> + <cd:parameter name="left"> + <cd:constant type="cd:command"/> + </cd:parameter> + <cd:parameter name="right"> + <cd:constant type="cd:command"/> + </cd:parameter> </cd:assignments> </cd:arguments> </cd:command> @@ -107,4 +113,4 @@ </cd:arguments> </cd:command> -</cd:interface>
\ No newline at end of file +</cd:interface> diff --git a/tex/context/interface/mkiv/i-math.xml b/tex/context/interface/mkiv/i-math.xml index d16ba5173..3381a4273 100644 --- a/tex/context/interface/mkiv/i-math.xml +++ b/tex/context/interface/mkiv/i-math.xml @@ -81,8 +81,8 @@ <cd:parameter name="textcolor"> <cd:constant type="cd:color"/> </cd:parameter> - <cd:parameter name="functionstyle"> - <cd:resolve name="value-style"/> + <cd:parameter name="functioncolor"> + <cd:resolve name="cd:color"/> </cd:parameter> <cd:parameter name="integral"> <cd:constant type="limits"/> diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex cf4df2f98..1e326ed67 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/mkiv/x-setups-basics.mkiv b/tex/context/modules/mkiv/x-setups-basics.mkiv index 4a7859c7f..9faf3f79c 100644 --- a/tex/context/modules/mkiv/x-setups-basics.mkiv +++ b/tex/context/modules/mkiv/x-setups-basics.mkiv @@ -912,7 +912,13 @@ [definition] [align=flushright] -\unexpanded\def\showdefinition#1% +\unexpanded\def\showdefinition + {\doifelsenextoptional\cmd_show_definition_yes\cmd_show_definition_nop} + +\unexpanded\def\cmd_show_definition_nop#1% + {\cmd_show_definition_yes[#1]} + +\unexpanded\def\cmd_show_definition_yes[#1]% {\placedefinition[here][definition:#1]{\tex{#1}}{\showsetup{#1}}} \unexpanded\def\definition[#1]% diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 9e7d88910..4d1ef8322 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 : 05/22/16 15:18:33 +-- merge date : 05/31/16 09:02:55 do -- begin closure to overcome local limits and interference @@ -5286,6 +5286,19 @@ function constructors.enhanceparameters(parameters) extra=extra, } end +local function mathkerns(v,vdelta) + local k={} + for i=1,#v do + local entry=v[i] + local height=entry.height + local kern=entry.kern + k[i]={ + height=height and vdelta*height or 0, + kern=kern and vdelta*kern or 0, + } + end + return k +end function constructors.scale(tfmdata,specification) local target={} if tonumber(specification) then @@ -5624,22 +5637,15 @@ function constructors.scale(tfmdata,specification) chr.top_accent=vdelta*va end if stackmath then - local mk=character.mathkerns + local mk=character.mathkerns if mk then - local kerns={} - local v=mk.top_right if v then local k={} for i=1,#v do local vi=v[i] - k[i]={ height=vdelta*vi.height,kern=vdelta*vi.kern } - end kerns.top_right=k end - local v=mk.top_left if v then local k={} for i=1,#v do local vi=v[i] - k[i]={ height=vdelta*vi.height,kern=vdelta*vi.kern } - end kerns.top_left=k end - local v=mk.bottom_left if v then local k={} for i=1,#v do local vi=v[i] - k[i]={ height=vdelta*vi.height,kern=vdelta*vi.kern } - end kerns.bottom_left=k end - local v=mk.bottom_right if v then local k={} for i=1,#v do local vi=v[i] - k[i]={ height=vdelta*vi.height,kern=vdelta*vi.kern } - end kerns.bottom_right=k end - chr.mathkern=kerns + local tr,tl,br,bl=mk.topright,mk.topleft,mk.bottomright,mk.bottomleft + chr.mathkern={ + top_right=tr and mathkerns(tr,vdelta) or nil, + top_left=tl and mathkerns(tl,vdelta) or nil, + bottom_right=br and mathkerns(br,vdelta) or nil, + bottom_left=bl and mathkerns(bl,vdelta) or nil, + } end end if hasitalics then @@ -11953,6 +11959,13 @@ do end end local reported={} + local function report_issue(i,what,sequence,kind) + local name=sequence.name + if not reported[name] then + report("rule %i in %s lookup %a has %s lookups",i,what,name,kind) + reported[name]=true + end + end for i=lastsequence+1,nofsequences do local sequence=sequences[i] local steps=sequence.steps @@ -11964,37 +11977,42 @@ do local rule=rules[i] local rlookups=rule.lookups if not rlookups then - local name=sequence.name - if not reported[name] then - report("rule %i in %s lookup %a has %s lookups",i,what,name,"no") - reported[name]=true - end + report_issue(i,what,sequence,"no") elseif not next(rlookups) then - local name=sequence.name - if not reported[name] then - report("rule %i in %s lookup %a has %s lookups",i,what,name,"empty") - reported[name]=true - end + report_issue(i,what,sequence,"empty") rule.lookups=nil else for index,lookupid in sortedhash(rlookups) do local h=sublookuphash[lookupid] if not h then - nofsublookups=nofsublookups+1 - local d=lookups[lookupid].done - h={ - index=nofsublookups, - name=f_lookupname(lookupprefix,"d",lookupid+lookupidoffset), - derived=true, - steps=d.steps, - nofsteps=d.nofsteps, - type=d.lookuptype, - markclass=d.markclass or nil, - flags=d.flags, - } - sublookuplist[nofsublookups]=h - sublookuphash[lookupid]=nofsublookups - sublookupcheck[lookupid]=1 + local lookup=lookups[lookupid] + if lookup then + local d=lookup.done + if d then + nofsublookups=nofsublookups+1 + h={ + index=nofsublookups, + name=f_lookupname(lookupprefix,"d",lookupid+lookupidoffset), + derived=true, + steps=d.steps, + nofsteps=d.nofsteps, + type=d.lookuptype, + markclass=d.markclass or nil, + flags=d.flags, + } + sublookuplist[nofsublookups]=h + sublookuphash[lookupid]=nofsublookups + sublookupcheck[lookupid]=1 + else + report_issue(i,what,sequence,"missing") + rule.lookups=nil + break + end + else + report_issue(i,what,sequence,"bad") + rule.lookups=nil + break + end else sublookupcheck[lookupid]=sublookupcheck[lookupid]+1 end @@ -12335,7 +12353,13 @@ local function readmathglyphinfo(f,fontdata,offset) local function get(offset) setposition(f,kernoffset+offset) local n=readushort(f) - if n>0 then + if n==0 then + local k=readmathvalue(f) + if k==0 then + else + return { { kern=k } } + end + else local l={} for i=1,n do l[i]={ height=readmathvalue(f) } @@ -12371,10 +12395,10 @@ local function readmathglyphinfo(f,fontdata,offset) if next(kernset) then local glyph=glyphs[coverage[i]] local math=glyph.math - if not math then - glyph.math={ kerns=kernset } - else + if math then math.kerns=kernset + else + glyph.math={ kerns=kernset } end end end @@ -14508,7 +14532,7 @@ local trace_defining=false registertracker("fonts.defining",function(v) trace_de local report_otf=logs.reporter("fonts","otf loading") local fonts=fonts local otf=fonts.handlers.otf -otf.version=3.020 +otf.version=3.021 otf.cache=containers.define("fonts","otl",otf.version,true) local otfreaders=otf.readers local hashes=fonts.hashes @@ -16147,7 +16171,7 @@ local function inject_pairs_only(head,where) end local leftkern=i.leftkern if leftkern and leftkern~=0 then - insert_node_before(head,current,newkern(leftkern)) + head=insert_node_before(head,current,newkern(leftkern)) end local rightkern=i.rightkern if rightkern and rightkern~=0 then @@ -16808,10 +16832,19 @@ function injections.handler(head,where) head=injectspaces(head) end if nofregisteredmarks>0 or nofregisteredcursives>0 then + if trace_injections then + report_injections("injection variant %a","everything") + end return inject_everything(head,where) elseif nofregisteredpairs>0 then + if trace_injections then + report_injections("injection variant %a","pairs") + end return inject_pairs_only(head,where) elseif nofregisteredkerns>0 then + if trace_injections then + report_injections("injection variant %a","kerns") + end return inject_kerns_only(head,where) else return head,false |