diff options
Diffstat (limited to 'tex')
43 files changed, 2817 insertions, 638 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 9387a9475..9af34509b 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2019.07.31 18:05} +\newcontextversion{2019.08.02 19:40} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 0c0370cd4..83494251a 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2019.07.31 18:05} +\edef\contextversion{2019.08.02 19:40} %D For those who want to use this: diff --git a/tex/context/base/mkii/grph-trf.mkii b/tex/context/base/mkii/grph-trf.mkii index bd9875806..68e53d376 100644 --- a/tex/context/base/mkii/grph-trf.mkii +++ b/tex/context/base/mkii/grph-trf.mkii @@ -554,7 +554,7 @@ %D \stopbuffer %D %D \typebuffer \getbuffer - + %D Mirroring. \def\domirrorbox % \hbox/\vbox/\vtop diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index 302bc3fa3..da1370aaf 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -637,6 +637,7 @@ \setinterfaceconstant{aligntitle}{alinieretitlu} \setinterfaceconstant{alternative}{alternativ} \setinterfaceconstant{anchor}{anchor} +\setinterfaceconstant{anchoring}{anchoring} \setinterfaceconstant{andtext}{andtext} \setinterfaceconstant{apa}{apa} \setinterfaceconstant{arguments}{arguments} @@ -866,6 +867,7 @@ \setinterfaceconstant{hfil}{hfil} \setinterfaceconstant{hidenumber}{hidenumber} \setinterfaceconstant{hoffset}{hoffset} +\setinterfaceconstant{horizontal}{orizontal} \setinterfaceconstant{horoffset}{offsetoriz} \setinterfaceconstant{hyphen}{hyphen} \setinterfaceconstant{hyphens}{hyphens} @@ -1286,6 +1288,7 @@ \setinterfaceconstant{vcompact}{vcompact} \setinterfaceconstant{vector}{vector} \setinterfaceconstant{veroffset}{veroffset} +\setinterfaceconstant{vertical}{vertical} \setinterfaceconstant{vfactor}{vfactor} \setinterfaceconstant{vfil}{vfil} \setinterfaceconstant{viewerprefix}{viewerprefix} @@ -1296,6 +1299,7 @@ \setinterfaceconstant{white}{alb} \setinterfaceconstant{width}{latime} \setinterfaceconstant{words}{words} +\setinterfaceconstant{xanchor}{xanchor} \setinterfaceconstant{xfactor}{xfactor} \setinterfaceconstant{xhtml}{xhtml} \setinterfaceconstant{xmax}{xmax} @@ -1303,6 +1307,7 @@ \setinterfaceconstant{xoffset}{xoffset} \setinterfaceconstant{xscale}{xscala} \setinterfaceconstant{xstep}{xstep} +\setinterfaceconstant{yanchor}{yanchor} \setinterfaceconstant{yfactor}{yfactor} \setinterfaceconstant{ymax}{ymax} \setinterfaceconstant{yoffset}{yoffset} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 08abe123a..0665e7235 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2019.07.31 18:05} +\newcontextversion{2019.08.02 19:40} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 497bfdc08..79f24bda9 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.07.31 18:05} +\edef\contextversion{2019.08.02 19:40} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index f3373a1f7..128eddc68 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.07.31 18:05} +\edef\contextversion{2019.08.02 19:40} \edef\contextkind {beta} %D Kind of special: @@ -112,8 +112,8 @@ \loadmarkfile{toks-scn} \loadmkxlfile{syst-aux} % LMTX -\loadmarkfile{syst-lua} -\loadmarkfile{syst-con} +\loadmkxlfile{syst-lua} % LMTX +\loadmkxlfile{syst-con} % LMTX \loadmarkfile{syst-fnt} \loadmarkfile{syst-rtp} @@ -245,6 +245,7 @@ \loadmarkfile{sort-ini} \loadmkvifile{pack-mis} +\loadmkxlfile{pack-ori} % LMTX \loadmkxlfile{pack-rul} % LMTX \loadmarkfile{pack-mrl} \loadmkvifile{pack-bck} @@ -330,7 +331,13 @@ %loadmarkfile{page-set} % \usecolumns[old-columnsets] \loadmarkfile{page-cst} \loadmarkfile{page-pcl} % new -\loadmarkfile{pack-lyr} + +\doifelsefileexists {pack-lyr.mkxl} { + \loadmkxlfile{pack-lyr} % LMTX +} { + \loadmkivfile{pack-lyr} +} + \loadmarkfile{pack-pos} \loadmkvifile{page-mak} @@ -458,7 +465,7 @@ \loadmkxlfile{mlib-ctx} % messy order -\loadmarkfile{meta-ini} +\loadmkxlfile{meta-ini} \loadmarkfile{meta-tex} \loadmarkfile{meta-fun} \loadmarkfile{meta-pag} diff --git a/tex/context/base/mkiv/core-con.lua b/tex/context/base/mkiv/core-con.lua index 3829efc9c..3cf1485a1 100644 --- a/tex/context/base/mkiv/core-con.lua +++ b/tex/context/base/mkiv/core-con.lua @@ -313,6 +313,7 @@ end function converters.year () return osdate("%Y") end function converters.month () return osdate("%m") end +function converters.day () return osdate("%d") end function converters.hour () return osdate("%H") end function converters.minute() return osdate("%M") end function converters.second() return osdate("%S") end diff --git a/tex/context/base/mkiv/driv-shp.lua b/tex/context/base/mkiv/driv-shp.lua index 980dda357..b965b6c64 100644 --- a/tex/context/base/mkiv/driv-shp.lua +++ b/tex/context/base/mkiv/driv-shp.lua @@ -70,40 +70,40 @@ local dircodes = nodes.dircodes local dirvalues = nodes.dirvalues local subtypes = nodes.subtypes -local <const> normaldir_code = dircodes.normal - -local <const> lefttoright_code = dirvalues.lefttoright -local <const> righttoleft_code = dirvalues.righttoleft - -local <const> glyph_code = nodecodes.glyph -local <const> kern_code = nodecodes.kern -local <const> glue_code = nodecodes.glue -local <const> hlist_code = nodecodes.hlist -local <const> vlist_code = nodecodes.vlist -local <const> dir_code = nodecodes.dir -local <const> disc_code = nodecodes.disc -local <const> math_code = nodecodes.math -local <const> rule_code = nodecodes.rule -local <const> marginkern_code = nodecodes.marginkern -local <const> whatsit_code = nodecodes.whatsit ------ <const> penalty_code = nodecodes.penalty ------ <const> boundary_code = nodecodes.boundary - -local <const> leaders_code = leadercodes.leaders -local <const> cleaders_code = leadercodes.cleaders -local <const> xleaders_code = leadercodes.xleaders -local <const> gleaders_code = leadercodes.gleaders - -local <const> saveposwhatsit_code = whatsitcodes.savepos -local <const> userdefinedwhatsit_code = whatsitcodes.userdefined -local <const> openwhatsit_code = whatsitcodes.open -local <const> writewhatsit_code = whatsitcodes.write -local <const> closewhatsit_code = whatsitcodes.close -local <const> lateluawhatsit_code = whatsitcodes.latelua -local <const> literalwhatsit_code = whatsitcodes.literal -local <const> setmatrixwhatsit_code = whatsitcodes.setmatrix -local <const> savewhatsit_code = whatsitcodes.save -local <const> restorewhatsit_code = whatsitcodes.restore +local normaldir_code <const> = dircodes.normal + +local lefttoright_code <const> = dirvalues.lefttoright +local righttoleft_code <const> = dirvalues.righttoleft + +local glyph_code <const> = nodecodes.glyph +local kern_code <const> = nodecodes.kern +local glue_code <const> = nodecodes.glue +local hlist_code <const> = nodecodes.hlist +local vlist_code <const> = nodecodes.vlist +local dir_code <const> = nodecodes.dir +local disc_code <const> = nodecodes.disc +local math_code <const> = nodecodes.math +local rule_code <const> = nodecodes.rule +local marginkern_code <const> = nodecodes.marginkern +local whatsit_code <const> = nodecodes.whatsit +----- penalty_code <const> = nodecodes.penalty +----- boundary_code <const> = nodecodes.boundary + +local leaders_code <const> = leadercodes.leaders +local cleaders_code <const> = leadercodes.cleaders +local xleaders_code <const> = leadercodes.xleaders +local gleaders_code <const> = leadercodes.gleaders + +local saveposwhatsit_code <const> = whatsitcodes.savepos +local userdefinedwhatsit_code <const> = whatsitcodes.userdefined +local openwhatsit_code <const> = whatsitcodes.open +local writewhatsit_code <const> = whatsitcodes.write +local closewhatsit_code <const> = whatsitcodes.close +local lateluawhatsit_code <const> = whatsitcodes.latelua +local literalwhatsit_code <const> = whatsitcodes.literal +local setmatrixwhatsit_code <const> = whatsitcodes.setmatrix +local savewhatsit_code <const> = whatsitcodes.save +local restorewhatsit_code <const> = whatsitcodes.restore local getpagedimensions getpagedimensions = function() getpagedimensions = backends.codeinjections.getpagedimensions diff --git a/tex/context/base/mkiv/grph-trf.mkiv b/tex/context/base/mkiv/grph-trf.mkiv index 35e812b3e..0c7ba22f8 100644 --- a/tex/context/base/mkiv/grph-trf.mkiv +++ b/tex/context/base/mkiv/grph-trf.mkiv @@ -924,12 +924,10 @@ \doifelserightpage{\def\p_rotation_rotation{90}}{\def\p_rotation_rotation{270}}} \setvalue{\??rotatepreset\v!default}% - {\edef\p_rotation_rotation{\realnumber{\p_rotation_rotation}}}% get rid of leading zeros and spaces + {} \def\grph_rotate_finish_yes - {\csname\??rotatepreset - \ifcsname\??rotatepreset\p_rotation_rotation\endcsname\p_rotation_rotation\else\v!default\fi - \endcsname + {\begincsname\??rotatepreset\p_rotation_rotation\endcsname \setbox\nextbox\vpack{\box\nextbox}% not really needed \dontcomplain \ifconditional\c_grph_rotate_center diff --git a/tex/context/base/mkiv/lpdf-lmt.lua b/tex/context/base/mkiv/lpdf-lmt.lua index 5d8ad063c..bab3d682b 100644 --- a/tex/context/base/mkiv/lpdf-lmt.lua +++ b/tex/context/base/mkiv/lpdf-lmt.lua @@ -38,7 +38,7 @@ local band, extract = bit32.band, bit32.extract local concat, sortedhash = table.concat, table.sortedhash local setmetatableindex = table.setmetatableindex -local <const> bpfactor = number.dimenfactors.bp +local bpfactor <const> = number.dimenfactors.bp local md5HEX = md5.HEX local osuuid = os.uuid @@ -596,15 +596,15 @@ end local flushliteral do - local <const> nodeproperties = nodes.properties.data - local <const> literalvalues = nodes.literalvalues + local nodeproperties <const> = nodes.properties.data + local literalvalues <const> = nodes.literalvalues - local <const> originliteral_code = literalvalues.origin - local <const> pageliteral_code = literalvalues.page - local <const> alwaysliteral_code = literalvalues.always - local <const> rawliteral_code = literalvalues.raw - local <const> textliteral_code = literalvalues.text - local <const> fontliteral_code = literalvalues.font + local originliteral_code <const> = literalvalues.origin + local pageliteral_code <const> = literalvalues.page + local alwaysliteral_code <const> = literalvalues.always + local rawliteral_code <const> = literalvalues.raw + local textliteral_code <const> = literalvalues.text + local fontliteral_code <const> = literalvalues.font flushliteral = function(current,pos_h,pos_v,mode,str) if mode then @@ -845,16 +845,16 @@ local flushrule, flushsimplerule, flushimage do local setprop = nuts.setprop local getprop = nuts.getprop - local <const> normalrule_code = rulecodes.normal - local <const> boxrule_code = rulecodes.box - local <const> imagerule_code = rulecodes.image - local <const> emptyrule_code = rulecodes.empty - local <const> userrule_code = rulecodes.user - local <const> overrule_code = rulecodes.over - local <const> underrule_code = rulecodes.under - local <const> fractionrule_code = rulecodes.fraction - local <const> radicalrule_code = rulecodes.radical - local <const> outlinerule_code = rulecodes.outline + local normalrule_code <const> = rulecodes.normal + local boxrule_code <const> = rulecodes.box + local imagerule_code <const> = rulecodes.image + local emptyrule_code <const> = rulecodes.empty + local userrule_code <const> = rulecodes.user + local overrule_code <const> = rulecodes.over + local underrule_code <const> = rulecodes.under + local fractionrule_code <const> = rulecodes.fraction + local radicalrule_code <const> = rulecodes.radical + local outlinerule_code <const> = rulecodes.outline local rule_callback = callbacks.functions.process_rule @@ -1016,7 +1016,7 @@ local flushrule, flushsimplerule, flushimage do local img_stream = imagetypes.stream local img_memstream = imagetypes.memstream - local <const> one_bp = 65536 * bpfactor + local one_bp <const> = 65536 * bpfactor local imageresources, n = { }, 0 @@ -1618,13 +1618,13 @@ end local addtocache, flushcache, cache do - local data, d = { }, 0 - local list, l = { }, 0 - local coffset = 0 - local indices = { } + local data, d = { }, 0 + local list, l = { }, 0 + local coffset = 0 + local indices = { } - local <const> maxsize = 32 * 1024 -- uncompressed - local <const> maxcount = 0xFF + local maxsize <const> = 32 * 1024 -- uncompressed + local maxcount <const> = 0xFF addtocache = function(n,str) local size = #str @@ -2197,8 +2197,8 @@ updaters.register("backend.update.pdf",function() local lastindex = 0 local indices = { } - local <const> bpfactor = number.dimenfactors.bp - local <const> imagerule_code = rulecodes.image + local bpfactor <const> = number.dimenfactors.bp + local imagerule_code <const> = rulecodes.image function codeinjections.newimage(specification) return specification diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua index fda27222e..d8f4f36fd 100644 --- a/tex/context/base/mkiv/math-noa.lua +++ b/tex/context/base/mkiv/math-noa.lua @@ -850,23 +850,33 @@ do return f end --- local function show(where,pointer) --- print("") --- local i = 0 --- for n in nuts.traverse(pointer) do --- i = i + 1 --- print(i,where,nuts.tonode(n)) --- end --- print("") --- end - - local function makelist(middle, noad, f_o,o_next,c_prev,f_c) + local function show(where,pointer) + print("") + local i = 0 + for n in nuts.traverse(pointer) do + i = i + 1 + print(i,where,nuts.tonode(n)) + end + print("") + end + + local function makelist(middle,noad,f_o,o_next,c_prev,f_c) +-- report_fences( +-- "middle %s, noad %s, open %s, opennext %s, closeprev %s, close %s", +-- middle or "?", +-- noad or "?", +-- f_o or "?", +-- o_next or "?", +-- c_prev or "?", +-- f_c or "?" +-- ) local list = new_submlist() setsubtype(noad,innernoad_code) setnucleus(noad,list) setlist(list,f_o) setlink(f_o,o_next) -- prev of list is nil setlink(c_prev,f_c) -- next of list is nil +-- show("list",f_o) if middle and next(middle) then local prev = f_o local current = o_next @@ -890,17 +900,17 @@ do return noad end - -- relinking is not somewhat overdone + -- relinking is now somewhat overdone local function convert_both(open,close,middle) - local o_prev, o_next = getboth(open) + local o_next = getnext(open) if o_next == close then return close else local c_prev, c_next = getboth(close) local f_o = makefence(leftfence_code,open) local f_c = makefence(rightfence_code,close) - makelist(middle, open, f_o,o_next,c_prev,f_c) + makelist(middle,open,f_o,o_next,c_prev,f_c) setnucleus(close) flush_node(close) -- open is now a list @@ -909,12 +919,11 @@ do end end - local function convert_open(open,last,middle) + local function convert_open(open,last,middle) -- last is really last (final case) local f_o = makefence(leftfence_code,open) local f_c = makefence(rightfence_code) - local o_prev, o_next = getboth(open) - local l_prev, l_next = getboth(last) - makelist(middle, open, f_o,o_next,l_prev,f_c) + local o_next = getnext(open) + makelist(middle,open,f_o,o_next,last,nil) -- open is now a list setlink(open,l_next) return open @@ -923,8 +932,8 @@ do local function convert_close(first,close,middle) local f_o = makefence(leftfence_code) local f_c = makefence(rightfence_code,close) - local c_prev, c_next = getboth(close) - local f_prev, f_next = getboth(first) + local c_prev = getprev(close) + local f_next = getnext(first) makelist(middle, close, f_o,f_next,c_prev,f_c) -- close is now a list if c_prev ~= first then @@ -1035,10 +1044,11 @@ do for i=1,s do local open = remove(stack) if trace_fences then - report_fences("%2i: level %i, handling %s, action %s",#stack,"flush","open") + report_fences("%2i: level %i, handling %s, action %s",n,#stack,"flush","open") end last = convert_open(open,last,middle) end +-- show("done",pointer) end end end diff --git a/tex/context/base/mkiv/meta-ini.mkiv b/tex/context/base/mkiv/meta-ini.mkiv index 65811a8ff..88549c34a 100644 --- a/tex/context/base/mkiv/meta-ini.mkiv +++ b/tex/context/base/mkiv/meta-ini.mkiv @@ -579,36 +579,17 @@ \def\meta_prepare_variable_dimension {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\the\dimexpr\m_meta_current_variable}} -\startmkivmode - - \def\meta_prepare_variable_yes - {\defconvertedcommand\ascii\m_meta_current_variable % otherwise problems - \doifelsecolor \ascii % with 2\bodyfontsize - {\meta_prepare_variable_color} - {\begingroup - \setbox\b_meta_variable_box\hpack{\scratchdimen\m_meta_current_variable sp}% - \ifzeropt\wd\b_meta_variable_box - \endgroup\meta_prepare_variable_number - \else - \endgroup\meta_prepare_variable_dimension - \fi}} - -\stopmkivmode - -\startlmtxmode - - \def\meta_prepare_variable_yes - {\ifchkdim\m_meta_current_variable\or - \meta_prepare_variable_dimension - \else\ifchknum\m_meta_current_variable\or - \meta_prepare_variable_number - \else - \doifelsecolor\m_meta_current_variable - \meta_prepare_variable_color - \meta_prepare_variable_dimension - \fi\fi} - -\stoplmtxmode +\def\meta_prepare_variable_yes + {\defconvertedcommand\ascii\m_meta_current_variable % otherwise problems + \doifelsecolor \ascii % with 2\bodyfontsize + {\meta_prepare_variable_color} + {\begingroup + \setbox\b_meta_variable_box\hpack{\scratchdimen\m_meta_current_variable sp}% + \ifzeropt\wd\b_meta_variable_box + \endgroup\meta_prepare_variable_number + \else + \endgroup\meta_prepare_variable_dimension + \fi}} % \def\meta_prepare_variable_yes % {\expandafter\edef\csname\m_meta_current_variable_template\endcsname diff --git a/tex/context/base/mkiv/meta-ini.mkxl b/tex/context/base/mkiv/meta-ini.mkxl new file mode 100644 index 000000000..4ae748ba8 --- /dev/null +++ b/tex/context/base/mkiv/meta-ini.mkxl @@ -0,0 +1,1457 @@ +%D \module +%D [ file=meta-ini, +%D version=2008.03.25, +%D title=\METAPOST\ Graphics, +%D subtitle=Initialization, +%D author=Hans Hagen, +%D date=\ currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% initializations: +% +% - pass settings from tex to mp (delayed expansion) +% - used by context core (and modules) +% - cummulative definitions +% - flushed each graphic +% - can be disabled per instance +% - managed at the tex end +% +% extensions: +% +% - add mp functionality (immediate expansion) +% - cummulative +% - all instances or subset of instances +% - can be disabled per instance +% - managed at the lua/mp end +% - could be managed at the tex end but no real reason and also messy +% +% definitions: +% +% - add mp functionality (delayed expansion) +% - cummulative +% - per instance +% - managed at the tex end +% +% inclusions: +% +% - add mp functionality (delayed expansion) +% - cummulative only when [+] +% - per instance +% - managed at the tex end +% +% order of execution: +% +% definitions +% extensions +% inclusions +% beginfig +% initializations +% graphic +% endfig + +% The instance will be implemented stepwise ... I should redo some code in order to +% make the macros look better than they do now. + +\writestatus{loading}{MetaPost Graphics / Initializations} + +\registerctxluafile{meta-ini}{} + +\unprotect + +\newtoks \everyMPgraphic % mp % public or not ? + +\appendtoks + \restoreendofline % see interferences-001.tex +\to \everyMPgraphic + +\def\MPruntimefile {mprun} +\def\currentMPformat {metafun} +\def\defaultMPinstance{metafun} + +\installcorenamespace{mpinstance} +\installcorenamespace{mpinclusions} +\installcorenamespace{mpdefinitions} +\installcorenamespace{mpgraphic} +\installcorenamespace{mpstaticgraphic} +\installcorenamespace{mpclip} + +\newtoks \t_meta_initializations % tex, each +\def \t_meta_inclusions {\csname\??mpinclusions \currentMPinstance\endcsname} % token register +\def \t_meta_definitions {\csname\??mpdefinitions\currentMPinstance\endcsname} % token register + +%D The next command is, of course, dedicated to Mojca, who needs it for gnuplot. +%D Anyway, the whole multiple engine mechanism is to keep her gnuplot from +%D interfering. + +\unexpanded\def\startMPdefinitions + {\dosinglegroupempty\meta_start_definitions} + +\def\meta_start_definitions#1#2\stopMPdefinitions + {\let\m_meta_saved_instance\currentMPinstance + \edef\currentMPinstance{#1}% + \ifx\currentMPinstance\empty + \let\currentMPinstance\defaultMPinstance + \fi + \gtoksapp\t_meta_definitions{#2}% + \let\currentMPinstance\m_meta_saved_instance} + +\let\stopMPdefinitions\relax + +\unexpanded\def\startMPextensions + {\dosinglegroupempty\meta_start_extensions} + +\def\meta_start_extensions#1#2\stopMPextensions % we could use buffers instead + {\clf_setmpextensions{#1}{#2}} + +\let\stopMPextensions\relax + +\unexpanded\def\startMPinitializations#1\stopMPinitializations % for all instances, when enabled + {\gtoksapp\t_meta_initializations{#1}} + +\let\stopMPinitializations\relax + +\unexpanded\def\startMPinclusions + {\dosingleempty\meta_start_inclusions} + +\unexpanded\def\meta_start_inclusions[#1]% + {\edef\m_meta_option{#1}% + \dosinglegroupempty\meta_start_inclusions_indeed} + +\def\meta_start_inclusions_indeed#1#2\stopMPinclusions + {\let\m_meta_saved_instance\currentMPinstance + \edef\currentMPinstance{#1}% + \ifx\currentMPinstance\empty + \let\currentMPinstance\defaultMPinstance + \fi + \ifx\m_meta_option\!!plustoken \else + \global\t_meta_inclusions\emptytoks + \fi + \gtoksapp\t_meta_inclusions{#2}% + \let\currentMPinstance\m_meta_saved_instance} + +\let\stopMPinclusions\relax + +\unexpanded\def\MPinclusions + {\dosingleempty\meta_inclusions} + +\def\meta_inclusions[#1]% + {\edef\m_meta_option{#1}% + \dosinglegroupempty\meta_inclusions_indeed} + +\def\meta_inclusions_indeed#1#2% + {\let\m_meta_saved_instance\currentMPinstance + \edef\currentMPinstance{#1}% + \ifx\currentMPinstance\empty + \let\currentMPinstance\defaultMPinstance + \fi + \ifx\m_meta_option\!!plustoken \else + \global\t_meta_inclusions\emptytoks + \fi + \gtoksapp\t_meta_inclusions{#2}% + \let\currentMPinstance\m_meta_saved_instance} + +\installcommandhandler \??mpinstance {MPinstance} \??mpinstance + +\setupMPinstance + [\s!format=metafun, + \s!extensions=\v!no, + \s!initializations=\v!no, + \c!method=\s!default, + \c!textstyle=, + \c!textcolor=] + +\appendtoks + \ifcsname\??mpdefinitions\currentMPinstance\endcsname \else + \expandafter\newtoks\csname\??mpdefinitions\currentMPinstance\endcsname + \fi + \ifcsname\??mpinclusions\currentMPinstance\endcsname \else + \expandafter\newtoks\csname\??mpinclusions\currentMPinstance\endcsname + \fi + \t_meta_definitions\emptytoks % in case we redefine + \t_meta_inclusions \emptytoks % in case we redefine +\to \everydefineMPinstance + +\unexpanded\def\resetMPinstance[#1]% + {\writestatus\m!metapost{reset will be implemented when needed}} + +\def\meta_analyze_graphicname[#1]% + %{\normalexpanded{\meta_analyze_graphicname_indeed[#1::::]}} + {\normalexpanded{\meta_analyze_graphicname_indeed[#1}::::]} + +\def\meta_show_properties_indeed + {\writestatus{metapost}{name: \currentMPgraphicname, instance: \currentMPinstance, format: \currentMPformat}} + +\let\meta_show_properties\donothing + +\installtextracker + {metapost.properties} + {\let\meta_show_properties\meta_show_properties_indeed} + {\let\meta_show_properties\donothing} + +\unexpanded\def\meta_analyze_graphicname_indeed[#1::#2::#3]% instance :: + {\edef\currentMPgraphicname{#2}% + \ifx\currentMPgraphicname\empty + \edef\currentMPgraphicname{#1}% + \let\currentMPinstance\defaultMPinstance + \orelse\ifcsname\??mpdefinitions#1\endcsname + \edef\currentMPinstance{#1}% + \else + \let\currentMPinstance\defaultMPinstance + \fi + \edef\currentMPformat{\MPinstanceparameter\s!format}% + \meta_show_properties} + +\def\currentMPgraphicname{\s!unknown} +\def\currentMPinstance {\defaultMPinstance} +\def\currentMPformat {\currentMPinstance} + +\defineMPinstance[metafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] +\defineMPinstance[minifun] [\s!format=minifun,\s!extensions=\v!yes,\s!initializations=\v!yes] +\defineMPinstance[extrafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] +\defineMPinstance[lessfun] [\s!format=metafun] +\defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double] +\defineMPinstance[binaryfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!binary] +\defineMPinstance[decimalfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal] + +\defineMPinstance[mprun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] + +\defineMPinstance[metapost] [\s!format=mpost] +\defineMPinstance[nofun] [\s!format=mpost] +\defineMPinstance[doublepost] [\s!format=mpost,\c!method=\s!double] +\defineMPinstance[binarypost] [\s!format=mpost,\c!method=\s!binary] +\defineMPinstance[decimalpost][\s!format=mpost,\c!method=\s!decimal] + +%defineMPinstance[megapost] [\s!format=mpost,\c!method=\s!decimal] + +\newconditional\c_meta_include_initializations + +\def\meta_begin_graphic_group#1% + {\begingroup + \meta_analyze_graphicname[#1]} + +\def\meta_end_graphic_group + {\endgroup} + +\def\MPaskedfigure{false} + +\def\meta_flush_current_initializations + {\ifconditional\c_meta_include_initializations + \the\t_meta_initializations + \fi} + +\def\meta_flush_current_inclusions + {\the\t_meta_inclusions} + +\def\meta_flush_current_definitions + {\the\t_meta_definitions} + +\def\meta_start_current_graphic + {\begingroup + \meta_enable_include + \the\everyMPgraphic + \edef\p_initializations{\MPinstanceparameter\s!initializations}% + \ifx\p_initializations\v!yes + \settrue \c_meta_include_initializations + \else + \setfalse\c_meta_include_initializations + \fi + \edef\p_setups{\MPinstanceparameter\c!setups}% + \ifx\p_setups\empty \else + \setups[\p_setups]% + \fi + \useMPinstancestyleparameter\c!textstyle} + +\def\meta_set_current_color + {\useMPinstancecolorparameter\c!textcolor} + +\def\meta_stop_current_graphic + {\global\t_meta_definitions\emptytoks + \global\t_meta_inclusions\emptytoks + \endgroup} + +\def\meta_process_graphic_start + {\pushMPboundingbox + \setbox\b_meta_graphic\hpack\bgroup} + +\def\meta_process_graphic_stop + {\egroup + \meta_place_graphic + \popMPboundingbox} + +\unexpanded\def\meta_process_graphic_instance#1% + {\edef\currentMPinstance{#1}% + \ifx\currentMPinstance\empty + \let\currentMPinstance\defaultMPinstance + \fi + \edef\currentMPformat{\MPinstanceparameter\s!format}% + \meta_process_graphic} + +\unexpanded\def\meta_process_graphic#1% todo: extensions and inclusions outside beginfig + {\meta_start_current_graphic + \forgetall + \edef\p_extensions{\MPinstanceparameter\s!extensions}% + \meta_process_graphic_start + \normalexpanded{\noexpand\clf_mpgraphic + instance {\currentMPinstance}% + format {\currentMPformat}% + data {#1;}% + initializations {\meta_flush_current_initializations}% + \ifx\p_extensions\v!yes + extensions {\clf_getmpextensions{\currentMPinstance}}% goes through tex again + \fi + inclusions {\meta_flush_current_inclusions}% + definitions {\meta_flush_current_definitions}% + figure {\MPaskedfigure}% + method {\MPinstanceparameter\c!method}% + namespace {\??graphicvariable\currentmpvariableclass:}% + \relax}% + \meta_process_graphic_stop + \meta_stop_current_graphic} + +\let\meta_process_graphic_figure_start\relax +\let\meta_process_graphic_figure_stop \relax + +\unexpanded\def\processMPfigurefile#1% special case: obeys beginfig .. endfig and makes pages + {\begingroup + \let\normal_meta_process_graphic_start\meta_process_graphic_start + \let\normal_meta_process_graphic_stop \meta_process_graphic_stop + \let\meta_process_graphic_start\relax + \let\meta_process_graphic_stop \relax + \def\meta_process_graphic_figure_start{\startTEXpage[\c!offset=\v!overlay,\c!align=]\normal_meta_process_graphic_start}% + \def\meta_process_graphic_figure_stop {\normal_meta_process_graphic_stop\stopTEXpage} + \def\MPaskedfigure{all}% + \meta_process_graphic{input "#1" ;}% + \endgroup} + +%D Calling up previously defined graphics. + +% \def\includeMPgraphic#1% gets expanded ! +% {\ifcsname\??mpgraphic#1\endcsname +% \csname\??mpgraphic#1\endcsname ; % ; is safeguard +% \fi} +% +% \unexpanded\def\meta_enable_include % public +% {\let\meta_handle_use_graphic \thirdofthreearguments +% \let\meta_handle_reusable_graphic\thirdofthreearguments} +% +% but ... we want this too: +% +% \startuseMPgraphic{x} +% draw textext("\externalfigure[foo.pdf]") ; +% \stopuseMPgraphic +% +% \useMPgraphic{x} +% +% so we cannot overload unless we let back to the original meanings each graphic +% ... a better solution is: + +\def\includeMPgraphic#1% gets expanded ! + {\ifcsname\??mpgraphic#1\endcsname + \doubleexpandafter\fourthoffourarguments\lastnamedcs ; % ; is safeguard + \fi} + +\let\meta_enable_include\relax + +%D Drawings (stepwise built): + +\newif\ifMPdrawingdone \MPdrawingdonefalse + +\unexpanded\def\finalizeMPdrawing + {\MPdrawingdonetrue} + +\let\MPdrawingdata\empty + +\unexpanded\def\resetMPdrawing + {\glet\MPdrawingdata\empty + \global\MPdrawingdonefalse} + +\unexpanded\def\pushMPdrawing + {\globalpushmacro\MPdrawingdata + \glet\MPdrawingdata\empty} + +\unexpanded\def\popMPdrawing + {\globalpopmacro\MPdrawingdata} + +\unexpanded\def\getMPdrawing + {\ifMPdrawingdone + \expandafter\meta_process_graphic\expandafter{\MPdrawingdata}% is this expansion still needed? + \fi} + +\def\startMPdrawing + {\dosingleempty\meta_start_drawing} + +\def\meta_start_drawing[#1]#2\stopMPdrawing % to be redone, this ascii stuff + {\relax + \bgroup + \meta_enable_include + \doifelse{#1}{-}{\convertargument#2\to\asciia}{\def\asciia{#2}}% + \xdef\MPdrawingdata{\MPdrawingdata\asciia}% + \egroup} + +\let\stopMPdrawing\relax + +\def\MPdrawing#1% + {\relax + \bgroup + \meta_enable_include + \xdef\MPdrawingdata{\MPdrawingdata#1}% + \egroup} + +\unexpanded\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less + {\setgvalue{\??mpclip#1}{#2}} + +\let\stopMPclip\relax + +\unexpanded\def\meta_grab_clip_path#1#2#3% + {\begingroup + \d_overlay_width #2\relax + \d_overlay_height#3\relax + \edef\width {\the\d_overlay_width \space}% + \edef\height{\the\d_overlay_height\space}% + \edef\currentMPclip{#1}% + \ifcsname\??mpclip\currentMPclip\endcsname + \meta_grab_clip_path_yes + \else + \meta_grab_clip_path_nop + \fi + \endgroup} + +\def\meta_grab_clip_path_yes + {\meta_start_current_graphic + \normalexpanded{\noexpand\clf_mpsetclippath + instance {\currentMPinstance}% + format {\currentMPformat}% + data {\csname\??mpclip\currentMPclip\endcsname}% + initializations {\meta_flush_current_initializations}% + useextensions {\MPinstanceparameter\s!extensions}% + inclusions {\meta_flush_current_inclusions}% + method {\MPinstanceparameter\c!method}% + width \d_overlay_width + height \d_overlay_height + \relax}% + \meta_stop_current_graphic} + +\def\meta_grab_clip_path_nop + {\clf_mpsetclippath + width \d_overlay_width + height \d_overlay_height + \relax} + +%D Since we want labels to follow the document settings, we also set the font +%D related variables. + +\unexpanded\def\MPfontsizehskip#1% + {\dontleavehmode + \begingroup + \definedfont[#1]% + \hskip\clf_currentdesignsize\scaledpoint\relax + \endgroup} + +\definefontsynonym[MetafunDefault][Regular*default] + +\startMPinitializations % scale is not yet ok + defaultfont:="\truefontname{MetafunDefault}"; + % defaultscale:=\the\bodyfontsize/10pt; % only when hard coded 10pt + % defaultscale:=1; +\stopMPinitializations + +%D A signal that we're in combined \CONTEXT||\METAFUN mode: + +\startMPextensions + string contextversion;contextversion:="\contextversion"; % expanded +\stopMPextensions + +%D \macros +%D {setupMPvariables} +%D +%D When we build collections of \METAPOST\ graphics, like background and buttons, +%D the need for passing settings arises. By (mis|)|using the local prefix that +%D belongs to \type {\framed}, we get a rather natural interface to backgrounds. To +%D prevent conflicts, we will use the \type {-} in \METAPOST\ specific variables, +%D like: +%D +%D \starttyping +%D \setupMPvariables[meta:button][size=20pt] +%D \stoptyping + +% \lineheight 2pt 2 \scratchcounter red 0.4 .5\bodyfontsize +% +% see cont-loc for test code + +%D Currently the inheritance of backgrounds does not work and we might drop it +%D anyway (too messy) + +\newbox\b_meta_variable_box + +\let \currentmpvariableclass \empty +\let \m_meta_current_variable \empty +\let \m_meta_current_variable_template\empty + +\installcorenamespace{graphicvariable} + +\def\meta_prepare_variable_default{\MPcolor{black}} % just to be sure we use a color but ... + +\unexpanded\def\setupMPvariables + {\dodoubleempty\meta_setup_variables} + +\def\meta_setup_variables[#1][#2]% + {\ifsecondargument + \getrawparameters[\??graphicvariable#1:][#2]% + \else + \getrawparameters[\??graphicvariable:][#1]% + \fi} + +\unexpanded\def\presetMPvariable + {\dodoubleargument\meta_preset_variable} + +\def\meta_preset_variable[#1][#2=#3]% + {\ifcsname\??graphicvariable#1:#2\endcsname \else + \setvalue{\??graphicvariable#1:#2}{#3}% + \fi} + +\def\MPrawvar#1#2% no checking + {\begincsname\??graphicvariable#1:#2\endcsname} + +\def\MPvariable#1% todo: could be a framed chain + {\begincsname\??graphicvariable\currentmpvariableclass:#1\endcsname} + +\unexpanded\def\useMPvariables + {\dodoubleargument\meta_use_variables} + +\def\meta_use_variables[#1][#2]% + {\edef\currentmpvariableclass{#1}% + \meta_prepare_variables{#2}} + +\unexpanded\def\meta_prepare_variables#1% + {\processcommalist[#1]\meta_prepare_variable} + +\unexpanded\def\meta_prepare_variable#1% + {\edef\m_meta_current_variable_template + {\??graphicvariable\currentmpvariableclass:#1}% + \edef\m_meta_current_variable + {\begincsname\m_meta_current_variable_template\endcsname}% + \ifx\m_meta_current_variable\empty + \expandafter\meta_prepare_variable_nop + \else + \expandafter\meta_prepare_variable_yes + \fi} + +\unexpanded\def\meta_prepare_instance_variables + {\expandafter\processcommalist\expandafter[\m_meta_instance_variables]\meta_prepare_instance_variable} + +\unexpanded\def\meta_prepare_instance_variable#1% + {\edef\m_meta_current_variable_template + {\??graphicvariable\currentmpvariableclass:#1}% + \edef\m_meta_current_variable + {\ifcsname\m_meta_current_variable_template\endcsname + \lastnamedcs + \else + \begincsname\??graphicvariable\currentMPgraphicname:#1\endcsname + \fi}% + \ifx\m_meta_current_variable\empty + \expandafter\meta_prepare_variable_nop + \else + \expandafter\meta_prepare_variable_yes + \fi} + +\def\meta_prepare_variable_nop + {\expandafter \let\csname\m_meta_current_variable_template\endcsname\meta_prepare_variable_default} + +\def\meta_prepare_variable_color % we use the attribute so we dont' go through namedcolor (why not) + {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\MPcolor\m_meta_current_variable}} + +\def\meta_prepare_variable_number + {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\number\m_meta_current_variable}}% also accepts 0.number + +\def\meta_prepare_variable_dimension + {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\the\dimexpr\m_meta_current_variable}} + +\def\meta_prepare_variable_yes + {\ifchkdim\m_meta_current_variable\or + \meta_prepare_variable_dimension + \else\ifchknum\m_meta_current_variable\or + \meta_prepare_variable_number + \else + \doifelsecolor\m_meta_current_variable + \meta_prepare_variable_color + \meta_prepare_variable_dimension + \fi\fi} + +\let\MPvar \MPvariable +\let\setMPvariables\setupMPvariables + +%D \macros +%D {startuniqueMPgraphic, uniqueMPgraphic} +%D +%D This macros is probably of most use to myself, since I like to use graphics that +%D adapt themselves. The next \METAPOST\ kind of graphic is both unique and reused +%D when possible. +%D +%D \starttyping +%D \defineoverlay[example][\uniqueMPgraphic{test}] +%D +%D \startuniqueMPgraphic {test} +%D draw unitsquare xscaled \overlaywidth yscaled \overlayheight ; +%D \stopuniqueMPgraphic +%D \stoptyping + +\def\overlaystamp % watch the \MPcolor, since colors can be redefined + {\the\d_overlay_width :% + \the\d_overlay_height :% + \the\d_overlay_depth :% + \the\d_overlay_offset :% + \the\d_overlay_linewidth:% + \MPcolor\overlaycolor :% % todo, expand once \m_overlaycolor + \MPcolor\overlaylinecolor} % todo, expand once \m_overlaylinecolor + +%D A better approach is to let additional variables play a role in determining the +%D uniqueness. In the next macro, the second, optional, argument is used to +%D guarantee the uniqueness, as well as prepare variables for passing them to +%D \METAPOST. +%D +%D \starttyping +%D \startuniqueMPgraphic{meta:hash}{gap,angle,...} +%D \stoptyping +%D +%D The calling macro also accepts a second argument. For convenient use in overlay +%D definitions, we use \type {{}} instead of \type {[]}. +%D +%D \starttyping +%D \uniqueMPgraphic{meta:hash}{gap=10pt,angle=30} +%D \stoptyping + +\newcount\c_meta_object_counter +\newbox \b_meta_graphic + +% hm, isn't this already done elsewhere? + +\unexpanded\def\meta_obey_box_depth + {\setbox\b_meta_graphic\hpack\bgroup + \raise\MPlly\box\b_meta_graphic + \egroup} + +\unexpanded\def\meta_ignore_box_depth + {\normalexpanded + {\meta_obey_box_depth % hence the \unexpanded + \wd\b_meta_graphic\the\wd\b_meta_graphic + \ht\b_meta_graphic\the\ht\b_meta_graphic + \dp\b_meta_graphic\the\dp\b_meta_graphic}} + +\unexpanded\def\meta_obey_box_origin + {\setbox\b_meta_graphic\hpack\bgroup + \kern\MPllx\raise\MPlly\box\b_meta_graphic + \egroup} + +\unexpanded\def\obeyMPboxdepth {\let\meta_relocate_box\meta_obey_box_depth} +\unexpanded\def\ignoreMPboxdepth{\let\meta_relocate_box\meta_ignore_box_depth} +\unexpanded\def\obeyMPboxorigin {\let\meta_relocate_box\meta_obey_box_origin} +\unexpanded\def\normalMPboxdepth{\let\meta_relocate_box\relax} + +\let\meta_relocate_box\relax + +\unexpanded\def\meta_place_graphic % the converter also displaces so in fact we revert + {\meta_relocate_box + \box\b_meta_graphic} + +\unexpanded\def\meta_reuse_box#1#2#3#4#5% space delimiting would save some tokens + {\MPllx#2\MPlly#3\MPurx#4\MPury#5% + \hpack{\forcecolorhack\getobject{MP}{#1}}} % else no proper color intent + +\unexpanded\def\meta_use_box + {\setunreferencedobject{MP}} + +\def\meta_handle_unique_graphic#1#2#3% when there are too many, we can store data at the lua end, although, + {\begingroup % when there are that many they're probably not that unique anyway + \edef\currentmpvariableclass{#1}% + \extendMPoverlaystamp{#2}% incl prepare + \ifcsname\??mpgraphic\overlaystamp:#1\endcsname + \lastnamedcs + \else + \meta_enable_include % redundant + \global\advance\c_meta_object_counter\plusone + \meta_use_box{\number\c_meta_object_counter}\hpack{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox + \setxvalue{\??mpgraphic\overlaystamp:#1}{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% + \csname\??mpgraphic\overlaystamp:#1\endcsname\empty + \fi + \endgroup} + +\unexpanded\def\startuniqueMPgraphic + {\dodoublegroupempty\meta_start_unique_graphic} + +\def\meta_start_unique_graphic#1% + {\normalexpanded{\meta_start_unique_graphic_indeed{#1}}} + +\unexpanded\def\meta_start_unique_graphic_indeed#1#2#3\stopuniqueMPgraphic + {\setgvalue{\??mpgraphic#1}{\meta_handle_unique_graphic{#1}{#2}{#3}}} + +\let\stopuniqueMPgraphic\relax + +\unexpanded\def\uniqueMPgraphic + {\dodoublegroupempty\meta_unique_graphic} + +\def\meta_unique_graphic#1#2% + {\meta_begin_graphic_group{#1}% + \setupMPvariables[#1][#2]% + \csname\??mpgraphic#1\endcsname\empty + \meta_end_graphic_group} + +\def\meta_handle_use_graphic#1#2#3% + {\begingroup + \edef\currentmpvariableclass{#1}% + \edef\m_meta_instance_variables{#2}% + \ifx\m_meta_instance_variables\empty \else + \meta_prepare_instance_variables + \fi + \meta_enable_include % redundant + \meta_process_graphic{#3}% + \endgroup} + +\unexpanded\def\startuseMPgraphic + {\dodoublegroupempty\meta_start_use_graphic} + +\def\meta_start_use_graphic#1% + {\normalexpanded{\meta_start_use_graphic_indeed{#1}}} + +\unexpanded\def\meta_start_use_graphic_indeed#1#2#3\stopuseMPgraphic + {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}} + +\let\stopuseMPgraphic\relax + +\unexpanded\def\startusableMPgraphic % redundant but handy + {\dodoublegroupempty\meta_start_usable_graphic} + + +\def\meta_start_usable_graphic#1% + {\normalexpanded{\meta_start_usable_graphic_indeed{#1}}} + +\unexpanded\def\meta_start_usable_graphic_indeed#1#2#3\stopusableMPgraphic + {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}} + +\let\stopusableMPgraphic\relax + +\def\meta_handle_reusable_graphic#1#2#3% + {\begingroup + \edef\currentmpvariableclass{#1}% + \edef\m_meta_instance_variables{#2}% + \ifx\m_meta_instance_variables\empty \else + \meta_prepare_instance_variables + \fi + \meta_enable_include % redundant + \global\advance\c_meta_object_counter\plusone + \meta_use_box{\number\c_meta_object_counter}\hpack{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox + \setxvalue{\??mpgraphic#1}{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% + \csname\??mpgraphic#1\endcsname\empty + \endgroup} + +\unexpanded\def\startreusableMPgraphic + {\dodoublegroupempty\meta_start_reusable_graphic} + +\def\meta_start_reusable_graphic#1% + {\normalexpanded{\meta_start_reusable_graphic_indeed{#1}}} + +\unexpanded\def\meta_start_reusable_graphic_indeed#1#2#3\stopreusableMPgraphic + {\setgvalue{\??mpgraphic#1}{\meta_handle_reusable_graphic{#1}{#2}{#3}}} + +\let\stopreusableMPgraphic\relax + +\unexpanded\def\useMPgraphic + {\dodoublegroupempty\meta_use_graphic} + +\def\meta_use_graphic#1#2% + {\meta_begin_graphic_group{#1}% + \ifcsname\??mpgraphic#1\endcsname + \edef\usedMPgraphicname{#1}% + \else\ifcsname\??mpgraphic\currentMPgraphicname\endcsname + \let\usedMPgraphicname\currentMPgraphicname + \else + \let\usedMPgraphicname\empty + \fi\fi + \ifx\usedMPgraphicname\empty + % message + \else + \doifsomething{#2}{\setupMPvariables[\usedMPgraphicname][#2]}% + \csname\??mpgraphic\usedMPgraphicname\endcsname + \fi + \meta_end_graphic_group} + +\let\reuseMPgraphic \useMPgraphic % we can save a setup here if needed +\let\reusableMPgraphic\reuseMPgraphic % we can save a setup here if needed + +%D \macros +%D {startuniqueMPpagegraphic,uniqueMPpagegraphic} +%D +%D Experimental. + +\def\m_meta_page_prefix{\doifelseoddpage oe} + +\def\overlaypagestamp + {\m_meta_page_prefix :% + \the\d_overlay_width :% + \the\d_overlay_height :% + \the\d_overlay_depth :% + \the\d_overlay_offset :% + \the\d_overlay_linewidth:% + \MPcolor\overlaycolor :% + \MPcolor\overlaylinecolor} + +\unexpanded\def\startuniqueMPpagegraphic + {\dodoublegroupempty\meta_start_unique_page_graphic} + +\def\meta_start_unique_page_graphic#1% + {\normalexpanded{\meta_start_unique_page_graphic_indeed{#1}}} + +\unexpanded\def\meta_start_unique_page_graphic_indeed#1#2#3\stopuniqueMPpagegraphic % inefficient, double storage + {\setgvalue{\??mpgraphic o:#1}{\meta_handle_unique_graphic{o:#1}{#2}{#3}}% % but these also keep the state + \setgvalue{\??mpgraphic e:#1}{\meta_handle_unique_graphic{e:#1}{#2}{#3}}} % and meaning will be redefined + +\let\stopuniqueMPpagegraphic\relax + +\unexpanded\def\uniqueMPpagegraphic + {\dodoublegroupempty\meta_unique_page_graphic} + +\def\meta_unique_page_graphic#1#2% + {\meta_begin_graphic_group{#1}% + \let\overlaystamp\overlaypagestamp + \setupMPvariables[\m_meta_page_prefix:#1][#2]% prefix is new here + \csname\??mpgraphic\m_meta_page_prefix:#1\endcsname\empty + \meta_end_graphic_group} + +%D One way of defining a stamp is: +%D +%D \starttyping +%D \def\extendMPoverlaystamp#1% +%D {\def\docommand##1% +%D {\edef\overlaystamp{\overlaystamp:\MPvariable{##1}}}% +%D \processcommalist[#1]\docommand} +%D \stoptyping +%D +%D Since we need to feed \METAPOST\ with expanded dimensions, we introduce a +%D dedicated expansion engine. We redefine \type {\extendMPoverlaystamp} to + +\unexpanded\def\extendMPoverlaystamp#1% + {\processcommalist[#1]\meta_extend_overlay_stamp} + +\def\meta_extend_overlay_stamp#1% + {\meta_prepare_instance_variable{#1}% + \edef\overlaystamp{\overlaystamp:\MPvariable{#1}}} + +\unexpanded\def\getMPdata {\clf_getMPdata} + \let\rawMPdata \clf_getMPdata + +\unexpanded\def\getMPstored{\clf_getMPstored} + \let\rawMPstored \clf_getMPstored + +%D We need this trick because we need to make sure that the tex scanner sees +%D newlines and does not quit. Also, we do need to flush the buffer under a normal +%D catcode regime in order to expand embedded tex macros. As usual with buffers, +%D \type {#1} can be a list. + +\unexpanded\def\processMPbuffer + {\dosingleempty\meta_process_buffer} + +\def\meta_process_buffer[#1]% + {\meta_begin_graphic_group{#1}% + \meta_process_graphic{\clf_feedback{\currentMPgraphicname}}% + \meta_end_graphic_group} + +\unexpanded\def\runMPbuffer + {\dosingleempty\meta_run_buffer} + +\def\meta_run_buffer[#1]% processing only + {\startnointerference\meta_process_buffer[#1]\stopnointerference} + +%D \macros +%D {startMPenvironment, resetMPenvironment} +%D +%D In order to synchronize the main \TEX\ run and the runs local to \METAPOST, +%D environments can be passed. + +\unexpanded\def\startMPenvironment + {\begingroup + \catcode\endoflineasciicode \ignorecatcode + \dosingleempty\meta_start_environment} + +\def\meta_start_environment[#1]#2\stopMPenvironment + {\endgroup + \edef\m_meta_option{#1} + \ifx\m_meta_option\s!reset + \resetMPenvironment % reset mp toks + \orelse\ifx\m_meta_option\v!global + #2% % use in main doc too + \orelse\ifx\m_meta_option\!!plustoken + #2% % use in main doc too + \fi + \clf_mptexset{\detokenize{#2}}} + +\let\stopMPenvironment\relax + +\unexpanded\def\resetMPenvironment + {\clf_mptexreset} + +\unexpanded\def\useMPenvironmentbuffer[#1]% + {\clf_mptexsetfrombuffer{#1}} + +%D This command takes \type {[reset]} as optional argument. +%D +%D \starttyping +%D \startMPenvironment +%D \setupbodyfont[pos,14.4pt] +%D \stopMPenvironment +%D +%D \startMPcode +%D draw btex \sl Hans Hagen etex scaled 5 ; +%D \stopMPcode +%D \stoptyping +%D +%D The most simple case: + +\unexpanded\def\startMPcode + {\dosinglegroupempty\meta_start_code} + +\def\meta_start_code + {\iffirstargument + \expandafter\meta_start_code_instance + \else + \expandafter\meta_start_code_standard + \fi} + +\def\meta_start_code_instance#1#2\stopMPcode + {\begingroup + \edef\currentMPinstance{#1}% + \let\currentMPgraphicname\empty + \edef\currentMPformat{\MPinstanceparameter\s!format}% + \meta_enable_include + \meta_process_graphic{#2}% + \endgroup} + +\def\meta_start_code_standard#1#2\stopMPcode + {\begingroup + \let\currentMPinstance\defaultMPinstance + \let\currentMPgraphicname\empty + \edef\currentMPformat{\MPinstanceparameter\s!format}% + \meta_process_graphic{#2}% + \endgroup} + +\let\stopMPcode\relax + +\unexpanded\def\MPcode + {\dodoublegroupempty\meta_code} + +\def\meta_code + {\ifsecondargument + \expandafter\meta_code_instance + \else + \expandafter\meta_code_standard + \fi} + +\def\meta_code_instance#1#2% + {\meta_begin_graphic_group{#1}% + \meta_enable_include + \meta_process_graphic{#2}% + \meta_end_graphic_group} + +\def\meta_code_standard#1#2% + {\let\currentMPinstance\defaultMPinstance + \meta_enable_include + \meta_process_graphic{#1}} + +% a bit nasty (also needed for compatibility: + +% \startMPrun input mp-www.mp ; \stopMPrun +% \externalfigure[mprun.3][width=10cm,height=8cm] + +% \startMPrun{mprun} input mp-www.mp ; \stopMPrun % instance +% \externalfigure[mprun.4][width=10cm,height=8cm] + +\let\MPruninstance\defaultMPinstance + +\unexpanded\def\useMPrun#1#2% name n + {\begingroup + \def\MPaskedfigure{#2}% + \doifelsenothing{#1} + {\useMPgraphic{mprun}}% + {\useMPgraphic{#1}}% + \endgroup} + +\unexpanded\def\startMPrun + {\dosinglegroupempty\meta_start_run} + +\def\meta_start_run#1#2\stopMPrun + {\iffirstargument + \startuseMPgraphic{#1}#2\stopuseMPgraphic + \else + \startuseMPgraphic{mprun}#2\stopuseMPgraphic + \fi} + +\let\stopMPrun\relax + +%D The \type {\resetMPenvironment} is a quick way to erase +%D the token list. +%D +%D You should be aware of independencies. For instance, if you use a font +%D in a graphic that is not used in the main document, you need to load the +%D typescript at the outer level (either directly or by using the global +%D option). +%D +%D \starttyping +%D \usetypescript[palatino][texnansi] +%D +%D \startMPenvironment +%D \usetypescript[palatino][texnansi] +%D \enableregime[utf] +%D \setupbodyfont[palatino] +%D \stopMPenvironment +%D +%D \startMPpage +%D draw btex aap‒noot coördinatie – één etex ; +%D \stopMPpage +%D \stoptyping + +%D Loading specific \METAPOST\ related definitions is +%D accomplished by: + +\unexpanded\def\useMPlibrary[#1]{\clf_useMPlibrary{#1}} + +%D \macros +%D {setMPtext, MPtext, MPstring, MPbetex} +%D +%D To be documented: +%D +%D \starttyping +%D \setMPtext{identifier}{text} +%D +%D \MPtext {identifier} +%D \MPstring{identifier} +%D \MPbetex {identifier} +%D \stoptyping + +\installcorenamespace{mptext} + +\unexpanded\def\setMPtext#1#2% todo : #1 must be made : safe + {\defconvertedargument\ascii{#2}% + \dodoglobal\letvalue{\??mptext#1}\ascii} + +\def\MPtext #1{\begincsname\??mptext#1\endcsname\empty} +\def\MPstring#1{"\begincsname\??mptext#1\endcsname\empty"} +\def\MPbetex #1{btex \begincsname\??mptext#1\endcsname\space etex} + +%D In order to communicate conveniently with the \TEX\ engine, we introduce some +%D typesetting variables. + +% \setupcolors[state=stop,conversion=never] % quite tricky ... type mismatch + +% \startMPextensions +% color OverlayColor,OverlayLineColor; +% \stopMPextensions + +\startMPinitializations + CurrentLayout:="\currentlayout"; +\stopMPinitializations + +% \startMPinitializations +% OverlayWidth:=\overlaywidth; +% OverlayHeight:=\overlayheight; +% OverlayDepth:=\overlaydepth; +% OverlayLineWidth:=\overlaylinewidth; +% OverlayOffset:=\overlayoffset; +% \stopMPinitializations + +%D A dirty trick, ** in colo-ini.lua (mpcolor). We cannot use a vardef, because +%D that fails with spot colors. + +\startMPinitializations + def OverlayLineColor=\ifx\overlaylinecolor\empty black \else\MPcolor{\overlaylinecolor} \fi enddef; + def OverlayColor =\ifx\overlaycolor \empty black \else\MPcolor{\overlaycolor} \fi enddef; +\stopMPinitializations + +% \newcount\c_overlay_colormodel +% \newcount\c_overlay_color +% \newcount\c_overlay_transparency +% \newcount\c_overlay_linecolor +% \newcount\c_overlay_linetransparency + +% \appendtoks +% \c_overlay_colormodel \attribute\colormodelattribute +% \c_overlay_color \colo_helpers_inherited_current_ca\overlaycolor +% \c_overlay_transparency \colo_helpers_inherited_current_ta\overlaycolor +% \c_overlay_linecolor \colo_helpers_inherited_current_ca\overlaylinecolor +% \c_overlay_linetransparency\colo_helpers_inherited_current_ta\overlaylinecolor +% \to \everyMPgraphic + +% \startMPinitializations +% BaseLineSkip:=\the\baselineskip; +% LineHeight:=\the\baselineskip; +% BodyFontSize:=\the\bodyfontsize; +% % +% TopSkip:=\the\topskip; +% StrutHeight:=\strutheight; +% StrutDepth:=\strutdepth; +% % +% CurrentWidth:=\the\hsize; +% CurrentHeight:=\the\vsize; +% HSize:=\the\hsize ; +% VSize:=\the\vsize ; +% % +% EmWidth:=\the\emwidth; +% ExHeight:=\the\exheight; +% \stopMPinitializations + +\appendtoks + \disablediscretionaries + %\disablecompoundcharacters +\to \everyMPgraphic + +% \appendtoks % before color, inefficient, replace by low level copy +% \doregistercolor{currentcolor}\currentcolorname +% \to \everyMPgraphic + +% \color[green]{abc \startMPcode +% fill fullcircle scaled 3cm withoutcolor; +% fill fullcircle scaled 2cm withcolor \MPcolor{currentcolor} ; +% fill fullcircle scaled 1cm withcolor \MPcolor{red} ; +% \stopMPcode def} + +\appendtoks + \baselineskip1\baselineskip + \lineheight 1\lineheight + \topskip 1\topskip +\to \everyMPgraphic + +\appendtoks + \let \# \letterhash + \let \_ \letterunderscore + \let \& \letterampersand + \let \{ \letteropenbrace + \let \} \letterclosebrace +\to \everyMPgraphic + +%D \macros +%D {PDFMPformoffset} +%D +%D In \PDF, forms are clipped and therefore we have to take precautions to get this +%D right. Since this is related to objects, we use the same offset as used there. + +\def\PDFMPformoffset{\objectoffset} + +\newtoks\everyinsertMPfile + +\startMPextensions + def initialize_form_numbers = + do_initialize_numbers; + enddef; +\stopMPextensions + +\startMPextensions + vardef ForegroundBox = + unitsquare xysized(HSize,VSize) + enddef ; +\stopMPextensions + +% \startMPextensions +% PageFraction := 1 ; +% \stopMPextensions + +% \startMPinitializations +% PageFraction := if \lastpage>1: (\realfolio-1)/(\lastpage-1) else: 1 fi ; +% \stopMPinitializations + +\startMPdefinitions {metapost} + if unknown context_bare : input mp-bare.mpiv ; fi ; +\stopMPdefinitions +\startMPdefinitions {binarypost} + if unknown context_bare : input mp-bare.mpiv ; fi ; +\stopMPdefinitions +\startMPdefinitions {decimalpost} + if unknown context_bare : input mp-bare.mpiv ; fi ; +\stopMPdefinitions +\startMPdefinitions {doublepost} + if unknown context_bare : input mp-bare.mpiv ; fi ; +\stopMPdefinitions + +% \startMPdefinitions {nofun} +% if unknown context_bare : input mp-bare.mpiv ; fi ; +% \stopMPdefinitions + +%D And some more. These are not really needed since we don't use the normal figure +%D inclusion macros any longer. + +\appendtoks + \externalfigurepostprocessors\emptytoks % safeguard +\to \everyinsertMPfile + +%D We also take care of disabling fancy figure features, that can terribly interfere +%D when dealing with symbols, background graphics and running (postponed) graphics. +%D You won't believe me if I tell you what funny side effects can occur. One took me +%D over a day to uncover when processing the screen version of the \METAFUN\ manual. + +\def\doifelseMPgraphic#1% + {\ifcsname\??mpgraphic #1\endcsname\expandafter\firstoftwoarguments \orelse + \ifcsname\??mpgraphic o:#1\endcsname\expandafter\firstoftwoarguments \orelse + \ifcsname\??mpgraphic e:#1\endcsname\expandafter\firstoftwoarguments \else + \expandafter\secondoftwoarguments\fi} + +\let\doifMPgraphicelse\doifelseMPgraphic + +%D New: + +\definelayerpreset % no dx,dy - else nasty non-mp placement + [mp] + [\c!y=-\MPury, + \c!x=\MPllx, + \c!method=\v!fit] + +\definelayer + [mp] + [\c!preset=mp] + +%D Usage: +%D +%D \starttyping +%D \defineviewerlayer[one][state=start] +%D \defineviewerlayer[two][state=stop] +%D +%D \startuseMPgraphic{step-1} +%D fill fullcircle scaled 10cm withcolor red ; +%D \stopuseMPgraphic +%D +%D \startuseMPgraphic{step-2} +%D fill fullcircle scaled 5cm withcolor green ; +%D \stopuseMPgraphic +%D +%D \setlayer[mp]{\viewerlayer[one]{\useMPgraphic{step-1}}} +%D \setlayer[mp]{\viewerlayer[two]{\useMPgraphic{step-2}}} +%D +%D \ruledhbox{\flushlayer[mp]} +%D \stoptyping +%D +%D Reusing graphics is also possible (now): +%D +%D \starttyping +%D \startreusableMPgraphic{axis} +%D tickstep := 1cm ; ticklength := 2mm ; +%D drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ; +%D tickstep := tickstep/2 ; ticklength := ticklength/2 ; +%D drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ; +%D \stopreusableMPgraphic +%D +%D \startuseMPgraphic{demo} +%D drawpoint "1cm,1.5cm" ; +%D \stopuseMPgraphic +%D +%D \definelayer[mp][preset=mp] +%D \setlayer[mp]{\reuseMPgraphic{axis}} +%D \setlayer[mp]{\useMPgraphic{demo}} +%D \ruledhbox{\flushlayer[mp]} +%D \stoptyping + +%D \macros +%D {startstaticMPfigure,useMPstaticfigure} +%D +%D Static figures are processed only when there has been something changed. Here is +%D Aditya Mahajan's testcase: +%D +%D \startbuffer +%D \startstaticMPfigure{circle} +%D fill fullcircle scaled 1cm withcolor blue; +%D \stopstaticMPfigure +%D +%D \startstaticMPfigure{axis} +%D drawarrow (0,0)--(2cm,0) ; +%D drawarrow (0,0)--(0,2cm) ; +%D label.llft(textext("(0,0)") ,origin) ; +%D \stopstaticMPfigure +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +\unexpanded\def\startstaticMPfigure#1#2\stopstaticMPfigure + {\startreusableMPgraphic{\??mpstaticgraphic#1}#2\stopreusableMPgraphic} + +\unexpanded\def\startstaticMPgraphic + {\dodoublegroupempty\meta_start_static_graphic} + +\def\meta_start_static_graphic#1#2#3\stopstaticMPgraphic + {\startreusableMPgraphic{\??mpstaticgraphic#1}{#2}#3\stopreusableMPgraphic} + +\let\stopstaticMPfigure \relax +\let\stopstaticMPgraphic\relax + +\unexpanded\def\usestaticMPfigure + {\dodoubleempty\meta_use_static_figure} + +\def\meta_use_static_figure[#1][#2]% + {\ifsecondargument + \scale[#2]{\reuseMPgraphic{\??mpstaticgraphic#1}}% + \else + \reuseMPgraphic{\??mpstaticgraphic#1}% + \fi} + +%D Goody for preventing overflows: + +\def\MPdivten[#1]{\withoutpt\the\dimexpr#1pt/10\relax} + +%D There is no way to distinguish the black color that you get when you issue a +%D \type {draw} without color specification from a color that has an explicit black +%D specification unless you set the variable \type {defaultcolormodel} to 1. +%D Hoewever, in that case you cannot distinguish that draw from one with a \type +%D {withoutcolor} specification. This means that we have to provide multiple +%D variants of inheritance. +%D +%D In any case we need to tell the converter what the inherited color is to start +%D with. Case~3 is kind of unpredictable as it closely relates to the order in which +%D paths are flushed. If you want to inherit automatically from the surrounding, you +%D can best stick to variant 1. Variant 0 (an isolated graphic) is the default. +%D +%D \startbuffer +%D \startuseMPgraphic{test} +%D drawoptions(withpen pencircle scaled 1pt) ; +%D def shift_cp = currentpicture := currentpicture shifted (-15pt,0) ; enddef ; +%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ; +%D fill fullcircle scaled 10pt ; shift_cp ; +%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ; +%D fill fullcircle scaled 10pt withcolor red ; shift_cp ; +%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ; +%D fill fullcircle scaled 10pt ; shift_cp ; +%D \stopuseMPgraphic +%D +%D \starttabulate +%D \NC 0\quad \NC \MPcolormethod0 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 1\quad \NC \MPcolormethod1 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 2\quad \NC \MPcolormethod2 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 3\quad \NC \MPcolormethod3 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \stoptabulate +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +\newconstant\MPcolormethod + +\appendtoks + \clf_mpsetoutercolor + \MPcolormethod\space + \attribute\colormodelattribute\space + \attribute\colorattribute\space + \dogetattribute{transparency}\relax +\to \everyMPgraphic + +% \startMPinitializations +% defaultcolormodel := \ifcase\MPcolormethod1\or1\or3\else3\fi; +% \stopMPinitializations + +%D macros +%D {mprunvar,mpruntab,mprunset} +%D +%D \starttyping +%D \startMPcode +%D passvariable("version","1.0") ; +%D passvariable("number",123) ; +%D passvariable("string","whatever") ; +%D passvariable("point",(1.5,2.8)) ; +%D passvariable("triplet",(1/1,1/2,1/3)) ; +%D passvariable("quad",(1.1,2.2,3.3,4.4)) ; +%D passvariable("boolean",false) ; +%D passvariable("path",fullcircle scaled 1cm) ; +%D draw fullcircle scaled 20pt ; +%D \stopMPcode +%D +%D \ctxlua{inspect(metapost.variables)} +%D +%D \MPrunvar{version} \MPruntab{quad}{3} (\MPrunset{triplet}{,}) +%D +%D $(x,y) = (\MPruntab{point}{1},\MPruntab{point}{2})$ +%D $(x,y) = (\MPrunset{point}{,})$ +%D \stoptyping + +\def\MPrunvar #1{\clf_mprunvar{#1}} \let\mprunvar\MPrunvar +\def\MPruntab#1#2{\clf_mpruntab{#1}#2\relax} \let\mpruntab\MPruntab % #2 is number +\def\MPrunset#1#2{\clf_mprunset{#1}{#2}} \let\mprunset\MPrunset + +\prependtoks \clf_mppushvariables \to \everybeforepagebody +\appendtoks \clf_mppopvariables \to \everyafterpagebody + +\let\MPpushvariables\clf_mppushvariables +\let\MPpopvariables \clf_mppopvariables + +%D We also provide an outputless run: + +\unexpanded\def\startMPcalculation + {\begingroup + \setbox\nextbox\hpack\bgroup + \dosinglegroupempty\meta_start_calculation} + +\def\meta_start_calculation + {\iffirstargument + \expandafter\meta_start_calculation_instance + \else + \expandafter\meta_start_calculation_standard + \fi} + +\def\meta_start_calculation_instance#1#2\stopMPcalculation + {\edef\currentMPinstance{#1}% + \let\currentMPgraphicname\empty + \edef\currentMPformat{\MPinstanceparameter\s!format}% + \meta_enable_include + \meta_process_graphic{#2;draw origin}% + \egroup + \endgroup} + +\def\meta_start_calculation_standard#1#2\stopMPcalculation + {\let\currentMPinstance\defaultMPinstance + \let\currentMPgraphicname\empty + \edef\currentMPformat{\MPinstanceparameter\s!format}% + \meta_process_graphic{#2;draw origin}% + \egroup + \endgroup} + +\let\stopMPcalculation\relax + +%D \macros +%D {setupMPgraphics} +%D +%D Here is a generic setup command: + +\installcorenamespace{MPgraphics} + +\installsetuponlycommandhandler \??MPgraphics {MPgraphics} + +%D Here we hook in the outer color. When \type {color} is set to \type {global} we +%D get the outer color automatically. If you change this setting, you should do it +%D grouped in order not to make other graphics behave in unexpected ways. + +\appendtoks + \doifelse{\directMPgraphicsparameter\c!color}\v!global{\MPcolormethod\plusone}{\MPcolormethod\zerocount}% +\to \everysetupMPgraphics + +\setupMPgraphics + [\c!color=\v!local] + +%D This can save some runtime: rename the mpy file from a first run (when stable) to +%D another file and reuse it. One can also use the original filename, but a copy is +%D often better. +%D +%D \starttyping +%D \setupMPgraphics +%D [mpy=\jobname.mpy] +%D \stoptyping + +\appendtoks + \edef\p_mpy{\directMPgraphicsparameter{mpy}}% + \ifx\p_mpy\empty \else + \let\MPdataMPYfile\p_mpy + \clf_registermpyfile{\p_mpy}% + \fi +\to \everysetupMPgraphics + +%D Some more helpers (see \type {meta-grd.mkiv} for an example of usage): + +\def\MPdpar#1#2{\the\dimexpr#1#2\relax\empty} +\def\MPnpar#1#2{\the\numexpr#1#2\relax\empty} +\def\MPspar#1#2{"#1#2"} + +%D Done. + +\protect \endinput diff --git a/tex/context/base/mkiv/mlib-int.lua b/tex/context/base/mkiv/mlib-int.lua index 63e7278da..6fca95302 100644 --- a/tex/context/base/mkiv/mlib-int.lua +++ b/tex/context/base/mkiv/mlib-int.lua @@ -6,150 +6,261 @@ if not modules then modules = { } end modules ['mlib-int'] = { license = "see context related readme files", } -local factor = number.dimenfactors.bp ------ mpprint = mp.print -local mpnumeric = mp.numeric -local mpboolean = mp.boolean -local mpstring = mp.string -local mpquoted = mp.quoted -local getdimen = tex.getdimen -local getcount = tex.getcount -local getmacro = tokens.getters.macro -local get = tex.get -local mpcolor = attributes.colors.mpcolor -local emwidths = fonts.hashes.emwidths -local exheights = fonts.hashes.exheights - -local mpgetdimen = mp.getdimen - -function mp.PaperHeight () mpnumeric(getdimen("paperheight") *factor) end -function mp.PaperWidth () mpnumeric(getdimen("paperwidth") *factor) end -function mp.PrintPaperHeight () mpnumeric(getdimen("printpaperheight") *factor) end -function mp.PrintPaperWidth () mpnumeric(getdimen("printpaperwidth") *factor) end -function mp.TopSpace () mpnumeric(getdimen("topspace") *factor) end -function mp.BottomSpace () mpnumeric(getdimen("bottomspace") *factor) end -function mp.BackSpace () mpnumeric(getdimen("backspace") *factor) end -function mp.CutSpace () mpnumeric(getdimen("cutspace") *factor) end -function mp.MakeupHeight () mpnumeric(getdimen("makeupheight") *factor) end -function mp.MakeupWidth () mpnumeric(getdimen("makeupwidth") *factor) end -function mp.TopHeight () mpnumeric(getdimen("topheight") *factor) end -function mp.TopDistance () mpnumeric(getdimen("topdistance") *factor) end -function mp.HeaderHeight () mpnumeric(getdimen("headerheight") *factor) end -function mp.HeaderDistance () mpnumeric(getdimen("headerdistance") *factor) end -function mp.TextHeight () mpnumeric(getdimen("textheight") *factor) end -function mp.FooterDistance () mpnumeric(getdimen("footerdistance") *factor) end -function mp.FooterHeight () mpnumeric(getdimen("footerheight") *factor) end -function mp.BottomDistance () mpnumeric(getdimen("bottomdistance") *factor) end -function mp.BottomHeight () mpnumeric(getdimen("bottomheight") *factor) end -function mp.LeftEdgeWidth () mpnumeric(getdimen("leftedgewidth") *factor) end -function mp.LeftEdgeDistance () mpnumeric(getdimen("leftedgedistance") *factor) end -function mp.LeftMarginWidth () mpnumeric(getdimen("leftmarginwidth") *factor) end -function mp.LeftMarginDistance () mpnumeric(getdimen("leftmargindistance") *factor) end -function mp.TextWidth () mpnumeric(getdimen("textwidth") *factor) end -function mp.RightMarginDistance () mpnumeric(getdimen("rightmargindistance") *factor) end -function mp.RightMarginWidth () mpnumeric(getdimen("rightmarginwidth") *factor) end -function mp.RightEdgeDistance () mpnumeric(getdimen("rightedgedistance") *factor) end -function mp.RightEdgeWidth () mpnumeric(getdimen("rightedgewidth") *factor) end -function mp.InnerMarginDistance () mpnumeric(getdimen("innermargindistance") *factor) end -function mp.InnerMarginWidth () mpnumeric(getdimen("innermarginwidth") *factor) end -function mp.OuterMarginDistance () mpnumeric(getdimen("outermargindistance") *factor) end -function mp.OuterMarginWidth () mpnumeric(getdimen("outermarginwidth") *factor) end -function mp.InnerEdgeDistance () mpnumeric(getdimen("inneredgedistance") *factor) end -function mp.InnerEdgeWidth () mpnumeric(getdimen("inneredgewidth") *factor) end -function mp.OuterEdgeDistance () mpnumeric(getdimen("outeredgedistance") *factor) end -function mp.OuterEdgeWidth () mpnumeric(getdimen("outeredgewidth") *factor) end -function mp.PageOffset () mpnumeric(getdimen("pagebackgroundoffset")*factor) end -function mp.PageDepth () mpnumeric(getdimen("pagebackgrounddepth") *factor) end -function mp.LayoutColumns () mpnumeric(getcount("layoutcolumns")) end -function mp.LayoutColumnDistance() mpnumeric(getdimen("layoutcolumndistance")*factor) end -function mp.LayoutColumnWidth () mpnumeric(getdimen("layoutcolumnwidth") *factor) end -function mp.SpineWidth () mpnumeric(getdimen("spinewidth") *factor) end -function mp.PaperBleed () mpnumeric(getdimen("paperbleed") *factor) end - -function mp.RealPageNumber () mpnumeric(getcount("realpageno")) end -function mp.LastPageNumber () mpnumeric(getcount("lastpageno")) end - -function mp.PageNumber () mpnumeric(getcount("pageno")) end -function mp.NOfPages () mpnumeric(getcount("lastpageno")) end - -function mp.SubPageNumber () mpnumeric(getcount("subpageno")) end -function mp.NOfSubPages () mpnumeric(getcount("lastsubpageno")) end - -function mp.CurrentColumn () mpnumeric(getcount("mofcolumns")) end -function mp.NOfColumns () mpnumeric(getcount("nofcolumns")) end - -function mp.BaseLineSkip () mpnumeric(get ("baselineskip",true) *factor) end -function mp.LineHeight () mpnumeric(getdimen("lineheight") *factor) end -function mp.BodyFontSize () mpnumeric(getdimen("bodyfontsize") *factor) end - -function mp.TopSkip () mpnumeric(get ("topskip",true) *factor) end -function mp.StrutHeight () mpnumeric(getdimen("strutht") *factor) end -function mp.StrutDepth () mpnumeric(getdimen("strutdp") *factor) end - -function mp.PageNumber () mpnumeric(getcount("pageno")) end -function mp.RealPageNumber () mpnumeric(getcount("realpageno")) end -function mp.NOfPages () mpnumeric(getcount("lastpageno")) end - -function mp.CurrentWidth () mpnumeric(get ("hsize") *factor) end -function mp.CurrentHeight () mpnumeric(get ("vsize") *factor) end - -function mp.EmWidth () mpnumeric(emwidths [false]*factor) end -function mp.ExHeight () mpnumeric(exheights[false]*factor) end - -mp.HSize = mp.CurrentWidth -mp.VSize = mp.CurrentHeight -mp.LastPageNumber = mp.NOfPages - -function mp.PageFraction() - local lastpage = getcount("lastpageno") - if lastpage > 1 then - mpnumeric((getcount("realpageno")-1)/(lastpage-1)) - else - mpnumeric(1) - end +local factor = number.dimenfactors.bp +----- mpprint = mp.print +local mpnumeric = mp.numeric +local mpboolean = mp.boolean +local mpstring = mp.string +local mpquoted = mp.quoted +local getdimen = tex.getdimen +local getcount = tex.getcount +local getmacro = tokens.getters.macro +local get = tex.get +local mpcolor = attributes.colors.mpcolor +local emwidths = fonts.hashes.emwidths +local exheights = fonts.hashes.exheights + +local mpgetdimen = mp.getdimen + +local registerscript = metapost.registerscript + +local on_right_page = structures.pages.on_right +local is_odd_page = structures.pages.is_odd +local in_body_page = structures.pages.in_body +local page_fraction = structures.pages.fraction + +local function defaultcolormodel() -- can be helper + local colormethod = getcount("MPcolormethod") + return (colormethod == 0 or colormethod == 1) and 1 or 3 end --- locals +if CONTEXTLMTXMODE > 0 then -local on_right = structures.pages.on_right -local is_odd = structures.pages.is_odd -local in_body = structures.pages.in_body + local t = os.date("*t") -- maybe this should be a very early on global -mp.OnRightPage = function() mpboolean(on_right()) end -- needs checking -mp.OnOddPage = function() mpboolean(is_odd ()) end -- needs checking -mp.InPageBody = function() mpboolean(in_body ()) end -- needs checking + registerscript("year", function() return t.year end) + registerscript("month", function() return t.month end) + registerscript("day", function() return t.day end) + registerscript("hour", function() return t.hour end) + registerscript("minute", function() return t.min end) + registerscript("second", function() return t.sec end) --- mp.CurrentLayout : \currentlayout + registerscript("PaperHeight", function() return getdimen("paperheight") * factor end) + registerscript("PaperWidth", function() return getdimen("paperwidth") * factor end) + registerscript("PrintPaperHeight", function() return getdimen("printpaperheight") * factor end) + registerscript("PrintPaperWidth", function() return getdimen("printpaperwidth") * factor end) + registerscript("TopSpace", function() return getdimen("topspace") * factor end) + registerscript("BottomSpace", function() return getdimen("bottomspace") * factor end) + registerscript("BackSpace", function() return getdimen("backspace") * factor end) + registerscript("CutSpace", function() return getdimen("cutspace") * factor end) + registerscript("MakeupHeight", function() return getdimen("makeupheight") * factor end) + registerscript("MakeupWidth", function() return getdimen("makeupwidth") * factor end) + registerscript("TopHeight", function() return getdimen("topheight") * factor end) + registerscript("TopDistance", function() return getdimen("topdistance") * factor end) + registerscript("HeaderHeight", function() return getdimen("headerheight") * factor end) + registerscript("HeaderDistance", function() return getdimen("headerdistance") * factor end) + registerscript("TextHeight", function() return getdimen("textheight") * factor end) + registerscript("FooterDistance", function() return getdimen("footerdistance") * factor end) + registerscript("FooterHeight", function() return getdimen("footerheight") * factor end) + registerscript("BottomDistance", function() return getdimen("bottomdistance") * factor end) + registerscript("BottomHeight", function() return getdimen("bottomheight") * factor end) + registerscript("LeftEdgeWidth", function() return getdimen("leftedgewidth") * factor end) + registerscript("LeftEdgeDistance", function() return getdimen("leftedgedistance") * factor end) + registerscript("LeftMarginWidth", function() return getdimen("leftmarginwidth") * factor end) + registerscript("LeftMarginDistance", function() return getdimen("leftmargindistance") * factor end) + registerscript("TextWidth", function() return getdimen("textwidth") * factor end) + registerscript("RightMarginDistance", function() return getdimen("rightmargindistance") * factor end) + registerscript("RightMarginWidth", function() return getdimen("rightmarginwidth") * factor end) + registerscript("RightEdgeDistance", function() return getdimen("rightedgedistance") * factor end) + registerscript("RightEdgeWidth", function() return getdimen("rightedgewidth") * factor end) + registerscript("InnerMarginDistance", function() return getdimen("innermargindistance") * factor end) + registerscript("InnerMarginWidth", function() return getdimen("innermarginwidth") * factor end) + registerscript("OuterMarginDistance", function() return getdimen("outermargindistance") * factor end) + registerscript("OuterMarginWidth", function() return getdimen("outermarginwidth") * factor end) + registerscript("InnerEdgeDistance", function() return getdimen("inneredgedistance") * factor end) + registerscript("InnerEdgeWidth", function() return getdimen("inneredgewidth") * factor end) + registerscript("OuterEdgeDistance", function() return getdimen("outeredgedistance") * factor end) + registerscript("OuterEdgeWidth", function() return getdimen("outeredgewidth") * factor end) + registerscript("PageOffset", function() return getdimen("pagebackgroundoffset") * factor end) + registerscript("PageDepth", function() return getdimen("pagebackgrounddepth") * factor end) + registerscript("LayoutColumns", function() return getcount("layoutcolumns") end) + registerscript("LayoutColumnDistance", function() return getdimen("layoutcolumndistance") * factor end) + registerscript("LayoutColumnWidth", function() return getdimen("layoutcolumnwidth") * factor end) + registerscript("SpineWidth", function() return getdimen("spinewidth") * factor end) + registerscript("PaperBleed", function() return getdimen("paperbleed") * factor end) -function mp.OverlayWidth () mpnumeric(getdimen("d_overlay_width") * factor) end -function mp.OverlayHeight () mpnumeric(getdimen("d_overlay_height") * factor) end -function mp.OverlayDepth () mpnumeric(getdimen("d_overlay_depth") * factor) end -function mp.OverlayLineWidth() mpnumeric(getdimen("d_overlay_linewidth") * factor) end -function mp.OverlayOffset () mpnumeric(getdimen("d_overlay_offset") * factor) end -function mp.OverlayRegion () mpstring(getmacro("m_overlay_region")) end + registerscript("RealPageNumber", function() return getcount("realpageno") end) + registerscript("LastPageNumber", function() return getcount("lastpageno") end) + + registerscript("PageNumber", function() return getcount("pageno") end) + registerscript("NOfPages", function() return getcount("lastpageno") end) + + registerscript("SubPageNumber", function() return getcount("subpageno") end) + registerscript("NOfSubPages", function() return getcount("lastsubpageno") end) + + registerscript("CurrentColumn", function() return getcount("mofcolumns") end) + registerscript("NOfColumns", function() return getcount("nofcolumns") end) + + registerscript("BaseLineSkip", function() return get ("baselineskip",true) * factor end) + registerscript("LineHeight", function() return getdimen("lineheight") * factor end) + registerscript("BodyFontSize", function() return getdimen("bodyfontsize") * factor end) + + registerscript("TopSkip", function() return get ("topskip",true) * factor end) + registerscript("StrutHeight", function() return getdimen("strutht") * factor end) + registerscript("StrutDepth", function() return getdimen("strutdp") * factor end) + + registerscript("PageNumber", function() return getcount("pageno") end) + registerscript("RealPageNumber", function() return getcount("realpageno") end) + registerscript("NOfPages", function() return getcount("lastpageno") end) + + registerscript("CurrentWidth", function() return get ("hsize") * factor end) + registerscript("CurrentHeight", function() return get ("vsize") * factor end) + + registerscript("EmWidth", function() return emwidths [false] * factor end) + registerscript("ExHeight", function() return exheights[false] * factor end) + + registerscript("HSize", function() return get ("hsize") * factor end) + registerscript("VSize", function() return get ("vsize") * factor end) + registerscript("LastPageNumber", function() return getcount("lastpageno") end) + + registerscript("OverlayWidth", function() return getdimen("d_overlay_width") * factor end) + registerscript("OverlayHeight", function() return getdimen("d_overlay_height") * factor end) + registerscript("OverlayDepth", function() return getdimen("d_overlay_depth") * factor end) + registerscript("OverlayLineWidth", function() return getdimen("d_overlay_linewidth") * factor end) + registerscript("OverlayOffset", function() return getdimen("d_overlay_offset") * factor end) + registerscript("OverlayRegion", function() mpstring(getmacro("m_overlay_region")) end) + -- ("CurrentLayout", function() mpstring(getmacro("currentlayout")) end) + + registerscript("PageFraction", page_fraction) + registerscript("OnRightPage", on_right_page) + registerscript("OnOddPage", is_odd_page ) + registerscript("InPageBody", in_body_page ) + + registerscript("defaultcolormodel", defaultcolormodel) + +else + + function mp.PaperHeight () mpnumeric(getdimen("paperheight") * factor) end + function mp.PaperWidth () mpnumeric(getdimen("paperwidth") * factor) end + function mp.PrintPaperHeight () mpnumeric(getdimen("printpaperheight") * factor) end + function mp.PrintPaperWidth () mpnumeric(getdimen("printpaperwidth") * factor) end + function mp.TopSpace () mpnumeric(getdimen("topspace") * factor) end + function mp.BottomSpace () mpnumeric(getdimen("bottomspace") * factor) end + function mp.BackSpace () mpnumeric(getdimen("backspace") * factor) end + function mp.CutSpace () mpnumeric(getdimen("cutspace") * factor) end + function mp.MakeupHeight () mpnumeric(getdimen("makeupheight") * factor) end + function mp.MakeupWidth () mpnumeric(getdimen("makeupwidth") * factor) end + function mp.TopHeight () mpnumeric(getdimen("topheight") * factor) end + function mp.TopDistance () mpnumeric(getdimen("topdistance") * factor) end + function mp.HeaderHeight () mpnumeric(getdimen("headerheight") * factor) end + function mp.HeaderDistance () mpnumeric(getdimen("headerdistance") * factor) end + function mp.TextHeight () mpnumeric(getdimen("textheight") * factor) end + function mp.FooterDistance () mpnumeric(getdimen("footerdistance") * factor) end + function mp.FooterHeight () mpnumeric(getdimen("footerheight") * factor) end + function mp.BottomDistance () mpnumeric(getdimen("bottomdistance") * factor) end + function mp.BottomHeight () mpnumeric(getdimen("bottomheight") * factor) end + function mp.LeftEdgeWidth () mpnumeric(getdimen("leftedgewidth") * factor) end + function mp.LeftEdgeDistance () mpnumeric(getdimen("leftedgedistance") * factor) end + function mp.LeftMarginWidth () mpnumeric(getdimen("leftmarginwidth") * factor) end + function mp.LeftMarginDistance () mpnumeric(getdimen("leftmargindistance") * factor) end + function mp.TextWidth () mpnumeric(getdimen("textwidth") * factor) end + function mp.RightMarginDistance () mpnumeric(getdimen("rightmargindistance") * factor) end + function mp.RightMarginWidth () mpnumeric(getdimen("rightmarginwidth") * factor) end + function mp.RightEdgeDistance () mpnumeric(getdimen("rightedgedistance") * factor) end + function mp.RightEdgeWidth () mpnumeric(getdimen("rightedgewidth") * factor) end + function mp.InnerMarginDistance () mpnumeric(getdimen("innermargindistance") * factor) end + function mp.InnerMarginWidth () mpnumeric(getdimen("innermarginwidth") * factor) end + function mp.OuterMarginDistance () mpnumeric(getdimen("outermargindistance") * factor) end + function mp.OuterMarginWidth () mpnumeric(getdimen("outermarginwidth") * factor) end + function mp.InnerEdgeDistance () mpnumeric(getdimen("inneredgedistance") * factor) end + function mp.InnerEdgeWidth () mpnumeric(getdimen("inneredgewidth") * factor) end + function mp.OuterEdgeDistance () mpnumeric(getdimen("outeredgedistance") * factor) end + function mp.OuterEdgeWidth () mpnumeric(getdimen("outeredgewidth") * factor) end + function mp.PageOffset () mpnumeric(getdimen("pagebackgroundoffset") * factor) end + function mp.PageDepth () mpnumeric(getdimen("pagebackgrounddepth") * factor) end + function mp.LayoutColumns () mpnumeric(getcount("layoutcolumns")) end + function mp.LayoutColumnDistance() mpnumeric(getdimen("layoutcolumndistance") * factor) end + function mp.LayoutColumnWidth () mpnumeric(getdimen("layoutcolumnwidth") * factor) end + function mp.SpineWidth () mpnumeric(getdimen("spinewidth") * factor) end + function mp.PaperBleed () mpnumeric(getdimen("paperbleed") * factor) end + + function mp.RealPageNumber () mpnumeric(getcount("realpageno") ) end + function mp.LastPageNumber () mpnumeric(getcount("lastpageno") ) end + + function mp.PageNumber () mpnumeric(getcount("pageno") ) end + function mp.NOfPages () mpnumeric(getcount("lastpageno") ) end + + function mp.SubPageNumber () mpnumeric(getcount("subpageno") ) end + function mp.NOfSubPages () mpnumeric(getcount("lastsubpageno") ) end + + function mp.CurrentColumn () mpnumeric(getcount("mofcolumns") ) end + function mp.NOfColumns () mpnumeric(getcount("nofcolumns") ) end + + function mp.BaseLineSkip () mpnumeric(get ("baselineskip",true) * factor) end + function mp.LineHeight () mpnumeric(getdimen("lineheight") * factor) end + function mp.BodyFontSize () mpnumeric(getdimen("bodyfontsize") * factor) end + + function mp.TopSkip () mpnumeric(get ("topskip",true) * factor) end + function mp.StrutHeight () mpnumeric(getdimen("strutht") * factor) end + function mp.StrutDepth () mpnumeric(getdimen("strutdp") * factor) end + + function mp.PageNumber () mpnumeric(getcount("pageno") ) end + function mp.RealPageNumber () mpnumeric(getcount("realpageno") ) end + function mp.NOfPages () mpnumeric(getcount("lastpageno") ) end + + function mp.CurrentWidth () mpnumeric(get ("hsize") * factor) end + function mp.CurrentHeight () mpnumeric(get ("vsize") * factor) end + + function mp.EmWidth () mpnumeric(emwidths [false] * factor) end + function mp.ExHeight () mpnumeric(exheights[false] * factor) end + + function mp.OverlayWidth () mpnumeric(getdimen("d_overlay_width") * factor) end + function mp.OverlayHeight () mpnumeric(getdimen("d_overlay_height") * factor) end + function mp.OverlayDepth () mpnumeric(getdimen("d_overlay_depth") * factor) end + function mp.OverlayLineWidth () mpnumeric(getdimen("d_overlay_linewidth") * factor) end + function mp.OverlayOffset () mpnumeric(getdimen("d_overlay_offset") * factor) end + function mp.OverlayRegion () mpstring (getmacro("m_overlay_region") ) end + + function mp.PageFraction () mpnumeric(page_fraction() ) end + function mp.OnRightPage () mpboolean(on_right_page() ) end + function mp.OnOddPage () mpboolean(is_odd_page () ) end + function mp.InPageBody () mpboolean(in_body_page () ) end + + function mp.OverlayWidth () mpnumeric(getdimen("d_overlay_width") * factor) end + function mp.OverlayHeight () mpnumeric(getdimen("d_overlay_height") * factor) end + function mp.OverlayDepth () mpnumeric(getdimen("d_overlay_depth") * factor) end + function mp.OverlayLineWidth () mpnumeric(getdimen("d_overlay_linewidth") * factor) end + function mp.OverlayOffset () mpnumeric(getdimen("d_overlay_offset") * factor) end + function mp.OverlayRegion () mpstring (getmacro("m_overlay_region") ) end + -- mp.CurrentLayout () mpstring (getmacro("currentlayout")) end + + function mp.defaultcolormodel () mpnumeric(defaultcolormodel()) end + + mp.HSize = mp.CurrentWidth + mp.VSize = mp.CurrentHeight + mp.LastPageNumber = mp.NOfPages + + -- not much difference (10000 calls in a graphic neither as expansion seems to win + -- over defining the macro etc) so let's not waste counters then + + -- function mp.OverlayColor() + -- local c = mpcolor( + -- getcount("c_overlay_colormodel"), + -- getcount("c_overlay_color"), + -- getcount("c_overlay_transparency") + -- ) + -- mpquoted(c) + -- end + -- + -- function mp.OverlayLineColor() + -- local c = mpcolor( + -- getcount("c_overlay_colormodel"), + -- getcount("c_overlay_linecolor"), + -- getcount("c_overlay_linetransparency") + -- ) + -- mpquoted(c) + -- end -function mp.mf_default_color_model() - local colormethod = getcount("MPcolormethod") - return mpnumeric((colormethod == 0 or colormethod == 1) and 1 or 3) end --- not much difference (10000 calls in a graphic neither as expansion seems to win --- over defining the macro etc) so let's not waste counters then - --- function mp.OverlayColor() --- local c = mpcolor( --- getcount("c_overlay_colormodel"), --- getcount("c_overlay_color"), --- getcount("c_overlay_transparency") --- ) --- mpquoted(c) --- end --- --- function mp.OverlayLineColor() --- local c = mpcolor( --- getcount("c_overlay_colormodel"), --- getcount("c_overlay_linecolor"), --- getcount("c_overlay_linetransparency") --- ) --- mpquoted(c) --- end + diff --git a/tex/context/base/mkiv/mlib-pdf.mkiv b/tex/context/base/mkiv/mlib-pdf.mkiv index 6dc73a153..e47df4a99 100644 --- a/tex/context/base/mkiv/mlib-pdf.mkiv +++ b/tex/context/base/mkiv/mlib-pdf.mkiv @@ -88,16 +88,6 @@ \wd\MPbox\MPwidth \ht\MPbox\MPheight} -% \unexpanded\def\MPtextext#1#2#3#4#5% beware: we use a different method now (see mlib-pps) -% {\begingroup -% \setbox\MPbox\hbox{\font\temp=#1\space at #2\onebasepoint \let\c\char \temp #3}% text -% \MPllx-#4\onebasepoint -% \MPlly-#5\onebasepoint -% \repositionMPbox -% \smashbox\MPbox -% \box\MPbox -% \endgroup} - % MPLIB specific: \def\MPLIBtoPDF{\clf_mpflushliteral} % expanded @@ -146,30 +136,6 @@ \unexpanded\def\directMPgraphic {\dodoublegroupempty\mlib_direct_graphic} -% \def\mlib_direct_graphic#1#2% makes pages (todo: make boxes) -% {\meta_begin_graphic_group{#1}% -% \let\startMPLIBtoPDF\directstartMPLIBtoPDF -% \let\stopMPLIBtoPDF \directstopMPLIBtoPDF -% \meta_start_current_graphic -% \forgetall -% \edef\p_extensions{\MPinstanceparameter\s!extensions}% -% \normalexpanded{\noexpand\ctxlua{metapost.graphic { -% instance = "\currentMPinstance", -% format = "\currentMPformat", -% data = \!!bs#2;\!!es, -% initializations = \!!bs\meta_flush_current_initializations\!!es, -% % useextensions = "\MPinstanceparameter\s!extensions", -% \ifx\p_extensions\v!yes -% extensions = \!!bs\clf_getmpextensions{\currentMPinstance}\!!es, -% \fi -% inclusions = \!!bs\meta_flush_current_inclusions\!!es, -% definitions = \!!bs\meta_flush_current_definitions\!!es, -% figure = "all", -% method = "\MPinstanceparameter\c!method", -% }}}% -% \meta_stop_current_graphic -% \meta_end_graphic_group} - \def\mlib_direct_graphic#1#2% makes pages (todo: make boxes) {\meta_begin_graphic_group{#1}% \let\startMPLIBtoPDF\directstartMPLIBtoPDF diff --git a/tex/context/base/mkiv/mlib-scn.lua b/tex/context/base/mkiv/mlib-scn.lua index 4045173ac..d73e210c3 100644 --- a/tex/context/base/mkiv/mlib-scn.lua +++ b/tex/context/base/mkiv/mlib-scn.lua @@ -71,21 +71,21 @@ local mpvalue = mp.value local report = logs.reporter("metapost") -local <const> semicolon_code = codes.semicolon -local <const> equals_code = codes.equals -local <const> comma_code = codes.comma -local <const> colon_code = codes.colon -local <const> leftbrace_code = codes.leftbrace -local <const> rightbrace_code = codes.rightbrace -local <const> leftbracket_code = codes.leftbracket -local <const> rightbracket_code = codes.rightbracket -local <const> leftdelimiter_code = codes.leftdelimiter -local <const> rightdelimiter_code = codes.rightdelimiter -local <const> numeric_code = codes.numeric -local <const> string_code = codes.string -local <const> capsule_code = codes.capsule -local <const> nullary_code = codes.nullary -local <const> tag_code = codes.tag +local semicolon_code <const> = codes.semicolon +local equals_code <const> = codes.equals +local comma_code <const> = codes.comma +local colon_code <const> = codes.colon +local leftbrace_code <const> = codes.leftbrace +local rightbrace_code <const> = codes.rightbrace +local leftbracket_code <const> = codes.leftbracket +local rightbracket_code <const> = codes.rightbracket +local leftdelimiter_code <const> = codes.leftdelimiter +local rightdelimiter_code <const> = codes.rightdelimiter +local numeric_code <const> = codes.numeric +local string_code <const> = codes.string +local capsule_code <const> = codes.capsule +local nullary_code <const> = codes.nullary +local tag_code <const> = codes.tag local typescanners = nil local tokenscanners = nil @@ -484,9 +484,9 @@ local scandimension = scanners.dimension local definitions = { } -local <const> bpfactor = number.dimenfactors.bp -local <const> comma = byte(",") -local <const> close = byte("]") +local bpfactor <const> = number.dimenfactors.bp +local comma <const> = byte(",") +local close <const> = byte("]") local scanrest = function() return scanvalue(comma,close) or "" end local scandimension = function() return scandimension() * bpfactor end diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index bce5f9d83..b6fdb7021 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -8321,6 +8321,16 @@ return { ["hidenumber"]={ ["en"]="hidenumber", }, + ["horizontal"]={ + ["cs"]="horizontalne", + ["de"]="horizontal", + ["en"]="horizontal", + ["fr"]="horizontale", + ["it"]="orizzontale", + ["nl"]="horizontaal", + ["pe"]="افقی", + ["ro"]="orizontal", + }, ["hoffset"]={ ["cs"]="hoffset", ["de"]="hoffset", @@ -11384,6 +11394,16 @@ return { ["en"]="vector", ["nl"]="vector", }, + ["vertical"]={ + ["cs"]="vertikalne", + ["de"]="vertikal", + ["en"]="vertical", + ["fr"]="verticale", + ["it"]="verticale", + ["nl"]="vertikaal", + ["pe"]="عمودی", + ["ro"]="vertical", + }, ["veroffset"]={ ["cs"]="offsethlavicky", ["de"]="kopfoffset", @@ -11489,6 +11509,10 @@ return { ["xmlsetup"]={ ["en"]="xmlsetup", }, + ["xanchor"]={ + ["en"]="xanchor", + ["nl"]="xanker", + }, ["xoffset"]={ ["cs"]="xoffset", ["de"]="xoffset", @@ -11539,6 +11563,10 @@ return { ["pe"]="ymax", ["ro"]="ymax", }, + ["yanchor"]={ + ["en"]="yanchor", + ["nl"]="yanker", + }, ["yoffset"]={ ["cs"]="yoffset", ["de"]="yoffset", diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index 540b1cfba..02b5ae854 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -244,6 +244,8 @@ return { "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "flushnextbox", "boxisempty", -- + "givenwidth", "givenheight", "givendepth", "scangivendimensions", + -- "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchxoffset", "scratchyoffset", "scratchhoffset", "scratchvoffset", diff --git a/tex/context/base/mkiv/mult-mps.lua b/tex/context/base/mkiv/mult-mps.lua index b42beb2b8..335a4c612 100644 --- a/tex/context/base/mkiv/mult-mps.lua +++ b/tex/context/base/mkiv/mult-mps.lua @@ -67,7 +67,7 @@ return { "outputformat", "outputtemplate", "filenametemplate", "fontmapfile", "fontmapline", "fontpart", "fontsize", "glyph", "restoreclipcolor", "troffmode", -- - "runscript", "maketext", + "runscript", "maketext", "numbersystem", }, commands = { "upto", "downto", diff --git a/tex/context/base/mkiv/pack-lyr.mkiv b/tex/context/base/mkiv/pack-lyr.mkiv index e7070cfde..5112aed52 100644 --- a/tex/context/base/mkiv/pack-lyr.mkiv +++ b/tex/context/base/mkiv/pack-lyr.mkiv @@ -19,18 +19,16 @@ \unprotect -% When being backgrounds layers get the background offset -% displacement. Should be an option, on by default -% (compatibility). +% When being backgrounds layers get the background offset displacement. Should be +% an option, on by default (compatibility). -%D The layering mechanism implemented here is independent of -%D the output routine, but future extensions may depend on a -%D more close cooperation. - -%D First we overload a macro from \type {pack-rul}. From now on -%D we accept a (optional) argument: the specific layer it -%D will go in. This means that we can move an overlay from one -%D background to the other using the dimensions of the parent. +%D The layering mechanism implemented here is independent of the output routine, but +%D future extensions may depend on a more close cooperation. +%D +%D First we overload a macro from \type {pack-rul}. From now on we accept a +%D (optional) argument: the specific layer it will go in. This means that we can +%D move an overlay from one background to the other using the dimensions of the +%D parent. \ifdefined\defineoverlay \else \message{loaded to early} \wait \fi @@ -46,13 +44,12 @@ \fi \processcommalist[#1]\pack_framed_define_overlay_indeed} -%D We use the command handler code. The previous, more direct parameter -%D handling was 25\% faster when no parameters were passed when adding -%D content to a layer. However, when we pass for instance a preset, the -%D new methos is some 10\% faster and it happens that in most cases we -%D do pass some parameters. It would be interesting to see if we can push -%D the preset in between the regular chain but it could also lead to -%D unwanted side effects when nesting layer placement. +%D We use the command handler code. The previous, more direct parameter handling was +%D 25\% faster when no parameters were passed when adding content to a layer. +%D However, when we pass for instance a preset, the new methos is some 10\% faster +%D and it happens that in most cases we do pass some parameters. It would be +%D interesting to see if we can push the preset in between the regular chain but it +%D could also lead to unwanted side effects when nesting layer placement. \installcorenamespace{layer} \installcorenamespace{layerbox} @@ -62,13 +59,11 @@ %D \macros %D {definelayer,setuplayer} %D -%D Each layer gets its own (global) box. This also means that -%D the data that goes into a layer, is typeset immediately. -%D Each layer automatically gets an associated overlay, -%D which can be used in any background assignment. +%D Each layer gets its own (global) box. This also means that the data that goes +%D into a layer, is typeset immediately. Each layer automatically gets an associated +%D overlay, which can be used in any background assignment. %D -%D After a layer is defined, you can change its -%D characteristics. +%D After a layer is defined, you can change its characteristics. \installcommandhandler \??layer {layer} \??layer @@ -175,8 +170,7 @@ %D \macros %D {resetlayer} %D -%D This macro hardly needs an explanation (but is seldom -%D needed anyway). +%D This macro hardly needs an explanation (but is seldom needed anyway). \def\pack_layers_reset_box#1% {\ifcsname\??layerbox#1\endcsname @@ -193,10 +187,9 @@ %D \macros %D {setlayer} %D -%D Data is moved into a layer with the following macro. When -%D \type {position} is set, relative positioning is used, with -%D the current point as reference point. Otherwise the topleft -%D corner is used as reference point. +%D Data is moved into a layer with the following macro. When \type {position} is +%D set, relative positioning is used, with the current point as reference point. +%D Otherwise the topleft corner is used as reference point. %D %D \starttyping %D \setlayer [identifier] [optional parameters] {data} @@ -474,11 +467,10 @@ {\ifdim\d_pack_layers_x_size>\zeropoint \advance\d_pack_layers_x_position.5\d_pack_layers_x_size \fi \ifdim\d_pack_layers_y_size>\zeropoint \advance\d_pack_layers_y_position.5\d_pack_layers_y_size \fi} -%D Given the task to be accomplished, the previous macro is -%D not even that complicated. It mainly comes down to skipping -%D to the right place and placing a box on top of or below the -%D existing content. In the case of position tracking, another -%D reference point is chosen. +%D Given the task to be accomplished, the previous macro is not even that +%D complicated. It mainly comes down to skipping to the right place and placing a +%D box on top of or below the existing content. In the case of position tracking, +%D another reference point is chosen. %D \macros %D {doifelselayerdata} @@ -500,10 +492,9 @@ %D \macros %D {flushlayer} %D -%D When we flush a layer, we flush both the main one and the -%D page dependent one (when defined). This feature is more -%D efficient in \ETEX\ since there testing for an undefined -%D macro does not takes hash space. +%D When we flush a layer, we flush both the main one and the page dependent one +%D (when defined). This feature is more efficient in \ETEX\ since there testing for +%D an undefined macro does not takes hash space. % todo: setups before flush, handy hook @@ -709,9 +700,8 @@ %D \macros %D {composedlayer,placelayer,tightlayer} %D -%D This is a handy shortcut, which saves a couple of braces -%D when we use it as parameter. This name also suits better -%D to other layering commands. +%D This is a handy shortcut, which saves a couple of braces when we use it as +%D parameter. This name also suits better to other layering commands. \unexpanded\def\composedlayer#1{\flushlayer[#1]} @@ -736,8 +726,7 @@ %D \macros %D {setMPlayer} %D -%D The following layer macro uses the positions that are -%D registered by \METAPOST. +%D The following layer macro uses the positions that are registered by \METAPOST. %D %D \starttyping %D \definelayer[test] diff --git a/tex/context/base/mkiv/pack-obj.mkiv b/tex/context/base/mkiv/pack-obj.mkiv index d08c66494..4b3b6c2f0 100644 --- a/tex/context/base/mkiv/pack-obj.mkiv +++ b/tex/context/base/mkiv/pack-obj.mkiv @@ -20,24 +20,22 @@ %D \macros %D {setobject,getobject,ifinobject} %D -%D Boxes can be considered reuable objects. Traditionally once passed -%D to the \DVI\ file, such objects cannot be reused. In \PDF\ however, -%D reusing is possible and sometimes even a necessity. Therefore, -%D \CONTEXT\ supports reusable objects and \LUATEX\ has native support -%D for so called box resources. +%D Boxes can be considered reuable objects. Traditionally once passed to the \DVI\ +%D file, such objects cannot be reused. In \PDF\ however, reusing is possible and +%D sometimes even a necessity. Therefore, \CONTEXT\ supports reusable objects and +%D \LUATEX\ has native support for so called box resources. %D -%D The first application of objects in \CONTEXT\ concerned \METAPOST\ -%D graphics and fill||in form fields. Reusing resources can save lots -%D of bytes and sometimes also runtime. +%D The first application of objects in \CONTEXT\ concerned \METAPOST\ graphics and +%D fill||in form fields. Reusing resources can save lots of bytes and sometimes also +%D runtime. %D %D \starttyping %D \setobject{class}{name}\somebox{} %D \getobject{class}{name} %D \stoptyping %D -%D Here \type {\somebox} can be whatever box specification suits \TEX. -%D Although the implementation in \MKIV\ is somewhat different the -%D principles have not changed. +%D Here \type {\somebox} can be whatever box specification suits \TEX. Although the +%D implementation in \MKIV\ is somewhat different the principles have not changed. \installcorenamespace {objects} diff --git a/tex/context/base/mkiv/pack-ori.lua b/tex/context/base/mkiv/pack-ori.lua new file mode 100644 index 000000000..a786b19ef --- /dev/null +++ b/tex/context/base/mkiv/pack-ori.lua @@ -0,0 +1,70 @@ +if not modules then modules = { } end modules ['pack-ori'] = { + version = 1.001, + comment = "companion to supp-box.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local context = context +local implement = interfaces.implement +local variables = interfaces.variables + +local settings_to_array = utilities.parsers.settings_to_array + +local orientation = { + [variables.up] = 0x000, + [variables.left] = 0x001, + [variables.down] = 0x002, + [variables.right] = 0x003, + [variables.top] = 0x004, + [variables.bottom] = 0x005, +} +local vertical = { + [variables.line] = 0x000, + [variables.top] = 0x010, + [variables.bottom] = 0x020, + [variables.middle] = 0x030, +} +local horizontal = { + [variables.middle] = 0x000, + [variables.flushleft] = 0x100, + [variables.flushright] = 0x200, + [variables.left] = 0x300, + [variables.right] = 0x400, +} + +implement { + name = "toorientation", + public = true, + arguments = { + { + { "horizontal", "string" }, + { "vertical", "string" }, + { "orientation", "string" }, + } + }, + actions = function(t) + local n = 0 + local m = t.horizontal if m then n = n | (horizontal [m] or 0) end + local m = t.vertical if m then n = n | (vertical [m] or 0) end + local m = t.orientation if m then n = n | (orientation[m] or 0) end + -- logs.report("orientation","0x%03X : %s",n,table.sequenced(t)) + context(n) + end, +} + +implement { + name = "stringtoorientation", + public = true, + arguments = "string", + actions = function(s) + local n = 0 + local t = settings_to_array(s) + local m = t[1] if m then n = n | (horizontal [m] or 0) end + local m = t[2] if m then n = n | (vertical [m] or 0) end + local m = t[3] if m then n = n | (orientation[m] or 0) end + -- logs.report("orientation","0x%03X : %s",n,s) + context(n) + end, +} diff --git a/tex/context/base/mkiv/pack-ori.mkxl b/tex/context/base/mkiv/pack-ori.mkxl new file mode 100644 index 000000000..061768f94 --- /dev/null +++ b/tex/context/base/mkiv/pack-ori.mkxl @@ -0,0 +1,88 @@ +%D \module +%D [ file=pack-ori, % was experimental +%D version=2019.07.30, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Anchoring, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Packaging Macros / Anchoring} + +\registerctxluafile{pack-ori}{} + +\unprotect + +%D Possible options are: +%D +%D \starttabulate[|T|T|] +%D \NC orientation \NC up left down right top bottom +%D \NC vertical \NC line top bottom middle +%D \NC horizontal \NC middle flushleft flushright left right +%D \stoptabulate + +\installcorenamespace{orientation} +\installcorenamespace{orientations} + +\installcommandhandler \??orientation {orientation} \??orientation + +\setuporientation + [\c!orientation=\v!normal, + \c!horizontal=\v!normal, + \c!vertical=\v!normal] + +\appendtoks + \expandafter\chardef\csname\??orientations\currentorientation\endcsname\toorientation + orientation {\orientationparameter\c!orientation} + horizontal {\orientationparameter\c!horizontal} + vertical {\orientationparameter\c!vertical} + \relax\relax +\to \everydefineorientation + +\defineorientation[\v!normal] + +\defineorientation[\v!up] [\c!orientation=\v!up] +\defineorientation[\v!down] [\c!orientation=\v!down] +\defineorientation[\v!left] [\c!orientation=\v!left] +\defineorientation[\v!right] [\c!orientation=\v!right] +\defineorientation[\v!top] [\c!orientation=\v!top] +\defineorientation[\v!bottom][\c!orientation=\v!bottom] + +%D There will be some more helpers here. + +\def\theorientation#1% + {\numexpr + \ifcsname\??orientations#1\endcsname + \lastnamedcs + \else + \zerocount + \fi + \relax} + +\def\autoorientation#1% + {\numexpr + \ifcsname\??orientations#1\endcsname + \lastnamedcs + \else + \auto_orientation{#1}% + \fi + \relax} + +\def\auto_orientation#1% + {\immediateassignment\global\expandafter\chardef\csname\??orientations#1\endcsname\stringtoorientation{#1}% + \csname\??orientations#1\endcsname} + +\unexpanded\def\doifelseorientation#1% + {\ifcsname\??orientations#1\endcsname + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +% \def\iforientationcsname#1{\ifcsname\??orientations} + +\protect \endinput diff --git a/tex/context/base/mkiv/pack-rul.mkxl b/tex/context/base/mkiv/pack-rul.mkxl index e21f5f1c2..0da5bff61 100644 --- a/tex/context/base/mkiv/pack-rul.mkxl +++ b/tex/context/base/mkiv/pack-rul.mkxl @@ -1589,10 +1589,38 @@ \egroup} %D Anchoring is experimental and was prototyped around the ctx meeting in 2018 but -%D never mede it into the core yet. It operates indepedent of the orientation -%D mechanism already present. +%D never mede it into the core yet. It operates independent of the orientation +%D mechanism already present. It's a rather efficient feature. Best is to use +%D predefined orientations, like: +%D +%D \starttyping +%D \defineorientation[leftflushleft] [orientation=left,horizontal=flushleft] +%D +%D \framed [anchoring={leftflushleft}] {anchoring} +%D \stoptyping +%D +%D But this also works: +%D +%D \starttyping +%D \framed [anchoring={flushleft,top,up}] {anchoring} +%D \stoptyping +%D +%D When an anchoring is given (use \type {normal} for the default) you can also +%D use the \type {xanchor} and \type {yanchor} offsets. -\let\pack_framed_handle_anchoring\relax +% because we mess with the width later on, we need double wrapping: + +\def\pack_framed_handle_anchoring + {\scratchcounter\autoorientation\p_framed_anchoring\relax + \edef\p_xanchor{\framedparameter\c!xanchor}% + \edef\p_yanchor{\framedparameter\c!yanchor}% + \setbox\b_framed_normal\hpack{\hpack % here + % using the keyword approachs works ok, don't mess with orientation + % directly here using \boxorientation ... it doesn't work that well + \s!orientation\scratchcounter + \ifx\p_xanchor\empty\else \s!xoffset \p_xanchor\fi + \ifx\p_yanchor\empty\else \s!yoffset \p_yanchor\fi + {\box\b_framed_normal}}} \installcorenamespace{framedlocatorbefore} \installcorenamespace{framedlocatorafter} @@ -1771,7 +1799,7 @@ \setbox\b_framed_normal\hpack{\lower\d_framed_locator_dp\box\b_framed_normal}% \ht\b_framed_normal\d_framed_locator_ht \dp\b_framed_normal\d_framed_locator_dp - \hpack{\box\b_framed_normal}} % why do we pack .. dange of loosing? + \hpack{\box\b_framed_normal}} % why do we pack .. danger of loosing? % also used in fastlocalframed diff --git a/tex/context/base/mkiv/page-one.mkiv b/tex/context/base/mkiv/page-one.mkiv index 356fb4987..9572b3769 100644 --- a/tex/context/base/mkiv/page-one.mkiv +++ b/tex/context/base/mkiv/page-one.mkiv @@ -76,7 +76,7 @@ \global\advance\vsize\d_page_adapts_delta % alternatively we could set it in builders.buildpage_filter % \ifdim\pagegoal<\maxdimen .. \fi - \global\pagegoal\dimexpr\vsize-\d_page_floats_inserted_top-\d_page_floats_inserted_bottom\relax} + \pagegoal\dimexpr\vsize-\d_page_floats_inserted_top-\d_page_floats_inserted_bottom\relax} % 1 = partial page, 2 = whole page, 3 = partial page diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex c0b856eb0..096af2970 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 5d07a4305..05edff1b1 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-pag.lua b/tex/context/base/mkiv/strc-pag.lua index a9933a21f..216b5f705 100644 --- a/tex/context/base/mkiv/strc-pag.lua +++ b/tex/context/base/mkiv/strc-pag.lua @@ -316,6 +316,11 @@ function pages.in_body(n) return texgetcount("pagebodymode") > 0 end +function pages.fraction(n) + local lastpage = texgetcount("lastpageno") -- can be cached + return lastpage > 1 and (texgetcount("realpageno")-1)/(lastpage-1) or 1 +end + -- move to strc-pag.lua function counters.analyze(name,counterspecification) diff --git a/tex/context/base/mkiv/supp-box.lua b/tex/context/base/mkiv/supp-box.lua index 1f31f7681..f2da9155b 100644 --- a/tex/context/base/mkiv/supp-box.lua +++ b/tex/context/base/mkiv/supp-box.lua @@ -12,13 +12,13 @@ local report_hyphenation = logs.reporter("languages","hyphenation") local tonumber, next, type = tonumber, next, type -local lpegmatch = lpeg.match +local lpegmatch = lpeg.match -local tex = tex -local context = context -local nodes = nodes +local tex = tex +local context = context +local nodes = nodes -local implement = interfaces.implement +local implement = interfaces.implement local nodecodes = nodes.nodecodes @@ -625,8 +625,26 @@ implement { end } -interfaces.implement { +implement { name = "shiftbox", arguments = { "integer", "dimension" }, actions = function(n,d) setshift(getbox(n),d) end, } + +implement { + name = "scangivendimensions", + public = true, + protected = true, + arguments = { + { + { "width", "dimension" }, + { "height", "dimension" }, + { "depth", "dimension" }, + }, + }, + actions = function(t) + texsetdimen("givenwidth", t.width or 0) + texsetdimen("givenheight",t.height or 0) + texsetdimen("givendepth", t.depth or 0) + end, +} diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv index 2fce3311a..4a8ff33f8 100644 --- a/tex/context/base/mkiv/supp-box.mkiv +++ b/tex/context/base/mkiv/supp-box.mkiv @@ -23,6 +23,12 @@ \fixupboxesmode\plusone +%D And some dimensions: + +\newdimen\givenwidth +\newdimen\givenheight +\newdimen\givendepth + % handy to have % % \hbox to \hsize @@ -539,12 +545,9 @@ {\beginofshapebox \unvbox\nextbox \endofshapebox - % \global\count1\zerocount - % \reshapebox{\global\advance\count1\plusone}% - % \egroup\noflines\count1 }% - \scratchcounter\zerocount - \reshapebox{\global\advance\scratchcounter\plusone}% - \expandafter\egroup\expandafter\noflines\the\scratchcounter\relax} + \globalscratchcounter\zerocount + \reshapebox{\global\advance\globalscratchcounter\plusone}% + \expandafter\egroup\expandafter\noflines\the\globalscratchcounter\relax} \unexpanded\def\determinenoflines {\bgroup @@ -851,6 +854,7 @@ \newif \ifsomeshapeleft \newif \ifreshapingbox +\newif \ifreshapingfailed % may save redundant runs \newbox \shapebox \newcount \shapepenalty @@ -859,6 +863,7 @@ \newbox \newshapebox \newbox \oldshapebox +\newbox \tmpshapebox \newcount \shapecounter @@ -873,10 +878,6 @@ {\kern \shapekern }% {\vskip \shapeskip }} -\newbox\tmpshapebox - -\newif\ifreshapingfailed % may save redundant runs - \def\doreshapebox#1#2#3#4% \shapebox, \shapepenalty, \shapekern, \shapeskip {\global\reshapingfailedfalse \ifzeropt\ht\oldshapebox % \ifdim\ht\oldshapebox=\zeropoint @@ -1025,10 +1026,10 @@ \unexpanded\def\shapedhbox % lines with non strutted dimensions have {\expanded{\dowithnextbox % interlineskip so if we want the original - {\dp\nextbox\the\ht\shapebox % spacing, we need to preserve the original + {\ht\nextbox\the\ht\shapebox % spacing, we need to preserve the original \dp\nextbox\the\dp\shapebox % height and depth which is definitely \box\nextbox}} % needed if we apply struts to the 'new' - \hbox} % box or do something that changed ist size + \hbox} % box or do something that changed ist size %D \macros %D {hyphenatedword, @@ -1100,7 +1101,7 @@ \unexpanded\def\processtokens#1#2#3#4#5% {\begingroup - \def\lastcharacter{\lastcharacter}% + \def\lastcharacter{\lastcharacter}% hm, recursive ? \def\space{ }% \let\\=\space \def\before {#1}% @@ -1471,13 +1472,13 @@ \unexpanded\def\syst_boxes_sbox_finish {\setbox\nextbox\hpack - {\strut - \dp\nextbox\zeropoint + {\strut % not needed + \dp\nextbox\zeropoint % not needed \lower\strutdp\box\nextbox}% - \dp\nextbox\strutdp - \ht\nextbox\strutht - \box\nextbox - \egroup} + \dp\nextbox\strutdp + \ht\nextbox\strutht + \box\nextbox + \egroup} %D A variant on this: diff --git a/tex/context/base/mkiv/supp-box.mkxl b/tex/context/base/mkiv/supp-box.mkxl index 920624329..a77327b3e 100644 --- a/tex/context/base/mkiv/supp-box.mkxl +++ b/tex/context/base/mkiv/supp-box.mkxl @@ -23,6 +23,12 @@ \fixupboxesmode\plusone +%D And some dimensions: + +\newdimen\givenwidth +\newdimen\givenheight +\newdimen\givendepth + % handy to have % % \hbox to \hsize @@ -224,16 +230,20 @@ %D catcode safer. It is needed by the math module (although the \type {\leavevmode} %D is not added here). +% \unexpanded\def\smash +% {\begingroup +% \futurelet\nexttoken\syst_boxes_smash} +% +% \def\syst_boxes_smash +% {\ifx\nexttoken[% +% \expandafter\syst_boxes_smash_yes +% \else +% \expandafter\syst_boxes_smash_nop +% \fi} + \unexpanded\def\smash {\begingroup - \futurelet\nexttoken\syst_boxes_smash} - -\def\syst_boxes_smash - {\ifx\nexttoken[% - \expandafter\syst_boxes_smash_yes - \else - \expandafter\syst_boxes_smash_nop - \fi} + \futureexpandis[\syst_boxes_smash_yes\syst_boxes_smash_nop} \def\syst_boxes_smash_nop {\edef\m_boxes_smash_options{hd}% @@ -285,6 +295,9 @@ \def\syst_boxes_lower_nextbox_dp {\setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}} +% \def\syst_boxes_lower_nextbox_dp +% {\boxymove\nextbox-\dp\nextbox} + %D \starttabulate[|l|l|] %D \NC w \NC \ruledhbox{\smash [w]{This is some great smashing, isn't it?}} \NC \NR %D \NC h \NC \ruledhbox{\smash [h]{This is some great smashing, isn't it?}} \NC \NR @@ -403,8 +416,12 @@ %D The next alternative is slightly more clever, since it accepts \type {{12}} as %D well as \type {12} as box number. +% \unexpanded\def\getboxheight#1\of#2\box#3% +% {\def\next{#1\dimexpr\ht\c_boxes_register+\dp\c_boxes_register\relax}% +% \afterassignment\next\c_boxes_register=#3} + \unexpanded\def\getboxheight#1\of#2\box#3% - {\def\next{#1\dimexpr\ht\c_boxes_register+\dp\c_boxes_register\relax}% + {\def\next{#1\htdp\c_boxes_register}% \afterassignment\next\c_boxes_register=#3} %D For a long time the following three macros were part of the grid snapping core @@ -539,12 +556,9 @@ {\beginofshapebox \unvbox\nextbox \endofshapebox - % \global\count1\zerocount - % \reshapebox{\global\advance\count1\plusone}% - % \egroup\noflines\count1 }% - \scratchcounter\zerocount - \reshapebox{\global\advance\scratchcounter\plusone}% - \expandafter\egroup\expandafter\noflines\the\scratchcounter\relax} + \globalscratchcounter\zerocount + \reshapebox{\global\advance\globalscratchcounter\plusone}% + \expandafter\egroup\expandafter\noflines\the\globalscratchcounter\relax} \unexpanded\def\determinenoflines {\bgroup @@ -575,8 +589,6 @@ \endgroup\expandafter\firstoftwoarguments \fi} -\let\doiftextelse\doifelsetext - \unexpanded\def\doiftext#1% {\begingroup \setbox\scratchbox\hpack @@ -588,6 +600,12 @@ \endgroup\expandafter\firstofoneargument \fi} +% more efficient but maybe fragile: +% +% \nospacing#1}% + +\let\doiftextelse\doifelsetext + %D \macros %D {dowithnextbox,nextbox} %D @@ -851,6 +869,7 @@ \newif \ifsomeshapeleft \newif \ifreshapingbox +\newif \ifreshapingfailed % may save redundant runs \newbox \shapebox \newcount \shapepenalty @@ -859,6 +878,7 @@ \newbox \newshapebox \newbox \oldshapebox +\newbox \tmpshapebox \newcount \shapecounter @@ -873,10 +893,6 @@ {\kern \shapekern }% {\vskip \shapeskip }} -\newbox\tmpshapebox - -\newif\ifreshapingfailed % may save redundant runs - \def\doreshapebox#1#2#3#4% \shapebox, \shapepenalty, \shapekern, \shapeskip {\global\reshapingfailedfalse \ifzeropt\ht\oldshapebox % \ifdim\ht\oldshapebox=\zeropoint @@ -1025,7 +1041,7 @@ \unexpanded\def\shapedhbox % lines with non strutted dimensions have {\expanded{\dowithnextbox % interlineskip so if we want the original - {\dp\nextbox\the\ht\shapebox % spacing, we need to preserve the original + {\ht\nextbox\the\ht\shapebox % spacing, we need to preserve the original \dp\nextbox\the\dp\shapebox % height and depth which is definitely \box\nextbox}} % needed if we apply struts to the 'new' \hbox} % box or do something that changed ist size @@ -1100,7 +1116,7 @@ \unexpanded\def\processtokens#1#2#3#4#5% {\begingroup - \def\lastcharacter{\lastcharacter}% + \def\lastcharacter{\lastcharacter}% hm, recursive ? \def\space{ }% \let\\=\space \def\before {#1}% @@ -1114,17 +1130,18 @@ \def\doprocesstokens% the space after = is essential {\afterassignment\dodoprocesstokens\let\nextprocessedtoken= } +\def\redoprocessedtoken + {\dowithnextbox + {\before{\copy\nextbox}% \before can use nextbox several times + \let\before\between + \doprocesstokens} + \hbox\bgroup} + \def\dodoprocesstokens {\ifx\nextprocessedtoken\lastcharacter \after - \let\nextprocessedtoken\relax \orelse\ifx\nextprocessedtoken\bgroup - \def\nextprocessedtoken - {\dowithnextbox - {\before{\copy\nextbox}% \before can use nextbox several times - \let\before\between - \doprocesstokens} - \hbox\bgroup}% + \expandafter\redoprocessedtoken \else \expandafter\if\space\nextprocessedtoken \after\white @@ -1133,9 +1150,8 @@ \before\nextprocessedtoken \let\before\between \fi - \let\nextprocessedtoken\doprocesstokens - \fi - \nextprocessedtoken} + \expandafter\doprocesstokens + \fi} %D \macros %D {doboundtext} @@ -1466,33 +1482,51 @@ %D complicated menus, headers and footers and|/|or margin material. \unexpanded\def\sbox - {\vbox\bgroup + {\vpack\bgroup \dowithnextboxcs\syst_boxes_sbox_finish\vbox} +% \unexpanded\def\syst_boxes_sbox_finish +% {\setbox\nextbox\hpack +% {\strut +% \dp\nextbox\zeropoint +% \lower\strutdp\box\nextbox}% +% \dp\nextbox\strutdp +% \ht\nextbox\strutht +% \box\nextbox +% \egroup} + \unexpanded\def\syst_boxes_sbox_finish - {\setbox\nextbox\hpack - {\strut - \dp\nextbox\zeropoint - \lower\strutdp\box\nextbox}% - \dp\nextbox\strutdp - \ht\nextbox\strutht - \box\nextbox - \egroup} + {\boxyoffset\nextbox-\strutdp + \dp\nextbox\strutdp + \ht\nextbox\strutht + \box\nextbox + \egroup} %D A variant on this: +% \unexpanded\def\inlinedbox +% {\bgroup +% \dowithnextbox +% {\setbox\nextbox\hpack +% {\lower +% \dimexpr(\htdp\nextbox-\lineheight)/\plustwo+\strutdp\relax +% \box\nextbox}% +% \ht\nextbox\strutht +% \dp\nextbox\strutdp +% \box\nextbox +% \egroup}% +% \hbox} + \unexpanded\def\inlinedbox {\bgroup - \dowithnextbox - {\setbox\nextbox\hpack - {\lower - \dimexpr(\htdp\nextbox-\lineheight)/\plustwo+\strutdp\relax - \box\nextbox}% - \ht\nextbox\strutht - \dp\nextbox\strutdp - \box\nextbox - \egroup}% - \hbox} + \dowithnextboxcs\syst_boxes_inlined_finish\hbox} + +\unexpanded\def\syst_boxes_inlined_finish + {\boxyoffset\nextbox-\dimexpr(\htdp\nextbox-\lineheight)/\plustwo+\strutdp\relax + \ht\nextbox\strutht + \dp\nextbox\strutdp + \box\nextbox + \egroup} %D \macros %D {struttedbox} @@ -1567,37 +1601,65 @@ %D The dimensions of the surrounding box are kept intact. This commands handles %D positive and negative dimensions (which is why we need two boxes with rules). +% \unexpanded\def\centeredbox#1#% height +/-dimen width +/-dimen +% {\bgroup +% \setbox\scratchboxone\vpack to \vsize +% \bgroup +% \dontcomplain +% \forgetall +% \setbox\scratchboxone\hpack{\vrule\s!width \zeropoint#1}% +% \setbox\scratchboxtwo\vpack{\hrule\s!height\zeropoint#1}% +% \advance\vsize \ht\scratchboxtwo +% \advance\hsize \wd\scratchboxone +% \vpack to \vsize +% \bgroup +% \vskip-\ht\scratchboxtwo +% \vss +% \hpack to \hsize +% \bgroup +% \dowithnextbox +% {\hskip-\wd\scratchboxone +% \hss +% \box\nextbox +% \hss +% \egroup +% \vss +% \egroup +% \egroup +% \wd\scratchboxone\hsize +% \ht\scratchboxone\vsize +% \box\scratchboxone +% \egroup} +% \hbox} + \unexpanded\def\centeredbox#1#% height +/-dimen width +/-dimen {\bgroup - \setbox\scratchboxone\vpack to \vsize - \bgroup - \dontcomplain - \forgetall - \setbox\scratchboxone\hpack{\vrule\s!width \zeropoint#1}% - \setbox\scratchboxtwo\vpack{\hrule\s!height\zeropoint#1}% - \advance\vsize \ht\scratchboxtwo - \advance\hsize \wd\scratchboxone - \vpack to \vsize - \bgroup - \vskip-\ht\scratchboxtwo - \vss - \hpack to \hsize - \bgroup - \dowithnextbox - {\hskip-\wd\scratchboxone - \hss - \box\nextbox - \hss - \egroup - \vss - \egroup - \egroup - \wd\scratchboxone\hsize - \ht\scratchboxone\vsize - \box\scratchboxone - \egroup} + \dontcomplain + \forgetall + \scangivendimensions#1\relax + \advance\vsize\givenheight + \advance\hsize\givenwidth + \dowithnextboxcs\syst_boxes_centered_finish \hbox} +\def\syst_boxes_centered_finish + {\boxxoffset\nextbox.5\dimexpr + \hsize + -\wd\nextbox + -\givenwidth + \relax + \boxyoffset\nextbox.5\dimexpr + \vsize + -\ht\nextbox + +\dp\nextbox + -\givenheight + \relax + \wd\nextbox\dimexpr\hsize-\givenwidth \relax + \ht\nextbox\dimexpr\vsize-\givenheight\relax + \dp\nextbox\zeropoint + \box\nextbox + \egroup} + %D For those who don't want to deal with \type {\hsize} and \type {\vsize}, we have: %D %D \starttyping @@ -1605,7 +1667,7 @@ %D {\framed[width=100bp,height=100bp]{}} %D \stoptyping %D -%D Do you see what we call this one \type {next}? +%D Do you see why we call this one \type {next}? \unexpanded\def\centerednextbox#1#% {\bgroup @@ -2112,23 +2174,41 @@ \unexpanded\def\tbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_tbox_finish\hbox} \unexpanded\def\bbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_bbox_finish\hbox} +% \def\syst_boxes_tbox_finish +% {\scratchdepth\dimexpr\ht\nextbox+\dp\nextbox-\ht\strutbox\relax +% \ht\nextbox\ht\strutbox +% \dp\nextbox\scratchdepth +% \setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}% +% \ht\nextbox\ht\strutbox +% \dp\nextbox\scratchdepth +% \box\nextbox +% \egroup} + +% \def\syst_boxes_bbox_finish +% {\scratchheight\dimexpr\ht\nextbox+\dp\nextbox-\dp\strutbox\relax +% \dp\nextbox\dp\strutbox +% \ht\nextbox\scratchheight +% \setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}% +% \dp\nextbox\dp\strutbox +% \ht\nextbox\scratchheight +% \box\nextbox +% \egroup} + \def\syst_boxes_tbox_finish - {\scratchdepth\dimexpr\ht\nextbox+\dp\nextbox-\ht\strutbox\relax - \ht\nextbox\ht\strutbox - \dp\nextbox\scratchdepth - \setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}% - \ht\nextbox\ht\strutbox + {\scratchheight\ht\strutbox + \scratchdepth\dimexpr\htdp\nextbox-\scratchheight\relax + \ht\nextbox\scratchheight \dp\nextbox\scratchdepth + \boxyoffset\nextbox-\scratchdepth \box\nextbox \egroup} \def\syst_boxes_bbox_finish - {\scratchheight\dimexpr\ht\nextbox+\dp\nextbox-\dp\strutbox\relax - \dp\nextbox\dp\strutbox - \ht\nextbox\scratchheight - \setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}% - \dp\nextbox\dp\strutbox + {\scratchdepth\dp\strutbox + \scratchheight\dimexpr\htdp\nextbox-\scratchdepth\relax + \dp\nextbox\scratchdepth \ht\nextbox\scratchheight + \boxyoffset\nextbox-\scratchdepth \box\nextbox \egroup} @@ -2264,63 +2344,135 @@ \let\bottomleftbox \leftbottombox \let\bottomrightbox\rightbottombox +% \def\syst_boxes_rightbox_finish +% {\global\boxhdisplacement\boxoffset +% \global\boxvdisplacement.5\ht\nextbox +% \global\advance\boxvdisplacement-.5\dp\nextbox +% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_rightbox_finish {\global\boxhdisplacement\boxoffset - \global\boxvdisplacement.5\ht\nextbox - \global\advance\boxvdisplacement-.5\dp\nextbox - \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox + \global\boxvdisplacement.5\dimexpr\ht\nextbox-\dp\nextbox\relax + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_leftbox_finish +% {\global\boxhdisplacement-\wd\nextbox +% \global\advance\boxhdisplacement-\boxoffset +% \global\boxvdisplacement.5\ht\nextbox +% \global\advance\boxvdisplacement-.5\dp\nextbox +% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_leftbox_finish - {\global\boxhdisplacement-\wd\nextbox - \global\advance\boxhdisplacement-\boxoffset - \global\boxvdisplacement.5\ht\nextbox - \global\advance\boxvdisplacement-.5\dp\nextbox - \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox + {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax + \global\boxvdisplacement.5\dimexpr\ht\nextbox-\dp\nextbox\relax + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_topbox_finish +% {\global\boxhdisplacement-.5\wd\nextbox +% \global\boxvdisplacement-\dp\nextbox +% \global\advance\boxvdisplacement-\boxoffset +% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_topbox_finish {\global\boxhdisplacement-.5\wd\nextbox - \global\boxvdisplacement-\dp\nextbox - \global\advance\boxvdisplacement-\boxoffset - \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox + \global\boxvdisplacement\dimexpr-\dp\nextbox-\boxoffset\relax + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_bottombox_finish +% {\global\boxhdisplacement-.5\wd\nextbox +% \global\boxvdisplacement\ht\nextbox +% \global\advance\boxvdisplacement\boxoffset +% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_bottombox_finish {\global\boxhdisplacement-.5\wd\nextbox - \global\boxvdisplacement\ht\nextbox - \global\advance\boxvdisplacement\boxoffset - \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox + \global\boxvdisplacement\dimexpr\ht\nextbox+\boxoffset\relax + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_lefttopbox_finish +% {\global\boxhdisplacement-\wd\nextbox +% \global\advance\boxhdisplacement-\boxoffset +% \global\boxvdisplacement-\dp\nextbox +% \global\advance\boxvdisplacement-\boxoffset +% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_lefttopbox_finish - {\global\boxhdisplacement-\wd\nextbox - \global\advance\boxhdisplacement-\boxoffset - \global\boxvdisplacement-\dp\nextbox - \global\advance\boxvdisplacement-\boxoffset - \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox + {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax + \global\boxvdisplacement\dimexpr-\dp\nextbox-\boxoffset\relax + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_righttopbox_finish +% {\global\boxhdisplacement\boxoffset +% \global\boxvdisplacement-\dp\nextbox +% \global\advance\boxvdisplacement-\boxoffset +% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_righttopbox_finish {\global\boxhdisplacement\boxoffset - \global\boxvdisplacement-\dp\nextbox - \global\advance\boxvdisplacement-\boxoffset - \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox + \global\boxvdisplacement\dimexpr-\dp\nextbox-\boxoffset\relax + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_leftbottombox_finish +% {\global\boxhdisplacement-\wd\nextbox +% \global\advance\boxhdisplacement-\boxoffset +% \global\boxvdisplacement\ht\nextbox +% \global\advance\boxvdisplacement\boxoffset +% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_leftbottombox_finish - {\global\boxhdisplacement-\wd\nextbox - \global\advance\boxhdisplacement-\boxoffset - \global\boxvdisplacement\ht\nextbox - \global\advance\boxvdisplacement\boxoffset - \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox + {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax + \global\boxvdisplacement\dimexpr\ht\nextbox+\boxoffset\relax + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_rightbottombox_finish +% {\global\boxhdisplacement\boxoffset +% \global\boxvdisplacement\ht\nextbox +% \global\advance\boxvdisplacement\boxoffset +% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_rightbottombox_finish {\global\boxhdisplacement\boxoffset - \global\boxvdisplacement\ht\nextbox - \global\advance\boxvdisplacement\boxoffset - \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox + \global\boxvdisplacement\dimexpr\ht\nextbox+\boxoffset\relax + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} \unexpanded\def\middlebox {\hpack\bgroup\dowithnextboxcs\syst_boxes_middlebox_finish \placedbox} @@ -2328,31 +2480,67 @@ \unexpanded\def\baselineleftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselineleftbox_finish \placedbox} \unexpanded\def\baselinerightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinerightbox_finish \placedbox} +% \def\syst_boxes_middlebox_finish +% {\global\boxhdisplacement-.5\wd\nextbox +% \global\boxvdisplacement.5\ht\nextbox +% \global\advance\boxvdisplacement-.5\dp\nextbox +% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_middlebox_finish {\global\boxhdisplacement-.5\wd\nextbox - \global\boxvdisplacement.5\ht\nextbox - \global\advance\boxvdisplacement-.5\dp\nextbox - \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox + \global\boxvdisplacement.5\dimexpr\ht\nextbox-\dp\nextbox\relax + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_baselinemiddlebox_finish +% {\global\boxhdisplacement-.5\wd\nextbox +% \global\advance\boxhdisplacement-\boxoffset +% \global\boxvdisplacement-\boxoffset +% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_baselinemiddlebox_finish - {\global\boxhdisplacement-.5\wd\nextbox - \global\advance\boxhdisplacement-\boxoffset + {\global\boxhdisplacement\dimexpr-.5\wd\nextbox-\boxoffset\relax \global\boxvdisplacement-\boxoffset - \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_baselineleftbox_finish +% {\global\boxhdisplacement-\wd\nextbox +% \global\advance\boxhdisplacement-\boxoffset +% \global\boxvdisplacement-\boxoffset +% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_baselineleftbox_finish - {\global\boxhdisplacement-\wd\nextbox - \global\advance\boxhdisplacement-\boxoffset + {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax \global\boxvdisplacement-\boxoffset - \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} +% \def\syst_boxes_baselinerightbox_finish +% {\global\boxhdisplacement\boxoffset +% \global\boxvdisplacement-\boxoffset +% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox +% \egroup} + \def\syst_boxes_baselinerightbox_finish {\global\boxhdisplacement\boxoffset \global\boxvdisplacement-\boxoffset - \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox + \boxcursor + \boxxmove\nextbox \boxhdisplacement + \boxymove\nextbox-\boxvdisplacement + \box\nextbox \egroup} %D \macros @@ -2591,14 +2779,14 @@ \def\syst_boxes_lower_indeed{\dowithnextboxcs\syst_boxes_lower_finish} \def\syst_boxes_raise_finish - {\setbox\nextbox\hpack{\raise\scratchdimen\box\nextbox}% + {\boxyoffset\nextbox\scratchdimen \ht\nextbox\strutht \dp\nextbox\strutdp \box\nextbox \egroup} \def\syst_boxes_lower_finish - {\setbox\nextbox\hpack{\lower\scratchdimen\box\nextbox}% + {\boxyoffset\nextbox-\scratchdimen \ht\nextbox\strutht \dp\nextbox\strutdp \box\nextbox diff --git a/tex/context/base/mkiv/syst-con.mkiv b/tex/context/base/mkiv/syst-con.mkiv index afbdf8605..56155460a 100644 --- a/tex/context/base/mkiv/syst-con.mkiv +++ b/tex/context/base/mkiv/syst-con.mkiv @@ -15,36 +15,10 @@ \unprotect -%D When the number of conversions grew, it did no longer make -%D sense to spread them over multiple files. So, instead of -%D defining these in \type {font-ini}, we now have a dedicated -%D module. - -%D \macros -%D {lchexnumber,uchexnumber,lchexnumbers,uchexnumbers} -%D -%D In addition to the uppercase hex conversion, as needed in -%D math families, we occasionally need a lowercase one, for -%D instance when we want to compose gbsong fontnames. -%D -%D The ugly indirectness is needed to get rid of \TEX\ -%D induced spaces and \type {\relax}'s. +%D \macros{lchexnumber,uchexnumber,lchexnumbers,uchexnumbers} %D -%D \starttyping -%D [\uchexnumber{0}] -%D [\uchexnumber\scratchcounter] -%D [\uchexnumber\zerocount] -%D [\uchexnumber{\number0}] -%D [\uchexnumber{\number\scratchcounter}] -%D [\uchexnumber{\number\zerocount}] -%D [\uchexnumber{\the\scratchcounter}] -%D [\uchexnumber{\the\zerocount}] -%D [\expandafter\uchexnumber\expandafter{\number0}] -%D [\expandafter\uchexnumber\expandafter{\number\scratchcounter}] -%D [\expandafter\uchexnumber\expandafter{\number\zerocount}] -%D [\expandafter\uchexnumber\expandafter{\the\scratchcounter}] -%D [\expandafter\uchexnumber\expandafter{\the\zerocount}] -%D \stoptyping +%D In addition to the uppercase hex conversion, as needed in math families, we +%D occasionally need a lowercase one. \def\lchexnumber #1{\clf_lchexnumber \numexpr#1\relax} \def\uchexnumber #1{\clf_uchexnumber \numexpr#1\relax} @@ -53,33 +27,28 @@ \let\hexnumber\uchexnumber -%D \macros -%D {octnumber} +%D \macros{octnumber} %D -%D For unicode remapping purposes, we need octal numbers. +%D For \UNICODE\ remapping purposes, we need octal numbers. \def\octnumber#1{\clf_octnumber\numexpr#1\relax} -%D \macros -%D {hexstringtonumber,octstringtonumber} +%D \macros{hexstringtonumber,octstringtonumber} %D -%D This macro converts a two character hexadecimal number into -%D a decimal number, thereby taking care of lowercase characters -%D as well. +%D This macro converts a two character hexadecimal number into a decimal number, +%D thereby taking care of lowercase characters as well. \def\hexstringtonumber#1{\clf_hexstringtonumber\numexpr#1\relax} \def\octstringtonumber#1{\clf_octstringtonumber\numexpr#1\relax} -%D \macros -%D {rawcharacter} +%D \macros{rawcharacter} %D -%D This macro can be used to produce proper 8 bit characters -%D that we sometimes need in backends and round||trips. +%D This macro can be used to produce proper 8 bit characters that we sometimes need +%D in backends and round||trips. \def\rawcharacter#1{\clf_rawcharacter\numexpr#1\relax} -%D \macros -%D {twodigits, threedigits} +%D \macros{twodigits, threedigits} %D %D These macros provides two or three digits always: @@ -88,50 +57,42 @@ %D \macros{modulonumber} %D -%D In the conversion macros described in \type {core-con} we -%D need a wrap||around method. The following solution is -%D provided by Taco. +%D In the conversion macros described in \type {core-con} we need a wrap||around +%D method. The following solution is provided by Taco. %D -%D The \type {modulonumber} macro expands to the mathematical -%D modulo of a positive integer. It is crucial for it's -%D application that this macro is fully exandable. +%D The \type {modulonumber} macro expands to the mathematical modulo of a positive +%D integer. It is crucial for it's application that this macro is fully exandable. %D -%D The expression inside the \type {\numexpr} itself is -%D somewhat bizarre because \ETEX\ uses a rounding -%D division instead of truncation. If \ETEX's division -%D would have behaved like \TEX's normal\type{\divide}, then -%D the expression could have been somewhat simpler, like -%D \type {#2-(#2/#1)*#1}. This works just as well, but a bit -%D more complex. +%D The expression inside the \type {\numexpr} itself is somewhat bizarre because +%D \ETEX\ uses a rounding division instead of truncation. If \ETEX's division would +%D have behaved like \TEX's normal\type {\divide}, then the expression could have +%D been somewhat simpler, like \type {#2-(#2/#1)*#1}. This works just as well, but a +%D bit more complex. -\def\modulonumber#1#2% - {\the\numexpr#2-((((#2+(#1/2))/#1)-1)*#1)\relax} +\def\modulonumber#1#2{\the\numexpr#2-((((#2+(#1/2))/#1)-1)*#1)\relax} %D \macros{modulatednumber} %D -%D Modulo numbers run from zero to one less than the limit, -%D but for conversion sets, we need a value between 1 and the -%D limit. The \type{\modulatednumber} arranges that. This -%D macro also needs to be fully expandable, resulting in -%D two \type{\numexpr}s. +%D Modulo numbers run from zero to one less than the limit, but for conversion sets, +%D we need a value between 1 and the limit. The \type {\modulatednumber} arranges +%D that. This macro also needs to be fully expandable, resulting in two \type +%D {\numexpr}s. \def\modulatednumber#1#2% {\ifnum\the\numexpr\modulonumber{#1}{#2}\relax=0 #1% \else \the\numexpr\modulonumber{#1}{#2}\relax \fi} -%D \macros -%D {realnumber} % used? +%D \macros{setcalculatedsin,setcalculatedcos,setcalculatedtan} -\def\realnumber#1{\withoutpt\the\dimexpr#1\s!pt\relax} % brrr +\unexpanded\def\setcalculatedsin#1#2{\edef#1{\clf_sind#2}} +\unexpanded\def\setcalculatedcos#1#2{\edef#1{\clf_cosd#2}} +\unexpanded\def\setcalculatedtan#1#2{\edef#1{\clf_tand#2}} -%D \macros -%D {setcalculatedsin,setcalculatedcos,setcalculatedtan} - -\def\setcalculatedsin#1#2{\edef#1{\clf_sind#2}} -\def\setcalculatedcos#1#2{\edef#1{\clf_cosd#2}} -\def\setcalculatedtan#1#2{\edef#1{\clf_tand#2}} +%D \macros{formatted,format} \def\formatted#1{\ctxcommand{format(#1)}} % not clf \unexpanded\def\format #1{\ctxcommand{format(#1)}} % not clf +%D The \type {\modulatednumber} and \type {\realnumber} macros have been removed. + \protect \endinput diff --git a/tex/context/base/mkiv/syst-con.mkxl b/tex/context/base/mkiv/syst-con.mkxl new file mode 100644 index 000000000..c3293b221 --- /dev/null +++ b/tex/context/base/mkiv/syst-con.mkxl @@ -0,0 +1,93 @@ +%D \module +%D [ file=syst-con, +%D version=2006.09.16, % real old stuff ... 2000.12.10 +%D title=\CONTEXT\ System Macros, +%D subtitle=Conversions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\registerctxluafile{syst-con}{} + +\unprotect + +%D \macros{lchexnumber,uchexnumber,lchexnumbers,uchexnumbers} +%D +%D In addition to the uppercase hex conversion, as needed in math families, we +%D occasionally need a lowercase one. + +\def\lchexnumber #1{\clf_lchexnumber \numexpr#1\relax} +\def\uchexnumber #1{\clf_uchexnumber \numexpr#1\relax} +\def\lchexnumbers#1{\clf_lchexnumbers\numexpr#1\relax} +\def\uchexnumbers#1{\clf_uchexnumbers\numexpr#1\relax} + +\let\hexnumber\uchexnumber + +%D \macros{octnumber} +%D +%D For \UNICODE\ remapping purposes, we need octal numbers. + +\def\octnumber#1{\clf_octnumber\numexpr#1\relax} + +%D \macros{hexstringtonumber,octstringtonumber} +%D +%D This macro converts a two character hexadecimal number into a decimal number, +%D thereby taking care of lowercase characters as well. + +\def\hexstringtonumber#1{\clf_hexstringtonumber\numexpr#1\relax} +\def\octstringtonumber#1{\clf_octstringtonumber\numexpr#1\relax} + +%D \macros{rawcharacter} +%D +%D This macro can be used to produce proper 8 bit characters that we sometimes need +%D in backends and round||trips. + +\def\rawcharacter#1{\clf_rawcharacter\numexpr#1\relax} + +%D \macros{twodigits, threedigits} +%D +%D These macros provides two or three digits always: + +\def\twodigits #1{\ifnum #1<10 0\fi\number#1} +\def\threedigits#1{\ifnum#1<100 \ifnum#1<10 0\fi0\fi\number#1} + +%D \macros{modulonumber} +%D +%D In the conversion macros described in \type {core-con} we need a wrap||around +%D method. The following solution is provided by Taco. +%D +%D The \type {modulonumber} macro expands to the mathematical modulo of a positive +%D integer. It is crucial for it's application that this macro is fully exandable. +%D +%D The expression inside the \type {\numexpr} itself is somewhat bizarre because +%D \ETEX\ uses a rounding division instead of truncation. If \ETEX's division would +%D have behaved like \TEX's normal\type {\divide}, then the expression could have +%D been somewhat simpler, like \type {#2-(#2/#1)*#1}. This works just as well, but a +%D bit more complex. +%D +%D \starttyping +%D \def\modulonumber#1#2{\the\numexpr#2-((((#2+(#1/2))/#1)-1)*#1)\relax} +%D \stoptyping +%D +%D But \unknown\ now we can also do this: + +\def\modulonumber#1#2{\the\numexpr#2-(#2:#1)*#1\relax} + +%D \macros{setcalculatedsin,setcalculatedcos,setcalculatedtan} + +\unexpanded\def\setcalculatedsin#1#2{\edef#1{\clf_sind#2}} +\unexpanded\def\setcalculatedcos#1#2{\edef#1{\clf_cosd#2}} +\unexpanded\def\setcalculatedtan#1#2{\edef#1{\clf_tand#2}} + +%D \macros{formatted,format} + + \def\formatted#1{\ctxcommand{format(#1)}} % not clf +\unexpanded\def\format #1{\ctxcommand{format(#1)}} % not clf + +%D The \type {\modulatednumber} and \type {\realnumber} macros have been removed. + +\protect \endinput diff --git a/tex/context/base/mkiv/syst-lua.mkiv b/tex/context/base/mkiv/syst-lua.mkiv index a9905c7cc..3683f9ed8 100644 --- a/tex/context/base/mkiv/syst-lua.mkiv +++ b/tex/context/base/mkiv/syst-lua.mkiv @@ -24,31 +24,31 @@ %D {\expanded} primitive were mentioned in talks.} trip. For now I don't really see %D other useful applications. -\def\expandeddoif#1#2% +\def\expandeddoifelse#1#2% {\immediateassignment\edef\m_syst_string_one{#1}% \immediateassignment\edef\m_syst_string_two{#2}% \ifx\m_syst_string_one\m_syst_string_two - \expandafter\firstofoneargument + \expandafter\firstoftwoarguments \else - \expandafter\gobbleoneargument + \expandafter\secondoftwoarguments \fi} -\def\expandeddoifnot#1#2% +\def\expandeddoif#1#2% {\immediateassignment\edef\m_syst_string_one{#1}% \immediateassignment\edef\m_syst_string_two{#2}% \ifx\m_syst_string_one\m_syst_string_two - \expandafter\gobbleoneargument - \else \expandafter\firstofoneargument + \else + \expandafter\gobbleoneargument \fi} -\def\expandeddoifelse#1#2% +\def\expandeddoifnot#1#2% {\immediateassignment\edef\m_syst_string_one{#1}% \immediateassignment\edef\m_syst_string_two{#2}% \ifx\m_syst_string_one\m_syst_string_two - \expandafter\firstoftwoarguments + \expandafter\gobbleoneargument \else - \expandafter\secondoftwoarguments + \expandafter\firstofoneargument \fi} % \testfeatureonce{100000}{\doifelse{hello world}{here i am}{}} % 0.3 @@ -60,35 +60,24 @@ \def\expdoifcommonelse\expdoifelsecommon \def\expdoifinsetelse \expdoifelseinset -% we define these here, just in case ... +%D We define these here, just in case. This permits \typefile {self} otherwise +%D nested b|/|e sep problems. -\def\luastringsep{===} % this permits \typefile{self} otherwise nested b/e sep problems +\def\luastringsep{===} \edef\!!bs{[\luastringsep[} \edef\!!es{]\luastringsep]} \unexpanded\def\writestatus#1#2{\clf_writestatus{#1}{#2}} -% A handy helper: - -% \def\luaexpr#1{\ctxlua{context(tostring(#1))}} % more efficient: - -% We can omit the tex.ctxcatcodes here as nowadays we seldom -% change the regime at the \TEX\ end: +%D We can omit the tex.ctxcatcodes here as nowadays we seldom change the regime at +%D the \TEX\ end: +%def\luaexpr#1{\ctxlua{context (tostring(#1))}} % more efficient: \def\luaexpr#1{\ctxlua{tex.print(tostring(#1))}} % no use is shortcutting has to be compiled -% helpers: - -\def\ui_fo #1{#1} -\def\ui_go #1{} -\def\ui_ft#1#2{#1} -\def\ui_st#1#2{#2} - - -%D But as we only use write 16 we could as well do all in \LUA\ -%D and ignore the rest. Okay, we still can do writes here but only -%D when not blocked. +%D But as we only use write 16 we could as well do all in \LUA\ and ignore the rest. +%D Okay, we still can do writes here but only when not blocked. \let\syst_write_execute\clf_execute % always {...} diff --git a/tex/context/base/mkiv/syst-lua.mkxl b/tex/context/base/mkiv/syst-lua.mkxl new file mode 100644 index 000000000..b6f1e8eaa --- /dev/null +++ b/tex/context/base/mkiv/syst-lua.mkxl @@ -0,0 +1,61 @@ +%D \module +%D [ file=syst-lua, +%D version=2008.01.25, +%D title=\CONTEXT\ System Macros, +%D subtitle=Helper macros based on \LUA, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\registerctxluafile{syst-lua}{} + +\unprotect + +\def\expdoifelse#1#2{\clf_doifelsesame{#1}{#2}} +\def\expdoif #1#2{\clf_doifsame {#1}{#2}} +\def\expdoifnot #1#2{\clf_doifnotsame {#1}{#2}} + +%D Here is variant using a brainwave of the 12\high{+} hour \quotation {Long Road +%D Out of Eden}\footnote {Eden being Backo\TeX\ 2018, where the virtues of the \type +%D {\expanded} primitive were mentioned in talks.} trip. For now I don't really see +%D other useful applications. + +\def\expandeddoifelse#1#2{\iftok{#1}{#2}\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} +\def\expandeddoif #1#2{\iftok{#1}{#2}\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi} +\def\expandeddoifnot #1#2{\iftok{#1}{#2}\expandafter\gobbleoneargument \else\expandafter\firstofoneargument \fi} + +% \testfeatureonce{100000}{\doifelse{hello world}{here i am}{}} % 0.3 +% \testfeatureonce{100000}{\expandabledoifelse{hello world}{here i am}{}} % 1.5 + +\def\expdoifelsecommon#1#2{\clf_doifelsecommon{#1}{#2}} +\def\expdoifelseinset #1#2{\clf_doifelseinset {#1}{#2}} + +\def\expdoifcommonelse\expdoifelsecommon +\def\expdoifinsetelse \expdoifelseinset + +%D We define these here, just in case. This permits \typefile {self} otherwise +%D nested b|/|e sep problems. + +\def\luastringsep{===} + +\edef\!!bs{[\luastringsep[} +\edef\!!es{]\luastringsep]} + +\unexpanded\def\writestatus#1#2{\clf_writestatus{#1}{#2}} + +%D We can omit the tex.ctxcatcodes here as nowadays we seldom change the regime at +%D the \TEX\ end: + +%def\luaexpr#1{\ctxlua{context (tostring(#1))}} % more efficient: +\def\luaexpr#1{\ctxlua{tex.print(tostring(#1))}} % no use is shortcutting has to be compiled + +%D But as we only use write 16 we could as well do all in \LUA\ and ignore the rest. +%D Okay, we still can do writes here but only when not blocked. + +\let\syst_write_execute\clf_execute % always {...} + +\protect \endinput diff --git a/tex/context/base/mkiv/tabl-tsp.mkiv b/tex/context/base/mkiv/tabl-tsp.mkiv index 9395f4039..9e30975cd 100644 --- a/tex/context/base/mkiv/tabl-tsp.mkiv +++ b/tex/context/base/mkiv/tabl-tsp.mkiv @@ -187,9 +187,9 @@ \bgroup \forcelocalfloats \setuplocalfloats[\c!before=,\c!after=,\c!inbetween=]% - \settrialtypesetting % this controls samepage resetting too +% \settrialtypesetting % this controls samepage resetting too but it also messes up the numbering \splitfloatcommand{\hbox to #1{\strut}}% dummy line - \resettrialtypesetting +% \resettrialtypesetting \setbox\scratchbox\vbox{\flushlocalfloats}% \vpack ? \getnoflines{\ht\scratchbox}% \resetlocalfloats diff --git a/tex/context/filenames.pdf b/tex/context/filenames.pdf Binary files differnew file mode 100644 index 000000000..6e1f07bf0 --- /dev/null +++ b/tex/context/filenames.pdf diff --git a/tex/context/filenames.tex b/tex/context/filenames.tex new file mode 100644 index 000000000..bf40b6445 --- /dev/null +++ b/tex/context/filenames.tex @@ -0,0 +1,119 @@ +% language=uk + +\usemodule[article-basic] +\usemodule[abbreviations-logos] + +\setupheader[state=high] + +\starttext + +\starttitle[title=Filenames] + +The \CONTEXT\ distribution follows a rather strict organisation. Originally +all files that implemented macros had names using the pattern: + +\starttabulate[|Tw(10em)||] +\FL +\NC xxxx-xxx.tex \NC \TEX\ file \NC \NR +\NC mp-xxxx.mp \NC \METAPOST\ file \NC \NR +\LL +\stoptabulate + +You can still find files that conform to these patterns but the organization +evolved. The \type {tex} suffix is now normally used just for documents. + +Styles and modules can have names of any length, and can be recognized by their +prefix: + +\starttabulate[|Tw(10em)||] +\FL +\NC s-aaaa.tex \NC style (rendering related) \NC \NR +\NC m-aaaaaa.tex \NC module (functionality related) \NC \NR +\NC x-aaaaa.tex \NC xml module (functionality related) \NC \NR +\LL +\stoptabulate + +\CONTEXT\ \MKII, the frozen version for \PDFTEX\ and \XETEX, uses names like: + +\starttabulate[|Tw(10em)||] +\FL +\NC context.mkii \NC the main \TEX\ file \NC \NR +\NC cont-xx.mkii \NC an interface specific \TEX\ file \NC \NR +\NC xxxx-xxx.mkii \NC \TEX\ file \NC \NR +\ML +\NC mp-xxxx.mpii \NC \METAPOST\ file \NC \NR +\NC metafun.mpii \NC the main \METAFUN\ file \NC \NR +\LL +\stoptabulate + +\CONTEXT\ \MKIV, the current version, has files with names like: + +\starttabulate[|Tw(10em)||] +\FL +\NC context.mkiv \NC the main \TEX\ file \NC \NR +\NC cont-xx.mkiv \NC an interface specific \TEX\ file \NC \NR +\NC xxxx-xxx.mkiv \NC \TEX\ file \NC \NR +\NC xxxx-xxx.mkvi \NC \TEX\ file with named parameters \NC \NR +\NC xxxx-xxx.mkix \NC file with \LMX\ template \NC \NR +\NC xxxx-xxx.mkxi \NC file with \LMX\ template with named parameters \NC \NR +\NC xxxx-xxx.lua \NC a file with \LUA\ code \NC \NR +\NC xxxx-xxx.lfg \NC so called font goodie \LUA\ files \NC \NR +\ML +\NC metafun.mpiv \NC the main \METAFUN\ file \NC \NR +\NC minifun.mpiv \NC a subset of \METAFUN\ \NC \NR +\NC mp-xxxx.mpiv \NC \METAPOST\ file \NC \NR +\LL +\stoptabulate + +There are more suffixes used, like \type {tua} and \type {tuc} for multipass +jobdata, and \type {log} for log files. In the cache tree you can run into \type +{luv}, \type {lui}, \type {luj} and \type {lum} for startup data, +\type {tma} for \LUA\ cache files, \type {tmb} for \LUAJITTEX\ bytecode, \type +{tmc} for \LUATEX {bytecode} and \type {tmd} for \LUAMETATEX\ bytecode, but you +can forget about them. + +There can be files with \type {-imp-} in the name: these relate to other files with +a similar name. + +The follow up on \MKIV\ is called \LMTX\ (or MkXL?) and is compatible with \MKIV: it uses, +at least now, mostly the same code. But, as it depends on \LUAMETATEX\ it also +has some different internals. Therefore you will find some additional files: + +\starttabulate[|Tw(10em)||] +\FL +\NC context.mkxl \NC the main \TEX\ file \NC \NR +\NC cont-xx.mkxl \NC an interface specific \TEX\ file \NC \NR +\NC xxxx-xxx.mkxl \NC \TEX\ file \NC \NR +\NC xxxx-xxx.mklx \NC \TEX\ file with named parameters \NC \NR +\ML +\NC metafun.mpxl \NC the main \METAFUN\ file \NC \NR +\NC minifun.mpxl \NC a subset of \METAFUN\ \NC \NR +\NC mp-xxxx.mpxl \NC \METAPOST\ file \NC \NR +\LL +\stoptabulate + +This means that a file \type {xxxx-xxx} can be present with any of the \type +{mk..} suffixes. In the standard distribution the \MKII\ and \MKIV\ files have +their own path (directory), and \LMTX\ only ships what it needs. + +This somewhat complicated setup is needed in order to support both \LUATEX\ and +\LUAMETATEX\ system. The more \LUAMETATEX\ diverges from \LUATEX, the more the +codebase will be split so eventually we might end up with \MKII, \MKIV\ and \LMTX\ +as more or less independent versions. We try to share the \LUA\ code as much as +possible, also because some components are generic. + +The name pattern \type {xxxx-} groups the files in categories. These are also +referred to from the interface definitions. Examples of categories are \type +{syst} for system modules that define various low level support macros and +mechanisms. The user interface is handled by modules in the \type {mult} +namespace. The \type {supp} modules layer on top of that and provide more +helpers. The \type {font} and \type {type} modules deal with fonts, \type {lang} +handles language support. The \type {strc} modules implement structural +components, \type {tabl} does tables and \type {page} handles the layout. +Specialized categories like \type {mlib}, \type {meta} and \type {grph} are for +graphics, and \type {publ} is used for the publication (bibliography) subsystem. +Just to give you an idea. + +\stoptitle + +\stoptext diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index 9a2154718..77404fcff 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -643,6 +643,7 @@ <cd:constant name='aligntitle' value='alinieretitlu'/> <cd:constant name='alternative' value='alternativ'/> <cd:constant name='anchor' value='anchor'/> + <cd:constant name='anchoring' value='anchoring'/> <cd:constant name='andtext' value='andtext'/> <cd:constant name='apa' value='apa'/> <cd:constant name='arguments' value='arguments'/> @@ -872,6 +873,7 @@ <cd:constant name='hfil' value='hfil'/> <cd:constant name='hidenumber' value='hidenumber'/> <cd:constant name='hoffset' value='hoffset'/> + <cd:constant name='horizontal' value='orizontal'/> <cd:constant name='horoffset' value='offsetoriz'/> <cd:constant name='hyphen' value='hyphen'/> <cd:constant name='hyphens' value='hyphens'/> @@ -1292,6 +1294,7 @@ <cd:constant name='vcompact' value='vcompact'/> <cd:constant name='vector' value='vector'/> <cd:constant name='veroffset' value='veroffset'/> + <cd:constant name='vertical' value='vertical'/> <cd:constant name='vfactor' value='vfactor'/> <cd:constant name='vfil' value='vfil'/> <cd:constant name='viewerprefix' value='viewerprefix'/> @@ -1302,6 +1305,7 @@ <cd:constant name='white' value='alb'/> <cd:constant name='width' value='latime'/> <cd:constant name='words' value='words'/> + <cd:constant name='xanchor' value='xanchor'/> <cd:constant name='xfactor' value='xfactor'/> <cd:constant name='xhtml' value='xhtml'/> <cd:constant name='xmax' value='xmax'/> @@ -1309,6 +1313,7 @@ <cd:constant name='xoffset' value='xoffset'/> <cd:constant name='xscale' value='xscala'/> <cd:constant name='xstep' value='xstep'/> + <cd:constant name='yanchor' value='yanchor'/> <cd:constant name='yfactor' value='yfactor'/> <cd:constant name='ymax' value='ymax'/> <cd:constant name='yoffset' value='yoffset'/> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex e1c0e85ae..20ca3b4a7 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 9fa13268b..41bca13ac 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index c43b1d8da..7b3dbccbd 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 : 07/31/19 18:05:38 +-- merge date : 08/02/19 19:40:08 do -- begin closure to overcome local limits and interference |