From 0f76c97e6a4dafdbee3f18f33275936b5528d1dc Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Wed, 26 Oct 2011 15:10:00 +0200 Subject: beta 2011.10.26 15:10 --- tex/context/base/back-exp.lua | 8 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4075 -> 4074 bytes tex/context/base/context-version.png | Bin 106436 -> 105820 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/font-con.lua | 77 ++- tex/context/base/font-otf.lua | 2 + tex/context/base/font-otn.lua | 5 + tex/context/base/font-tra.mkiv | 17 +- tex/context/base/m-chart.lua | 7 +- tex/context/base/node-ini.lua | 46 +- tex/context/base/page-mis.lua | 10 +- tex/context/base/page-mis.mkiv | 14 +- tex/context/base/page-one.mkiv | 16 +- tex/context/base/s-abr-01.tex | 1 + tex/context/base/s-fnt-20.mkiv | 20 + tex/context/base/s-fnt-35.mkiv | 341 ---------- tex/context/base/s-fonts-tables.lua | 288 +++++++++ tex/context/base/s-fonts-tables.mkiv | 30 + tex/context/base/s-mod-01.mkiv | 69 +- tex/context/base/spac-ali.mkiv | 11 +- tex/context/base/spac-chr.lua | 26 +- tex/context/base/spac-chr.mkiv | 41 +- tex/context/base/spac-hor.mkiv | 6 +- tex/context/base/status-files.pdf | Bin 23819 -> 23826 bytes tex/context/base/status-lua.pdf | Bin 163940 -> 165294 bytes tex/context/base/strc-ref.lua | 19 +- tex/context/base/supp-vis.mkiv | 2 - tex/context/base/syst-aux.mkiv | 708 +++++++-------------- tex/generic/context/luatex/luatex-fonts-merged.lua | 86 ++- 32 files changed, 926 insertions(+), 932 deletions(-) delete mode 100644 tex/context/base/s-fnt-35.mkiv create mode 100644 tex/context/base/s-fonts-tables.lua create mode 100644 tex/context/base/s-fonts-tables.mkiv (limited to 'tex') diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index dd6e13515..4fd5aa32d 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -2131,10 +2131,12 @@ local function cleanxhtmltree(xmltree) for e in xml.collected(xmltree,"link") do local at = e.at local href - if at.url then + if at.location then + href = "#" .. gsub(at.location,":","_") + elseif at.url then href = at.url - elseif at.location then - at.href = "#" .. gsub(at.location,":","_") + elseif at.file then + href = at.file end if href then wrapper.at.href = href diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 13dad229b..f3d979a4b 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2011.10.20 15:49} +\newcontextversion{2011.10.26 15:10} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index f4840be48..94e082a36 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2011.10.20 15:49} +\newcontextversion{2011.10.26 15:10} %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/context-version.pdf b/tex/context/base/context-version.pdf index 71af8f3f7..2f6eed468 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index c1279e9d8..7ef6208ce 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index f7fe26995..d489e30b6 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.10.20 15:49} +\edef\contextversion{2011.10.26 15:10} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 9147474d8..76056b772 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.10.20 15:49} +\edef\contextversion{2011.10.26 15:10} %D For those who want to use this: diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua index 75d90f136..93567cb2d 100644 --- a/tex/context/base/font-con.lua +++ b/tex/context/base/font-con.lua @@ -7,6 +7,8 @@ if not modules then modules = { } end modules ['font-con'] = { } +-- some names of table entries will be changed (no _) + local utf = unicode.utf8 local next, tostring, rawget = next, tostring, rawget @@ -51,7 +53,80 @@ constructors.cache = containers.define("fonts", "constructors", constr constructors.privateoffset = 0xF0000 -- 0x10FFFF --- This might become an interface; +-- Some experimental helpers (handy for tracing): + +constructors.keys = { + properties = { + encodingbytes = "number", + embedding = "number", + cidinfo = { + }, + format = "string", + fontname = "string", + fullname = "string", + filename = "filename", + psname = "string", + name = "string", + virtualized = "boolean", + italic_correction = "boolean", + auto_italic_correction = "boolean", + no_stackmath = "boolean", + noglyphnames = "boolean", + mode = "string", + has_math = "boolean", + no_math_italics = "boolean", + no_text_italics = "boolean", + finalized = "boolean", + }, + parameters = { + mathsize = "scaledpoints", + scriptpercentage = "float", + scriptscriptpercentage = "float", + units = "cardinal", + designsize = "scalespoints", + expansion = { + stretch = "integerscale", -- might become float + shrink = "integerscale", -- might become float + step = "integerscale", -- might become float + auto = "boolean", + }, + protrusion = { + auto = "boolean", + }, + expand_factor = "float", + slant_factor = "float", + factor = "float", + hfactor = "float", + vfactor = "float", + size = "scaledpoints", + units = "scaledpoints", + scaledpoints = "scaledpoints", + slant = "float", + space = "scaledpoints", + space_stretch = "scaledpoints", + space_shrink = "scaledpoints", + x_height = "scaledpoints", + quad = "scaledpoints", + extra_space = "scaledpoints", + ascender = "scaledpoints", + descender = "scaledpoints", + }, + description = { + width = "basepoints", + height = "basepoints", + depth = "basepoints", + boundingbox = { }, + }, + character = { + width = "scaledpoints", + height = "scaledpoints", + depth = "scaledpoints", + italic = "scaledpoints", + }, + +} + +-- This might become an interface: local designsizes = allocate() constructors.designsizes = designsizes diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index cab6fae2b..cb309a39f 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -12,6 +12,8 @@ if not modules then modules = { } end modules ['font-otf'] = { -- to_table -> totable -- ascent descent +-- more checking against low level calls of functions + local utf = unicode.utf8 local utfbyte = utf.byte diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index beb3ae740..af8264939 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -399,6 +399,11 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- start = start.next end end + -- we do need components in funny kerning mode but maybe I can better reconstruct then + -- as we do have the font components info available; removing components makes the + -- previous code much simpler + -- + -- flush_node_list(head.components) return head end end diff --git a/tex/context/base/font-tra.mkiv b/tex/context/base/font-tra.mkiv index 8344b7658..0f16dbc43 100644 --- a/tex/context/base/font-tra.mkiv +++ b/tex/context/base/font-tra.mkiv @@ -50,6 +50,7 @@ {\begingroup \tttf\language\minusone \veryraggedright + \forgetparindent \hangindent1em \hangafter\plusone \dontleavehmode\hbox{\detokenize{#1}}\removeunwantedspaces @@ -67,7 +68,10 @@ {\ctxlua{nodes.tracers.steppers.features()}} \def\showotfsteps - {\dontleavehmode\bgroup\tttf \language\minusone features: \showotfstepfeatures\egroup + {\begingroup + \veryraggedright + \forgetparindent + \dontleavehmode\bgroup\tttf \language\minusone features: \showotfstepfeatures\egroup \blank \dontleavehmode\bgroup\tttf result:\egroup \blank @@ -84,14 +88,17 @@ \blank \startlinecorrection \ruledhbox % can be mode - \bgroup\resetallattributes\showotfstepglyphs\recurselevel\egroup % reset is new, we don't want additional processing + \bgroup\resetallattributes\showotfstepglyphs\recurselevel\egroup % reset is new, we don't want additional processing \stoplinecorrection - \blank}} + \blank}% + \endgroup} \unexpanded\def\startotfsample {\enabletrackers[*otf.sample]% beware, kind of global \startotfcollecting - \begingroup} + \begingroup + \veryraggedright + \forgetparindent} \unexpanded\def\stopotfsample {\endgroup @@ -104,6 +111,8 @@ \def\showotfcomposition#1#2#3% {font*features at size}, rl=-1, text {\begingroup + \veryraggedright + \forgetparindent \setupcolors[\c!state=\v!start]% can be option \startotfsample \global\setbox\otfcompositionbox\hbox{\definedfont[#1]\ifnum#2<0 \textdir TRT\else\ifnum#2>0 \textdir TLT\fi\fi\relax#3}% diff --git a/tex/context/base/m-chart.lua b/tex/context/base/m-chart.lua index 943e6be63..0000d28e5 100644 --- a/tex/context/base/m-chart.lua +++ b/tex/context/base/m-chart.lua @@ -711,6 +711,8 @@ local function getchart(settings) if miny == 0 or y > maxy then maxy = y end end end +-- print("1>",x,y,nx,ny) +-- print("2>",minx, miny, maxx, maxy) -- check of window should be larger (maybe autofocus + nx/ny?) if autofocus then -- x and y are ignored @@ -725,15 +727,16 @@ local function getchart(settings) minx = x end if y and y > 0 then - minx = y + miny = y end if nx and nx > 0 then maxx = minx + nx - 1 end if ny and ny > 0 then - miny = miny + ny - 1 + maxy = miny + ny - 1 end end +-- print("3>",minx, miny, maxx, maxy) -- local nx = maxx - minx + 1 local ny = maxy - miny + 1 diff --git a/tex/context/base/node-ini.lua b/tex/context/base/node-ini.lua index a27efe0cf..0ed17a1b5 100644 --- a/tex/context/base/node-ini.lua +++ b/tex/context/base/node-ini.lua @@ -94,6 +94,12 @@ local skipcodes = allocate { [18] = "thickmuskip", } +local penaltycodes = allocate { -- unfortunately not used + [ 0] = "userpenalty", +} + +table.setmetatableindex(penaltycodes,function(t,k) return "userpenalty" end) -- not used anyway + local noadcodes = allocate { [ 0] = "ord", [ 1] = "opdisplaylimits", @@ -158,25 +164,27 @@ end local nodecodes = simplified(node.types()) local whatcodes = simplified(node.whatsits()) -skipcodes = allocate(swapped(skipcodes, skipcodes )) -noadcodes = allocate(swapped(noadcodes, noadcodes )) -nodecodes = allocate(swapped(nodecodes, nodecodes )) -whatcodes = allocate(swapped(whatcodes, whatcodes )) -listcodes = allocate(swapped(listcodes, listcodes )) -glyphcodes = allocate(swapped(glyphcodes,glyphcodes)) -kerncodes = allocate(swapped(kerncodes, kerncodes )) -mathcodes = allocate(swapped(mathcodes, mathcodes )) -fillcodes = allocate(swapped(fillcodes, fillcodes )) - -nodes.skipcodes = skipcodes nodes.gluecodes = skipcodes -- more official -nodes.noadcodes = noadcodes -nodes.nodecodes = nodecodes -nodes.whatcodes = whatcodes nodes.whatsitcodes = whatcodes -- more official -nodes.listcodes = listcodes -nodes.glyphcodes = glyphcodes -nodes.kerncodes = kerncodes -nodes.mathcodes = mathcodes -nodes.fillcodes = fillcodes +skipcodes = allocate(swapped(skipcodes, skipcodes )) +noadcodes = allocate(swapped(noadcodes, noadcodes )) +nodecodes = allocate(swapped(nodecodes, nodecodes )) +whatcodes = allocate(swapped(whatcodes, whatcodes )) +listcodes = allocate(swapped(listcodes, listcodes )) +glyphcodes = allocate(swapped(glyphcodes, glyphcodes)) +kerncodes = allocate(swapped(kerncodes, kerncodes )) +penaltycodes = allocate(swapped(penaltycodes, penaltycodes )) +mathcodes = allocate(swapped(mathcodes, mathcodes )) +fillcodes = allocate(swapped(fillcodes, fillcodes )) + +nodes.skipcodes = skipcodes nodes.gluecodes = skipcodes -- more official +nodes.noadcodes = noadcodes +nodes.nodecodes = nodecodes +nodes.whatcodes = whatcodes nodes.whatsitcodes = whatcodes -- more official +nodes.listcodes = listcodes +nodes.glyphcodes = glyphcodes +nodes.kerncodes = kerncodes +nodes.penaltycodes = kerncodes +nodes.mathcodes = mathcodes +nodes.fillcodes = fillcodes listcodes.row = listcodes.alignment listcodes.column = listcodes.alignment diff --git a/tex/context/base/page-mis.lua b/tex/context/base/page-mis.lua index 21c122fa2..d32eb8a00 100644 --- a/tex/context/base/page-mis.lua +++ b/tex/context/base/page-mis.lua @@ -23,7 +23,15 @@ local function flush(page) end local function setnextpage() - tex.setcount("global","postponed_page_blocks_next_page",next(cache) and sortedkeys(cache)[1] or -1) + local n = next(cache) and sortedkeys(cache)[1] + if not n then + n = 0 -- nothing in the cache + elseif n == 0 then + n = -1 -- generic buffer (0) + elseif n > 0 then + -- upcoming page (realpageno) + end + tex.setcount("global","postponed_page_blocks_next_page",n) end function commands.flushpostponedblocks(page) diff --git a/tex/context/base/page-mis.mkiv b/tex/context/base/page-mis.mkiv index 808f42aa6..d3c1e5051 100644 --- a/tex/context/base/page-mis.mkiv +++ b/tex/context/base/page-mis.mkiv @@ -207,21 +207,23 @@ \restoreglobalbodyfont % otherwise problems inside split verbatim \ctxcommand{flushpostponedblocks()}% \relax - \doflushfloats % new but potential dangerous - \egroup} + \doflushfloats % new but potential dangerous, maybe we need a classification + \egroup} % of blocks: with and without flush \def\doflushpostponedblocks {\ifinpostponing % probably a nested flush \else\ifnum\postponed_page_blocks_next_page=\zerocount + % nothing in cache + \else\ifnum\postponed_page_blocks_next_page<\zerocount + % generic cache \postponed_page_block_flush - %\doflushpostponedblocks \else\ifnum\postponed_page_blocks_next_page>\realpageno - % not yet + % future content \else + % pending content \postponed_page_block_flush - %\doflushpostponedblocks - \fi\fi\fi} + \fi\fi\fi\fi} \def\doflushpostponedcontent % called in page-one {\bgroup diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv index 6156ab8b1..b1ee82302 100644 --- a/tex/context/base/page-one.mkiv +++ b/tex/context/base/page-one.mkiv @@ -50,12 +50,14 @@ \ifdim\oldvsize=\vsize % let's assume that the layout didn't change \else - \bgroup - \global\oldvsize\vsize - \advance\vsize-\topinserted - \advance\vsize-\botinserted - \global\pagegoal\vsize - \egroup + \global\oldvsize\vsize + \global\pagegoal\dimexpr\vsize-\topinserted-\botinserted\relax +% \bgroup +% \global\oldvsize\vsize +% \advance\vsize-\topinserted +% \advance\vsize-\botinserted +% \global\pagegoal\vsize +% \egroup \fi \fi} @@ -354,7 +356,7 @@ \dofloatscollect\s!text{\hsize}{1em}% %% no longer (interferes with footnotes): %% - %% \OTRONEsetvsize / test 2011.06.24.001 + %% \OTRONEsetvsize % test 2011.06.24.001 %% \global\setbox\floatbox\hbox to \hsize {\hfil diff --git a/tex/context/base/s-abr-01.tex b/tex/context/base/s-abr-01.tex index a180876a5..a0d8ba2ca 100644 --- a/tex/context/base/s-abr-01.tex +++ b/tex/context/base/s-abr-01.tex @@ -179,6 +179,7 @@ \logo [OVF] {ovf} \logo [PASCAL] {Pascal} \logo [PCTEX] {pc\TeX} +\logo [PFA] {pfa} \logo [PFB] {pfb} \logo [PDF] {pdf} \logo [PDFETEX] {pdfe\TeX} diff --git a/tex/context/base/s-fnt-20.mkiv b/tex/context/base/s-fnt-20.mkiv index 5ea740c0a..a78f62555 100644 --- a/tex/context/base/s-fnt-20.mkiv +++ b/tex/context/base/s-fnt-20.mkiv @@ -138,3 +138,23 @@ {\getvariable{otftracker}{sample}} \stoptext \stopsetups + +\continueifinputfile{s-fnt-20.mkiv} + +\usemodule[art-01] + +\setupbodyfont +% [cambria] + [dejavu] + +\starttext + +\setvariables + [otftracker] + [font=Serif, + size=48pt, + figure=, + title=Feature Check, + sample={affiliation}] + +\stoptext diff --git a/tex/context/base/s-fnt-35.mkiv b/tex/context/base/s-fnt-35.mkiv deleted file mode 100644 index 157d3062c..000000000 --- a/tex/context/base/s-fnt-35.mkiv +++ /dev/null @@ -1,341 +0,0 @@ -%D \module -%D [ file=s-fnt-35, -%D version=2011.10.10, -%D title=\CONTEXT\ Style File, -%D subtitle=Feature List, -%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. - -% we already have a way to show character tables - -\startluacode - --- the table will move to a font-* file - -moduledata.fonts = moduledata.fonts or { } - -local digits = { - dflt = { - dflt = "1234567890 1/2", - }, -} - -local punctuation = { - dflt = { - dflt = ". , : ; ? !", - }, -} - -local symbols = { - dflt = { - dflt = "@ # $ % & * () [] {} <> + - = / |", - }, -} - -local uppercase = { - latn = { - dflt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - }, - grek = { - dftl = "ΑΒΓΔΕΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ", - }, - cyrl= { - dflt = "АБВГДЕЖЗИІЙКЛМНОПРСТУФХЦЧШЩЪЫЬѢЭЮЯѲ" - }, -} - -local lowercase = { - latn = { - dftl = "abcdefghijklmnopqrstuvwxyz", - }, - grek = { - dftl = "αβγδεηθικλμνξοπρστυφχψω", - }, - cyrl= { - dflt = "абвгдежзиійклмнопрстуфхцчшщъыьѣэюяѳ" - }, -} - -local samples = { - digits = digits, - punctuation = punctuation, - symbols = symbols, - uppercase = uppercase, - lowercase = lowercase, -} - -fonts.tracers.samples = samples - -table.setmetatableindex(uppercase, function(t,k) return rawget(t,"latn") end) -table.setmetatableindex(lowercase, function(t,k) return rawget(t,"latn") end) -table.setmetatableindex(digits, function(t,k) return rawget(t,"dflt") end) -table.setmetatableindex(symbols, function(t,k) return rawget(t,"dflt") end) -table.setmetatableindex(punctuation, function(t,k) return rawget(t,"dflt") end) - -table.setmetatableindex(uppercase.latn, function(t,k) return rawget(t,"dflt") end) -table.setmetatableindex(uppercase.grek, function(t,k) return rawget(t,"dflt") end) -table.setmetatableindex(uppercase.cyrl, function(t,k) return rawget(t,"dflt") end) - -table.setmetatableindex(lowercase.latn, function(t,k) return rawget(t,"dflt") end) -table.setmetatableindex(lowercase.grek, function(t,k) return rawget(t,"dflt") end) -table.setmetatableindex(lowercase.cyrl, function(t,k) return rawget(t,"dflt") end) - -table.setmetatableindex(digits.dflt, function(t,k) return rawget(t,"dflt") end) -table.setmetatableindex(symbols.dflt, function(t,k) return rawget(t,"dflt") end) -table.setmetatableindex(punctuation.dflt, function(t,k) return rawget(t,"dflt") end) - -fonts.constructors.keys = { - properties = { - encodingbytes = "number", - embedding = "number", - cidinfo = "table", - format = "string", - fontname = "string", - fullname = "string", - filename = "filename", - psname = "string", - name = "string", - virtualized = "boolean", - italic_correction = "boolean", - auto_italic_correction = "boolean", - no_stackmath = "boolean", - noglyphnames = "boolean", - mode = "string", - has_math = "boolean", - no_math_italics = "boolean", - no_text_italics = "boolean", - finalized = "boolean", - }, - parameters = { - mathsize = "scaledpoints", - scriptpercentage = "float", - scriptscriptpercentage = "float", - units = "cardinal", - designsize = "basepoints", - expansion = "table", - protrusion = "table", - expand_factor = "float", - slant_factor = "float", - factor = "float", - hfactor = "float", - vfactor = "float", - size = "scaledpoints", - units = "scaledpoints", - scaledpoints = "scaledpoints", - slant = "float", - space = "scaledpoints", - space_stretch = "scaledpoints", - space_shrink = "scaledpoints", - x_height = "scaledpoints", - quad = "scaledpoints", - extra_space = "scaledpoints", - ascender = "scaledpoints", - descender = "scaledpoints", - }, -} - --- parameters.expansion = { --- stretch = tfmdata.stretch or 0, --- shrink = tfmdata.shrink or 0, --- step = tfmdata.step or 0, --- auto = tfmdata.auto_expand or false, --- } --- parameters.protrusion = { --- auto = auto_protrude --- } - -local function showtable(t,keys) - if t then - context.starttabulate { "|Tl|Tl|" } - for k, v in table.sortedhash(keys) do - context.NC() - context(k) - context.NC() - local tk = t[k] - if not tk then - context("") - elseif v == "filename" then - context(file.basename(tk)) - elseif v == "boolean" then - context(tostring(tk or false)) - elseif v == "scaledpoints" or v == "basepoints" then - context(number.points(tk)) - elseif v == "table" then - -- todo - context("") - else - context(tostring(tk)) - end - context.NC() - context.NR() - end - context.stoptabulate() - end -end - -function moduledata.fonts.show_properties() - local tfmdata = fonts.hashes.identifiers[font.current()] - showtable(tfmdata.properties,fonts.constructors.keys.properties) -end - -function moduledata.fonts.show_parameters() - local tfmdata = fonts.hashes.identifiers[font.current()] - showtable(tfmdata.parameters,fonts.constructors.keys.parameters) -end - -function moduledata.fonts.show_positional_features() - local tfmdata = fonts.hashes.identifiers[font.current()] - local resources = tfmdata.resources - if resources then - local features = resources.features - if features then - local gpos = features.gpos - if gpos and next(gpos) then - context.starttabulate { "|Tl|Tl|Tlp|" } - for feature, scripts in table.sortedpairs(gpos) do - for script, languages in table.sortedpairs(scripts) do - context.NC() - context(feature) - context.NC() - context(script) - context.NC() - context(table.concat(table.sortedkeys(languages)," ")) - context.NC() - context.NR() - end - end - context.stoptabulate() - else - context("no entries") - context.par() - end - end - end -end - -local dynamics = true - -function moduledata.fonts.show_substitution_features() - local tfmdata = fonts.hashes.identifiers[font.current()] - local resources = tfmdata.resources - if resources then - local features = resources.features - if features then - local gsub = features.gsub - if gsub then - local makes_sense = { } - for feature, scripts in table.sortedpairs(gsub) do - for script, languages in table.sortedpairs(scripts) do - for language in table.sortedpairs(languages) do - local tag = string.format("dummy-%s-%s-%s",feature,script,language) - local fnt = string.format("file:%s*%s",file.basename(tfmdata.properties.filename),tag) - context.definefontfeature ( - { tag }, - { - mode = "node", - script = script, - language = language, - [feature] = "yes" - } - ) - if not dynamics then - context.definefont( { fnt }, { fnt } ) - end - makes_sense[#makes_sense+1] = { - feature = feature, - tag = tag, - script = script, - language = language, - fontname = fnt, - } - end - end - end - if #makes_sense > 0 then - context.starttabulate { "|Tl|Tl|Tl|p|" } - for i=1,#makes_sense do - local data = makes_sense[i] - local script = data.script - local language = data.language - context.NC() - context(data.feature) - context.NC() - context(script) - context.NC() - context(language) - context.NC() - if not dynamics then - context.startfont { data.fontname } - else - context.addff(data.tag) - end - context.verbatim(samples.lowercase [script][language]) context.par() - context.verbatim(samples.uppercase [script][language]) context.par() - context.verbatim(samples.digits [script][language]) context.par() - context.verbatim(samples.punctuation[script][language]) - context.verbatim(samples.symbols [script][language]) - if not dynamics then - context.stopfont() - end - context.NC() - context.NR() - end - context.stoptabulate() - else - context("no entries") - context.par() - end - end - end - end -end - -function moduledata.fonts.show_a_lot(title) - - if title == "" then title = false end - - if title then - context.starttitle { title = title } - end - - context.startsubject { title = "Properties" } - moduledata.fonts.show_properties() - context.stopsubject() - - context.startsubject { title = "Parameters" } - moduledata.fonts.show_parameters() - context.stopsubject() - - context.startsubject { title = "Positional features" } - moduledata.fonts.show_positional_features() - context.stopsubject() - - context.startsubject { title = "Substitution features" } - moduledata.fonts.show_substitution_features() - context.stopsubject() - - if title then - context.stoptitle() - end - -end - -\stopluacode - -% todo: make a mtxrun --script --font option - -\continueifinputfile{s-fnt-35.mkiv} - -\usemodule[art-01] - -\setupbodyfont - [cambria] - -\starttext - \ctxlua{moduledata.fonts.show_a_lot("Cambria")} -\stoptext diff --git a/tex/context/base/s-fonts-tables.lua b/tex/context/base/s-fonts-tables.lua new file mode 100644 index 000000000..856a34cd8 --- /dev/null +++ b/tex/context/base/s-fonts-tables.lua @@ -0,0 +1,288 @@ +if not modules then modules = { } end modules ['s-fonts-tables'] = { + version = 1.001, + comment = "companion to s-fonts-tables.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local setmetatableindex = table.setmetatableindex +local sortedhash = table.sortedhash +local sortedkeys = table.sortedkeys +local format = string.format +local concat = table.concat + +moduledata.fonts = moduledata.fonts or { } +moduledata.fonts.tracers = moduledata.fonts.tracers or { } +moduledata.fonts.tracers.tables = moduledata.fonts.tracers.tables or { } + +local tabletracers = moduledata.fonts.tracers.tables + +local digits = { + dflt = { + dflt = "1234567890 1/2", + }, +} + +local punctuation = { + dflt = { + dflt = ". , : ; ? !", + }, +} + +local symbols = { + dflt = { + dflt = "@ # $ % & * () [] {} <> + - = / |", + }, +} + +local uppercase = { + latn = { + dflt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + }, + grek = { + dftl = "ΑΒΓΔΕΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ", + }, + cyrl= { + dflt = "АБВГДЕЖЗИІЙКЛМНОПРСТУФХЦЧШЩЪЫЬѢЭЮЯѲ" + }, +} + +local lowercase = { + latn = { + dftl = "abcdefghijklmnopqrstuvwxyz", + }, + grek = { + dftl = "αβγδεηθικλμνξοπρστυφχψω", + }, + cyrl= { + dflt = "абвгдежзиійклмнопрстуфхцчшщъыьѣэюяѳ" + }, +} + +local samples = { + digits = digits, + punctuation = punctuation, + symbols = symbols, + uppercase = uppercase, + lowercase = lowercase, +} + +tabletracers.samples = samples + +setmetatableindex(uppercase, function(t,k) return rawget(t,"latn") end) +setmetatableindex(lowercase, function(t,k) return rawget(t,"latn") end) +setmetatableindex(digits, function(t,k) return rawget(t,"dflt") end) +setmetatableindex(symbols, function(t,k) return rawget(t,"dflt") end) +setmetatableindex(punctuation, function(t,k) return rawget(t,"dflt") end) + +setmetatableindex(uppercase.latn, function(t,k) return rawget(t,"dflt") end) +setmetatableindex(uppercase.grek, function(t,k) return rawget(t,"dflt") end) +setmetatableindex(uppercase.cyrl, function(t,k) return rawget(t,"dflt") end) + +setmetatableindex(lowercase.latn, function(t,k) return rawget(t,"dflt") end) +setmetatableindex(lowercase.grek, function(t,k) return rawget(t,"dflt") end) +setmetatableindex(lowercase.cyrl, function(t,k) return rawget(t,"dflt") end) + +setmetatableindex(digits.dflt, function(t,k) return rawget(t,"dflt") end) +setmetatableindex(symbols.dflt, function(t,k) return rawget(t,"dflt") end) +setmetatableindex(punctuation.dflt, function(t,k) return rawget(t,"dflt") end) + +local function typeset(t,keys,nesting,prefix) + if t then + if not prefix then + context.starttabulate { "|Tl|Tl|" } + end + for k, v in sortedhash(keys) do + if type(v) ~= "table" then + context.NC() + if prefix then + context("%s.%s",prefix,k) + else + context(k) + end + context.NC() + local tk = t[k] + if not tk then + context("") + elseif v == "filename" then + context(file.basename(tk)) + elseif v == "boolean" then + context(tostring(tk or false)) + elseif v == "basepoints" then + context("%sbp",tk) + elseif v == "scaledpoints" then + context(number.points(tk)) + elseif v == "table" then + context("
") + else -- if v == "integerscale" then + context(tostring(tk)) + end + context.NC() + context.NR() + elseif nesting == false then + context("
") + else -- true or nil + typeset(t[k],v,nesting,k) + end + end + if not prefix then + context.stoptabulate() + end + end +end + +tabletracers.typeset = typeset + +function tabletracers.properties(nesting) + local tfmdata = fonts.hashes.identifiers[font.current()] + typeset(tfmdata.properties,fonts.constructors.keys.properties,nesting) +end + +function tabletracers.parameters(nesting) + local tfmdata = fonts.hashes.identifiers[font.current()] + typeset(tfmdata.parameters,fonts.constructors.keys.parameters,nesting) +end + +function tabletracers.positionalfeatures() + local tfmdata = fonts.hashes.identifiers[font.current()] + local resources = tfmdata.resources + if resources then + local features = resources.features + if features then + local gpos = features.gpos + if gpos and next(gpos) then + context.starttabulate { "|Tl|Tl|Tlp|" } + for feature, scripts in sortedhash(gpos) do + for script, languages in sortedhash(scripts) do + context.NC() + context(feature) + context.NC() + context(script) + context.NC() + context(concat(sortedkeys(languages)," ")) + context.NC() + context.NR() + end + end + context.stoptabulate() + else + context("no entries") + context.par() + end + end + end +end + +local dynamics = true + +function tabletracers.substitutionfeatures() + local tfmdata = fonts.hashes.identifiers[font.current()] + local resources = tfmdata.resources + if resources then + local features = resources.features + if features then + local gsub = features.gsub + if gsub then + local makes_sense = { } + for feature, scripts in sortedhash(gsub) do + for script, languages in sortedhash(scripts) do + for language in sortedhash(languages) do + local tag = format("dummy-%s-%s-%s",feature,script,language) + local fnt = format("file:%s*%s",file.basename(tfmdata.properties.filename),tag) + context.definefontfeature ( + { tag }, + { + mode = "node", + script = script, + language = language, + [feature] = "yes" + } + ) + if not dynamics then + context.definefont( { fnt }, { fnt } ) + end + makes_sense[#makes_sense+1] = { + feature = feature, + tag = tag, + script = script, + language = language, + fontname = fnt, + } + end + end + end + if #makes_sense > 0 then + context.starttabulate { "|Tl|Tl|Tl|p|" } + for i=1,#makes_sense do + local data = makes_sense[i] + local script = data.script + local language = data.language + context.NC() + context(data.feature) + context.NC() + context(script) + context.NC() + context(language) + context.NC() + if not dynamics then + context.startfont { data.fontname } + else + context.addff(data.tag) + end + context.verbatim(samples.lowercase [script][language]) context.par() + context.verbatim(samples.uppercase [script][language]) context.par() + context.verbatim(samples.digits [script][language]) context.par() + context.verbatim(samples.punctuation[script][language]) + context.verbatim(samples.symbols [script][language]) + if not dynamics then + context.stopfont() + end + context.NC() + context.NR() + end + context.stoptabulate() + else + context("no entries") + context.par() + end + end + end + end +end + +function tabletracers.all(settings) -- not interfaced + + if type(settings) == "string" then + settings = utilities.parsers.settings_to_hash(settings) + end + + local title = settings and settings.title or "" + + if title == "" then title = false end + + if title then + context.starttitle { title = title } + end + + context.startsubject { title = "Properties" } + tabletracers.properties() + context.stopsubject() + + context.startsubject { title = "Parameters" } + tabletracers.parameters() + context.stopsubject() + + context.startsubject { title = "Positional features" } + tabletracers.positionalfeatures() + context.stopsubject() + + context.startsubject { title = "Substitution features" } + tabletracers.substitutionfeatures() + context.stopsubject() + + if title then + context.stoptitle() + end + +end diff --git a/tex/context/base/s-fonts-tables.mkiv b/tex/context/base/s-fonts-tables.mkiv new file mode 100644 index 000000000..efe1500fb --- /dev/null +++ b/tex/context/base/s-fonts-tables.mkiv @@ -0,0 +1,30 @@ +%D \module +%D [ file=s-fonts-tables, +%D version=2011.10.10, +%D title=\CONTEXT\ Style File, +%D subtitle=Basic Font Data Tables, +%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. + +% todo: make a mtxrun --script --font option + +\registerctxluafile{s-fonts-tables}{} + +\def\ModuleFontsTracersTablesAll[#1]% + {\ctxlua{moduledata.fonts.tracers.tables.all("#1")}} + +\continueifinputfile{s-fonts-tables.mkiv} + +\usemodule[art-01] + +\setupbodyfont + [cambria] + +\starttext + \ModuleFontsTracersTablesAll[title=Cambria] +\stoptext diff --git a/tex/context/base/s-mod-01.mkiv b/tex/context/base/s-mod-01.mkiv index 2feeaad77..cca0e96e7 100644 --- a/tex/context/base/s-mod-01.mkiv +++ b/tex/context/base/s-mod-01.mkiv @@ -162,13 +162,6 @@ {\blank \endgroup} -\doifnotmode {nocode} { % \startmode ... \stopmode fails in the module documentation - - \unexpanded\def\startdefinition{\gobbleuntil\stopdefinition} - \unexpanded\def\stopdefinition {} - -} - \definetyping [PL] [\c!option=PL] \definetyping [JV] [\c!option=JV] \definetyping [MP] [\c!option=MP] @@ -185,35 +178,34 @@ \c!distance=\leftmargindistance, \c!align=\v!flushright] -\unexpanded\def\dodomodulemarginstuff[#1]#2% - {\def\docommand##1% - {\indent\hbox - {\ifx#2\relax - \index{##1}% - \else - \index{#2{##1}}% - \fi - #2{\doboundtext{##1}{\leftmarginwidth}{..}}}% - \endgraf}% - \processcommalist[#1]\docommand} - -\unexpanded\def\modulemarginstuff#1[#2]% to be renamed - {\def\domodulemarginstuff##1##2% - {\margintitle[#2]% - {\switchtobodyfont[\v!small]% - \dodomodulemarginstuff[##1]#1% - \processcommalist[##2]\index}}% - \dodoublegroupempty\domodulemarginstuff} - -\unexpanded\def\complexmacros {\modulemarginstuff\tex } -\unexpanded\def\complexextras {\modulemarginstuff\relax} -\unexpanded\def\complexelements{\modulemarginstuff\someelement} +% This will be cleaned up. + +\unexpanded\def\domodulemarginstuff#1#2% + {\marginstuff + {\ifx#1\relax + \index{#2}% + \else + \index{#1{#2}}% + \fi + #1{\doboundtext{#2}{\leftmarginwidth}{..}}}} + +\unexpanded\def\modulemarginstuff#1#2% to be renamed + {\processcommalist[#2]{\domodulemarginstuff#1}} + +\definemargindata + [marginstuff] + [left] + [stack=yes, + hoffset=2em, + style=\ttxx] + +\unexpanded\def\macros {\modulemarginstuff\tex } +\unexpanded\def\extras {\modulemarginstuff\relax} +\unexpanded\def\elements{\modulemarginstuff\someelement} \unexpanded\def\someelement#1{\type{<#1>}} -\definecomplexorsimpleempty\macros -\definecomplexorsimpleempty\extras -\definecomplexorsimpleempty\elements +% [index]{command} % \macros{a,b} % \macros{a,b}{b} @@ -344,10 +336,17 @@ % modes +\doifmode {nocode} { % \startmode ... \stopmode fails in the module documentation + + \unexpanded\def\startdefinition{\gobbleuntil\stopdefinition} + \unexpanded\def\stopdefinition {} + +} + \doifmode {nocolor} { - \setupcolors - [\c!conversion=\v!always] + \setupcolors + [\c!conversion=\v!always] } diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index ffc1f2434..b7418bd0b 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -17,7 +17,8 @@ \registerctxluafile{spac-ali}{1.001} -\definesystemattribute[realign][public] +\definesystemattribute[realign] [public] % might be combined with the next one +\definesystemattribute[alignstate][public] % will make a single attributes for several states \unexpanded\def\resetrealignsignal{\attribute\realignattribute\attributeunsetvalue} \unexpanded\def\signalinnerrealign{\ctxcommand{setrealign(2)}} @@ -318,6 +319,9 @@ \newconstant\raggedstatus % normal left center right +% \unexpanded\def\setalignstateattribute % unexpanded ! +% {\attribute\alignstateattribute\ifcase\raggedstatus\attributeunsetvalue\else\raggedstatus\fi} + \def\leftraggedness {2\bodyfontsize} \def\rightraggedness {2\bodyfontsize} \def\middleraggedness {6\bodyfontsize} @@ -368,6 +372,7 @@ \def\dosetraggedskips#1#2#3#4#5#6#7% {\raggedstatus#1\relax + \attribute\alignstateattribute\ifcase\raggedstatus\attributeunsetvalue\else\raggedstatus\fi \leftskip 1\leftskip \!!plus#2\relax % zie: Tex By Topic 8.1.3 \rightskip 1\rightskip\!!plus#3\relax % zie: Tex By Topic 8.1.3 \spaceskip #4\relax @@ -375,6 +380,10 @@ \parfillskip\zeropoint\!!plus#6\relax \parindent #7\relax} +\appendtoks + \attribute\alignstateattribute\attributeunsetvalue +\to \everyforgetall + % \def\notragged% % {\setraggedskips{0}{0em}{0em}{0em}{0em}{1fil}{\parindent}} diff --git a/tex/context/base/spac-chr.lua b/tex/context/base/spac-chr.lua index 9771ad2e8..add46c4d0 100644 --- a/tex/context/base/spac-chr.lua +++ b/tex/context/base/spac-chr.lua @@ -8,6 +8,9 @@ if not modules then modules = { } end modules ['spac-chr'] = { local byte, lower = string.byte, string.lower +-- to be redone: characters will become tagged spaces instead as then we keep track of +-- spaceskip etc + trace_characters = false trackers.register("typesetters.characters", function(v) trace_characters = v end) report_characters = logs.reporter("typesetting","characters") @@ -15,6 +18,7 @@ report_characters = logs.reporter("typesetting","characters") local nodes, node = nodes, node local set_attribute = node.set_attribute +local has_attribute = node.has_attribute local insert_node_after = node.insert_after local remove_node = nodes.remove -- ! nodes @@ -25,7 +29,11 @@ local new_penalty = nodepool.penalty local new_glue = nodepool.glue local nodecodes = nodes.nodecodes +local skipcodes = nodes.skipcodes local glyph_code = nodecodes.glyph +local glue_code = nodecodes.glue + +local space_skip_code = skipcodes["spaceskip"] local chardata = characters.data @@ -38,6 +46,7 @@ local fontparameters = fonts.hashes.parameters local fontcharacters = fonts.hashes.characters local a_character = attributes.private("characters") +local a_alignstate = attributes.private("alignstate") local c_zero = byte('0') local c_period = byte('.') @@ -64,6 +73,7 @@ end local function inject_nobreak_space(unicode,head,current,space,spacestretch,spaceshrink) local attr = current.attr + local next = current.next head, current = insert_node_after(head,current,new_penalty(10000)) head, current = insert_node_after(head,current,new_glue(space,spacestretch,spaceshrink)) current.attr = attr @@ -73,9 +83,18 @@ end local methods = { - [0x00A0] = function(head,current) -- nobreakspace + -- The next one uses an attribute assigned to the character but still we + -- don't have the 'local' value. + + [0x00A0] = function(head,current) local para = fontparameters[current.font] - return inject_nobreak_space(0x00A0,head,current,para.space,para.spacestretch,para.spaceshrink) + if has_attribute(current,a_alignstate) == 1 then -- flushright + head, current = inject_nobreak_space(0x00A0,head,current,para.space,0,0) + current.subtype = space_skip_code + else + head, current = inject_nobreak_space(0x00A0,head,current,para.space,para.spacestretch,para.spaceshrink) + end + return head, current end, [0x2000] = function(head,current) -- enquad @@ -145,7 +164,8 @@ function characters.handler(head) local done = false while current do local next = current.next - if current.id == glyph_code then + local id = current.id + if id == glyph_code then local char = current.char local method = methods[char] if method then diff --git a/tex/context/base/spac-chr.mkiv b/tex/context/base/spac-chr.mkiv index 1e7943ea1..e2ed12522 100644 --- a/tex/context/base/spac-chr.mkiv +++ b/tex/context/base/spac-chr.mkiv @@ -19,8 +19,44 @@ \definesystemattribute[characters][public] -\edef\nobreakspace {\utfchar{"00A0}} +%D The nobreakspace is special as it needs to keep track of the space being +%D flexible. Another option is to use space (glue) nodes and tag them as characters +%D instead. No big deal but takes a moment of coding. So, as a prelude we +%D tag the nobreakspace only. Interesting is that it also fits better in the +%D tagging mechanism. +%D +%D But we need to do some checking as from then on we no longer can compare +%D them in a string. So this needs thinking. Not that we can compare the +%D nobreakspace now anyway. + +% \unexpanded\def\specialspacecharacter#1{\begingroup\attribute\charactersattribute#1\ \endgroup} +% +% \unexpanded\edef\nobreakspace {\specialspacecharacter{"00A0}} % 1 = left +% \unexpanded\edef\ideographicspace {\specialspacecharacter{"2000}} +% \unexpanded\edef\ideographichalffillspace{\specialspacecharacter{"2001}} +% \unexpanded\edef\twoperemspace {\specialspacecharacter{"2002}} +% \unexpanded\edef\threeperemspace {\specialspacecharacter{"2004}} +% \unexpanded\edef\fourperemspace {\specialspacecharacter{"2005}} +% \unexpanded\edef\sixperemspace {\specialspacecharacter{"2006}} +% \unexpanded\edef\figurespace {\specialspacecharacter{"2007}} +% \unexpanded\edef\punctuationspace {\specialspacecharacter{"2008}} +% \unexpanded\edef\breakablethinspace {\specialspacecharacter{"2009}} +% \unexpanded\edef\hairspace {\specialspacecharacter{"200A}} +% \unexpanded\edef\zerowidthspace {\specialspacecharacter{"200B}} +% \unexpanded\edef\zwnj {\specialspacecharacter{"200C}} +% \unexpanded\edef\zwj {\specialspacecharacter{"200D}} +% \unexpanded\edef\narrownobreakspace {\specialspacecharacter{"202F}} + +% This does not work as spaceskip is only inserted in the case of raggedleft +% and we need to be able to figure out all of them. Which makes me wonder ... +% can't we just always set spaceskip to some value? + +% Making them active is also not an option unless we do that in every +% catcode vector. + +% \nobreakspace {\begingroup\setalignstateattribute\utfchar{"00A0}\endgroup} % 1 = left +\edef\nobreakspace {\utfchar{"00A0}} \edef\ideographicspace {\utfchar{"2000}} \edef\ideographichalffillspace{\utfchar{"2001}} \edef\twoperemspace {\utfchar{"2002}} @@ -34,7 +70,6 @@ \edef\zerowidthspace {\utfchar{"200B}} \edef\zwnj {\utfchar{"200C}} \edef\zwj {\utfchar{"200D}} - \edef\narrownobreakspace {\utfchar{"202F}} %edef\zerowidthnobreakspace {\utfchar{"FEFF}} @@ -45,7 +80,7 @@ % unexpanded as otherwise we need to intercept / cleanup a lot -\unexpanded\edef~{\utfchar{"00A0}} +\unexpanded\def~{\nobreakspace} % Goodies: diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv index 88374e497..e3496e923 100644 --- a/tex/context/base/spac-hor.mkiv +++ b/tex/context/base/spac-hor.mkiv @@ -370,9 +370,9 @@ {\letcatcodecommand \ctxcatcodes \tildeasciicode \fixedspace} \appendtoks - \let~\space - \let\ \space -\to\simplifiedcommands + \let~\space + \let\ \space +\to \simplifiedcommands \unexpanded\def\removeunwantedspaces {\ifhmode diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 0d023d90e..f2006bb38 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 31d2db8db..5fb64b64f 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index 213caf30d..f141af982 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -1683,7 +1683,7 @@ end filters.section = { } -function filters.section.number(data,what,prefixspec) +local function filternumber(data,what,prefixspec) if data then local numberdata = data.numberdata if numberdata then @@ -1697,15 +1697,22 @@ function filters.section.number(data,what,prefixspec) end end +filters.section.number = filternumber filters.section.title = filters.generic.title filters.section.page = filters.generic.page filters.section.default = filters.section.number -filters.note = { default = filters.generic.number } -filters.formula = { default = filters.generic.number } -filters.float = { default = filters.generic.number } -filters.description = { default = filters.generic.number } -filters.item = { default = filters.generic.number } +-- filters.note = { default = filters.generic.number } +-- filters.formula = { default = filters.generic.number } +-- filters.float = { default = filters.generic.number } +-- filters.description = { default = filters.generic.number } +-- filters.item = { default = filters.generic.number } + +setmetatableindex(filters, function(t,k) + local v = { default = filternumber } -- not copy as it might be extended differently + t[k] = v + return v +end) -- function references.sectiontitle(n) -- helpers.sectiontitle(lists.collected[tonumber(n) or 0]) diff --git a/tex/context/base/supp-vis.mkiv b/tex/context/base/supp-vis.mkiv index 460020306..18f6262d2 100644 --- a/tex/context/base/supp-vis.mkiv +++ b/tex/context/base/supp-vis.mkiv @@ -232,8 +232,6 @@ \fi -\ifx\contextversion\undefined \def~{\normalpenalty\!!tenthousand\ } \fi - %D \macros %D {makeruledbox} %D diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 513d8761b..011e25e48 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -39,6 +39,9 @@ %D Some of the macros here are used in the bibliography module. They %D will be moved to a separate syst module some once the bib module %D is made \MKIV. +%D +%D The original files contain previous implementations and notes about +%D performance. This file will be stripped down in due time. \unprotect @@ -165,20 +168,20 @@ \let\@@expanded\empty % always long and global (less restores) -\long\def\expanded#1% - {\long\xdef\@@expanded{\noexpand#1}\@@expanded} +\def\expanded#1% + {\xdef\@@expanded{\noexpand#1}\@@expanded} -\long\def\startexpanded#1\stopexpanded % see x-fo for example - {\long\xdef\@@expanded{#1}\@@expanded} +\def\startexpanded#1\stopexpanded % see x-fo for example + {\xdef\@@expanded{#1}\@@expanded} %D Recent \TEX's have a primitive \expanded % not yet as we need to adapt ##'s in calls % -% \long\def\expanded#1% +% \def\expanded#1% % {\normalexpanded{\noexpand#1}} % -% \long\def\startexpanded#1\stopexpanded +% \def\startexpanded#1\stopexpanded % {\normalexpanded{#1}} %D \macros @@ -187,16 +190,16 @@ %D The next set of macros just do nothing, except that they %D get rid of a number of arguments. -\long\def\gobbleoneargument #1{} -\long\def\gobbletwoarguments #1#2{} -\long\def\gobblethreearguments#1#2#3{} -\long\def\gobblefourarguments #1#2#3#4{} -\long\def\gobblefivearguments #1#2#3#4#5{} -\long\def\gobblesixarguments #1#2#3#4#5#6{} -\long\def\gobblesevenarguments#1#2#3#4#5#6#7{} -\long\def\gobbleeightarguments#1#2#3#4#5#6#7#8{} -\long\def\gobbleninearguments #1#2#3#4#5#6#7#8#9{} -\long\def\gobbletenarguments #1{\gobbleninearguments} +\def\gobbleoneargument #1{} +\def\gobbletwoarguments #1#2{} +\def\gobblethreearguments#1#2#3{} +\def\gobblefourarguments #1#2#3#4{} +\def\gobblefivearguments #1#2#3#4#5{} +\def\gobblesixarguments #1#2#3#4#5#6{} +\def\gobblesevenarguments#1#2#3#4#5#6#7{} +\def\gobbleeightarguments#1#2#3#4#5#6#7#8{} +\def\gobbleninearguments #1#2#3#4#5#6#7#8#9{} +\def\gobbletenarguments #1{\gobbleninearguments} \def\gobbleoneoptional [#1]{} \def\gobbletwooptionals [#1][#2]{} @@ -229,7 +232,7 @@ %D {\localnext} because we don't want clashes with \type %D {\next}. -\long\def\doifnextcharelse#1#2#3% #1 should not be {} ! +\unexpanded\def\doifnextcharelse#1#2#3% #1 should not be {} ! {\let\charactertoken=#1% = needed here \def\!!stringa{#2}% \def\!!stringb{#3}% @@ -259,7 +262,7 @@ \let\next_optional_character_token=[ -\long\def\doifnextoptionalelse#1#2% +\unexpanded\def\doifnextoptionalelse#1#2% {\def\next_optional_command_yes{#1}% \def\next_optional_command_nop{#2}% \let\if_next_blank_space_token\iffalse @@ -281,7 +284,7 @@ \let\next_bgroup_character_token\bgroup -\long\def\doifnextbgroupelse#1#2% +\unexpanded\def\doifnextbgroupelse#1#2% {\def\next_bgroup_command_yes{#1}% \def\next_bgroup_command_nop{#2}% \let\if_next_blank_space_token\iffalse @@ -303,7 +306,7 @@ \let\next_parenthesis_character_token( -\long\def\doifnextparenthesiselse#1#2% +\unexpanded\def\doifnextparenthesiselse#1#2% {\def\next_parenthesis_command_yes{#1}% \def\next_parenthesis_command_nop{#2}% \let\if_next_blank_space_token\iffalse @@ -325,7 +328,7 @@ %D The next one is handy in predictable situations: -\long\def\doiffastoptionalcheckelse#1#2% +\unexpanded\def\doiffastoptionalcheckelse#1#2% {\def\next_optional_command_yes{#1}% \def\next_optional_command_nop{#2}% \let\if_next_blank_space_token\iffalse % not needed @@ -462,53 +465,27 @@ % % use a real if like \ifcsname#1\endcsname\else instead -\ifdefined\suppressifcsnameerror - - \suppressifcsnameerror\plusone - - \def\doifundefinedelse#1% - {\ifcsname#1\endcsname - \expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments - \fi} - - \def\doifdefinedelse#1% - {\ifcsname#1\endcsname - \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments - \fi} - - \def\doifundefined#1% - {\ifcsname#1\endcsname - \expandafter\gobbleoneargument\else\expandafter\firstofoneargument - \fi} - - \def\doifdefined#1% - {\ifcsname#1\endcsname - \expandafter\firstofoneargument\else\expandafter\gobbleoneargument - \fi} - -\else - - \def\doifundefinedelse#1% - {\ifcsname\detokenize\expandafter{\normalexpanded{#1}}\endcsname - \expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments - \fi} +\suppressifcsnameerror\plusone - \def\doifdefinedelse#1% - {\ifcsname\detokenize\expandafter{\normalexpanded{#1}}\endcsname - \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments - \fi} +\def\doifundefinedelse#1% + {\ifcsname#1\endcsname + \expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments + \fi} - \def\doifundefined#1% - {\ifcsname\detokenize\expandafter{\normalexpanded{#1}}\endcsname - \expandafter\gobbleoneargument\else\expandafter\firstofoneargument - \fi} +\def\doifdefinedelse#1% + {\ifcsname#1\endcsname + \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments + \fi} - \def\doifdefined#1% - {\ifcsname\detokenize\expandafter{\normalexpanded{#1}}\endcsname - \expandafter\firstofoneargument\else\expandafter\gobbleoneargument - \fi} +\def\doifundefined#1% + {\ifcsname#1\endcsname + \expandafter\gobbleoneargument\else\expandafter\firstofoneargument + \fi} -\fi +\def\doifdefined#1% + {\ifcsname#1\endcsname + \expandafter\firstofoneargument\else\expandafter\gobbleoneargument + \fi} %D \macros %D {letbeundefined} @@ -537,7 +514,7 @@ %D was due to this grouping subtilities. We therefore decided %D to use \type{\begingroup} instead of \type{\bgroup}. -\def\doifalldefinedelse#1% +\unexpanded\def\doifalldefinedelse#1% {\begingroup \donetrue \processcommalist[#1]\do_if_all_defined_else @@ -572,7 +549,7 @@ %D \doifelse {string1} {string2} {then ...}{else ...} %D \stoptyping -\long\def\doif#1#2% +\def\doif#1#2% {\edef\!!stringa{#1}% \edef\!!stringb{#2}% \ifx\!!stringa\!!stringb @@ -581,7 +558,7 @@ \expandafter\gobbleoneargument \fi} -\long\def\doifnot#1#2% +\def\doifnot#1#2% {\edef\!!stringa{#1}% \edef\!!stringb{#2}% \ifx\!!stringa\!!stringb @@ -590,7 +567,7 @@ \expandafter\firstofoneargument \fi} -\long\def\doifelse#1#2% +\def\doifelse#1#2% {\edef\!!stringa{#1}% \edef\!!stringb{#2}% \ifx\!!stringa\!!stringb @@ -612,7 +589,7 @@ %D %D This time, the string is not expanded. -\long\def\doifemptyelse#1% +\def\doifemptyelse#1% {\def\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\firstoftwoarguments @@ -620,7 +597,7 @@ \expandafter\secondoftwoarguments \fi} -\long\def\doifempty#1% +\def\doifempty#1% {\def\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\firstofoneargument @@ -628,7 +605,7 @@ \expandafter\gobbleoneargument \fi} -\long\def\doifnotempty#1% +\def\doifnotempty#1% {\def\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\gobbleoneargument @@ -678,15 +655,15 @@ \def\right_optional_bracket{]} -\long\def\do_quit_if_item_in_set_else#1],\relax{\firstoftwoarguments} -\long\def\do_quit_if_item_in_set #1],\relax{\firstofoneargument} -\long\def\do_quit_if_item_not_in_set #1],\relax{\gobbleoneargument} +\def\do_quit_if_item_in_set_else#1],\relax{\firstoftwoarguments} +\def\do_quit_if_item_in_set #1],\relax{\firstofoneargument} +\def\do_quit_if_item_not_in_set #1],\relax{\gobbleoneargument} -\long\def\re_do_if_in_set_else{\expandafter\do_check_if_item_in_set_else\!!stringb,],\relax} -\long\def\re_do_if_in_set {\expandafter\do_check_if_item_in_set \!!stringb,],\relax} -\long\def\re_do_if_not_in_set {\expandafter\do_check_if_item_not_in_set \!!stringb,],\relax} +\def\re_do_if_in_set_else{\expandafter\do_check_if_item_in_set_else\!!stringb,],\relax} +\def\re_do_if_in_set {\expandafter\do_check_if_item_in_set \!!stringb,],\relax} +\def\re_do_if_not_in_set {\expandafter\do_check_if_item_not_in_set \!!stringb,],\relax} -\long\def\doifinsetelse#1% make this two step too +\def\doifinsetelse#1% make this two step too {\edef\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\thirdofthreearguments @@ -694,7 +671,7 @@ \expandafter\do_if_in_set_else \fi} -\long\def\do_if_in_set_else#1% +\def\do_if_in_set_else#1% {\edef\!!stringb{#1}% \ifx\!!stringb\empty \expandafter\secondoftwoarguments @@ -702,7 +679,7 @@ \expandafter\re_do_if_in_set_else \fi} -\long\def\doifinset#1% +\def\doifinset#1% {\edef\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\gobbletwoarguments @@ -710,7 +687,7 @@ \expandafter\do_if_in_set \fi} -\long\def\do_if_in_set#1% +\def\do_if_in_set#1% {\edef\!!stringb{#1}% \ifx\!!stringb\empty \expandafter\gobbleoneargument @@ -718,7 +695,7 @@ \expandafter\re_do_if_in_set \fi} -\long\def\doifnotinset#1% +\def\doifnotinset#1% {\edef\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\secondoftwoarguments @@ -726,7 +703,7 @@ \expandafter\do_if_not_in_set \fi} -\long\def\do_if_not_in_set#1% +\def\do_if_not_in_set#1% {\edef\!!stringb{#1}% \ifx\!!stringb\empty \expandafter\firstofoneargument @@ -828,7 +805,7 @@ % !9yes=\doifcommonelse{,a,}{,,,a,}{yes}{nop} % !9yes=\doifcommonelse{,,a,}{,,,a,}{yes}{nop} -\long\def\do_quit_if_common_else#1],\relax#2],\relax{\firstoftwoarguments} +\def\do_quit_if_common_else#1],\relax#2],\relax{\firstoftwoarguments} \def\do_check_if_common_else_one#1,#2% {\edef\!!stringc{#1}% @@ -953,7 +930,7 @@ \def\do_process_comma_list#1]#2% {\global\advance\commalevel \plusone - \long\expandafter\def\csname\s!next\the\commalevel\endcsname##1,% + \expandafter\def\csname\s!next\the\commalevel\endcsname##1,% {#2{##1}\do_process_comma_item}% \expandafter\do_do_process_comma_item\gobbleoneargument#1,]\relax \global\advance\commalevel \minusone } @@ -1027,7 +1004,7 @@ %D \def\command[#1]{... #1 ...} %D \stoptyping -\def\processcommalistwithparameters[#1]#2% +\unexpanded\def\processcommalistwithparameters[#1]#2% {\def\do_process_comma_list_with_parameters##1{#2[##1]}% \processcommalist[#1]\do_process_comma_list_with_parameters} @@ -1036,12 +1013,12 @@ %D %D Two more: -\long\unexpanded\def\startprocesscommalist[#1]#2\stopprocesscommalist - {\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}% +\unexpanded\def\startprocesscommalist[#1]#2\stopprocesscommalist + {\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}% \processcommalist[#1]\currentcommalistcommand} -\long\unexpanded\def\startprocesscommacommand[#1]#2\stopprocesscommacommand - {\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}% +\unexpanded\def\startprocesscommacommand[#1]#2\stopprocesscommacommand + {\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}% \normalexpanded{\processcommalist[#1]}\currentcommalistcommand} %D \macros @@ -1189,7 +1166,7 @@ {#1% \let\nexttoken#4% \global\advance\commalevel \plusone - \long\expandafter\def\csname\s!next\the\commalevel\endcsname##1,% + \expandafter\def\csname\s!next\the\commalevel\endcsname##1,% {#3{##1}\do_process_comma_item}% \do_do_process_comma_item#4#5,]\relax \global\advance\commalevel\minusone @@ -1271,7 +1248,7 @@ % replaces prev \unexpanded\def\do_if_in_string_else#1#2% ##2 can be {abc} - {\long\expandafter\def\expandafter\do_do_if_in_string_else + {\expandafter\def\expandafter\do_do_if_in_string_else \expandafter##\expandafter1#1##2##3\war{\unless\if##2@}% expand #1 here \expandafter\do_do_if_in_string_else\normalexpanded{#2#1}@@\war} % expand #2 here @@ -1289,7 +1266,7 @@ %D expansion. \unexpanded\def\do_if_in_csname_else#1#2% - {\long\def\do_do_if_in_csname_else##1#1##2##3\war + {\def\do_do_if_in_csname_else##1#1##2##3\war {\unless\if##2@}% \expandafter\do_do_if_in_csname_else#2#1@@\war} @@ -1317,7 +1294,7 @@ %D \type{\getal} and \type{\the\count...}. This macro is a %D rather dirty one. -\long\def\doifnumberelse#1% does not accept counters (fully expandable) +\def\doifnumberelse#1% does not accept counters (fully expandable) {\ifcase0\ifcase1#1\or\or\or\or\or\or\or\or\or\else1\fi\space \expandafter\secondoftwoarguments \else @@ -1621,7 +1598,7 @@ \def\xdogetparameters#1]% {\xprocesscommaitem#1,],\@relax@} -\long\def\xprocesscommaitem#1,#2% #2 takes space before , +\def\xprocesscommaitem#1,#2% #2 takes space before , {\if,#1,% dirty trick for testing #1=empty \expandafter\xprocesscommaitem \else\if]#1% @@ -1686,12 +1663,12 @@ \unexpanded\def\processassignmentcommand[#1]% {\normalexpanded{\processassignmentlist[#1]}} -\long\unexpanded\def\startprocessassignmentlist[#1]#2\stopprocessassignmentlist - {\long\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}% +\unexpanded\def\startprocessassignmentlist[#1]#2\stopprocessassignmentlist + {\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}% \processassignmentlist[#1]\currentassignmentlistcommand} -\long\unexpanded\def\startprocessassignmentcommand[#1]#2\stopprocessassignmentcommand - {\long\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}% +\unexpanded\def\startprocessassignmentcommand[#1]#2\stopprocessassignmentcommand + {\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}% \normalexpanded{\processassignmentlist[#1]}\currentassignmentlistcommand} %D \macros{currentvalue} @@ -1791,7 +1768,7 @@ %D By using \type{\docopyvalue} we've prepared this command %D for use in a multi||lingual environment. -\def\copyparameters[#1]#2[#3]#4[#5]% +\unexpanded\def\copyparameters[#1]#2[#3]#4[#5]% {\doifnot{#1}{#3} {\def\docopyparameter{\docopyvalue{#1}{#3}}% ##1 \processcommalist[#5]\docopyparameter}} @@ -2045,169 +2022,6 @@ \def\noshowargumenterror {\let\expectedarguments\noexpectedarguments} -% \long\def\dogetargument#1#2#3#4% -% {\let\charactertoken=#1% -% \def\!!stringa{\noshowargumenterror#3\dodogetargument}% -% \def\!!stringb{\doshowargumenterror#4\dodogetargument#1#2}% -% \futurelet\nexttoken\inspect_next_character} - -% \def\getsingleempty#1#2#3% -% {\def\dodogetargument% -% {#3}% -% \dogetargument#1#2\firstargumenttrue\firstargumentfalse} - -% \def\getdoubleempty#1#2#3% -% {\def\dodogetargument#1##1#2% -% {\def\dodogetargument% -% {#3#1{##1}#2}% -% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}% -% \dogetargument#1#2\firstargumenttrue\firstargumentfalse} - -% \def\gettripleempty#1#2#3% -% {\def\dodogetargument#1##1#2% -% {\def\dodogetargument#1####1#2% -% {\def\dodogetargument% -% {#3#1{##1}#2% -% #1{####1}#2}% -% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}% -% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}% -% \dogetargument#1#2\firstargumenttrue\firstargumentfalse} - -% \def\getquadrupleempty#1#2#3% -% {\def\dodogetargument#1##1#2% -% {\def\dodogetargument#1####1#2% -% {\def\dodogetargument#1########1#2% -% {\def\dodogetargument% -% {#3#1{##1}#2% -% #1{####1}#2% -% #1{########1}#2}% -% \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}% -% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}% -% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}% -% \dogetargument#1#2\firstargumenttrue\firstargumentfalse} - -% \def\getquintupleempty#1#2#3% -% {\def\dodogetargument#1##1#2% -% {\def\dodogetargument#1####1#2% -% {\def\dodogetargument#1########1#2% -% {\def\dodogetargument#1################1#2% -% {\def\dodogetargument% -% {#3#1{##1}#2% -% #1{####1}#2% -% #1{########1}#2% -% #1{################1}#2}% -% \dogetargument#1#2\fifthargumenttrue\fifthargumentfalse}% -% \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}% -% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}% -% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}% -% \dogetargument#1#2\firstargumenttrue\firstargumentfalse} - -% \def\getsixtupleempty#1#2#3% -% {\def\dodogetargument#1##1#2% -% {\def\dodogetargument#1####1#2% -% {\def\dodogetargument#1########1#2% -% {\def\dodogetargument#1################1#2% -% {\def\dodogetargument#1################################1#2% -% {\def\dodogetargument% -% {#3#1{##1}#2% -% #1{####1}#2% -% #1{########1}#2% -% #1{################1}#2% -% #1{################################1}#2}% -% \dogetargument#1#2\sixthargumenttrue\sixthargumentfalse}% -% \dogetargument#1#2\fifthargumenttrue\fifthargumentfalse}% -% \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}% -% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}% -% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}% -% \dogetargument#1#2\firstargumenttrue\firstargumentfalse} - -% \def\getseventupleempty#1#2#3% -% {\def\dodogetargument#1##1#2% -% {\def\dodogetargument#1####1#2% -% {\def\dodogetargument#1########1#2% -% {\def\dodogetargument#1################1#2% -% {\def\dodogetargument#1################################1#2% -% {\def\dodogetargument#1################################% -% ################################1#2% -% {\def\dodogetargument% -% {#3#1{##1}#2% -% #1{####1}#2% -% #1{########1}#2% -% #1{################1}#2% -% #1{################################1}#2% -% #1{################################% -% ################################1}#2}% -% \dogetargument#1#2\seventhargumenttrue\seventhargumentfalse}% -% \dogetargument#1#2\sixthargumenttrue\sixthargumentfalse}% -% \dogetargument#1#2\fifthargumenttrue\fifthargumentfalse}% -% \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}% -% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}% -% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}% -% \dogetargument#1#2\firstargumenttrue\firstargumentfalse} - -% \def\dosingleempty {\getsingleempty []} -% \def\dodoubleempty {\getdoubleempty []} -% \def\dotripleempty {\gettripleempty []} -% \def\doquadrupleempty {\getquadrupleempty []} -% \def\doquintupleempty {\getquintupleempty []} -% \def\dosixtupleempty {\getsixtupleempty []} -% \def\doseventupleempty{\getseventupleempty[]} - -%D Because some of these are called quite often, we will now -%D replace the more general version by alternatives tuned for -%D speed. - -% \def\dosingleempty#1% we can make dedicated doifnextoptional's -% {\noshowargumenterror % \relax % prevents lookahead, brr -% \doifnextoptionalelse -% {\firstargumenttrue#1}% -% {\dosinglefakeempty#1}} -% -% \def\dosinglefakeempty#1% -% {\firstargumentfalse#1[]} -% -% \def\dodoubleempty#1% -% {\noshowargumenterror % \relax % prevents lookahead, brr -% \doifnextoptionalelse -% {\dodoubletestempty#1}% -% {\dodoublefakeempty#1}} -% -% \def\dodoublefakeempty#1% -% {\firstargumentfalse\secondargumentfalse#1[][]} -% -% \long\def\dodoubletestempty#1[#2]% -% {\firstargumenttrue -% \doifnextoptionalelse -% {\secondargumenttrue #1[{#2}]}% -% {\secondargumentfalse#1[{#2}][]}} -% -% \def\dotripleempty#1% -% {\noshowargumenterror % \relax % prevents lookahead, brr -% \doifnextoptionalelse -% {\dotripletestempty#1}% -% {\dotriplefakeempty#1}} -% -% \def\dotriplefakeempty#1% -% {\firstargumentfalse\secondargumentfalse\thirdargumentfalse#1[][][]} -% -% \long\def\dotripletestempty#1[#2]% -% {\firstargumenttrue -% \doifnextoptionalelse -% {\dotripletestemptyx #1[{#2}]}% -% {\secondargumentfalse -% \thirdargumentfalse #1[{#2}][][]}} -% -% \long\def\dotripletestemptyx#1[#2][#3]% -% {\secondargumenttrue -% \doifnextoptionalelse -% {\thirdargumenttrue #1[{#2}][{#3}]}% -% {\thirdargumentfalse#1[{#2}][{#3}][]}} - -%D We can obey following spaces with a bit more code. - -% 0.172 0.187 new (per 10000) -% 0.156 0.140 old (per 10000) -% % \def\test[#1]{(#1)} % % \dosingleempty\test[] xxx\par @@ -2228,7 +2042,7 @@ %D Single: -\def\dosingleempty#1% +\unexpanded\def\dosingleempty#1% {\noshowargumenterror \doifnextoptionalelse {\firstargumenttrue#1}% @@ -2240,13 +2054,13 @@ %D Double -\def\dodoubleempty#1% +\unexpanded\def\dodoubleempty#1% {\noshowargumenterror \doifnextoptionalelse {\dodoubleemptyYESone#1}% {\dodoubleemptyNOPone#1}} -\long\def\dodoubleemptyYESone#1[#2]% +\def\dodoubleemptyYESone#1[#2]% {\firstargumenttrue \doifnextoptionalelse {\secondargumenttrue#1[{#2}]}% @@ -2270,19 +2084,19 @@ % Three -\def\dotripleempty#1% +\unexpanded\def\dotripleempty#1% {\noshowargumenterror \doifnextoptionalelse {\dotripleemptyYESone#1}% {\dotripleemptyNOPone#1}} -\long\def\dotripleemptyYESone#1[#2]% +\def\dotripleemptyYESone#1[#2]% {\firstargumenttrue \doifnextoptionalelse {\dotripleemptyYEStwo#1{#2}}% {\dotripleemptyNOPtwo#1{#2}}} -\long\def\dotripleemptyYEStwo#1#2[#3]% +\def\dotripleemptyYEStwo#1#2[#3]% {\secondargumenttrue \doifnextoptionalelse {\thirdargumenttrue#1[{#2}][{#3}]}% @@ -2318,25 +2132,25 @@ %D Four: -\def\doquadrupleempty#1% +\unexpanded\def\doquadrupleempty#1% {\noshowargumenterror \doifnextoptionalelse {\doquadrupleemptyYESone#1}% {\doquadrupleemptyNOPone#1}} -\long\def\doquadrupleemptyYESone#1[#2]% +\def\doquadrupleemptyYESone#1[#2]% {\firstargumenttrue \doifnextoptionalelse {\doquadrupleemptyYEStwo#1{#2}}% {\doquadrupleemptyNOPtwo#1{#2}}} -\long\def\doquadrupleemptyYEStwo#1#2[#3]% +\def\doquadrupleemptyYEStwo#1#2[#3]% {\secondargumenttrue \doifnextoptionalelse {\doquadrupleemptyYESthree#1{#2}{#3}}% {\doquadrupleemptyNOPthree#1{#2}{#3}}} -\long\def\doquadrupleemptyYESthree#1#2#3[#4]% +\def\doquadrupleemptyYESthree#1#2#3[#4]% {\thirdargumenttrue \doifnextoptionalelse {\fourthargumenttrue#1[{#2}][{#3}][{#4}]}% @@ -2385,31 +2199,31 @@ %D Five: -\def\doquintupleempty#1% +\unexpanded\def\doquintupleempty#1% {\noshowargumenterror \doifnextoptionalelse {\doquintupleemptyYESone#1}% {\doquintupleemptyNOPone#1}} -\long\def\doquintupleemptyYESone#1[#2]% +\def\doquintupleemptyYESone#1[#2]% {\firstargumenttrue \doifnextoptionalelse {\doquintupleemptyYEStwo#1{#2}}% {\doquintupleemptyNOPtwo#1{#2}}} -\long\def\doquintupleemptyYEStwo#1#2[#3]% +\def\doquintupleemptyYEStwo#1#2[#3]% {\secondargumenttrue \doifnextoptionalelse {\doquintupleemptyYESthree#1{#2}{#3}}% {\doquintupleemptyNOPthree#1{#2}{#3}}} -\long\def\doquintupleemptyYESthree#1#2#3[#4]% +\def\doquintupleemptyYESthree#1#2#3[#4]% {\thirdargumenttrue \doifnextoptionalelse {\doquintupleemptyYESfour#1{#2}{#3}{#4}}% {\doquintupleemptyNOPfour#1{#2}{#3}{#4}}} -\long\def\doquintupleemptyYESfour#1#2#3#4[#5]% +\def\doquintupleemptyYESfour#1#2#3#4[#5]% {\fourthargumenttrue \doifnextoptionalelse {\fifthargumenttrue#1[{#2}][{#3}][{#4}][{#5}]}% @@ -2472,37 +2286,37 @@ %D Six -\def\dosixtupleempty#1% +\unexpanded\def\dosixtupleempty#1% {\noshowargumenterror \doifnextoptionalelse {\dosixtupleemptyYESone#1} {\dosixtupleemptyNOPone#1}} -\long\def\dosixtupleemptyYESone#1[#2]% +\def\dosixtupleemptyYESone#1[#2]% {\firstargumenttrue \doifnextoptionalelse {\dosixtupleemptyYEStwo#1{#2}}% {\dosixtupleemptyNOPtwo#1{#2}}} -\long\def\dosixtupleemptyYEStwo#1#2[#3]% +\def\dosixtupleemptyYEStwo#1#2[#3]% {\secondargumenttrue \doifnextoptionalelse {\dosixtupleemptyYESthree#1{#2}{#3}}% {\dosixtupleemptyNOPthree#1{#2}{#3}}} -\long\def\dosixtupleemptyYESthree#1#2#3[#4]% +\def\dosixtupleemptyYESthree#1#2#3[#4]% {\thirdargumenttrue \doifnextoptionalelse {\dosixtupleemptyYESfour#1{#2}{#3}{#4}}% {\dosixtupleemptyNOPfour#1{#2}{#3}{#4}}} -\long\def\dosixtupleemptyYESfour#1#2#3#4[#5]% +\def\dosixtupleemptyYESfour#1#2#3#4[#5]% {\fourthargumenttrue \doifnextoptionalelse {\dosixtupleemptyYESfive#1{#2}{#3}{#4}{#5}}% {\dosixtupleemptyNOPfive#1{#2}{#3}{#4}{#5}}} -\long\def\dosixtupleemptyYESfive#1#2#3#4#5[#6]% +\def\dosixtupleemptyYESfive#1#2#3#4#5[#6]% {\fifthargumenttrue \doifnextoptionalelse {\sixthargumenttrue#1[{#2}][{#3}][{#4}][{#5}][{#6}]}% @@ -2580,43 +2394,43 @@ %D Seven: -\def\doseventupleempty#1% +\unexpanded\def\doseventupleempty#1% {\noshowargumenterror \doifnextoptionalelse {\doseventupleemptyYESone#1}% {\doseventupleemptyNOPone#1}} -\long\def\doseventupleemptyYESone#1[#2]% +\def\doseventupleemptyYESone#1[#2]% {\firstargumenttrue \doifnextoptionalelse {\doseventupleemptyYEStwo#1{#2}}% {\doseventupleemptyNOPtwo#1{#2}}} -\long\def\doseventupleemptyYEStwo#1#2[#3]% +\def\doseventupleemptyYEStwo#1#2[#3]% {\secondargumenttrue \doifnextoptionalelse {\doseventupleemptyYESthree#1{#2}{#3}}% {\doseventupleemptyNOPthree#1{#2}{#3}}} -\long\def\doseventupleemptyYESthree#1#2#3[#4]% +\def\doseventupleemptyYESthree#1#2#3[#4]% {\thirdargumenttrue \doifnextoptionalelse {\doseventupleemptyYESfour#1{#2}{#3}{#4}}% {\doseventupleemptyNOPfour#1{#2}{#3}{#4}}} -\long\def\doseventupleemptyYESfour#1#2#3#4[#5]% +\def\doseventupleemptyYESfour#1#2#3#4[#5]% {\fourthargumenttrue \doifnextoptionalelse {\doseventupleemptyYESfive#1{#2}{#3}{#4}{#5}}% {\doseventupleemptyNOPfive#1{#2}{#3}{#4}{#5}}} -\long\def\doseventupleemptyYESfive#1#2#3#4#5[#6]% +\def\doseventupleemptyYESfive#1#2#3#4#5[#6]% {\fifthargumenttrue \doifnextoptionalelse {\doseventupleemptyYESsix#1{#2}{#3}{#4}{#5}{#6}}% {\doseventupleemptyNOPsix#1{#2}{#3}{#4}{#5}{#6}}} -\long\def\doseventupleemptyYESsix#1#2#3#4#5#6[#7]% +\def\doseventupleemptyYESsix#1#2#3#4#5#6[#7]% {\sixthargumenttrue \doifnextoptionalelse {\seventhargumenttrue#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}]}% @@ -2764,13 +2578,13 @@ %D but changed into more versatile (more object oriented) ones %D using the \type{\get..argument} commands. -\def\complexorsimple#1% +\unexpanded\def\complexorsimple#1% {% \relax % prevents lookahead, brrr \doifnextoptionalelse {\firstargumenttrue \csname\s!complex\strippedcsname#1\endcsname} {\firstargumentfalse\csname\s!simple \strippedcsname#1\endcsname}} -\def\complexorsimpleempty#1% +\unexpanded\def\complexorsimpleempty#1% {% \relax % prevents lookahead, brrr \doifnextoptionalelse {\firstargumenttrue \csname\s!complex\strippedcsname#1\endcsname} @@ -2961,32 +2775,32 @@ %D used to select arguments. Their names explain their %D functionality. -\long\def\firstofoneargument #1{#1} +\def\firstofoneargument #1{#1} -\long\def\firstoftwoarguments #1#2{#1} -\long\def\secondoftwoarguments #1#2{#2} +\def\firstoftwoarguments #1#2{#1} +\def\secondoftwoarguments #1#2{#2} -\long\def\firstofthreearguments #1#2#3{#1} -\long\def\secondofthreearguments #1#2#3{#2} -\long\def\thirdofthreearguments #1#2#3{#3} +\def\firstofthreearguments #1#2#3{#1} +\def\secondofthreearguments #1#2#3{#2} +\def\thirdofthreearguments #1#2#3{#3} -\long\def\firstoffourarguments #1#2#3#4{#1} -\long\def\secondoffourarguments #1#2#3#4{#2} -\long\def\thirdoffourarguments #1#2#3#4{#3} -\long\def\fourthoffourarguments #1#2#3#4{#4} +\def\firstoffourarguments #1#2#3#4{#1} +\def\secondoffourarguments #1#2#3#4{#2} +\def\thirdoffourarguments #1#2#3#4{#3} +\def\fourthoffourarguments #1#2#3#4{#4} -\long\def\firstoffivearguments #1#2#3#4#5{#1} -\long\def\secondoffivearguments #1#2#3#4#5{#2} -\long\def\thirdoffivearguments #1#2#3#4#5{#3} -\long\def\fourthoffivearguments #1#2#3#4#5{#4} -\long\def\fifthoffivearguments #1#2#3#4#5{#5} +\def\firstoffivearguments #1#2#3#4#5{#1} +\def\secondoffivearguments #1#2#3#4#5{#2} +\def\thirdoffivearguments #1#2#3#4#5{#3} +\def\fourthoffivearguments #1#2#3#4#5{#4} +\def\fifthoffivearguments #1#2#3#4#5{#5} -\long\def\firstofsixarguments #1#2#3#4#5#6{#1} -\long\def\secondofsixarguments#1#2#3#4#5#6{#2} -\long\def\thirdofsixarguments #1#2#3#4#5#6{#3} -\long\def\fourthofsixarguments#1#2#3#4#5#6{#4} -\long\def\fifthofsixarguments #1#2#3#4#5#6{#5} -\long\def\sixthofsixarguments #1#2#3#4#5#6{#6} +\def\firstofsixarguments #1#2#3#4#5#6{#1} +\def\secondofsixarguments#1#2#3#4#5#6{#2} +\def\thirdofsixarguments #1#2#3#4#5#6{#3} +\def\fourthofsixarguments#1#2#3#4#5#6{#4} +\def\fifthofsixarguments #1#2#3#4#5#6{#5} +\def\sixthofsixarguments #1#2#3#4#5#6{#6} %D \macros %D {globalletempty,letempty, @@ -3558,9 +3372,9 @@ \def\@@irecurse{@@ir@@} % ecurse} % stepper \def\@@arecurse{@@ar@@} % ecurse} % action -\long\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 +\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 {\global\advance\outerrecurse \plusone - \long\global\expandafter\def\csname\@@arecurse\recursedepth\endcsname{#4}% + \global\expandafter\def\csname\@@arecurse\recursedepth\endcsname{#4}% \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \ifnum#3>0\relax \ifnum#2<#1\relax @@ -3580,7 +3394,7 @@ \fi \fi\normalexpanded{\nextrecurse{\number#1}{\number#2}{\number#3}}} -\long\def\dodostepwiserecurse#1#2#3% from to step +\def\dodostepwiserecurse#1#2#3% from to step {\ifnum#1>#2\relax \expandafter\nodostepwiserecurse \else @@ -3594,7 +3408,7 @@ \unexpanded\def\redostepwiserecurse {\expandrecursecontent\dodostepwiserecurse} -\long\unexpanded\def\dodostepwisereverse#1#2#3% from to step +\unexpanded\def\dodostepwisereverse#1#2#3% from to step {\ifnum#1<#2\relax \expandafter\nodostepwiserecurse \else @@ -3640,7 +3454,7 @@ %D Because the simple case is used often, we implement it %D more efficiently: -\long\unexpanded\def\dorecurse#1% +\unexpanded\def\dorecurse#1% {\ifcase#1\relax \expandafter\gobbletwoarguments \or @@ -3649,13 +3463,13 @@ \expandafter\xdorecurse \fi{#1}} -\long\unexpanded\def\xdorecurse#1#2% +\unexpanded\def\xdorecurse#1#2% {\global\advance\outerrecurse \plusone - \long\expandafter\gdef\csname\@@arecurse\recursedepth\endcsname{#2}% + \expandafter\gdef\csname\@@arecurse\recursedepth\endcsname{#2}% \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \expandafter\dodorecurse\expandafter1\expandafter{\number#1}} -\long\unexpanded\def\ydorecurse#1#2% +\unexpanded\def\ydorecurse#1#2% {\global\advance\outerrecurse \plusone \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \let\recurselevel\!!plusone @@ -3663,7 +3477,7 @@ \expandafter\let\expandafter\recurselevel\csname\@@irecurse\recursedepth\endcsname \global\advance\outerrecurse \minusone} -\long\unexpanded\def\dodorecurse#1#2% from to +\unexpanded\def\dodorecurse#1#2% from to {\ifnum#1>#2\relax \expandafter\nodorecurse \else @@ -3671,7 +3485,7 @@ \doubleexpandafter\redorecurse \fi\expandafter{\the\numexpr\recurselevel+\plusone\relax}{#2}} -\long\unexpanded\def\dodorecurse#1#2% from to +\unexpanded\def\dodorecurse#1#2% from to {\ifnum#1>#2\relax \expandafter\nodorecurse \else @@ -3707,14 +3521,14 @@ \let\endofloop\donothing -\unexpanded\long\def\doloop#1% +\unexpanded\def\doloop#1% {\global\advance\outerrecurse \plusone - \long\expandafter\gdef\csname\@@arecurse\recursedepth\endcsname{#1}% + \expandafter\gdef\csname\@@arecurse\recursedepth\endcsname{#1}% \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \let\endofloop\dodoloop \dodoloop1} % no \plusone else \recurselevel wrong -\unexpanded\long\def\dodoloop#1% +\unexpanded\def\dodoloop#1% {\def\recurselevel{#1}% \expandafter\redoloop\expandafter{\the\numexpr\recurselevel+\plusone\relax}} @@ -3729,7 +3543,7 @@ \unexpanded\def\exitloop % \exitloop quits at end {\let\endofloop\nodoloop} -\long\unexpanded\def\exitloopnow#1\endofloop % \exitloopnow quits directly +\unexpanded\def\exitloopnow#1\endofloop % \exitloopnow quits directly {\nodoloop} %D The loop is executed at least once, so beware of situations @@ -3774,24 +3588,24 @@ {\csname\@@arecurse\recursedepth\expandafter\expandafter\expandafter\endcsname \expandafter\expandafter\expandafter{\expandafter\recurselevel\expandafter}\expandafter{\recursedepth}} -\long\unexpanded\def\xdorecurse#1#2% +\unexpanded\def\xdorecurse#1#2% {\global\advance\outerrecurse \plusone - \long\global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#2}% + \global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#2}% \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \expandafter\dodorecurse\expandafter1\expandafter{\number#1}} -\long\unexpanded\def\ydorecurse#1#2% +\unexpanded\def\ydorecurse#1#2% {\global\advance\outerrecurse \plusone \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \let\recurselevel\!!plusone - \long\global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#2}% + \global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#2}% \expandrecursecontent \expandafter\let\expandafter\recurselevel\csname\@@irecurse\recursedepth\endcsname \global\advance\outerrecurse \minusone} -\long\unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 +\unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 {\global\advance\outerrecurse \plusone - \long\global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#4}% + \global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#4}% \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \ifnum#3>0\relax \ifnum#2<#1\relax @@ -3811,45 +3625,18 @@ \fi \fi\normalexpanded{\nextrecurse{\number#1}{\number#2}{\number#3}}} -\long\unexpanded\def\doloop#1% +\unexpanded\def\doloop#1% {\global\advance\outerrecurse \plusone - \long\global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#1}% + \global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#1}% \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \let\endofloop\dodoloop \dodoloop1} % no \plusone else \recurselevel wrong -% EXPERIMENT - % faster -% \long\unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 -% {\global\advance\outerrecurse \plusone -% \long\global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#4}% -% \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel -% \ifnum#3>\zerocount -% \ifnum#2<#1\relax -% \let\nextrecurse\exitstepwiserecurse -% \else -% \let\nextrecurse\dodostepwiserecurse -% \fi -% \else -% \ifnum#3<\zerocount -% \ifnum#1<#2\relax -% \let\nextrecurse\exitstepwiserecurse -% \else -% \let\nextrecurse\dodostepwisereverse -% \fi -% \else -% \let\nextrecurse\exitstepwiserecurse -% \fi -% \fi -% \normalexpanded{\nextrecurse{\number#1}{\number#2}{\number#3}}} - -% slightly faster - -\long\unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 +\unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 {\global\advance\outerrecurse \plusone - \long\global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#4}% + \global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#4}% \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \csname @swr% \ifnum#3>\zerocount @@ -3865,9 +3652,9 @@ % quite okay too, but untested % -% \long\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 +% \def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 % {\global\advance\outerrecurse \plusone -% \long\global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#4}% +% \global\expandafter\def\csname\@@arecurse\recursedepth\endcsname##1##2{#4}% % \global\expandafter\let\csname\@@irecurse\recursedepth\endcsname\recurselevel % \normalexpanded % {\ifnum#3>\zerocount @@ -3950,30 +3737,6 @@ \expandafter\let\expandafter\recursestring\csname\@@irecurse\recursedepth\endcsname \global\advance\outerrecurse\minusone} -% D This alternative looks a bit different and uses a -% D pseudo counter. When this macro is nested, we have to use -% D different counters. This time we use keywords. -% D -% D \starttyping -% D \def\alfa{2} \def\beta{100} \def\gamma{3} -% D -% D \for \n=55 \to 100 \step 1 \do {... \n ...} -% D \for \n=\alfa \to \beta \step \gamma \do {... \n ...} -% D \for \n=\n \to 120 \step 1 \do {... \n ...} -% D \for \n=120 \to 100 \step -3 \do {... \n ...} -% D \for \n=55 \to 100 \step 2 \do {... \n ...} -% D \stoptyping -% D -% D Only in the third example we need to predefine \type{\n}. -% D The use of \type{\od} as a dilimiter would have made nested -% D use more problematic. -% -% obsolete: -% -% \def\for#1=#2\to#3\step#4\do#5% -% {\dostepwiserecurse{#2}{#3}{#4} -% {\let#1\recurselevel#5\let#1\recurselevel}} - %D \macros %D {newevery,everyline,EveryLine,EveryPar} %D @@ -4118,9 +3881,9 @@ %D \doifassignmentelse {...} {then ...} {else ...} %D \stoptyping -\long\def\docheckifassignmentelse#1=#2#3\@end@{\if#2@}% +\def\docheckifassignmentelse#1=#2#3\@end@{\if#2@}% -\long\def\doifassignmentelse#1% +\def\doifassignmentelse#1% {\expandafter\docheckifassignmentelse\detokenize{#1}=@@\@end@ \expandafter\secondoftwoarguments \else @@ -4147,16 +3910,16 @@ %D something I found out when primitives like \type %D {\jobname} were fed (or something undefined). -\long\def\convertargument#1\to#2{\dodoglobal\edef#2{\detokenize{#1}}} -\long\def\convertcommand #1\to#2{\dodoglobal\edef#2{\expandafter\detokenize\expandafter{#1}}} % hm, only second is also ok +\def\convertargument#1\to#2{\dodoglobal\edef#2{\detokenize{#1}}} +\def\convertcommand #1\to#2{\dodoglobal\edef#2{\expandafter\detokenize\expandafter{#1}}} % hm, only second is also ok -\long\def\defconvertedargument #1#2{\edef#1{\detokenize{#2}}} -\long\def\defconvertedcommand #1#2{\edef#1{\detokenize\expandafter{#2}}} -\long\def\edefconvertedargument#1#2{\edef#1{#2}% +\def\defconvertedargument #1#2{\edef#1{\detokenize{#2}}} +\def\defconvertedcommand #1#2{\edef#1{\detokenize\expandafter{#2}}} +\def\edefconvertedargument#1#2{\edef#1{#2}% \edef#1{\detokenize\expandafter{#1}}} -\long\def\gdefconvertedargument#1#2{\xdef#1{\detokenize{#2}}} -\long\def\gdefconvertedcommand #1#2{\xdef#1{\detokenize\expandafter{#2}}} -\long\def\xdefconvertedargument#1#2{\xdef#1{#2}% +\def\gdefconvertedargument#1#2{\xdef#1{\detokenize{#2}}} +\def\gdefconvertedcommand #1#2{\xdef#1{\detokenize\expandafter{#2}}} +\def\xdefconvertedargument#1#2{\xdef#1{#2}% \xdef#1{\detokenize\expandafter{#1}}} %D When you try to convert a primitive command, you'll find @@ -4263,7 +4026,7 @@ %D In examples~2 and~3 both arguments equal, in~1 and~4 %D they differ. -\long\def\ConvertToConstant#1#2#3% +\def\ConvertToConstant#1#2#3% {\edef\!!stringa{\expandafter\detokenize\expandafter{#2}}% \edef\!!stringb{\expandafter\detokenize\expandafter{#3}}% #1{\!!stringa}{\!!stringb}} @@ -4363,7 +4126,7 @@ %D results in: \type{\message{Hello world!}}. \def\dograbuntil#1#2% - {\long\def\next##1#1{#2{##1}}\next} + {\def\next##1#1{#2{##1}}\next} \def\grabuntil#1% {\expandafter\dograbuntil\expandafter{\csname#1\endcsname}} @@ -4390,11 +4153,11 @@ %D is related to these commands. This one simply throws away %D everything preceding \type{\command}. -\long\def\processbetween#1#2% +\def\processbetween#1#2% {\setvalue{\s!start#1}{\grabuntil{\s!stop#1}{#2}}} \def\gobbleuntil#1% - {\long\def\next##1#1{}\next} + {\def\next##1#1{}\next} \def\gobbleuntilrelax#1\relax {} @@ -4406,7 +4169,7 @@ %D \stoptyping \def\processuntil#1% - {\long\def\next##1#1{##1}\next} + {\def\next##1#1{##1}\next} %D \macros %D {groupedcommand} @@ -4476,23 +4239,23 @@ %D extra \type{\bgroup}||\type{\egroup} is needed to keep %D \type{\AfterGroup} both into sight and local. -\long\def\HandleGroup#1#2% +\def\HandleGroup#1#2% {\bgroup - \long\def\BeforeGroup{\bgroup#1\bgroup\aftergroup\AfterGroup}% - \long\def\AfterGroup {#2\egroup\egroup}% + \def\BeforeGroup{\bgroup#1\bgroup\aftergroup\AfterGroup}% + \def\AfterGroup {#2\egroup\egroup}% \afterassignment\BeforeGroup \let\next=} -\long\def\HandleSimpleGroup#1#2% no inner group (so no kerning interference) +\def\HandleSimpleGroup#1#2% no inner group (so no kerning interference) {\bgroup - %long\def\BeforeGroup{\bgroup#1\aftergroup\AfterGroup}% interferes - \long\def\BeforeGroup{\bgroup\aftergroup\AfterGroup#1}% - \long\def\AfterGroup {#2\egroup}% + %def\BeforeGroup{\bgroup#1\aftergroup\AfterGroup}% interferes + \def\BeforeGroup{\bgroup\aftergroup\AfterGroup#1}% + \def\AfterGroup {#2\egroup}% \afterassignment\BeforeGroup \let\next=} -% \long\def\HandleNoGroup#1#2% -% {\long\def\AfterGroup{#2\egroup}% +% \def\HandleNoGroup#1#2% +% {\def\AfterGroup{#2\egroup}% % \bgroup\aftergroup\AfterGroup#1} \def\HandleNoGroup % retrofit into mkii @@ -4502,12 +4265,12 @@ \expandafter\HandleNoGroupB \fi} -\long\def\HandleNoGroupA#1#2% - {\long\def\AfterGroup{#2\endgroup}% +\def\HandleNoGroupA#1#2% + {\def\AfterGroup{#2\endgroup}% \begingroup\aftergroup\AfterGroup#1} -\long\def\HandleNoGroupB#1#2% - {\long\def\AfterGroup{#2\egroup}% +\def\HandleNoGroupB#1#2% + {\def\AfterGroup{#2\egroup}% \bgroup\aftergroup\AfterGroup#1} %D I considered it a nuisance that @@ -4522,10 +4285,10 @@ %D line||ending token is treated as a blank space. So the final %D implementation became: -\long\unexpanded\def\groupedcommand#1#2% +\unexpanded\def\groupedcommand#1#2% {\doifnextbgroupelse{\HandleGroup{#1}{#2}}{\HandleNoGroup{#1}{#2}}} -\long\unexpanded\def\simplegroupedcommand#1#2% +\unexpanded\def\simplegroupedcommand#1#2% {\doifnextbgroupelse{\HandleSimpleGroup{#1}{#2}}{\HandleNoGroup{#1}{#2}}} %D Users should be aware of the fact that grouping can @@ -4746,10 +4509,10 @@ \def\dorepeatwithcommand[#1]% {\dodorepeatwithcommand#1*\empty*\relax} -\long\def\dodorepeatwithcommand#1*#2#3*#4\relax#5% +\def\dodorepeatwithcommand#1*#2#3*#4\relax#5% {\ifx#2\empty\redorepeatwithcommand[#1]#5\else\dododorepeatwithcommand{#1}{#2}{#3}#5\fi} -\long\def\dododorepeatwithcommand#1#2#3#4% +\def\dododorepeatwithcommand#1#2#3#4% {\ifx#2\empty % redundant but gives cleaner extensions #4{#1}% \else\ifnum#1<\zerocount @@ -4773,7 +4536,7 @@ %D \gdef\redorepeatwithcommand[#1]% %D {\redodorepeatwithcommand#1*\empty*\relax} %D -%D \long\gdef\redodorepeatwithcommand#1*#2#3*#4\relax#5% +%D \gdef\redodorepeatwithcommand#1*#2#3*#4\relax#5% %D {\dododorepeatwithcommand{#1}{#2}{#3}#5} %D %D \egroup @@ -4796,7 +4559,7 @@ %D are macros. This save some unneeded expansion. %D %D \starttyping -%D \long\def\doifstringinstringelse#1#2% +%D \def\doifstringinstringelse#1#2% %D {\do_if_in_string_else#1#2% %D \expandafter\firstoftwoarguments %D \else @@ -4813,8 +4576,8 @@ \expandafter\firstoftwoarguments \fi} -\long\def\doifstringinstringelse#1#2% - {\long\expandafter\def\expandafter\p!doifstringinstringelse\expandafter##\expandafter1#1##2##3\war +\def\doifstringinstringelse#1#2% + {\expandafter\def\expandafter\p!doifstringinstringelse\expandafter##\expandafter1#1##2##3\war {\pp!doifstringinstringelse##2}% \expandafter\expandafter\expandafter\p!doifstringinstringelse\expandafter#2#1@@\war} @@ -4849,20 +4612,20 @@ \def\dodoprependtoks {\dodoglobal\@@toks\doubleexpandafter{\expandafter\the\expandafter\@@scratchtoks\the\@@toks}} -\long\def\doappendtoks#1\to#2% +\def\doappendtoks#1\to#2% {\def\@@toks{#2}% \@@scratchtoks\expandafter{\gobbleoneargument#1}\dodoappendtoks} -\long\def\doprependtoks#1\to#2% +\def\doprependtoks#1\to#2% {\def\@@toks{#2}% \@@scratchtoks\expandafter{\gobbleoneargument#1}\dodoprependtoks} -\long\def\doappendtoksonce#1\to#2% +\def\doappendtoksonce#1\to#2% {\def\@@toks{#2}% \@@scratchtoks\expandafter{\gobbleoneargument#1}% \doifintokselse\@@scratchtoks\@@toks\donothing\dodoappendtoks} -\long\def\doprependtoksonce#1\to#2% +\def\doprependtoksonce#1\to#2% {\def\@@toks{#2}% \@@scratchtoks\expandafter{\gobbleoneargument#1}% \doifintokselse\@@scratchtoks\@@toks\donothing\dodoprependtoks} @@ -5411,40 +5174,7 @@ %D tokens per call. Anyone familiar with the not||values %D ones, can derive their meaning from the definitions. - \def\doifvalue#1{\doif {\csname#1\endcsname}} - \def\doifnotvalue#1{\doifnot {\csname#1\endcsname}} - \def\doifelsevalue#1{\doifelse{\csname#1\endcsname}} - - \def\doifnothing#1{\doif {#1}{}} - \def\doifsomething#1{\doifnot {#1}{}} - \def\doifelsenothing#1{\doifelse{#1}{}} - - \def\doifvaluenothing#1{\doif {\csname#1\endcsname}{}} - \def\doifvaluesomething#1{\doifnot {\csname#1\endcsname}{}} -\def\doifelsevaluenothing#1{\doifelse{\csname#1\endcsname}{}} - -%D Faster but spoiling inheritance (copying parameters): -%D -%D \starttyping -%D \def\doifelsevaluesomething#1#2#3% -%D {\expandafter\ifx\csname#1\endcsname\empty#3\else#2\fi} -%D -%D \def\doifvaluesomething#1#2% -%D {\expandafter\ifx\csname#1\endcsname\empty\else#2\fi} -%D -%D \def\doifvaluenothing#1#2% -%D {\expandafter\ifx\csname#1\endcsname\empty#2\fi} -%D \stoptyping -%D -%D Slightly more efficient: - - \def\doifnothing{\doif \empty} - \def\doifsomething{\doifnot \empty} -\def\doifelsenothing{\doifelse\empty} - -%D The somewhat faster alternatives are: - -\long\def\doifvalue#1#2% +\def\doifvalue#1#2% {\edef\!!stringa{\csname#1\endcsname}\edef\!!stringb{#2}% \ifx\!!stringa\!!stringb \expandafter\firstofoneargument @@ -5452,7 +5182,7 @@ \expandafter\gobbleoneargument \fi} -\long\def\doifnotvalue#1#2% +\def\doifnotvalue#1#2% {\edef\!!stringa{\csname#1\endcsname}\edef\!!stringb{#2}% \ifx\!!stringa\!!stringb \expandafter\gobbleoneargument @@ -5460,7 +5190,7 @@ \expandafter\firstofoneargument \fi} -\long\def\doifelsevalue#1#2% +\def\doifelsevalue#1#2% {\edef\!!stringa{\csname#1\endcsname}\edef\!!stringb{#2}% \ifx\!!stringa\!!stringb \expandafter\firstoftwoarguments @@ -5468,7 +5198,7 @@ \expandafter\secondoftwoarguments \fi} -\long\def\doifnothing#1% +\def\doifnothing#1% {\edef\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\firstofoneargument @@ -5476,7 +5206,7 @@ \expandafter\gobbleoneargument \fi} -\long\def\doifsomething#1% +\def\doifsomething#1% {\edef\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\gobbleoneargument @@ -5484,7 +5214,7 @@ \expandafter\firstofoneargument \fi} -\long\def\doifelsenothing#1% +\def\doifelsenothing#1% {\edef\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\firstoftwoarguments @@ -5492,7 +5222,7 @@ \expandafter\secondoftwoarguments \fi} -\long\def\doifsomethingelse#1% +\def\doifsomethingelse#1% {\edef\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\secondoftwoarguments @@ -5500,7 +5230,7 @@ \expandafter\firstoftwoarguments \fi} -\long\def\doifvaluenothing#1% +\def\doifvaluenothing#1% {\edef\!!stringa{\csname#1\endcsname}% \ifx\!!stringa\empty \expandafter\firstofoneargument @@ -5508,7 +5238,7 @@ \expandafter\gobbleoneargument \fi} -\long\def\doifvaluesomething#1% +\def\doifvaluesomething#1% {\edef\!!stringa{\csname#1\endcsname}% \ifx\!!stringa\empty \expandafter\gobbleoneargument @@ -5516,7 +5246,7 @@ \expandafter\firstofoneargument \fi} -\long\def\doifelsevaluenothing#1% +\def\doifelsevaluenothing#1% {\edef\!!stringa{\csname#1\endcsname}% \ifx\!!stringa\empty \expandafter\firstoftwoarguments @@ -5769,7 +5499,7 @@ \def\p!doifsomespaceelse#1 #2#3\war{\if\noexpand#2@} -\long\def\doifsomespaceelse#1% % #2#3% +\def\doifsomespaceelse#1% % #2#3% {\p!doifsomespaceelse#1 @ @\war % #3\else#2\fi} \expandafter\secondoftwoarguments \else @@ -5892,7 +5622,7 @@ %D \processlist(){=>}\docommand(a=>b=>c=>d) %D \stoptyping -\long\def\processlist#1#2#3#4% no blank skipping ! +\def\processlist#1#2#3#4% no blank skipping ! {\def\doprocesslist##1#2% {\def\dodoprocesslist####1####2#3% {\ifx#2####1% @@ -5951,7 +5681,7 @@ \escapechar\minusone \dountexsomething} -\long\def\dountexsomething#1#2\to#3% +\def\dountexsomething#1#2\to#3% {\doglobal#1#2\to\untexedargument \endgroup \let#3\untexedargument} @@ -6128,7 +5858,7 @@ %D Consider for instance the macro for which I originally %D wrote this token handler. -\long\def\splitofftokens#1\from#2\to#3% slow but hardly used +\def\splitofftokens#1\from#2\to#3% slow but hardly used {\ifnum#1>\zerocount \scratchcounter#1\relax \def\dosplitofftokens##1% @@ -6178,7 +5908,7 @@ \def\dohandletokens % \nexthandledtoken is part of interface {\futurelet\nexthandledtoken\dodohandletokens} -\long\def\handletokens#1\with#2% +\def\handletokens#1\with#2% {\gdef\dododohandletokens{#2}% permits more complex #2's \dohandletokens#1\end} @@ -6194,7 +5924,7 @@ \def\dodohandletokensone * % {\dododohandletokens{ }\dohandletokens} -\long\def\dodohandletokenstwo *#1% +\def\dodohandletokenstwo *#1% {\dododohandletokens{#1}\dohandletokens} %D This macro is tested on: @@ -6316,8 +6046,8 @@ {\begingroup\expandafter\doprocesscontent\csname#1\endcsname} \def\doprocesscontent#1#2#3% - {\long\def\doprocesscontent##1#1% - {\endgroup\long\def#2{##1}#3}% + {\def\doprocesscontent##1#1% + {\endgroup\def#2{##1}#3}% \doprocesscontent} %D \macros @@ -7029,12 +6759,12 @@ % The following macros are used in XML handling. -\long\setvalue{@u@s@"}#1#2"{#2} \long\setvalue{@g@s@"}#1#2"{\scratchtoks{#2}} -\long\setvalue{@u@s@'}#1#2'{#2} \long\setvalue{@g@s@'}#1#2'{\scratchtoks{#2}} -\long\setvalue{@u@s@ }#1#2 {#2} \long\setvalue{@g@s@ }#1#2 {\scratchtoks{#2}} +\setvalue{@u@s@"}#1#2"{#2} \setvalue{@g@s@"}#1#2"{\scratchtoks{#2}} +\setvalue{@u@s@'}#1#2'{#2} \setvalue{@g@s@'}#1#2'{\scratchtoks{#2}} +\setvalue{@u@s@ }#1#2 {#2} \setvalue{@g@s@ }#1#2 {\scratchtoks{#2}} -\long\def\unstringed#1{\csname\ifcsname @u@s@#1\endcsname @u@s@#1\else\s!empty\fi\endcsname#1} -\long\def\grabstring#1{\csname\ifcsname @g@s@#1\endcsname @g@s@#1\else\s!empty\fi\endcsname#1} +\def\unstringed#1{\csname\ifcsname @u@s@#1\endcsname @u@s@#1\else\s!empty\fi\endcsname#1} +\def\grabstring#1{\csname\ifcsname @g@s@#1\endcsname @g@s@#1\else\s!empty\fi\endcsname#1} \def\dowithgrabbedstring#1% {\def\@@dowithgrabbedstring{#1}% @@ -7061,8 +6791,8 @@ \fi \@@ifequal#2\@@and} -\long\def\@@if@@equal@@true #1\@@then#2#3{#2} -\long\def\@@if@@equal@@false#1\@@then#2#3{#3} +\def\@@if@@equal@@true #1\@@then#2#3{#2} +\def\@@if@@equal@@false#1\@@then#2#3{#3} \def\appended#1#2#3{\expandafter#1\expandafter#2\expandafter{#2#3}} \def\appendvalue #1{\expandafter\appended\expandafter \def\csname#1\endcsname} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index e55076710..917c3939d 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 : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 10/20/11 15:49:15 +-- merge date : 10/26/11 15:10:36 do -- begin closure to overcome local limits and interference @@ -3172,6 +3172,8 @@ if not modules then modules = { } end modules ['font-con'] = { } +-- some names of table entries will be changed (no _) + local utf = unicode.utf8 local next, tostring, rawget = next, tostring, rawget @@ -3216,7 +3218,80 @@ constructors.cache = containers.define("fonts", "constructors", constr constructors.privateoffset = 0xF0000 -- 0x10FFFF --- This might become an interface; +-- Some experimental helpers (handy for tracing): + +constructors.keys = { + properties = { + encodingbytes = "number", + embedding = "number", + cidinfo = { + }, + format = "string", + fontname = "string", + fullname = "string", + filename = "filename", + psname = "string", + name = "string", + virtualized = "boolean", + italic_correction = "boolean", + auto_italic_correction = "boolean", + no_stackmath = "boolean", + noglyphnames = "boolean", + mode = "string", + has_math = "boolean", + no_math_italics = "boolean", + no_text_italics = "boolean", + finalized = "boolean", + }, + parameters = { + mathsize = "scaledpoints", + scriptpercentage = "float", + scriptscriptpercentage = "float", + units = "cardinal", + designsize = "scalespoints", + expansion = { + stretch = "integerscale", -- might become float + shrink = "integerscale", -- might become float + step = "integerscale", -- might become float + auto = "boolean", + }, + protrusion = { + auto = "boolean", + }, + expand_factor = "float", + slant_factor = "float", + factor = "float", + hfactor = "float", + vfactor = "float", + size = "scaledpoints", + units = "scaledpoints", + scaledpoints = "scaledpoints", + slant = "float", + space = "scaledpoints", + space_stretch = "scaledpoints", + space_shrink = "scaledpoints", + x_height = "scaledpoints", + quad = "scaledpoints", + extra_space = "scaledpoints", + ascender = "scaledpoints", + descender = "scaledpoints", + }, + description = { + width = "basepoints", + height = "basepoints", + depth = "basepoints", + boundingbox = { }, + }, + character = { + width = "scaledpoints", + height = "scaledpoints", + depth = "scaledpoints", + italic = "scaledpoints", + }, + +} + +-- This might become an interface: local designsizes = allocate() constructors.designsizes = designsizes @@ -5113,6 +5188,8 @@ if not modules then modules = { } end modules ['font-otf'] = { -- to_table -> totable -- ascent descent +-- more checking against low level calls of functions + local utf = unicode.utf8 local utfbyte = utf.byte @@ -8628,6 +8705,11 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- start = start.next end end + -- we do need components in funny kerning mode but maybe I can better reconstruct then + -- as we do have the font components info available; removing components makes the + -- previous code much simpler + -- + -- flush_node_list(head.components) return head end end -- cgit v1.2.3