diff options
Diffstat (limited to 'tex/context/base')
50 files changed, 1026 insertions, 694 deletions
diff --git a/tex/context/base/buff-ini.mkiv b/tex/context/base/buff-ini.mkiv index dea7b0a49..c27c77b18 100644 --- a/tex/context/base/buff-ini.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -169,6 +169,9 @@ \def\definebuffer {\dodoubleempty\dodefinebuffer} + +\def\thebuffernumber#1% + {\csname\??bu#1\c!number\endcsname} \unexpanded\def\getbuffer {\dodoubleempty\dogetbuffer} diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index 928f26057..d39a9b824 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -17,9 +17,9 @@ \unprotect -\ifx\startlinenumbering\undefined \let\startlinenumbering\relax \fi -\ifx\stoplinenumbering \undefined \let\stoplinenumbering\relax \fi -\ifx\setuplinenumbering\undefined \def\setuplinenumbering[#1]{} \fi +\ifdefined\startlinenumbering\else \let\startlinenumbering \relax \fi +\ifdefined\stoplinenumbering \else \let\stoplinenumbering \relax \fi +\ifdefined\setuplinenumbering\else \def\setuplinenumbering[#1]{} \fi % D \macros % D {iflinepar} @@ -640,13 +640,12 @@ \def\dotypefileverbatim {\doinitializeverbatim - \ctxlua{buffers.typefile("\readfilename","\typingparameter\c!strip")}} + \beginofverbatimlines + \ctxlua{buffers.typefile("\readfilename","\typingparameter\c!strip")}% + \endofverbatimlines} \def\dotypefilelinesverbatim#1#2% - {#1% - \doinitializeverbatim - \ctxlua{buffers.typefile("\readfilename","\typingparameter\c!strip")}% - #2} + {#1\dotypefileverbatim#2} \unexpanded\def\dotypeblockverbatim#1#2% {\dowithbuffer{_typing_}{#1}{#2} @@ -688,7 +687,7 @@ %D ... %D \stopcode %D -%D \startcode[continue] +%D \startcode[start=continue] %D ... %D ... %D \stopcode @@ -746,7 +745,7 @@ %D %D The definitions default to the standard typing values. -\def\presettyping[#1][#2]% +\def\presettyping[#1][#2]% brrr also use parent here {\copyparameters[\??tp#1][\??tp][\c!color,\c!style]% \getparameters [\??tp#1][#2]} @@ -853,34 +852,57 @@ \dodotypefile[\v!file][]{#3}% \fi\fi} +% \def\dosetuptypelinenumbering#1% fuzzy +% {\ifcsname\currenttypingclass\currenttyping\c!start\endcsname \else +% \setuptyping[\currenttyping][\c!start=1,\c!stop=,\c!step=1,\c!nlines=]% +% \fi +% \setuptyping[\currenttyping][#1]% +% \doifelse{\typingparameter\c!numbering}\v!file +% {% kind of special: filters lines ! +% \setuplinenumbering[\c!method=\v!file]% +% \donetrue} +% {\doifelse{\typingparameter\c!numbering}\v!line +% {% \setuplinenumbering defaults start/step to 1/1, so we need +% \doifinsetelse\v!continue{#1,\typingparameter\c!start} +% {\scratchcounter0\typingparameter\c!n +% \setxtypingparameter\c!start{\ifnum\scratchcounter=0 1\else\number\scratchcounter\fi}}% +% {\doifnothing{\typingparameter\c!start}{\settypingparameter\c!start{1}}}% +% \doifnothing{\typingparameter\c!step}{\settypingparameter\c!step{1}}% +% \setuplinenumbering +% [\c!method=\v!type, +% \c!start=\typingparameter\c!start, +% \c!stop=\typingparameter\c!stop, +% \c!step=\typingparameter\c!step]% +% \donetrue} +% {\donefalse}}% +% \ifdone +% \def\beginofverbatimlines{\startlinenumbering}% +% \def\endofverbatimlines {\stoplinenumbering\setxtypingparameter\c!n{\number\linenumber}}% +% \fi} + \def\dosetuptypelinenumbering#1% fuzzy - {\ifcsname\currenttypingclass\currenttyping\c!start\endcsname \else - \setuptyping[\currenttyping][\c!start=1,\c!stop=,\c!step=1,\c!nlines=]% - \fi - \setuptyping[\currenttyping][#1]% + {%\ifcsname\currenttypingclass\currenttyping\c!start\endcsname \else + % \setuptyping[\currenttyping][\c!start=1,\c!stop=,\c!step=1,\c!continue=\v!no,\c!nlines=]% + %\fi + \doifassignmentelse{#1}{\setuptyping[\currenttyping][#1]}\donothing \doifelse{\typingparameter\c!numbering}\v!file {% kind of special: filters lines ! - \setuplinenumbering[\c!method=\v!file]% + \setuplinenumbering[\currenttyping][\c!method=\v!file]% \donetrue} {\doifelse{\typingparameter\c!numbering}\v!line - {% \setuplinenumbering defaults start/step to 1/1, so we need - \doifinsetelse\v!continue{#1,\typingparameter\c!start} - {\scratchcounter0\typingparameter\c!n - \setxtypingparameter\c!start{\ifnum\scratchcounter=0 1\else\number\scratchcounter\fi}}% - {\doifnothing{\typingparameter\c!start}{\settypingparameter\c!start{1}}}% - \doifnothing{\typingparameter\c!step}{\settypingparameter\c!step{1}}% - \setuplinenumbering - [\c!method=\v!type, - \c!start=\typingparameter\c!start, - \c!stop=\typingparameter\c!stop, - \c!step=\typingparameter\c!step]% + {\doifinset\v!continue{#1}{\setuptyping[\currenttyping][\c!continue=\v!yes]}% fails: \settypingparameter\c!continue{\v!yes} \donetrue} {\donefalse}}% \ifdone - \ifx\startlinenumbering\undefined \let\startlinenumbering\relax \fi - \ifx\stoplinenumbering \undefined \let\stoplinenumbering \relax \fi - \def\beginofverbatimlines{\startlinenumbering}% - \def\endofverbatimlines {\stoplinenumbering\setxtypingparameter\c!n{\number\linenumber}}% + \edef\beginofverbatimlines{\noexpand\startlinenumbering + [\currenttyping]% + [\c!continue=\typingparameter\c!continue, + \c!method=\v!type, + \c!start=\typingparameter\c!start, + \c!stop=\typingparameter\c!stop, % ? + \c!step=\typingparameter\c!step]% + }% + \def\endofverbatimlines{\stoplinenumbering}% \fi} \def\reporttypingerror#1% temp hack diff --git a/tex/context/base/cont-fil.tex b/tex/context/base/cont-fil.tex index 28b6b6f55..b295872ca 100644 --- a/tex/context/base/cont-fil.tex +++ b/tex/context/base/cont-fil.tex @@ -20,7 +20,8 @@ \definefilesynonym [eenheid] [units] \definefilesynonym [einheit] [units] -\definefilesynonym [pstricks] [pstric] +\definefilesynonym [pstric] [pstricks] +\definefilesynonym [pstrick] [pstricks] \definefilesynonym [finance] [financ] diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index e080d3904..6008b6aa6 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2010.03.12 19:49} +\newcontextversion{2010.03.18 14:42} %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.tex b/tex/context/base/context.tex index c70f20b8e..7590f0d8e 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2010.03.12 19:49} +\edef\contextversion{2010.03.18 14:42} %D For those who want to use this: diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index e37c0ea76..419bd25e0 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -410,17 +410,17 @@ end) local calculate_scale = fonts.tfm.calculate_scale function fonts.tfm.calculate_scale(tfmtable, scaledpoints, relativeid) - local scaledpoints, delta = calculate_scale(tfmtable, scaledpoints, relativeid) + local scaledpoints, delta, units = calculate_scale(tfmtable, scaledpoints, relativeid) if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific local relativedata = fontdata[relativeid] local id_x_height = relativedata and relativedata.parameters and relativedata.parameters.x_height local tf_x_height = id_x_height and tfmtable.parameters and tfmtable.parameters.x_height * delta if tf_x_height then scaledpoints = (id_x_height/tf_x_height) * scaledpoints - delta = scaledpoints/(tfmtable.units or 1000) + delta = scaledpoints/units end end - return scaledpoints, delta + return scaledpoints, delta, units end --~ table.insert(readers.sequence,1,'vtf') diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua index 2a6d9f8e4..0013cb2ff 100644 --- a/tex/context/base/font-gds.lua +++ b/tex/context/base/font-gds.lua @@ -9,6 +9,8 @@ if not modules then modules = { } end modules ['font-gds'] = { local type, next = type, next local gmatch = string.gmatch +local trace_goodies = false trackers.register("fonts.goodies", function(v) trace_goodies = v end) + -- goodies=name,colorscheme=,featureset= -- -- goodies=auto @@ -36,6 +38,13 @@ local function getgoodies(filename) -- maybe a merge is better data[filename] = false -- signal for not found else goodies = dofile(fullname) or false + if not goodies then + logs.report("fonts", "goodie file '%s' is invalid",fullname) + return nil + elseif trace_goodies then + logs.report("fonts", "goodie file '%s' is loaded",fullname) + end + goodies.name = goodies.name or "no name" for name, fnc in next, list do fnc(goodies) end @@ -93,14 +102,30 @@ local function flattened(t,tt) return tt end +fonts.flattened_features = flattened + +function fonts.goodies.prepare_features(goodies,name,set) + if set then + local ff = fonts.flattened_features(set) + local fullname = goodies.name .. "::" .. name + local n, s = preset_context(fullname,"",ff) + goodies.featuresets[name] = s -- set + if trace_goodies then + logs.report("fonts", "feature set '%s' gets number %s and name '%s'",name,n,fullname) + end + return n + end +end + local function initialize(goodies,tfmdata) local featuresets = goodies.featuresets local goodiesname = goodies.name if featuresets then - for name,set in next, featuresets do - local ff = flattened(set) - local n, s = preset_context(goodiesname .. "::" .. name,"",ff) - featuresets[name] = s -- set + if trace_goodies then + logs.report("fonts", "checking featuresets in '%s'",goodies.name) + end + for name, set in next, featuresets do + fonts.goodies.prepare_features(goodies,name,set) end end end diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index 16ecc2d48..dcec234b1 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -1881,7 +1881,7 @@ function fonts.methods.node.otf.features(head,font,attr) local ra = rl [attr] if ra == nil then ra = { } rl [attr] = ra end -- attr can be false -- sequences always > 1 so no need for optimization for s=1,#sequences do - local pardir, txtdir = 0, { } + local pardir, txtdir = 0, { } local success = false local sequence = sequences[s] local r = ra[s] -- cache @@ -1907,12 +1907,10 @@ function fonts.methods.node.otf.features(head,font,attr) -- only first attribute match check, so we assume simple fina's -- default can become a font feature itself if l[language] then ---~ valid, what = true, language valid, what = s_e or a_e, language -- elseif l[default] then -- valid, what = true, default elseif l[wildcard] then ---~ valid, what = true, wildcard valid, what = s_e or a_e, wildcard end if valid then @@ -1988,19 +1986,15 @@ function fonts.methods.node.otf.features(head,font,attr) if not lookupcache then report_missing_cache(typ,lookupname) else ---~ print(typ,lookupname,lookupcache,table.serialize(lookupcache)) while start do local id = start.id if id == glyph then ---~ if start.font == font and start.subtype<256 and (not attr or has_attribute(start,0,attr)) and (not attribute or has_attribute(start,state,attribute)) then if start.font == font and start.subtype<256 and has_attribute(start,0,attr) and (not attribute or has_attribute(start,state,attribute)) then local lookupmatch = lookupcache[start.char] if lookupmatch then -- sequence kan weg local ok ---~ print("!!!") start, ok = handler(start,r[4],lookupname,lookupmatch,sequence,featuredata,1) ---~ texio.write_nl(tostring(lookupname),tostring(lookupmatch),tostring(ok)) if ok then success = true end @@ -2025,25 +2019,6 @@ function fonts.methods.node.otf.features(head,font,attr) -- start = start.next -- end elseif id == whatsit then ---~ if subtype == 7 then ---~ local dir = start.dir ---~ if dir == "+TRT" then ---~ rlmode = -1 ---~ elseif dir == "+TLT" then ---~ rlmode = 1 ---~ else ---~ rlmode = 0 ---~ end ---~ elseif subtype == 6 then ---~ local dir = start.dir ---~ if dir == "TRT" then ---~ rlmode = -1 ---~ elseif dir == "TLT" then ---~ rlmode = 1 ---~ else ---~ rlmode = 0 ---~ end ---~ end local subtype = start.subtype if subtype == 7 then local dir = start.dir @@ -2129,59 +2104,40 @@ function fonts.methods.node.otf.features(head,font,attr) -- end elseif id == whatsit then local subtype = start.subtype ---~ if subtype == 7 then ---~ local dir = start.dir ---~ if dir == "+TRT" then ---~ rlmode = -1 ---~ elseif dir == "+TLT" then ---~ rlmode = 1 ---~ else ---~ rlmode = 0 ---~ end ---~ elseif subtype == 6 then ---~ local dir = start.dir ---~ if dir == "TRT" then ---~ rlmode = -1 ---~ elseif dir == "TLT" then ---~ rlmode = 1 ---~ else ---~ rlmode = 0 ---~ end ---~ end - local subtype = start.subtype - if subtype == 7 then - local dir = start.dir - if dir == "+TRT" or dir == "+TLT" then - insert(txtdir,dir) - elseif dir == "-TRT" or dir == "-TLT" then - remove(txtdir) - end - local d = txtdir[#txtdir] - if d == "+TRT" then - rlmode = -1 - elseif d == "+TLT" then - rlmode = 1 - else - rlmode = pardir - end - if trace_directions then - logs.report("fonts","directions after textdir %s: pardir=%s, txtdir=%s:%s, rlmode=%s",dir,pardir,#txtdir,txtdir[#txtdir] or "unset",rlmode) - end - elseif subtype == 6 then - local dir = start.dir - if dir == "TRT" then - pardir = -1 - elseif dir == "TLT" then - pardir = 1 - else - pardir = 0 - end + local subtype = start.subtype + if subtype == 7 then + local dir = start.dir + if dir == "+TRT" or dir == "+TLT" then + insert(txtdir,dir) + elseif dir == "-TRT" or dir == "-TLT" then + remove(txtdir) + end + local d = txtdir[#txtdir] + if d == "+TRT" then + rlmode = -1 + elseif d == "+TLT" then + rlmode = 1 + else rlmode = pardir - --~ txtdir = { } + end if trace_directions then - logs.report("fonts","directions after pardir %s: pardir=%s, txtdir=%s:%s, rlmode=%s",dir,pardir,#txtdir,txtdir[#txtdir] or "unset",rlmode) + logs.report("fonts","directions after textdir %s: pardir=%s, txtdir=%s:%s, rlmode=%s",dir,pardir,#txtdir,txtdir[#txtdir] or "unset",rlmode) end + elseif subtype == 6 then + local dir = start.dir + if dir == "TRT" then + pardir = -1 + elseif dir == "TLT" then + pardir = 1 + else + pardir = 0 end + rlmode = pardir + --~ txtdir = { } + if trace_directions then + logs.report("fonts","directions after pardir %s: pardir=%s, txtdir=%s:%s, rlmode=%s",dir,pardir,#txtdir,txtdir[#txtdir] or "unset",rlmode) + end + end start = start.next else start = start.next diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua index aa8739800..ea1b409e6 100644 --- a/tex/context/base/font-tfm.lua +++ b/tex/context/base/font-tfm.lua @@ -205,29 +205,21 @@ local charactercache = { } -- a virtual font has italic correction make sure to set the -- has_italic flag. Some more flags will be added in the future. - function tfm.calculate_scale(tfmtable, scaledpoints, relativeid) if scaledpoints < 0 then scaledpoints = (- scaledpoints/1000) * tfmtable.designsize -- already in sp end - local delta = scaledpoints/(tfmtable.units or 1000) -- brr, some open type fonts have 2048 - return scaledpoints, delta + local units = tfmtable.units or 1000 + local delta = scaledpoints/units -- brr, some open type fonts have 2048 + return scaledpoints, delta, units end function tfm.do_scale(tfmtable, scaledpoints, relativeid) -- tfm.prepare_base_kerns(tfmtable) -- optimalization - local scaledpoints, delta = tfm.calculate_scale(tfmtable, scaledpoints, relativeid) - if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific - local relativedata = fontdata[relativeid] - local id_x_height = relativedata and relativedata.parameters and relativedata.parameters.x_height - local tf_x_height = id_x_height and tfmtable.parameters and tfmtable.parameters.x_height * delta - if tf_x_height then - scaledpoints = (id_x_height/tf_x_height) * scaledpoints - delta = scaledpoints/(tfmtable.units or 1000) - end - end + local t = { } -- the new table + local scaledpoints, delta, units = tfm.calculate_scale(tfmtable, scaledpoints, relativeid) + t.units_per_em = units or 1000 local hdelta, vdelta = delta, delta - local t = { } -- unicoded unique descriptions shared cidinfo characters changed parameters indices for k,v in next, tfmtable do if type(v) == "table" then diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index 574bece89..a91bd1d71 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -36,7 +36,7 @@ run TeX code from within Lua. Some more functionality will move to Lua. ]]-- local format, lower, find, match, gsub, gmatch = string.format, string.lower, string.find, string.match, string.gsub, string.gmatch -local texsprint, texbox, texwd, texht, texdp = tex.sprint, tex.box, tex.wd, tex.ht, tex.dp +local texsprint, texbox = tex.sprint, tex.box local contains = table.contains local concat = table.concat @@ -670,8 +670,9 @@ function figures.done(data) figures.n = figures.n + 1 data = data or figures.current() local dr, du, ds, nr = data.request, data.used, data.status, figures.boxnumber - ds.width = texwd[nr] - ds.height = texht[nr] + local box = tex.box[nr] + ds.width = box.width + ds.height = box.height ds.xscale = ds.width /(du.width or 1) ds.yscale = ds.height/(du.height or 1) return data @@ -680,10 +681,11 @@ end function figures.dummy(data) data = data or figures.current() local dr, du, ds, nr = data.request, data.used, data.status, figures.boxnumber - texbox[nr] = node.new("hlist") - texwd [nr] = du.width or figures.defaultwidth - texht [nr] = du.height or figures.defaultheight - texdp [nr] = du.depth or figures.defaultdepth + local box = node.new("hlist") + box.width = du.width or figures.defaultwidth + box.height = du.height or figures.defaultheight + box.depth = du.depth or figures.defaultdepth + texbox[nr] = box end -- -- -- generic -- -- -- @@ -757,9 +759,9 @@ function figures.includers.generic(data) if figure then local nr = figures.boxnumber -- it looks like we have a leak in attributes here .. todo - texbox[nr] = node.hpack(img.node(figure)) - -- texbox[nr] = img.node(figure) -- img.write(figure) -- assigning img.node directly no longer valid - texwd[nr], texht[nr], texdp[nr] = figure.width, figure.height, 0 -- new, hm, tricky, we need to do that in tex (yet) + local box = node.hpack(img.node(figure)) -- img.node(figure) not longer valid + box.width, box.height, box.depth = figure.width, figure.height, 0 -- new, hm, tricky, we need to do that in tex (yet) + texbox[nr] = box ds.objectnumber = figure.objnum texsprint(ctxcatcodes,"\\relocateexternalfigure") end diff --git a/tex/context/base/l-file.lua b/tex/context/base/l-file.lua index be0e3d016..6f5f5d00e 100644 --- a/tex/context/base/l-file.lua +++ b/tex/context/base/l-file.lua @@ -19,7 +19,9 @@ function file.removesuffix(filename) end function file.addsuffix(filename, suffix) - if not find(filename,"%.[%a%d]+$") then + if not suffix or suffix == "" then + return filename + elseif not find(filename,"%.[%a%d]+$") then return filename .. "." .. suffix else return filename diff --git a/tex/context/base/lang-alt.tex b/tex/context/base/lang-alt.tex index e45748ead..f65acbda3 100644 --- a/tex/context/base/lang-alt.tex +++ b/tex/context/base/lang-alt.tex @@ -23,6 +23,8 @@ % Azeri/Azerbaijani, Chuvash, Turkish, Turkmen % Kazakh, Kazar, Kireghiz, Noghay, Talar % Buryat, Kalmuck, Khalkha +% +% Turkmen translation by Nazar Annagurban <nazartm at gmail.com> 18. March 2010 \unprotect @@ -38,54 +40,113 @@ \c!leftquotation=\upperleftdoublesixquote, \c!rightquotation=\upperrightdoubleninequote, \c!date={\v!year,\ ,\v!month,\ ,\v!day}] + +\installlanguage + [\s!tk] + [\c!spacing=\v!broad, + \c!leftsentence=---, + \c!rightsentence=---, + \c!leftsubsentence=---, + \c!rightsubsentence=---, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!year,\ ,\v!month,\ ,\v!day} + \s!patterns=\s!tk, + \s!lefthyphenmin=1, + \s!righthyphenmin=2] \installlanguage [turkish] [\s!tr] +\installlanguage [turkmen] [\s!tk] \setupheadtext [\s!tr] [\v!content=Fihrist] +\setupheadtext [\s!tk] [\v!content=Mazmuny] \setupheadtext [\s!tr] [\v!tables=Tablolar] +\setupheadtext [\s!tk] [\v!tables=Tablisalar] \setupheadtext [\s!tr] [\v!figures=\Scedilla ekiller] +\setupheadtext [\s!tk] [\v!figures=Suratlar] \setupheadtext [\s!tr] [\v!graphics=Grafikler] +\setupheadtext [\s!tk] [\v!graphics=Grafikler] \setupheadtext [\s!tr] [\v!intermezzi=...] +\setupheadtext [\s!tk] [\v!intermezzi=Arakesmeler] \setupheadtext [\s!tr] [\v!index=\Idotaccent ndex] +\setupheadtext [\s!tk] [\v!index=Indeks] \setupheadtext [\s!tr] [\v!abbreviations=K\dotlessi saltmalar] +\setupheadtext [\s!tk] [\v!abbreviations=Gysgaltmalar] \setupheadtext [\s!tr] [\v!logos=Logolar] +\setupheadtext [\s!tk] [\v!logos=Logolar] \setupheadtext [\s!tr] [\v!units=Birimler] +\setupheadtext [\s!tk] [\v!units=Birlikler] \setuplabeltext [\s!tr] [\v!table=Tablo ] +\setuplabeltext [\s!tk] [\v!table=Tablisa] \setuplabeltext [\s!tr] [\v!figure=\Scedilla ekil ] +\setuplabeltext [\s!tk] [\v!figure=Surat] \setuplabeltext [\s!tr] [\v!intermezzo=... ] -\setuplabeltext [\s!tr] [\v!graphic=Grafik ] +\setuplabeltext [\s!tk] [\v!intermezzo=Arakesme] +\setuplabeltext [\s!tr] [\v!graphic=Grafik] +\setuplabeltext [\s!tk] [\v!graphic=Grafik] \setuplabeltext [\s!tr] [\v!chapter=] +\setuplabeltext [\s!tk] [\v!chapter=Bap] \setuplabeltext [\s!tr] [\v!section=] +\setuplabeltext [\s!tk] [\v!section=] \setuplabeltext [\s!tr] [\v!subsection=] +\setuplabeltext [\s!tk] [\v!subsection=] \setuplabeltext [\s!tr] [\v!subsubsection=] \setuplabeltext [\s!tr] [\v!subsubsubsection=] +\setuplabeltext [\s!tk] [\v!subsubsubsection=] \setuplabeltext [\s!tr] [\v!appendix=] +\setuplabeltext [\s!tk] [\v!appendix=Go\scedilla ma\ccedilla a] \setuplabeltext [\s!tr] [\v!part=Cilt ] +\setuplabeltext [\s!tk] [\v!part=B\odiaeresis l\udiaeresis m] \setuplabeltext [\s!tr] [\v!line=sat\dotlessi r ] +\setuplabeltext [\s!tk] [\v!line=setir] \setuplabeltext [\s!tr] [\v!lines=sat\dotlessi rlar ] +\setuplabeltext [\s!tk] [\v!lines=setirler] -\setuplabeltext [\s!tr] [\v!january=ocak] +\setuplabeltext [\s!tk] [\v!january=\yacute anwar] +\setuplabeltext [\s!tk] [\v!february=fewral] +\setuplabeltext [\s!tk] [\v!march=mart] +\setuplabeltext [\s!tk] [\v!april=aprel] +\setuplabeltext [\s!tk] [\v!may=ma\yacute] +\setuplabeltext [\s!tk] [\v!june=i\yacute un] +\setuplabeltext [\s!tk] [\v!july=i\yacute ul] +\setuplabeltext [\s!tk] [\v!august=awgust] +\setuplabeltext [\s!tk] [\v!september=sent\yacute abr] +\setuplabeltext [\s!tk] [\v!october=okt\yacute abr] +\setuplabeltext [\s!tk] [\v!november=no\yacute abr] +\setuplabeltext [\s!tk] [\v!december=dekabr] + +\setuplabeltext [\s!tr] [\v!january=ocak] \setuplabeltext [\s!tr] [\v!february=\Scedilla ubat] -\setuplabeltext [\s!tr] [\v!march=mart] -\setuplabeltext [\s!tr] [\v!april=nisan] -\setuplabeltext [\s!tr] [\v!may=may\dotlessi s] -\setuplabeltext [\s!tr] [\v!june=haziran] -\setuplabeltext [\s!tr] [\v!july=temmuz] -\setuplabeltext [\s!tr] [\v!august=a\gbreve ustos] -\setuplabeltext [\s!tr] [\v!september=eyl\udiaeresis l] -\setuplabeltext [\s!tr] [\v!october=ekim] +\setuplabeltext [\s!tr] [\v!march=mart] +\setuplabeltext [\s!tr] [\v!april=nisan] +\setuplabeltext [\s!tr] [\v!may=may\dotlessi s] +\setuplabeltext [\s!tr] [\v!june=haziran] +\setuplabeltext [\s!tr] [\v!july=temmuz] +\setuplabeltext [\s!tr] [\v!august=a\gbreve ustos] +\setuplabeltext [\s!tr] [\v!september=eyl\udiaeresis l] +\setuplabeltext [\s!tr] [\v!october=ekim] \setuplabeltext [\s!tr] [\v!november=kas\dotlessi m] \setuplabeltext [\s!tr] [\v!december=aral\dotlessi k] -\setuplabeltext [\s!tr] [\v!sunday=pazar] -\setuplabeltext [\s!tr] [\v!monday=pazartesi] -\setuplabeltext [\s!tr] [\v!tuesday=sal\dotlessi] -\setuplabeltext [\s!tr] [\v!wednesday=\ccedilla ar\scedilla amba] +\setuplabeltext [\s!tr] [\v!sunday=pazar] +\setuplabeltext [\s!tr] [\v!monday=pazartesi] +\setuplabeltext [\s!tr] [\v!tuesday=sal\dotlessi] +\setuplabeltext [\s!tr] [\v!wednesday=\ccedilla ar\scedilla amba] \setuplabeltext [\s!tr] [\v!thursday=per\scedilla embe] -\setuplabeltext [\s!tr] [\v!friday=cuma] +\setuplabeltext [\s!tr] [\v!friday=cuma] \setuplabeltext [\s!tr] [\v!saturday=cumartesi] +\setuplabeltext [\s!tk] [\v!sunday=dyn\ccedilla\ g\udiaeresis n] +\setuplabeltext [\s!tk] [\v!monday=birinji g\udiaeresis n] +\setuplabeltext [\s!tk] [\v!tuesday=ikinji g\udiaeresis n] +\setuplabeltext [\s!tk] [\v!wednesday=\udiaeresis\ccedilla\udiaeresis nji] +\setuplabeltext [\s!tk] [\v!thursday=d\odiaeresis rd\udiaeresis nji g\udiaeresis n] +\setuplabeltext [\s!tk] [\v!friday=b\adiaeresis\scedilla inji g\udiaeresis n] +\setuplabeltext [\s!tk] [\v!saturday=altynjy g\udiaeresis n] + %D \ShowAllLanguageValues [\s!tr] [turkish] {Turkish} {delight} % turks fruit \protect \endinput diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua index 6e4bdb814..e9e67e163 100644 --- a/tex/context/base/lpdf-ano.lua +++ b/tex/context/base/lpdf-ano.lua @@ -70,6 +70,8 @@ end lpdf.pagedest = pagedest +local defaultdestination = pdfarray { 0, pdfconstant("Fit") } + local function link(url,filename,destination,page,actions) if filename and filename ~= "" then if file.basename(filename) == tex.jobname then @@ -92,9 +94,9 @@ local function link(url,filename,destination,page,actions) } elseif filename and filename ~= "" then return pdfdictionary { - S = pdf_gotor, + S = pdf_gotor, -- can also be pdf_launch F = filename, - D = destination and destination ~= "" and destination, + D = (destination and destination ~= "" and destination), -- or defaultdestination, NewWindow = (actions.newwindow and true) or nil, } elseif destination and destination ~= "" then @@ -270,12 +272,13 @@ runners["inner with arguments"] = function(var,actions) end runners["outer"] = function(var,actions) - return link(nil,var.f,nil,nil,actions) -- var.o ? + local file, url = jobreferences.checkedfileorurl(var.outer,var.outer) + return link(url,file,var.arguments,nil,actions) end runners["outer with inner"] = function(var,actions) - -- todo: resolve url/file name - return link(nil,var.f,var.inner,var.r,actions) + local file = jobreferences.checkedfile(var.f) + return link(nil,file,var.inner,var.r,actions) end runners["special outer with operation"] = function(var,actions) @@ -335,10 +338,7 @@ specials.i = specials.internal function specials.page(var,actions) -- better resolve in strc-ref local file = var.f if file then - local f = jobreferences.files.data[file] - if f then - file = f[1] or file - end + file = jobreferences.checkedfile(file) return link(nil,file,nil,p or var.operation,actions) else local p = jobreferences.pages[var.operation] @@ -368,62 +368,23 @@ function specials.order(var,actions) -- jobreferences.specials ! end end -function specials.url(var,actions) -- better resolve in strc-ref - local url = var.operation - if url then - local u = jobreferences.urls.data[url] - if u then - local u, f = u[1], u[2] - if f and f ~= "" then - url = u .. "/" .. f - else - url = u - end - end - end +function specials.url(var,actions) + local url = jobreferences.checkedurl(var.operation) return link(url,nil,var.arguments,nil,actions) end -function specials.file(var,actions) -- better resolve in strc-ref - local file = var.operation - if file then - local f = jobreferences.files.data[file] - if f then - file = f[1] or file - end - end +function specials.file(var,actions) + local file = jobreferences.checkedfile(var.operation) return link(nil,file,var.arguments,nil,actions) end -function specials.fileorurl(var,actions) -- better resolve in strc-ref - local whatever, url, file = var.operation, nil, nil - if whatever then - local w = jobreferences.files.data[whatever] - if w then - file = w[1] - else - w = jobreferences.urls.data[whatever] - if w then - local u, f = w[1], w[2] - if f and f ~= "" then - url = u .. "/" .. f - else - url = u - end - end - end - end +function specials.fileorurl(var,actions) + local file, url = jobreferences.checkedfileorurl(var.operation,var.operation) return link(url,file,var.arguments,nil,actions) end -function specials.program(var,content) -- better resolve in strc-ref - local program = var.operation - if program then - local p = jobreferences.programs[program] - if p then - program = p[1] - end - end +function specials.program(var,content) + local program = jobreferences.checkedprogram(var.operation) return lpdf.launch(program,var.arguments) end diff --git a/tex/context/base/lpdf-wid.lua b/tex/context/base/lpdf-wid.lua index 44d0c5154..40a81e7d4 100644 --- a/tex/context/base/lpdf-wid.lua +++ b/tex/context/base/lpdf-wid.lua @@ -31,6 +31,8 @@ local pdfimmediateobj = pdf.immediateobj local pdfannotation = nodes.pdfannotation +local hpack_node, write_node = node.hpack, node.write + -- symbols local presets = { } -- xforms @@ -133,10 +135,10 @@ function codeinjections.registercomment(specification) Parent = pdfreference(nd), } d.Popup = pdfreference(nc) - texbox["commentboxone"] = node.hpack(pdfannotation(0,0,0,d(),nd)) - texbox["commentboxtwo"] = node.hpack(pdfannotation(specification.width,specification.height,0,c(),nc)) + texbox["commentboxone"] = hpack_node(pdfannotation(0,0,0,d(),nd)) -- current dir + texbox["commentboxtwo"] = hpack_node(pdfannotation(specification.width,specification.height,0,c(),nc)) -- current dir else - texbox["commentboxone"] = node.hpack(pdfannotation(0,0,0,d())) + texbox["commentboxone"] = hpack_node(pdfannotation(0,0,0,d())) -- current dir texbox["commentboxtwo"] = nil end end @@ -209,7 +211,7 @@ function codeinjections.attachfile(specification) local width = specification.width or 0 local height = specification.height or 0 local depth = specification.depth or 0 - node.write(pdfannotation(width,height,depth,d())) + write_node(pdfannotation(width,height,depth,d())) end function codeinjections.attachmentid(filename) @@ -266,7 +268,7 @@ local function insertrenderingwindow(label,width,height,specification) AA = actions, } local r = pdfreserveobj("annot") - node.write(pdfannotation(width,height,0,d(),r)) -- save ref + write_node(pdfannotation(width,height,0,d(),r)) -- save ref return pdfreference(r) end diff --git a/tex/context/base/luat-lua.lua b/tex/context/base/luat-lua.lua index c4844396e..b964bf8e8 100644 --- a/tex/context/base/luat-lua.lua +++ b/tex/context/base/luat-lua.lua @@ -38,5 +38,6 @@ end end --~ tex.sprint(string.format("more pi: %s %s %s\\par",...)) --~ end) --~ tex.sprint(string.format("\\setbox0=\\hbox{%s}",math.pi*n)) ---~ lua.flush(tex.wd[0],tex.ht[0],tex.dp[0]) +--~ local box = tex.box[0] +--~ lua.flush(box.width,box.height,box.depth) --~ end diff --git a/tex/context/base/m-barcodes.mkiv b/tex/context/base/m-barcodes.mkiv new file mode 100644 index 000000000..1c352dd54 --- /dev/null +++ b/tex/context/base/m-barcodes.mkiv @@ -0,0 +1,96 @@ +%D \module +%D [ file=m-pstricks, +%D version=2010.03.14, +%D title=\CONTEXT\ Extra Modules, +%D subtitle=Barcodes, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=PRAGMA] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% \startTEXpage +% \startPSTRICKS +% \pspicture(-4mm,-1mm)(38mm,26mm) +% \psbarcode{9781860742712}{includetext guardwhitespace}{ean13}% +% \endpspicture +% \stopPSTRICKS +% \stopTEXpage + +% 978-94-90688-01-1 +% +% 978 = ean isbn identifier (979 also) +% 94 = country code +% 90688 = publisher code +% 01 = title 1 +% 1 = checksum + +\usemodule[pstricks] + +\usePSTRICKSmodule[pst-barcode] + +\startluacode +plugins.barcodes = { } + +function plugins.barcodes.strip(original) + local code = string.gsub(original,"%-","") + local t = { string.byte(code,1,#code) } + if #t >= 12 then + local s = 0 + for i=1,11,2 do + s = s + (t[i]-48) + end + for i=2,12,2 do + s = s + 3 * (t[i]-48) + end + local m = s % 10 + local c = (m > 0 and (10 - m)) or 0 + if #t == 13 then + local e = ((c == t[13] - 48) and "correct") or "wrong" + logs.report("isbn code","code=%s, sum=%s, checksum=%s, modulo=%s, status=%s",original,s,m,c,e) + else + logs.report("isbn code","code=%s, sum=%s, checksum=%s, modulo=%s",original,s,m,c) + code= code .. c + end + end + tex.sprint(code) +end +\stopluacode + +\startsetups barcode:isbn + \scale + [width=5cm] + { + \normalexpanded { \noexpand \setPSTRICKS { + \noexpand \pspicture(-4mm,-1mm)(38mm,26mm) + \noexpand \psbarcode { + \ctxlua{plugins.barcodes.strip("\getvariable{barcode}{code}")} + } { + includetext guardwhitespace + } { + ean13 + } + \noexpand \endpspicture + } + \noexpand \processPSTRICKS } + } +\stopsetups + +\def\barcode[#1]% + {\bgroup + \setvariables[barcode][type=isbn,#1]% + \directsetup{barcode:\getvariable{barcode}{type}}% + \egroup} + +% \usemodule[barcodes] +% +% \starttext +% \startTEXpage +% \barcode[type=isbn,code=978-94-90688-01-1] +% \stopTEXpage +% \stoptext + +\endinput + diff --git a/tex/context/base/m-pstricks.lua b/tex/context/base/m-pstricks.lua new file mode 100644 index 000000000..35cae93f6 --- /dev/null +++ b/tex/context/base/m-pstricks.lua @@ -0,0 +1,73 @@ +if not modules then modules = { } end modules ['m-pstricks'] = { + version = 1.001, + comment = "companion to m-pstricks.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- The following will be done when I need ps tricks figures +-- in large quantities: +-- +-- + hash graphics and only process them once +-- + save md5 checksums in tuc file +-- +-- It's no big deal but has a low priority. + +local format, lower, concat, gmatch = string.format, string.lower, table.concat, string.gmatch +local variables = interfaces.variables + +plugins = plugins or { } +plugins.pstricks = plugins.pstricks or { } + +local template = [[ +\starttext + \pushcatcodetable + \setcatcodetable\texcatcodes + \usemodule[pstric] + %s + \popcatcodetable + \startTEXpage + \hbox\bgroup + \ignorespaces + %s + \removeunwantedspaces + \egroup + \obeydepth %% temp hack as we need to figure this out + \stopTEXpage +\stoptext +]] + +local modules = { } +local graphics = 0 + +function plugins.pstricks.usemodule(names) + for name in gmatch(names,"([^%s,]+)") do + modules[#modules+1] = format([[\readfile{%s}{}{}]],name) + end +end + +function plugins.pstricks.process(n) + graphics = graphics + 1 + local name = string.format("%s-pstricks-%04i",tex.jobname,graphics) + local data = buffers.collect("def-"..n) + local tmpfile = name .. ".tmp" + local epsfile = name .. ".ps" + local pdffile = name .. ".pdf" + local modules = concat(modules,"\n") + os.remove(epsfile) + os.remove(pdffile) + io.savedata(tmpfile,format(template,modules,data)) + os.execute(format("mtxrun --script texexec %s --once --dvips",tmpfile)) + if lfs.isfile(epsfile) then + os.execute(format("ps2pdf %s %s",epsfile,pdffile)) + -- todo: direct call but not now + if lfs.isfile(pdffile) then + context.externalfigure( { pdffile }, { object = variables.no } ) + else + logs.report("plugins","pstricks run failed, no pdf file") + end + else + logs.report("plugins","pstricks run failed, no ps file") + end +end diff --git a/tex/context/base/m-pstric.tex b/tex/context/base/m-pstricks.mkii index f4be08dbd..384812ecc 100644 --- a/tex/context/base/m-pstric.tex +++ b/tex/context/base/m-pstricks.mkii @@ -44,6 +44,12 @@ \catcode`\|=\oldbarcode +\def\loadpstricksmodule[#1]% + {\chardef\oldbarcode\the\catcode`\| + \catcode`\|=12 + \readfile{#1}{}{}% + \catcode`\|=\oldbarcode} + %D The next piece of code is for John Culleton who suggested to %D handle \PSTRICKS\ in a similar fashion as \METAPOST, i.e.\ %D using a child process. For the moment there is no support @@ -111,6 +117,7 @@ \long\def\dostartPSTRICKS[#1]#2\stopPSTRICKS {\doifelse{\jobsuffix}{dvi} % will some day move to app as switch {\hbox{#2}} - {\startTEXapplication[#1]{\usemodule[pstric]}#2\stopTEXapplication}} +% {\startTEXapplication[#1]{\usemodule[pstric]}#2\stopTEXapplication}} + {\startTEXapplication[#1]{}#2\stopTEXapplication}} \protect \endinput diff --git a/tex/context/base/m-pstricks.mkiv b/tex/context/base/m-pstricks.mkiv new file mode 100644 index 000000000..c800ec199 --- /dev/null +++ b/tex/context/base/m-pstricks.mkiv @@ -0,0 +1,66 @@ +%D \module +%D [ file=m-pstricks, +%D version=2010.03.14, +%D title=\CONTEXT\ Extra Modules, +%D subtitle=\PSTRICKS\ Connections, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\ctxloadluafile{m-pstricks}{} + +%D \startbuffer +%D \usePSTRICKSmodule[pst-barcode] +%D +%D \startPSTRICKS +%D \pspicture(-4mm,-1mm)(38mm,26mm) +%D \psbarcode{9781860742712}{includetext guardwhitespace}{ean13}% +%D \endpspicture +%D \stopPSTRICKS +%D \stopbuffer +%D +%D \typebuffer \startlinecorrection \getbuffer \stoplinecorrection + +\unprotect + +% best we can make a special colors module +% +% \let\@unused\plussixteen +% \let\alloc@ \gobblefivearguments +% +% \def\loadpstrickscolors#1% +% {\pushmacro\dodefinecolor +% \pushmacro\dodefinepalet +% \pushmacro\dodefinecolorgroup +% \def\dodefinecolor[##1][##2]% +% {\doifassignmentelse{##2} +% {\getparameters[pstricks][r=0,g=0,b=0,##2]% +% \expanded{\newrgbcolor{##1}{{\pstricksr} {\pstricksg} {\pstricksb}}}}% +% {}}% +% \def\dodefinepalet [##1][##2]{}% +% \def\dodefinecolorgroup[##1][##2][##3]{}% +% \writestatus{pstricks}{loading colors from #1}% +% \input #1 \relax +% \popmacro\dodefinecolorgroup +% \popmacro\dodefinepalet +% \popmacro\dodefinecolor} +% +% \input multido \relax +% \input pstricks \relax +% \input pst-plot \relax +% +% \loadpstrickscolors{colo-rgb} + +\definebuffer[PSTRICKS] + +\unexpanded\def\processPSTRICKS {\ctxlua{plugins.pstricks.process(\thebuffernumber{PSTRICKS})}} +\unexpanded\def\usePSTRICKSmodule[#1]{\ctxlua{plugins.pstricks.usemodule("#1")}} +\unexpanded\def\setPSTRICKS #1{\setbuffer[def-\thebuffernumber{PSTRICKS}]#1\endbuffer} + +\let\stopPSTRICKS\processPSTRICKS + +\protect \endinput diff --git a/tex/context/base/m-pstricks.tex b/tex/context/base/m-pstricks.tex new file mode 100644 index 000000000..28bc9f30f --- /dev/null +++ b/tex/context/base/m-pstricks.tex @@ -0,0 +1,16 @@ +%D \module +%D [ file=m-pstricks, +%D version=1997.01.15, +%D title=\CONTEXT\ Extra Modules, +%D subtitle=\PSTRICKS\ Connections, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\loadmarkfile{m-pstricks} + +\endinput diff --git a/tex/context/base/m-timing.tex b/tex/context/base/m-timing.tex index f6b0348c8..f02a90087 100644 --- a/tex/context/base/m-timing.tex +++ b/tex/context/base/m-timing.tex @@ -36,7 +36,7 @@ \ctxloadluafile{trac-tim}{} \startluacode -local progress = goodies.progress +local progress = plugins.progress function progress.show(filename,parameters,nodes,other) for n, name in pairs(parameters or progress.parameters(filename)) do @@ -51,16 +51,16 @@ end % \everyfirstshipout \startnotmode[no-timing] - \appendtoks\ctxlua{goodies.progress.store()}\to\everystarttext - \appendtoks\ctxlua{goodies.progress.store()}\to\everyshipout - \ctxlua{main.register_stop_actions(function() goodies.progress.save() end)} + \appendtoks\ctxlua{plugins.progress.store()}\to\everystarttext + \appendtoks\ctxlua{plugins.progress.store()}\to\everyshipout + \ctxlua{main.register_stop_actions(function() plugins.progress.save() end)} \stopnotmode \def\ShowNamedUsage#1#2#3% {\setbox\scratchbox\vbox\bgroup\startMPcode begingroup ; save p, q, b, h, w ; path p, q, b ; numeric h, w ; - p := \ctxlua{tex.sprint(goodies.progress.path("#1","#2"))} ; + p := \ctxlua{tex.sprint(plugins.progress.path("#1","#2"))} ; % p := p shifted -llcorner p ; if bbwidth(p) > 1 : h := 100 ; w := 2 * h ; @@ -71,7 +71,7 @@ end draw b withcolor \MPcolor{usage:frame} ; draw p withcolor \MPcolor{usage:line} ; if ("#3" <> "") and ("#3" <> "#2") : - q := \ctxlua{tex.sprint(goodies.progress.path("#1","#3"))} ; + q := \ctxlua{tex.sprint(plugins.progress.path("#1","#3"))} ; % q := q shifted -llcorner q ; if bbwidth(q) > 1 : q := q xstretched w ; @@ -87,16 +87,16 @@ end \startlinecorrection \box\scratchbox \endgraf \hbox to \scratchdimen{\tttf\strut\detokenize{#2}\hss - min:\ctxlua{tex.sprint(goodies.progress.bot("#1","\detokenize{#2}"))}, % - max:\ctxlua{tex.sprint(goodies.progress.top("#1","\detokenize{#2}"))}, % - pages:\ctxlua{tex.sprint(goodies.progress.pages("#1"))}% + min:\ctxlua{tex.sprint(plugins.progress.bot("#1","\detokenize{#2}"))}, % + max:\ctxlua{tex.sprint(plugins.progress.top("#1","\detokenize{#2}"))}, % + pages:\ctxlua{tex.sprint(plugins.progress.pages("#1"))}% }% \stoplinecorrection \fi} -\def\LoadUsage #1{\ctxlua{goodies.progress.convert("#1")}} -\def\ShowUsage #1{\ctxlua{goodies.progress.show("#1",nil,nil,"elapsed_time")}} -\def\ShowMemoryUsage#1{\ctxlua{goodies.progress.show("#1",nil,{}, "elapsed_time")}} -\def\ShowNodeUsage #1{\ctxlua{goodies.progress.show("#1",{},nil, "elapsed_time")}} +\def\LoadUsage #1{\ctxlua{plugins.progress.convert("#1")}} +\def\ShowUsage #1{\ctxlua{plugins.progress.show("#1",nil,nil,"elapsed_time")}} +\def\ShowMemoryUsage#1{\ctxlua{plugins.progress.show("#1",nil,{}, "elapsed_time")}} +\def\ShowNodeUsage #1{\ctxlua{plugins.progress.show("#1",{},nil, "elapsed_time")}} \endinput diff --git a/tex/context/base/math-lan.mkiv b/tex/context/base/math-lan.mkiv index f6cd96220..bcf9cdc13 100644 --- a/tex/context/base/math-lan.mkiv +++ b/tex/context/base/math-lan.mkiv @@ -52,7 +52,13 @@ \setupmathlabeltext [\s!en] [tanh=tanh] \setupmathlabeltext [\s!en] [tan=tan] -\setupmathlabeltext [\s!pl] [tan=tg] +\setupmathlabeltext [\s!pl] [tg=tg] \setupmathlabeltext [\s!pl] [cot=ctg] +\setupmathlabeltext [\s!pl] [ctg=ctg] +\setupmathlabeltext [\s!pl] [arcsin=arc\,sin] +\setupmathlabeltext [\s!pl] [arccos=arc\,cos] +\setupmathlabeltext [\s!pl] [arctan=arc\,tg] +\setupmathlabeltext [\s!pl] [arctg=arc\,tg] +\setupmathlabeltext [\s!pl] [arcctg=arc\,ctg] \protect \endinput diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua index c209d52ef..f810087a2 100644 --- a/tex/context/base/math-vfu.lua +++ b/tex/context/base/math-vfu.lua @@ -1670,34 +1670,85 @@ mathematics.make_font ( "mathtimes-math", { } ) mathematics.make_font ( "charter-math", { - { name = "file:bchr8a", features = "virtualmath", main = true }, + -- { name = "file:bchr8a", features = "virtualmath", main = true }, + { name = "file:bchri8a", features = "virtualmath", main = true }, -- { name = "md-chr7m.tfm", vector = "tex-mr" }, { name = "md-chri7m.tfm", vector = "tex-mi", skewchar=0x7F }, { name = "md-chri7m.tfm", vector = "tex-it", skewchar=0x7F }, { name = "md-chr7y.tfm", vector = "tex-sy", skewchar=0x30, parameters = true }, { name = "md-chr7v.tfm", vector = "tex-ex", extension = true }, + -- { name = "md-chbma.tfm", vector = "tex-ma" }, + -- { name = "md-chbmb.tfm", vector = "tex-mb" }, { name = "msam10.tfm", vector = "tex-ma" }, { name = "msbm10.tfm", vector = "tex-mb" }, } ) mathematics.make_font ( "garamond-math", { - { name = "file:ugmr8y", features = "virtualmath", main = true }, + -- { name = "file:ugmr8a", features = "virtualmath", main = true }, + { name = "file:ugmri8a", features = "virtualmath", main = true }, -- { name = "md-gmr7m.tfm", vector = "tex-mr" }, { name = "md-gmri7m.tfm", vector = "tex-mi", skewchar=0x7F }, { name = "md-gmri7m.tfm", vector = "tex-it", skewchar=0x7F }, { name = "md-gmr7y.tfm", vector = "tex-sy", skewchar=0x30, parameters = true }, { name = "md-gmr7v.tfm", vector = "tex-ex", extension = true }, + -- { name = "md-gmmma.tfm", vector = "tex-ma" }, + -- { name = "md-gmmmb.tfm", vector = "tex-mb" }, { name = "msam10.tfm", vector = "tex-ma" }, { name = "msbm10.tfm", vector = "tex-mb" }, } ) mathematics.make_font ( "utopia-math", { - { name = "file:putr8y", features = "virtualmath", main = true }, + -- { name = "file:putr8a", features = "virtualmath", main = true }, + { name = "file:putri8a", features = "virtualmath", main = true }, -- { name = "md-utr7m.tfm", vector = "tex-mr" }, { name = "md-utri7m.tfm", vector = "tex-mi", skewchar=0x7F }, { name = "md-utri7m.tfm", vector = "tex-it", skewchar=0x7F }, { name = "md-utr7y.tfm", vector = "tex-sy", skewchar=0x30, parameters = true }, { name = "md-utr7v.tfm", vector = "tex-ex", extension = true }, + -- { name = "md-utbma.tfm", vector = "tex-ma" }, + -- { name = "md-utbmb.tfm", vector = "tex-mb" }, + { name = "msam10.tfm", vector = "tex-ma" }, + { name = "msbm10.tfm", vector = "tex-mb" }, +} ) + +mathematics.make_font ( "charter-math", { + -- { name = "file:bchr8a", features = "virtualmath", main = true }, + { name = "file:bchri8a", features = "virtualmath", main = true }, + -- { name = "md-chr7m.tfm", vector = "tex-mr" }, + { name = "md-chri7m.tfm", vector = "tex-mi", skewchar=0x7F }, + { name = "md-chri7m.tfm", vector = "tex-it", skewchar=0x7F }, + { name = "md-chr7y.tfm", vector = "tex-sy", skewchar=0x30, parameters = true }, + { name = "md-chr7v.tfm", vector = "tex-ex", extension = true }, + -- { name = "md-chbma.tfm", vector = "tex-ma" }, + -- { name = "md-chbmb.tfm", vector = "tex-mb" }, + { name = "msam10.tfm", vector = "tex-ma" }, + { name = "msbm10.tfm", vector = "tex-mb" }, +} ) + +mathematics.make_font ( "garamond-math", { + -- { name = "file:ugmr8a", features = "virtualmath", main = true }, + { name = "file:ugmri8a", features = "virtualmath", main = true }, + -- { name = "md-gmr7m.tfm", vector = "tex-mr" }, + { name = "md-gmri7m.tfm", vector = "tex-mi", skewchar=0x7F }, + { name = "md-gmri7m.tfm", vector = "tex-it", skewchar=0x7F }, + { name = "md-gmr7y.tfm", vector = "tex-sy", skewchar=0x30, parameters = true }, + { name = "md-gmr7v.tfm", vector = "tex-ex", extension = true }, + -- { name = "md-gmmma.tfm", vector = "tex-ma" }, + -- { name = "md-gmmmb.tfm", vector = "tex-mb" }, + { name = "msam10.tfm", vector = "tex-ma" }, + { name = "msbm10.tfm", vector = "tex-mb" }, +} ) + +mathematics.make_font ( "utopia-math", { + -- { name = "file:putr8a", features = "virtualmath", main = true }, + { name = "file:putri8a", features = "virtualmath", main = true }, + -- { name = "md-utr7m.tfm", vector = "tex-mr" }, + { name = "md-utri7m.tfm", vector = "tex-mi", skewchar=0x7F }, + { name = "md-utri7m.tfm", vector = "tex-it", skewchar=0x7F }, + { name = "md-utr7y.tfm", vector = "tex-sy", skewchar=0x30, parameters = true }, + { name = "md-utr7v.tfm", vector = "tex-ex", extension = true }, + -- { name = "md-utbma.tfm", vector = "tex-ma" }, + -- { name = "md-utbmb.tfm", vector = "tex-mb" }, { name = "msam10.tfm", vector = "tex-ma" }, { name = "msbm10.tfm", vector = "tex-mb" }, } ) @@ -1715,97 +1766,6 @@ mathematics.make_font ( "hvmath-math", { -- the lucida mess ---~ fonts.enc.math["lbr-ma"] = { ---~ [0x000A5] = 0x03, -- yen ---~ [0x000B7] = 0xE1, -- centerdot ---~ [0x000F0] = 0x03, -- eth ---~ [0x00127] = 0x1B, -- hbar ---~ [0x003DC] = 0x03, -- digamma ---~ [0x003F6] = 0x03, -- backepsilon ---~ [0x0219A] = 0x32, -- nleftarrow ---~ [0x0219B] = 0x33, -- nrightarrow ---~ [0x0219E] = 0x23, -- twoheadleftarrow ---~ [0x021A0] = 0x25, -- twoheadrightarrow ---~ [0x021A2] = 0x28, -- leftarrowtail ---~ [0x021A3] = 0x29, -- rightarrowtail ---~ [0x021A6] = 0x2C, -- mapsto ---~ [0x021A9] = 0x3C, -- hookleftarrow ---~ [0x021AA] = 0x3E, -- hookrightarrow ---~ [0x021AB] = 0x3F, -- looparrowleft ---~ [0x021AC] = 0x40, -- looparrowright ---~ [0x021AD] = 0x91, -- leftrightsquigarrow ---~ [0x021AE] = 0x34, -- nleftrightarrow ---~ [0x021B0] = 0x7B, -- Lsh ---~ [0x021B1] = 0x7D, -- Rsh ---~ [0x021B6] = 0x87, -- curvearrowleft ---~ [0x021B7] = 0x88, -- curvearrowright ---~ [0x021BA] = 0x8C, -- circlearrowright ---~ [0x021BB] = 0x8B, -- circlearrowleft ---~ [0x021BF] = 0x76, -- upharpoonleft ---~ [0x021C2] = 0x77, -- downharpoonright ---~ [0x021C3] = 0x78, -- downharpoonleft ---~ [0x021C4] = 0x6D, -- rightleftarrows ---~ [0x021C6] = 0x6E, -- leftrightarrows ---~ [0x021C7] = 0x71, -- leftleftarrows ---~ [0x021C8] = 0x72, -- upuparrows ---~ [0x021C9] = 0x73, -- rightrightarrows ---~ [0x021CA] = 0x74, -- downdownarrows ---~ [0x021CB] = 0x79, -- leftrightharpoons ---~ [0x021CC] = 0x7A, -- rightleftharpoons ---~ [0x021CD] = 0x66, -- nLeftarrow ---~ [0x021CE] = 0x67, -- nLeftrightarrow ---~ [0x021CF] = 0x68, -- nRightarrow ---~ [0x021DA] = 0x6A, -- Lleftarrow ---~ [0x021DB] = 0x6C, -- Rrightarrow ---~ [0x021E0] = 0x38, -- dashleftarrow ---~ [0x02204] = 0x20, -- nexists ---~ [0x02226] = 0xF7, -- nparallel ---~ [0x02241] = 0x96, -- nsim ---~ [0x02268] = 0xDC, -- lneqq ---~ [0x02269] = 0xDE, -- gneqq ---~ [0x0226E] = 0x9A, -- nless ---~ [0x0226F] = 0x9B, -- ngtr ---~ [0x02270] = 0x9C, -- nleq ---~ [0x02271] = 0x9D, -- ngeq ---~ [0x02280] = 0xE5, -- nprec ---~ [0x02281] = 0xE6, -- nsucc ---~ [0x02288] = 0xC8, -- nsubseteq ---~ [0x02289] = 0xC9, -- nsupseteq ---~ [0x0228A] = 0xCC, -- subsetneq ---~ [0x0228B] = 0xCD, -- supsetneq ---~ [0x022AC] = 0xF8, -- nvdash ---~ [0x022AD] = 0xFA, -- nvDash ---~ [0x022AE] = 0xF9, -- nVdash ---~ [0x022AF] = 0xFB, -- nVDash ---~ [0x022BA] = 0x03, -- intercal ---~ [0x022D4] = 0xF3, -- pitchfork ---~ [0x022E6] = 0xE0, -- lnsim ---~ [0x022E7] = 0xE2, -- gnsim ---~ [0x022E8] = 0xEB, -- precnsim ---~ [0x022E9] = 0xEC, -- succnsim ---~ [0x022EA] = 0xF0, -- ntriangleright ---~ [0x022EB] = 0xEF, -- ntriangleleft ---~ [0x022EC] = 0xF1, -- ntrianglelefteq ---~ [0x022ED] = 0xF2, -- ntrianglerighteq ---~ [0x0231C] = 0x5B, -- ulcorner ---~ [0x0231D] = 0x5C, -- urcorner ---~ [0x0231E] = 0x5D, -- llcorner ---~ [0x0231F] = 0x5E, -- lrcorner ---~ [0x025A2] = 0x03, -- blacksquare ---~ [0x02605] = 0xAB, -- bigstar ---~ [0x02713] = 0xAC, -- checkmark ---~ [0x029EB] = 0x09, -- blacklozenge ---~ [0x02A87] = 0xDA, -- lneq ---~ [0x02A89] = 0xE4, -- lnapprox ---~ [0x02A8A] = 0xE3, -- gnapprox ---~ [0x02AB5] = 0xE9, -- precneqq ---~ [0x02AB6] = 0xEA, -- succneqq ---~ [0x02AB9] = 0xED, -- precnapprox ---~ [0x02ABA] = 0xEE, -- succnapprox ---~ [0x02ACB] = 0xCE, -- subsetneqq ---~ [0x02ACC] = 0xCF, -- supsetneqq ---~ } - fonts.enc.math["lbr-ma"] = { [0x025CB] = 0x00, -- circle [0x025CF] = 0x01, -- blackcircle @@ -2056,12 +2016,6 @@ fonts.enc.math["lbr-mb"] = { [0x1D718] = 0x9B, -- varkappa } ---~ fonts.enc.math["lbr-mi"] = { ---~ ["0x00127"] = 0x9D, -- hbar ---~ ["0x003D1"] = 0x02, -- varTheta ---~ ["0x020D7"] = 0x7E, -- vec ---~ } - fonts.enc.math["lbr-sy"] = { [0x021CB] = 0x8D, -- leftrightharpoons [0x021CC] = 0x8E, -- rightleftharpoons @@ -2109,18 +2063,6 @@ fonts.enc.math["lbr-sy"] = { fonts.enc.math["lbr-sy"] = table.merged(fonts.enc.math["tex-sy"],fonts.enc.math["lbr-sy"]) ---~ fonts.enc.math["lbr-rm"] = { ---~ [0x00060] = 0x12, -- grave ---~ [0x000A8] = 0x7F, -- ddot ---~ [0x000AF] = 0x16, -- bar ---~ [0x000B4] = 0x13, -- acute ---~ [0x002C6] = 0x5E, -- hat ---~ [0x002C7] = 0x14, -- check ---~ [0x002D8] = 0x15, -- breve ---~ [0x002D9] = 0x05, -- dot ---~ [0x002DC] = 0x7E, -- tilde ---~ } - mathematics.make_font ( "lucida-math", { { name = "file:lbr.afm", features = "virtualmath", main = true }, { name = "hlcrim.tfm", vector = "tex-mi", skewchar=0x7F }, diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index c1e1b71c0..d1e1e2e4a 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -13,6 +13,7 @@ local format, gmatch, concat, round, match = string.format, string.gmatch, table local sprint = tex.sprint local tonumber, type = tonumber, type local lpegmatch = lpeg.match +local texbox = tex.box local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming @@ -426,11 +427,10 @@ metapost.textext_current = metapost.first_box metapost.multipass = false function metapost.free_boxes() -- todo: mp direct list ipv box - local tb = tex.box for i = metapost.first_box,metapost.last_box do - local b = tb[i] + local b = texbox[i] if b then - tb[i] = nil -- no node.flush_list(b) needed, else double free error + texbox[i] = nil -- no node.flush_list(b) needed, else double free error else break end @@ -480,7 +480,8 @@ function metapost.specials.ts(specification,object,result,flusher) metapost.textext_current = metapost.first_box + n - 1 end local b = metapost.textext_current - sprint(ctxcatcodes,format("\\MPLIBgettextscaled{%s}{%s}{%s}",b, metapost.sxsy(tex.wd[b],tex.ht[b],tex.dp[b]))) + local box = texbox[b] + sprint(ctxcatcodes,format("\\MPLIBgettextscaled{%s}{%s}{%s}",b, metapost.sxsy(box.width,box.height,box.depth))) result = { "Q" } return object, result end @@ -697,8 +698,10 @@ function metapost.text_texts_data() if trace_textexts then logs.report("metapost","passed data: order %s, box %s",n,i) end - if tex.box[i] then - t[#t+1] = format("_tt_w_[%i]:=%f;_tt_h_[%i]:=%f;_tt_d_[%i]:=%f;", n,tex.wd[i]/factor, n,tex.ht[i]/factor, n,tex.dp[i]/factor) + local box = texbox[i] + if box then + t[#t+1] = format("_tt_w_[%i]:=%f;_tt_h_[%i]:=%f;_tt_d_[%i]:=%f;", + n,box.width/factor,n,box.height/factor,n,box.depth/factor) else break end diff --git a/tex/context/base/mult-ini.lua b/tex/context/base/mult-ini.lua index a1dd5ecfd..d876e98b5 100644 --- a/tex/context/base/mult-ini.lua +++ b/tex/context/base/mult-ini.lua @@ -8,6 +8,7 @@ if not modules then modules = { } end modules ['mult-ini'] = { local format, gmatch, gsub = string.format, string.gmatch, string.gsub local lpegmatch = lpeg.match +local serialize = table.serialize interfaces = interfaces or { } interfaces.messages = interfaces.messages or { } @@ -74,3 +75,27 @@ end function interfaces.setconstant(constant,given) constants[given] = constant end + +-- it's nicer to have numbers as reference than a hash + +interfaces.cachedsetups = interfaces.cachedsetups or { } +interfaces.hashedsetups = interfaces.hashedsetups or { } + +storage.register("interfaces.cachedsetups", interfaces.cachedsetups, "interfaces.cachedsetups") +storage.register("interfaces.hashedsetups", interfaces.hashedsetups, "interfaces.hashedsetups") + +local cachedsetups = interfaces.cachedsetups +local hashedsetups = interfaces.hashedsetups + +function interfaces.cachesetup(t) + local hash = serialize(t) + local done = hashedsetups[hash] + if done then + return cachedsetups[done] + else + done = #cachedsetups + 1 + cachedsetups[done] = t + hashedsetups[hash] = done + return t + end +end diff --git a/tex/context/base/mult-sys.tex b/tex/context/base/mult-sys.tex index 72b0bce5d..5a718cc60 100644 --- a/tex/context/base/mult-sys.tex +++ b/tex/context/base/mult-sys.tex @@ -64,6 +64,7 @@ \definesystemconstant {spanish} \definesystemconstant {es} \definesystemconstant {swedish} \definesystemconstant {sv} \definesystemconstant {turkish} \definesystemconstant {tr} +\definesystemconstant {turkmen} \definesystemconstant {tk} \definesystemconstant {gbenglish} \definesystemconstant {gb} \definesystemconstant {ukenglish} \definesystemconstant {uk} \definesystemconstant {usenglish} \definesystemconstant {us} \definesystemconstant {ukrainian} \definesystemconstant {ua} @@ -496,6 +497,7 @@ \definesystemvariable {fl} % Floats \definesystemvariable {fm} % ForMules \definesystemvariable {fn} % subformulas +\definesystemvariable {fo} % xml FO \definesystemvariable {fp} % FilegroeP \definesystemvariable {fq} % Features \definesystemvariable {fr} % ForM diff --git a/tex/context/base/node-aux.lua b/tex/context/base/node-aux.lua new file mode 100644 index 000000000..8bbfbe918 --- /dev/null +++ b/tex/context/base/node-aux.lua @@ -0,0 +1,56 @@ +if not modules then modules = { } end modules ['node-aux'] = { + version = 1.001, + comment = "companion to node-spl.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local gsub, format = string.gsub, string.format + +local free_node = node.free +local hpack_nodes = node.hpack +local node_fields = node.fields + +function nodes.repack_hlist(list,...) + local temp, b = hpack_nodes(list,...) + list = temp.list + temp.list = nil + free_node(temp) + return list, b +end + +function nodes.merge(a,b) + if a and b then + local t = node.fields(a.id) + for i=3,#t do + local name = t[i] + a[name] = b[name] + end + end + return a, b +end + +local fields, whatsits = { }, { } + +for k, v in pairs(node.types()) do + if v == "whatsit" then + fields[k], fields[v] = { }, { } + for kk, vv in pairs(node.whatsits()) do + local f = node_fields(k,kk) + whatsits[kk], whatsits[vv] = f, f + end + else + local f = node_fields(k) + fields[k], fields[v] = f, f + end +end + +nodes.fields, nodes.whatsits = fields, whatsits + +function nodes.info(n) + logs.report(format("%14s","type"),node.type(n.id)) + for k,v in pairs(fields[n.id]) do + logs.report(format("%14s",v),gsub(gsub(tostring(n[v]),"%s+"," "),"node ","")) + end +end diff --git a/tex/context/base/node-ini.lua b/tex/context/base/node-ini.lua index 741e53d6b..e21fc70e4 100644 --- a/tex/context/base/node-ini.lua +++ b/tex/context/base/node-ini.lua @@ -212,7 +212,7 @@ end nodes.count = count --- new +-- new, will move function attributes.ofnode(n) local a = n.attr diff --git a/tex/context/base/node-ini.mkiv b/tex/context/base/node-ini.mkiv index 0659539bc..227533413 100644 --- a/tex/context/base/node-ini.mkiv +++ b/tex/context/base/node-ini.mkiv @@ -18,6 +18,7 @@ \newcount\filterstate \filterstate\plusone \registerctxluafile{node-ini}{1.001} +\registerctxluafile{node-aux}{1.001} \registerctxluafile{node-tst}{1.001} \registerctxluafile{node-tra}{1.001} % we might split it off (module) \registerctxluafile{node-seq}{1.001} % we might generalize this one diff --git a/tex/context/base/node-res.lua b/tex/context/base/node-res.lua index 5398d8433..47f0c8d60 100644 --- a/tex/context/base/node-res.lua +++ b/tex/context/base/node-res.lua @@ -120,6 +120,48 @@ function nodes.latelua(code) return n end +--[[ +<p>At some point we ran into a problem that the glue specification +of the zeropoint dimension was overwritten when adapting a glue spec +node. This is a side effect of glue specs being shared. After a +couple of hours tracing and debugging Taco and I came to the +conclusion that it made no sense to complicate the spec allocator +and settled on a writable flag. This all is a side effect of the +fact that some glues use reserved memory slots (with the zeropoint +glue being a noticeable one). So, next we wrap this into a function +and hide it for the user. And yes, LuaTeX now gives a warning as +well.</p> +]]-- + +if tex.luatexversion > 51 then + + function nodes.writable_spec(n) + local spec = n.spec + if not spec then + spec = copy_node(glue_spec) + n.spec = spec + elseif not spec.writable then + spec = copy_node(spec) + n.spec = spec + end + return spec + end + +else + + function nodes.writable_spec(n) + local spec = n.spec + if not spec then + spec = copy_node(glue_spec) + else + spec = copy_node(spec) + end + n.spec = spec + return spec + end + +end + local cache = { } function nodes.usernumber(num) diff --git a/tex/context/base/node-rul.lua b/tex/context/base/node-rul.lua index f217c3a97..17b7c7658 100644 --- a/tex/context/base/node-rul.lua +++ b/tex/context/base/node-rul.lua @@ -13,26 +13,28 @@ local disc = node.id("disc") local rule = node.id("rule") function nodes.strip_range(first,last) -- todo: dir - local current = first - while current ~= last do - local id = current.id - if id == glyph or id == disc then ---~ if id == glyph or id == rule or id == disc then - first = current - break - else - current = current.next + if first and last then -- just to be sure + local current = first + while current and current ~= last do + local id = current.id + if id == glyph or id == disc then + --~ if id == glyph or id == rule or id == disc then + first = current + break + else + current = current.next + end end - end - local current = last - while current ~= first do - local id = current.id ---~ if id == glyph or id == rule or id == disc then - if id == glyph or id == disc then - last = current - break - else - current = current.prev + local current = last + while current and current ~= first do + local id = current.id + --~ if id == glyph or id == rule or id == disc then + if id == glyph or id == disc then + last = current + break + else + current = current.prev + end end end return first, last @@ -169,6 +171,7 @@ function nodes.rules.define(settings) end local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but acceptable for this purpose +-- check for f and l local r, m if true then f, l = strip_range(f,l) diff --git a/tex/context/base/node-ser.lua b/tex/context/base/node-ser.lua index 95b08a4d0..e632e92da 100644 --- a/tex/context/base/node-ser.lua +++ b/tex/context/base/node-ser.lua @@ -196,6 +196,8 @@ local function serialize(root,name,handle,depth,m) else handle(format("%s %s=%q,",depth,key(k),v)) end + elseif t == "boolean" then + handle(format("%s %s=%q,",depth,key(k),tostring(v))) elseif v then -- userdata or table serialize(v,k,handle,depth,m+1) end diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua index 39ff32209..83340331b 100644 --- a/tex/context/base/node-tra.lua +++ b/tex/context/base/node-tra.lua @@ -333,7 +333,8 @@ function nodes.tosequence(start,stop,compact) if start then local t = { } while start do - if start.id == glyph then + local id = start.id + if id == glyph then local c = start.char if compact then if start.components then @@ -344,11 +345,13 @@ function nodes.tosequence(start,stop,compact) else t[#t+1] = format("U+%04X:%s",c,utfchar(c)) end + elseif id == whatsit and start.subtype == 6 or start.subtype == 7 then + t[#t+1] = "[" .. start.dir .. "]" else if compact then t[#t+1] = "[]" else - t[#t+1] = match(tostring(start),": (%S+)") + t[#t+1] = node_type(id) end end if start == stop then diff --git a/tex/context/base/pack-rul.lua b/tex/context/base/pack-rul.lua index 9cbb9b2ca..378167c97 100644 --- a/tex/context/base/pack-rul.lua +++ b/tex/context/base/pack-rul.lua @@ -10,16 +10,16 @@ if not modules then modules = { } end modules ['pack-rul'] = { <p>An explanation is given in the history document <t>mk</t>.</p> --ldx]]-- -local texdimen, texcount, texbox, texwd = tex.dimen, tex.count, tex.box, tex.wd +local texdimen, texcount, texbox = tex.dimen, tex.count, tex.box local hpack, free, copy, traverse_id = node.hpack, node.free, node.copy_list, node.traverse_id function commands.doreshapeframedbox(n) - local noflines, lastlinelength = 0, 0 - if texwd[n] ~= 0 then - local list = texbox[n].list + local noflines, lastlinelength, box = 0, 0, texbox[n] + if box.width ~= 0 then + local list = box.list if list then local width, done = 0, false - for h in traverse_id('hlist',list) do + for h in traverse_id('hlist',list) do -- no dir etc needed local l = h.list if l then done = true @@ -37,14 +37,14 @@ function commands.doreshapeframedbox(n) local l = h.list if l then -- if h.width ~= width then -- else no display math handling (uses shift) - h.list = hpack(l,width,'exactly') + h.list = hpack(l,width,'exactly',h.dir) h.shift = 0 -- needed for display math h.width = width -- end end end end - texwd[n] = width + box.width = width end end end diff --git a/tex/context/base/page-app.mkiv b/tex/context/base/page-app.mkiv index e5c149aa0..90abf0898 100644 --- a/tex/context/base/page-app.mkiv +++ b/tex/context/base/page-app.mkiv @@ -96,16 +96,16 @@ \presetlocalframed[\??tg] -\def\setupTEXpage +\unexpanded\def\setupTEXpage {\dodoubleargument\getparameters[\??tg]} -\def\startTEXpage +\unexpanded\def\startTEXpage {\dosingleempty\dostartTEXpage} \def\dostartTEXpage[#1]% {\dostartfittingpage[\??tg][#1]\gobblespacetokens} -\def\stopTEXpage +\unexpanded\def\stopTEXpage {\removelastspace \dostopfittingpage} @@ -127,14 +127,14 @@ %D %D maybe I should support stream=yes in framed. -\def\startTEXstream +\unexpanded\def\startTEXstream {\dosingleempty\dostartTEXstream} \def\dostartTEXstream[#1]% {\page \defineoutputstream[tex]% \enableoutputstream[tex]% - \def\stopTEXstream + \unexpanded\def\stopTEXstream {\disableoutputstream \startTEXpage \outputstreamunvbox[tex]% diff --git a/tex/context/base/page-lin.lua b/tex/context/base/page-lin.lua index facec7911..444210428 100644 --- a/tex/context/base/page-lin.lua +++ b/tex/context/base/page-lin.lua @@ -8,15 +8,19 @@ if not modules then modules = { } end modules ['page-lin'] = { -- experimental +local trace_numbers = false trackers.register("lines.numbers", function(v) trace_numbers = v end) + local format = string.format local texsprint, texwrite, texbox = tex.sprint, tex.write, tex.box local ctxcatcodes = tex.ctxcatcodes local variables = interfaces.variables -nodes = nodes or { } -nodes.lines = nodes.lines or { } -nodes.lines.data = nodes.lines.data or { } -- start step tag +nodes = nodes or { } +nodes.lines = nodes.lines or { } +nodes.lines.data = nodes.lines.data or { } -- start step tag + +storage.register("lines/data", nodes.lines.data, "nodes.lines.data") -- if there is demand for it, we can support multiple numbering streams -- and use more than one attibute @@ -37,6 +41,7 @@ local traverse = node.traverse local copy_node = node.copy local data = nodes.lines.data +local last = #data nodes.lines.scratchbox = nodes.lines.scratchbox or 0 @@ -99,20 +104,35 @@ function filters.line.linenumber(data) -- raw texwrite(data.entries.linenumber or "0") end - --- boxed variant +-- boxed variant, todo: use number mechanism nodes.lines.boxed = { } +-- todo: cache setups, and free id no longer used +-- use interfaces.cachesetup(t) + function nodes.lines.boxed.register(configuration) - data[#data+1] = configuration - return #data + last = last + 1 + data[last] = configuration + if trace_numbers then + logs.report("lines","registering setup %s",last) + end + return last end + function nodes.lines.boxed.setup(n,configuration) local d = data[n] if d then - for k,v in pairs(configuration) do d[k] = v end + if trace_numbers then + logs.report("lines","updating setup %s",n) + end + for k,v in pairs(configuration) do + d[k] = v + end else + if trace_numbers then + logs.report("lines","registering setup %s (br)",n) + end data[n] = configuration end return n @@ -123,10 +143,14 @@ local leftskip = nodes.leftskip local function check_number(n,a,skip) -- move inline local d = data[a] if d then - local s = d.start + local s = d.start or 1 current_list[#current_list+1] = { n, s } if not skip and s % d.step == 0 then - texsprint(ctxcatcodes, format("\\makenumber{%s}{%s}{%s}{%s}{%s}\\endgraf", d.tag or "", s, n.shift, n.width, leftskip(n.list))) + local tag = d.tag or "" + texsprint(ctxcatcodes, format("\\makenumber{%s}{%s}{%s}{%s}{%s}\\endgraf", tag, s, n.shift, n.width, leftskip(n.list))) + if trace_numbers then + logs.report("numbers","making number %s for setup %s: %s (%s)",#current_list,a,s,d.continue or "no") + end else texsprint(ctxcatcodes, "\\skipnumber\\endgraf") end @@ -139,9 +163,6 @@ function nodes.lines.boxed.stage_one(n) local head = texbox[n] if head then local list = head.list - --~ while list.id == vlist and not list.next do - --~ list = list.list - --~ end local last_a, skip = nil, false for n in traverse_id(hlist,list) do -- attr test here and quit as soon as zero found if n.height == 0 and n.depth == 0 then @@ -178,116 +199,11 @@ function nodes.lines.boxed.stage_two(n,m) for l in traverse_id(hlist,texbox[m].list) do t[#t+1] = copy_node(l) end - for j=1,#current_list do - local l = current_list[j] - local n, m = l[1], l[2] - i = i + 1 - t[i].next = n.list - n.list = t[i] + for i=1,#current_list do + local li = current_list[i] + local n, m, ti = li[1], li[2], t[i] + ti.next, n.list = n.list, ti resolve(n,m) end end end - --- flow variant --- --- it's too hard to make this one robust, so for the moment it's not --- available; todo: line refs - -if false then - - nodes.lines.flowed = { } - - function nodes.lines.flowed.prepare(tag) - for i=1,#data do -- ?? - texsprint(ctxcatcodes,format("\\ctxlua{nodes.lines.flowed.prepare_a(%s)}\\ctxlua{nodes.lines.flowed.prepare_b(%s)}",i,i)) - end - end - - function nodes.lines.flowed.prepare_a(i) - local d = data[i] - local p = d.present - if p and p < chunksize then - local b = nodes.lines.scratchbox - texsprint(ctxcatcodes, format("{\\forgetall\\global\\setbox%s=\\vbox{\\unvbox%s\\relax\\offinterlineskip", b, b)) - while p < chunksize do - texsprint(ctxcatcodes, format("\\mkmaketextlinenumber{%s}{%s}\\endgraf",d.start,1)) - p = p + 1 - d.start = d.start + d.step - end - d.present = p - texsprint(ctxcatcodes, "}}") - end - end - - function nodes.lines.flowed.prepare_b(i) - local d = data[i] - local b = nodes.lines.scratchbox - local l = texbox[b] - if l then - l = l.list - local n = d.numbers - while l do - if l.id == hlist then - local m = copy_node(l) - m.next = nil - if n then - n.next = m - else - d.numbers = m - end - n = m - end - l = l.next - end - end - tex.box[b] = nil - end - - function nodes.lines.flowed.cleanup(i) - if i then - node.flush_list(data[i].numbers) - else - for i=1,#data do - node.flush_list(data[i].numbers) - end - end - end - - local function check_number(n,a) - local d = data[a] - if d then - local m = d.numbers - if m then - d.numbers = m.next - m.next = n.list - n.list = m - d.present = d.present - 1 - end - end - end - - function nodes.lines.flowed.apply(head) - for n in node.traverse(head) do - local id = n.id - if id == hlist then - if n.height == 0 and n.depth == 0 then - -- skip funny hlists - else - local a = has_attribute(n,line_number) - if a and a > 0 then - if has_attribute(n,display_math) then - if nodes.is_display_math(n) then - check_number(n,a) - end - else - check_number(n,a) - end - end - end - end - end - return head, true - end - -end diff --git a/tex/context/base/page-lin.mkiv b/tex/context/base/page-lin.mkiv index 2e3703eae..1cbf649dd 100644 --- a/tex/context/base/page-lin.mkiv +++ b/tex/context/base/page-lin.mkiv @@ -70,34 +70,37 @@ \def\mkdoprocessboxcontents #1{\mkaddtextlinenumbers{#1}\plusone \plusone} \def\mkdoprocesscolumncontents#1{\mkaddtextlinenumbers{#1}\currentcolumn\nofcolumns} +\def\mklinenumberparameters + {continue = "\linenumberparameter\c!continue", + start = \linenumberparameter\c!start, + step = \linenumberparameter\c!step, + method = "\linenumberparameter\c!method", + tag = "\currentlinenumbering"} + +\def\mklinenumberupdateparameters + {continue = "\linenumberparameter\c!continue"} + \def\mkdefinetextlinenumbering - {\setxvalue{ln:c:\currentlinenumbering}{\number\ctxlua{tex.sprint(nodes.lines.boxed.register({ - start = \linenumberparameter\c!start, - step = \linenumberparameter\c!step, - method = "\linenumberparameter\c!method", - tag = "\currentlinenumbering", - }))}}} - -\def\mkstarttextlinenumbering#1#2% + {\setxvalue{ln:c:\currentlinenumbering}{\number\ctxlua{tex.sprint(nodes.lines.boxed.register({\mklinenumberparameters}))}}} + +\def\mkupdatetextlinenumbering + {\ctxlua{nodes.lines.boxed.setup(\getvalue{ln:c:\currentlinenumbering},{\mklinenumberupdateparameters})}} + +\def\mkstarttextlinenumbering#1#2% always when assignment {\globallet\mkprocesspagecontents \mkdoprocesspagecontents \globallet\mkprocesscolumncontents\mkdoprocesscolumncontents \global\settrue\boxcontentneedsprocessing % see core-rul.mkiv \edef\currentlinenumbering{#1}% \ifcase#2\relax - % continue + \mkupdatetextlinenumbering % continue \or - \mkdefinetextlinenumbering % restart + \mkdefinetextlinenumbering % only when assignment \fi \attribute\linenumberattribute\getvalue{ln:c:\currentlinenumbering}\relax} \def\mksetuptextlinenumbering {\ifcsname ln:c:\currentlinenumbering\endcsname - \expanded{\ctxlua{nodes.lines.boxed.setup(\getvalue{ln:c:\currentlinenumbering},{ - start = \linenumberparameter\c!start, - step = \linenumberparameter\c!step, - method = "\linenumberparameter\c!method", - tag = "\currentlinenumbering" - })}}% + \ctxlua{nodes.lines.boxed.setup(\getvalue{ln:c:\currentlinenumbering},{\mklinenumberparameters})}% \fi} \def\mkstoptextlinenumbering @@ -172,7 +175,7 @@ \c!start=1, \c!step=1, \c!method=\v!first, - \c!continue=v!no, + \c!continue=\v!no, \c!location=\v!left, \c!style=, \c!color=, @@ -211,24 +214,52 @@ \expandafter\chardef\csname\??rn:a:\v!flushright\endcsname \plustwo \expandafter\chardef\csname\??rn:a:\v!auto \endcsname \plusfive +% \def\dostartlinenumbering[#1][#2]% todo: c!continue +% {\begingroup +% \chardef\linenumbermode\plusone +% \ifsecondargument +% \def\currentlinenumbering{#1}% +% \doifnumberelse{#2}% downward compatible +% {\setvalue{\??rn#1\c!start}{#2}}% +% {\doif{#2}\v!continue{\chardef\linenumbermode\zerocount}}% +% \else\iffirstargument +% \doifnumberelse{#1}% downward compatible +% {\let\currentlinenumbering\empty +% \setvalue{\??rn\c!start}{#1}}% +% {\doifelse{#1}\v!continue +% {\let\currentlinenumbering\empty +% \chardef\linenumbermode\zerocount} +% {\def\currentlinenumbering{#1}}}% +% \fi\fi +% \doif{\linenumberparameter\c!continue}\v!yes +% {\chardef\linenumbermode\zerocount}% +% \numberinglinestrue +% \the\beforeeverylinenumbering +% \mkstarttextlinenumbering\currentlinenumbering\linenumbermode} + \def\dostartlinenumbering[#1][#2]% todo: c!continue {\begingroup \chardef\linenumbermode\plusone \ifsecondargument \def\currentlinenumbering{#1}% - \doifnumberelse{#2}% downward compatible - {\setvalue{\??rn#1\c!start}{#2}}% - {\doif{#2}\v!continue{\chardef\linenumbermode\zerocount}}% + \doifassignmentelse{#2} + {\getparameters[\??rn\currentlinenumbering][#2]} + {\doifnumberelse{#2}% downward compatible + {\setvalue{\??rn#1\c!start}{#2}}% + {\doif{#2}\v!continue + {\getparameters[\??rn\currentlinenumbering][\c!continue=\v!yes]% + \chardef\linenumbermode\zerocount}}}% \else\iffirstargument \doifnumberelse{#1}% downward compatible {\let\currentlinenumbering\empty \setvalue{\??rn\c!start}{#1}}% {\doifelse{#1}\v!continue {\let\currentlinenumbering\empty + \getparameters[\??rn\currentlinenumbering][\c!continue=\v!yes]% \chardef\linenumbermode\zerocount} {\def\currentlinenumbering{#1}}}% \fi\fi - \doifelse{\linenumberparameter\c!continue}\v!yes + \doif{\linenumberparameter\c!continue}\v!yes {\chardef\linenumbermode\zerocount}% \numberinglinestrue \the\beforeeverylinenumbering @@ -450,33 +481,3 @@ {\in[lr:b:#1]--\in[lr:e:#1]}} \protect \endinput - -\iffalse % \iftrue eventually we will do it like ... - - \appendtoks\ctxlua{nodes.lines.flowed.prepare()}\to\everyshipout - \appendtoks\ctxlua{nodes.lines.flowed.cleanup()}\to\everybye - - \def\mkstarttextlinenumbering#1#2% - {\ctxlua{nodes.lines.flowed.prepare("#1")}% - \attribute\linenumberattribute#2\relax} - - \def\mkstoptextlinenumbering - {\attribute\linenumberattribute\attributeunsetvalue} - - \def\mkmaketextlinenumber#1#2% - {\hbox \bgroup - \ifcase#2\relax - % - \or - \llap{#1\quad\hskip#2\scaledpoint}% - \else - \rlap{\hskip\textwidth\quad#1\hskip#2\scaledpoint}% - \fi - \egroup} - - \ctxlua{ - nodes.lines.scratchbox = \number\linenumberscratchbox ; - -- register nodes.lines.flowed.apply in post_linebreak_filter actions - } - -\fi diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua index af9f5170f..5acfd7dbb 100644 --- a/tex/context/base/spac-ver.lua +++ b/tex/context/base/spac-ver.lua @@ -20,7 +20,7 @@ if not modules then modules = { } end modules ['spac-ver'] = { local next, type, tonumber = next, type, tonumber local format, gmatch, concat, match = string.format, string.gmatch, table.concat, string.match local ceil, floor, max, min, round = math.ceil, math.floor, math.max, math.min, math.round -local texsprint, texlists, texdimen, texbox, texht, texdp = tex.sprint, tex.lists, tex.dimen, tex.box, tex.ht, tex.dp +local texsprint, texlists, texdimen, texbox = tex.sprint, tex.lists, tex.dimen, tex.box local lpegmatch = lpeg.match local unpack = unpack or table.unpack @@ -63,6 +63,7 @@ local count_nodes = nodes.count local node_ids_to_string = nodes.ids_to_string local hpack_node = node.hpack local vpack_node = node.vpack +local writable_spec = nodes.writable_spec local glyph = node.id("glyph") local penalty = node.id("penalty") @@ -247,6 +248,7 @@ local function snap_topskip(current,method) local wd = w if spec then wd = 0 + spec = writable_spec(current) spec.width = wd end return w, wd @@ -551,8 +553,8 @@ function vspacing.snap_box(n,how) logs.report("snapper", "hlist not snapped, already done") end else - local h, d, ch, cd, lines = snap_hlist(box,sv,texht[n],texdp[n]) - texht[n], texdp[n] = ch, cd + local h, d, ch, cd, lines = snap_hlist(box,sv,box.height,box.depth) + box.height, box.depth = ch, cd if trace_vsnapping then logs.report("snapper", "hlist snapped from (%s,%s) to (%s,%s) using method '%s' (%s) for '%s' (%s lines)",h,d,ch,cd,sv.name,sv.specification,"direct",lines) end @@ -696,6 +698,7 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail if cs and ps.stretch_order == 0 and ps.shrink_order == 0 and cs.stretch_order == 0 and cs.shrink_order == 0 then local pw, pp, pm = ps.width, ps.stretch, ps.shrink local cw, cp, cm = cs.width, cs.stretch, cs.shrink + ps = writable_spec(previous) ps.width, ps.stretch, ps.shrink = pw + cw, pp + cp, pm + cm if trace then trace_natural("removed",current) end head, current = remove_node(head, current, true) @@ -774,7 +777,8 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail head, current = remove_node(head, current, true) elseif sc == add then if trace then trace_skip('add',sc,so,sp,current) end - local old, new = glue_data.spec, current.spec +--~ local old, new = glue_data.spec, current.spec + local old, new = writable_spec(glue_data), current.spec old.width = old.width + new.width old.stretch = old.stretch + new.stretch old.shrink = old.shrink + new.shrink @@ -798,6 +802,7 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail set_attribute(current,snap_method,0) local spec = current.spec if spec then + spec = writable_spec(current) spec.width = 0 if trace_vsnapping then logs.report("snapper", "lineskip set to zero") @@ -1063,7 +1068,7 @@ function nodes.repackage_graphicvadjust(head,groupcode) -- we can make an action head, h, n = remove_node(head,h) local pl = p.list if n.width ~= 0 then - n = hpack_node(n,0,'exactly') + n = hpack_node(n,0,'exactly') -- todo: dir end if pl then pl.prev = n diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv index 1a4291e17..efeb54c8f 100644 --- a/tex/context/base/spac-ver.mkiv +++ b/tex/context/base/spac-ver.mkiv @@ -1086,7 +1086,7 @@ \let\pseudoendstrut\removeunwantedspaces \def\resetteststrut - {\let\strutwidth\zeropoint + {\def\strutwidth{\zeropoint}% no let \setstrut} \ifdefined\setfontparameters\else @@ -1115,7 +1115,7 @@ \lineskip\zeropoint \lineskiplimit\maxdimen % We also need this here now; thanks to taco for figuring that out! - \let\minimumlinedistance\zeropoint} + \def\minimumlinedistance{\zeropoint}} \def\nointerlineskip {\prevdepth-\thousandpoint} diff --git a/tex/context/base/spec-dpm.mkii b/tex/context/base/spec-dpm.mkii index 9cf023fe0..efecd7928 100644 --- a/tex/context/base/spec-dpm.mkii +++ b/tex/context/base/spec-dpm.mkii @@ -411,7 +411,8 @@ \scratchcounter#4\advance\scratchcounter\minusone \special{pdf: out \ifcase#5-\fi#2 % <</Page \the\scratchcounter\space /View [/Fit] /Title (#3)>>}% - <</Title (#3) /A <</S /GoTo /D [@page\number#4\space\PDFpageviewwrd]>> >>}% + % <</Title (#3) /A <</S /GoTo /D [@page\number#4\space\PDFpageviewwrd]>> >>}% + <</Title \ifPDFunicode<#3>\else(#3)\fi\space /A <</S /GoTo /D [@page\number#4\space\PDFpageviewwrd]>> >>}% \fi} %D \macros diff --git a/tex/context/base/spec-dpx.mkii b/tex/context/base/spec-dpx.mkii index ed49ea843..c521da8c7 100644 --- a/tex/context/base/spec-dpx.mkii +++ b/tex/context/base/spec-dpx.mkii @@ -590,7 +590,8 @@ %\scratchcounter#4\advance\scratchcounter\minusone \special{pdf:outline #1 %\ifcase#5 opened\fi % <</Title (#3) /A <</S /GoTo /D (page:\the\scratchcounter)>>>>}% - <</Title (#3) /A <</S /GoTo /D [@page\number#4\space\PDFpageviewwrd]>> >>}% + % <</Title (#3) /A <</S /GoTo /D [@page\number#4\space\PDFpageviewwrd]>> >>}% + <</Title \ifPDFunicode<#3>\else(#3)\fi\space /A <</S /GoTo /D [@page\number#4\space\PDFpageviewwrd]>> >>}% \fi} %D \macros diff --git a/tex/context/base/spec-fdf.mkii b/tex/context/base/spec-fdf.mkii index 4bf4115c6..30e15ff34 100644 --- a/tex/context/base/spec-fdf.mkii +++ b/tex/context/base/spec-fdf.mkii @@ -377,21 +377,39 @@ \flushPDFpageboxes \to \everyshipout +% \def\doPDFsetupidentity#1#2#3#4#5#6% +% {\bgroup +% \enablePDFdocencoding +% \edef\!!stringa{#5}% +% \ifx\!!stringa\empty \ifx\pdfdate\undefined\else +% \edef\!!stringa{D:\pdfdate}% +% \fi \fi +% \expanded{\doPDFaddtoinfo +% {/Title (#1) +% /Subject (#2) +% /Author (#3) +% /Creator (#4) +% /ModDate (\!!stringa) +% /ID (\jobname.\!!stringa) % needed for pdf/x +% /Keywords (#6)}}% +% \egroup} + \def\doPDFsetupidentity#1#2#3#4#5#6% {\bgroup \enablePDFdocencoding - \edef\!!stringa{#5}% - \ifx\!!stringa\empty \ifx\pdfdate\undefined\else - \edef\!!stringa{D:\pdfdate}% - \fi \fi + \sanitizePDFencoding#1\to\idtitle \stripstring\idtitle + \sanitizePDFencoding#2\to\idsubject\stripstring\idsubject + \sanitizePDFencoding#3\to\idauthor \stripstring\idauthor + \sanitizePDFencoding#4\to\idcreator\stripstring\idcreator + \sanitizePDFencoding#6\to\idkeyword\stripstring\idkeyword \expanded{\doPDFaddtoinfo - {/Title (#1) - /Subject (#2) - /Author (#3) - /Creator (#4) - /ModDate (\!!stringa) - /ID (\jobname.\!!stringa) % needed for pdf/x - /Keywords (#6)}}% + {/Title \ifPDFunicode<\idtitle >\else(\idtitle )\fi + /Subject \ifPDFunicode<\idsubject>\else(\idsubject)\fi + /Author \ifPDFunicode<\idauthor >\else(\idauthor )\fi + /Creator \ifPDFunicode<\idcreator>\else(\idcreator)\fi + /ModDate (#4) + /ID (\jobname.#5) % needed for pdf/x + /Keywords \ifPDFunicode<\idkeyword>\else(\idkeyword)\fi}}% \egroup} %D \macros @@ -1179,10 +1197,8 @@ \def\doPDFinsertbookmark#1#2#3#4#5% level sublevels text page open=1 {\bgroup - % todo, unicode - \sanitizePDFdocencoding#3\to\bookmarktext % uses scratchcounter + \sanitizePDFencoding#3\to\bookmarktext % uses scratchcounter \stripstring\bookmarktext - %\sanitizePDFstring#3\to\bookmarktext \doPDFbookmark{#1}{#2}{\bookmarktext}{#4}{#5}% \egroup} @@ -2364,7 +2380,69 @@ \let^^M=\\} \egroup -\let\sanitizePDFencoding\sanitizePDFdocencoding +% \let\sanitizePDFencoding\sanitizePDFdocencoding + +%D The conversions comes down to (for the sake of speed the +%D implementation combines steps): +%D +%D \startitemize +%D \item we expand the \UTF\ sequences into \type {\unicodechar}'s +%D \item spaces become character 255's (so that they are not +%D gobbled in argument fetching +%D \item normal \ASCII\ chars are unchanged +%D \item \par's and alike are converted to \type {\unicodechar}'s +%D \stopitemize +%D +%D This happens by expansion; next we convert the resulting +%D sequence by interpreting the stream. + +\long\def\sanitizePDFuniencoding#1\to#2% + {\enablePDFunicrlf + \simplifycommands % added due to Dohyun Kim + \let\unicodechar\relax % prevent further expansion + \retainlccodes\lccode32=255 % slooow + \lowercasestring\PDFunicodetrigger#1\to#2% + \edef#2{\expandafter\doPDFuni#2\empty\empty}} % slooow + +%D Handling of empty lines: + +\bgroup +\catcode`\^^M=\@@active +\gdef\enablePDFunicrlf% + {\def\\{\unicodechar{13}}% + \def\par{\\\\}% + \catcode`\^^M=\@@active% + \let^^M=\\} +\egroup + +%D Conversion to 16 bit \UNICODE: + +\def\PDFunicodechar#1% + {\@EA\lchexnumbers\@EA{\number\utfdiv{#1}}% + \@EA\lchexnumbers\@EA{\number\utfmod{#1}}} + +\def\PDFunicodetrigger + {\unicodechar{65279}} + +%D The postprocessor: + +\def\doPDFuni#1% + {\ifx#1\relax + \@EA\dodoPDFuni + \else\ifx#1\empty + % quit + \else + \@EAEAEA\nodoPDFuni + \fi\fi#1} + +\def\nodoPDFuni#1% + {\PDFunicodechar{\ifnum`#1=255 32\else`#1\fi}\doPDFuni} + +\def\dodoPDFuni#1#2% + {\PDFunicodechar{#2}\doPDFuni} + +\def\sanitizePDFencoding + {\doifelse\currentregime{utf}{\PDFunicodetrue\sanitizePDFuniencoding}\sanitizePDFdocencoding} %D A bit out of place, but useful: diff --git a/tex/context/base/spec-tpd.mkii b/tex/context/base/spec-tpd.mkii index 597993e0a..6af3b1272 100644 --- a/tex/context/base/spec-tpd.mkii +++ b/tex/context/base/spec-tpd.mkii @@ -1176,7 +1176,7 @@ \pdfoutline user {<</S /GoTo /D [\PDFobjectreference\space\PDFpageviewwrd]>>}% \ifcase#2 \else count \ifcase#5-\fi#2 \fi - {#3}} + {\ifPDFunicode<#3>\else#3\fi}} %D \macros %D {doPDFdictionaryobject,doPDFarrayobject} diff --git a/tex/context/base/spec-tst.mkii b/tex/context/base/spec-tst.mkii index bdd8a29b2..543baa647 100644 --- a/tex/context/base/spec-tst.mkii +++ b/tex/context/base/spec-tst.mkii @@ -11,113 +11,14 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\ifcase \pdfoutput \endinput \fi - \unprotect -%D The conversions comes down to (for the sake of speed the -%D implementation combines steps): -%D -%D \startitemize -%D \item we expand the \UTF\ sequences into \type {\unicodechar}'s -%D \item spaces become character 255's (so that they are not -%D gobbled in argument fetching -%D \item normal \ASCII\ chars are unchanged -%D \item \par's and alike are converted to \type {\unicodechar}'s -%D \stopitemize -%D -%D This happens by expansion; next we convert the resulting -%D sequence by interpreting the stream. - -\long\def\sanitizePDFuniencoding#1\to#2% - {\enablePDFunicrlf - \simplifycommands % added due to Dohyun Kim - \let\unicodechar\relax % prevent further expansion - \retainlccodes\lccode32=255 % slooow - \lowercasestring\PDFunicodetrigger#1\to#2% - \edef#2{\expandafter\doPDFuni#2\empty\empty}} % slooow - -%D Handling of empty lines: - -\bgroup -\catcode`\^^M=\@@active -\gdef\enablePDFunicrlf% - {\def\\{\unicodechar{13}}% - \def\par{\\\\}% - \catcode`\^^M=\@@active% - \let^^M=\\} -\egroup - -%D Conversion to 16 bit \UNICODE: - -\def\PDFunicodechar#1% - {\@EA\lchexnumbers\@EA{\number\utfdiv{#1}}% - \@EA\lchexnumbers\@EA{\number\utfmod{#1}}} - -\def\PDFunicodetrigger - {\unicodechar{65279}} - -%D The postprocessor: - -\def\doPDFuni#1% - {\ifx#1\relax - \@EA\dodoPDFuni - \else\ifx#1\empty - % quit - \else - \@EAEAEA\nodoPDFuni - \fi\fi#1} - -\def\nodoPDFuni#1% - {\PDFunicodechar{\ifnum`#1=255 32\else`#1\fi}\doPDFuni} - -\def\dodoPDFuni#1#2% - {\PDFunicodechar{#2}\doPDFuni} - -\def\sanitizePDFencoding - {\doifelse\currentregime{utf}% - {\PDFunicodetrue\sanitizePDFuniencoding}\sanitizePDFdocencoding} - -% pdftex specific - -\def\doPDFinsertbookmark#1#2#3#4#5% level sublevels text page open=1 - {\bgroup - \sanitizePDFencoding#3\to\bookmarktext % uses scratchcounter - \stripstring\bookmarktext - \doPDFbookmark{#1}{#2}{\bookmarktext}{#4}{#5}% - \egroup} - -\def\doPDFbookmark#1#2#3#4#5% - {\doPDFgetpagereference{#4}\PDFobjectreference - \pdfoutline - user {<</S /GoTo /D [\PDFobjectreference\space\PDFpageviewwrd]>>}% - \ifcase#2 \else count \ifcase#5-\fi#2 \fi - {\ifPDFunicode<#3>\else#3\fi}} - -\def\doPDFsetupidentity#1#2#3#4#5#6% - {\bgroup - \enablePDFdocencoding - \sanitizePDFencoding#1\to\idtitle \stripstring\idtitle - \sanitizePDFencoding#2\to\idsubject\stripstring\idsubject - \sanitizePDFencoding#3\to\idauthor \stripstring\idauthor - \sanitizePDFencoding#4\to\idcreator\stripstring\idcreator - \sanitizePDFencoding#6\to\idkeyword\stripstring\idkeyword - \expanded{\doPDFaddtoinfo - {/Title \ifPDFunicode<\idtitle >\else(\idtitle )\fi - /Subject \ifPDFunicode<\idsubject>\else(\idsubject)\fi - /Author \ifPDFunicode<\idauthor >\else(\idauthor )\fi - /Creator \ifPDFunicode<\idcreator>\else(\idcreator)\fi - /ModDate (#4) - /ID (\jobname.#5) % needed for pdf/x - /Keywords \ifPDFunicode<\idkeyword>\else(\idkeyword)\fi}}% - \egroup} +%D The code is now merged into spec-*.mkii \protect \doifnotmode{demo}{\endinput} -% \input spec-tst.tex - \mainlanguage[vn] \enableregime[utf] \usetypescript[all][computer-modern][t5] @@ -149,4 +50,3 @@ \subsection{Mục nhỏ thứ hai} Thử tiếng Việt \stoptext - diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv index 3c31bac4a..fcd5e6639 100644 --- a/tex/context/base/strc-itm.mkiv +++ b/tex/context/base/strc-itm.mkiv @@ -1211,7 +1211,7 @@ % \stopitemize \setvalue{\??op:\??op:\c!textdistance:\v!none}% - {\let\textitemdistance\zeropoint} + {\def\textitemdistance{\zeropoint}} \def\doassigngiventextitemdistance#1% {\assignvalue diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv index b13ee5371..a2c3dfd82 100644 --- a/tex/context/base/strc-lst.mkiv +++ b/tex/context/base/strc-lst.mkiv @@ -617,9 +617,6 @@ {\!!widtha\listparameter\c!width}}% \getvalue{\??li\c!alternative\listparameter\c!alternative}% \endgraf -% \doif{\listparameter\c!interaction}\v!text % not supported ! ! ! ! ! ! text == all -% {\setlistparameter\currentlist\c!interaction\v!all}% - % \dontleavehmode % new, else no margin, but wrong, better (else \indent as well): \noindent \domakelistelement\v!all{#2}\hbox {\setlocalhsize diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index 0cf06db02..475ab318a 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -291,6 +291,55 @@ function commands.doiffiledefinedelse(name) commands.doifelse(files[name]) end +-- helpers + +function jobreferences.checkedfile(whatever) -- return whatever if not resolved + if whatever then + local w = files[whatever] + if w then + return w[1] + else + return whatever + end + end +end + +function jobreferences.checkedurl(whatever) -- return whatever if not resolved + if whatever then + local w = urls[whatever] + if w then + local u, f = w[1], w[2] + if f and f ~= "" then + return u .. "/" .. f + else + return u + end + else + return whatever + end + end +end + +function jobreferences.checkedfileorurl(whatever,default) -- return nil, nil if not resolved + if whatever then + local w = files[whatever] + if w then + return w[1], nil + else + local w = urls[whatever] + if w then + local u, f = w[1], w[2] + if f and f ~= "" then + return nil, u .. "/" .. f + else + return nil, u + end + end + end + end + return default +end + -- programs jobreferences.programs = jobreferences.programs or { } @@ -311,6 +360,17 @@ function jobreferences.programs.get(name) end end +function jobreferences.checkedprogram(whatever) -- return whatever if not resolved + if whatever then + local w = programs[whatever] + if w then + return w[1] + else + return whatever + end + end +end + -- shared by urls and files function jobreferences.whatfrom(name) diff --git a/tex/context/base/strc-ref.mkiv b/tex/context/base/strc-ref.mkiv index ed77edc85..2c0a8842b 100644 --- a/tex/context/base/strc-ref.mkiv +++ b/tex/context/base/strc-ref.mkiv @@ -93,10 +93,10 @@ %D \reference[here]{some text} %D \stoptyping -\def\textreference {\dosingleargument\dotextreference} -\def\pagereference {\dosingleargument\dopagereference} -\def\reference {\dosingleargument\doreference } -\def\setreference {\dodoubleargument\dosetreference } +\unexpanded\def\textreference {\dosingleargument\dotextreference} +\unexpanded\def\pagereference {\dosingleargument\dopagereference} +\unexpanded\def\reference {\dosingleargument\doreference } +\unexpanded\def\setreference {\dodoubleargument\dosetreference } %D These are implemented in a low level form as: diff --git a/tex/context/base/trac-inf.lua b/tex/context/base/trac-inf.lua index 315195012..72f03675a 100644 --- a/tex/context/base/trac-inf.lua +++ b/tex/context/base/trac-inf.lua @@ -47,6 +47,8 @@ function statistics.starttiming(instance) if not instance.loadtime then instance.loadtime = 0 end + else +--~ logs.report("system","nested timing (%s)",tostring(instance)) end instance.timing = it + 1 end diff --git a/tex/context/base/trac-tim.lua b/tex/context/base/trac-tim.lua index 674abdf60..6aebb01ab 100644 --- a/tex/context/base/trac-tim.lua +++ b/tex/context/base/trac-tim.lua @@ -10,10 +10,10 @@ local format, gsub = string.format, string.gsub local concat, sort = table.concat, table.sort local next, pairs, ipairs = next, pairs, ipairs -goodies = goodies or { } -goodies.progress = goodies.progress or { } +plugins = plugins or { } +plugins.progress = plugins.progress or { } -local progress = goodies.progress +local progress = plugins.progress progress = progress or { } |