diff options
-rw-r--r-- | scripts/context/ruby/base/tex.rb | 53 | ||||
-rw-r--r-- | scripts/context/ruby/rlxtools.rb | 73 | ||||
-rw-r--r-- | scripts/context/ruby/texexec.rb | 7 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 57 | ||||
-rw-r--r-- | tex/context/base/core-fig.tex | 84 | ||||
-rw-r--r-- | tex/context/base/spec-dpx.tex | 14 |
6 files changed, 215 insertions, 73 deletions
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb index 4335a9618..61701e501 100644 --- a/scripts/context/ruby/base/tex.rb +++ b/scripts/context/ruby/base/tex.rb @@ -88,15 +88,17 @@ class TEX ['pdfetex','pdftex','pdf','pdftex','standard'] .each do |b| @@backends[b] = 'pdftex' end ['dvipdfmx','dvipdfm','dpx','dpm'] .each do |b| @@backends[b] = 'dvipdfmx' end - ['xetex','xtx'] .each do |b| @@backends[b] = 'dvipdfmx' end + ['xetex','xtx'] .each do |b| @@backends[b] = 'xetex' end ['dvips','ps'] .each do |b| @@backends[b] = 'dvips' end ['dvipsone'] .each do |b| @@backends[b] = 'dvipsone' end ['acrobat','adobe','distiller'] .each do |b| @@backends[b] = 'acrobat' end + ['xdv','xdv2pdf'] .each do |b| @@backends[b] = 'xdv2pdf' end ['tex','standard'] .each do |b| @@mappaths[b] = 'dvips' end ['pdftex','pdfetex'] .each do |b| @@mappaths[b] = 'pdftex' end - ['aleph','omega'] .each do |b| @@mappaths[b] = 'dvipdfm' end - ['xetex'] .each do |b| @@mappaths[b] = 'dvipdfm' end + ['aleph','omega','xetex'] .each do |b| @@mappaths[b] = 'dvipdfm' end + ['dvipdfm', 'dvipdfmx', 'xdvipdfmx'] .each do |b| @@mappaths[b] = 'dvipdfm' end + ['xdv','xdv2pdf'] .each do |b| @@mappaths[b] = 'dvips' end # todo norwegian (no) @@ -133,7 +135,8 @@ class TEX ['cont-en','cont-nl','cont-de','cont-it', 'cont-fr','cont-cz','cont-ro','cont-uk'] .each do |f| @@texprocstr[f] = "\\emergencyend" end - # @@runoptions['xetex'] = ['--no-pdf'] # from now on we assume (x)dvipdfmx to be used + # @@runoptions['xetex'] = ['--output-driver \\\"-d 4 -V 5\\\"'] # we need the pos pass + @@runoptions['xetex'] = ['--no-pdf'] # from now on we assume (x)dvipdfmx to be used @@booleanvars = [ 'batchmode', 'nonstopmode', 'fast', 'fastdisabled', 'silentmode', 'final', @@ -244,6 +247,12 @@ class TEX report("runtime: #{runtime}") end + def runcommand(something) + command = [something].flatten.join(' ') + report("running: #{command}") if getvariable('verbose') + system(command) + end + def inspect(name=nil) if ! name || name.empty? then name = [booleanvars,stringvars,standardvars,knownvars] @@ -507,9 +516,7 @@ class TEX end texformats.each do |texformat| report("generating tex format #{texformat}") - command = [quoted(texengine),prognameflag(progname),iniflag,tcxflag,prefixed(texformat,texengine),texmakeextras(texformat)].join(' ') - report(command) if getvariable('verbose') - system(command) + runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag,prefixed(texformat,texengine),texmakeextras(texformat)]) end else report("unable to make format due to lack of permissions") @@ -527,10 +534,8 @@ class TEX if FileTest.writable?(mpsformatpath) then mpsformats.each do |mpsformat| report("generating mps format #{mpsformat}") - # command = [quoted(mpsengine),prognameflag(progname),iniflag,tcxflag,mpsformat,mpsmakeextras(mpsformat)].join(' ') - command = [quoted(mpsengine),iniflag,tcxflag,mpsformat,mpsmakeextras(mpsformat)].join(' ') - report(command) if getvariable('verbose') - system(command) + # runcommand([quoted(mpsengine),prognameflag(progname),iniflag,tcxflag,mpsformat,mpsmakeextras(mpsformat)]) + runcommand([quoted(mpsengine),iniflag,tcxflag,mpsformat,mpsmakeextras(mpsformat)]) end else report("unable to make format due to lack of permissions") @@ -1183,9 +1188,7 @@ class TEX report("progname: #{progname}") if texengine && texformat && progname then fixbackendvars(@@mappaths[texengine]) - command = [quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag,runoptions(texengine),filename,texprocextras(texformat)].join(' ') - report(command) if getvariable('verbose') - system(command) + runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag,runoptions(texengine),filename,texprocextras(texformat)]) true else false @@ -1199,10 +1202,8 @@ class TEX progname = validprogname(getvariable('progname')) if mpsengine && mpsformat && progname then ENV["MPXCOMMAND"] = "0" unless mpx - # command = [quoted(mpsengine),prognameflag(progname),formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),filename,mpsprocextras(mpsformat)].join(' ') - command = [quoted(mpsengine),formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),mpname,mpsprocextras(mpsformat)].join(' ') - report(command) if getvariable('verbose') - system(command) + # runcommand([quoted(mpsengine),prognameflag(progname),formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),filename,mpsprocextras(mpsformat)]) + runcommand([quoted(mpsengine),formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),mpname,mpsprocextras(mpsformat)]) true else false @@ -1311,15 +1312,21 @@ class TEX case validbackend(getvariable('backend')) when 'dvipdfmx' then fixbackendvars('dvipdfm') - system("dvipdfmx -d 4 #{File.unsuffixed(rawname)}") + runcommand("dvipdfmx -d 4 -V 5 #{File.unsuffixed(rawname)}") when 'xetex' then # xetex now runs its own backend xdvfile = File.suffixed(rawname,'xdv') if FileTest.file?(xdvfile) then - fixbackendvars('xetex') - system("xdvipdfmx #{xdvfile}") + fixbackendvars('dvipdfm') + runcommand("xdvipdfmx -d 4 -V 5 #{xdvfile}") + end + when 'xdv2pdf' then + xdvfile = File.suffixed(rawname,'xdv') + if FileTest.file?(xdvfile) then + fixbackendvars('xdv2pdf') + runcommand("xdv2pdf #{xdvfile}") end - when 'dvips' then + when 'dvips' then fixbackendvars('dvips') mapfiles = '' begin @@ -1331,7 +1338,7 @@ class TEX rescue mapfiles = '' end - system("dvips #{mapfiles} #{File.unsuffixed(rawname)}") + runcommand("dvips #{mapfiles} #{File.unsuffixed(rawname)}") when 'pdftex' then # no need for postprocessing else diff --git a/scripts/context/ruby/rlxtools.rb b/scripts/context/ruby/rlxtools.rb index 6a796114f..a7af5b691 100644 --- a/scripts/context/ruby/rlxtools.rb +++ b/scripts/context/ruby/rlxtools.rb @@ -247,10 +247,83 @@ class Commands end +class Commands + + include CommandBase + + def identify + @commandline.arguments.each do |filename| + if state = do_identify(filename) then + begin + File.open(filename+'.rli','w') do |f| + f << state + end + rescue + report("error in identifying #{filename}") + else + report("#{filename} is identified") + end + end + end + end + + private + + def do_identify(filename) + begin + str = nil + if FileTest.file?(filename) then + result = `identify -format \"x=%x,y=%y,w=%w,h=%h,b=%b\" #{filename}`.chomp.split(',') + tags = Hash.new + result.each do |r| + if rr = r.split("=") then + tags[rr[0]] = rr[1] + end + end + size = (tags['b']||0).to_i + width = unified(tags['w']||0,tags['x']||'1') + height = unified(tags['h']||0,tags['y']||'1') + if size > 0 then + str = '' + str << "<?xml version='1.0' standalone='yes'?>\n" + str << "<rl:identify name='#{File.basename(filename)}'>\n" + str << " <rl:size>#{size}</rl:size>\n" + str << " <rl:path>#{File.dirname(filename).sub(/\\/o,'/')}</rl:path>\n" + str << " <rl:width>#{width}</rl:width>\n" + str << " <rl:height>#{height}</rl:height>\n" + str << "</rl:identify>\n" + end + else + str = nil + end + rescue + str = nil + end + return str + end + + def unified(dim,res) + case res + when /([\d\.]+)\s*PixelsPerInch/io then + sprintf("%.4fin",dim.to_f/$1.to_f) + when /([\d\.]+)\s*PixelsPerCentimeter/io then + sprintf("%.4fcm",dim.to_f/$1.to_f) + when /([\d\.]+)\s*PixelsPerMillimeter/io then + sprintf("%.4fmm",dim.to_f/$1.to_f) + when /([\d\.]+)\s*PixelsPerPoint/io then + sprintf("%.4fbp",dim.to_f/$1.to_f) + else + sprintf("%.4fbp",dim.to_f) + end + end + +end + logger = Logger.new(banner.shift) commandline = CommandLine.new commandline.registeraction('manipulate', ' [--test] manipulatorfile resourselog') +commandline.registeraction('identify', 'filename') commandline.registeraction('help') commandline.registeraction('version') diff --git a/scripts/context/ruby/texexec.rb b/scripts/context/ruby/texexec.rb index 2751cef63..06e74812d 100644 --- a/scripts/context/ruby/texexec.rb +++ b/scripts/context/ruby/texexec.rb @@ -501,15 +501,17 @@ class Commands elsif @commandline.oneof('dvipdfmx','dvipdfm','dpx','dpm') then job.setvariable('backend','dvipdfmx') elsif @commandline.oneof('xetex','xtx') then - job.setvariable('backend','dvipdfmx') + job.setvariable('backend','xetex') elsif @commandline.oneof('aleph') then job.setvariable('backend','dvipdfmx') elsif @commandline.oneof('dvips','ps') then job.setvariable('backend','dvips') + elsif @commandline.oneof('xdv') then + job.setvariable('backend','xdv') else case job.getvariable('texengine') when 'pdfetex' then job.setvariable('backend','pdftex') - when 'xetex' then job.setvariable('backend','dvipdfmx') + when 'xetex' then job.setvariable('backend','xetex') when 'aleph' then job.setvariable('backend','dvipdfmx') else job.setvariable('backend','standard') @@ -655,6 +657,7 @@ commandline.registerflag('ps') commandline.registerflag('xetex') commandline.registerflag('xtx') +commandline.registerflag('xdv') commandline.registerflag('aleph') diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index aaf2f7f52..9b1fa1627 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{2006.05.16 18:35} +\newcontextversion{2006.05.17 10:08} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new @@ -26,6 +26,61 @@ \writestatus{\m!systems}{beware: some patches loaded from cont-new.tex} +% This will move to core-fig asap: +% +% todo: process between runs + +\startXMLmapping[rli] + \defineXMLprocess[rl:identify] + \defineXMLsavecontent[rl:width] {\!!zeropoint} + \defineXMLsavecontent[rl:height]{\!!zeropoint} +\stopXMLmapping + +\def\getRLIfiguredimensions#1% + {\let\rliwidth \!!zeropoint + \let\rliheight\!!zeropoint + \doiffileelse{\@@effilenametype.rli} + {} + {% let's try runtime running first + \writestatus\m!figures{using rlxtools to determine size of \@@effilenametype}% + \executesystemcommand{texmfstart rlxtools --identify \@@effilenametype}}% + \doiffileelse{\@@effilenametype.rli} + {} + {% we assume that runtime running failed + \installprogram{texmfstart rlxtools --identify \@@effilenametype}}% + \startnointerference + \startXMLmapping[rli]% + \startXMLignore + \processXMLfile{\@@effilenametype.rli}% + \edef\rliwidth {\XMLflush{rl:width}}% + \edef\rliheight{\XMLflush{rl:height}}% + \stopXMLignore + \stopXMLmapping + \stopnointerference} + +\def\getfiguredimensionsC + {\ifcase\figurestatus\ifcase\figurefilemode\else + \doifsomething\@@efcurrentpath + {\doifnotinset\@@effiletype{\c!tex,\c!tmp} + {\doiffileelse\@@efcurrentfile + {\@@eftrace{using rlxtools to identify \@@effilenametype}% + \getRLIfiguredimensions{\@@effilenametype}% + \ifdim\rliwidth>\zeropoint \ifdim\rliheight>\zeropoint + \geteparameters % e ! + [\??ep] + [\c!x=\!!zeropoint,\c!y=\!!zeropoint, % brrr, todo: bbox + \c!w=\rliwidth,\c!h=\rliheight]% + \let\@@eftype\@@efcurrenttype + \let\@@effullname\@@efcurrentfile + \chardef\figurestatus\plusfour % todo, message is wrong now + \fi \fi + \@@eftrace{\ifcase\figurestatus not \fi found}} + {}}}% + \fi\fi} + +\let\doanalyzefigurefilesB\relax % obsolete +\let\doanalyzefigurefilesC\relax % obsolete + \def\environment #1 % at outermost level only (load only once) {\pushmacro\startenvironment \pushmacro\stopenvironment diff --git a/tex/context/base/core-fig.tex b/tex/context/base/core-fig.tex index cceb9cb1d..0c2d4f0c3 100644 --- a/tex/context/base/core-fig.tex +++ b/tex/context/base/core-fig.tex @@ -461,7 +461,7 @@ \@EA\DOIF\@EA{\@@effilenametype}{#1} % hm, tzt ook nog eens met pad/naam {\getparameters[\??ep][#2]% \ExpandBothAfter\doif\@@epe\@@efcurrenttype - {\chardef\figurestatus4 + {\chardef\figurestatus\plusfour \let\@@eftype\@@efcurrenttype \let\@@effullname\@@efcurrentfile}}% \else @@ -471,24 +471,22 @@ \def\getfiguredimensionsC {\ifconsultutilityfile \ifrunutilityfile \ifcase\figurestatus\ifcase\figurefilemode\else -\doifsomething\@@efcurrentpath -{% - \doifnotinset\@@effiletype{\c!tex,\c!tmp} - {\doiffileelse\@@efcurrentfile - {\edef\@@effilenametype{\@@effilename.\@@efcurrenttype}% - \@@eftrace{running texutil on \@@effilenametype}% - \def\@@efloadname{\f!utilityfilename.\f!temporaryextension}% - \executesystemcommand{texutil --fig --out=\@@efloadname\space\@@effilenametype}% - \@@eftrace{analyzing \@@efloadname\space on \@@effilenametype}% - \pushendofline - \startreadingfile - \let\presetfigure\presetfigureB - \readsetfile{.}\@@efloadname\donothing\donothing - \stopreadingfile - \popendofline - \@@eftrace{\ifcase\figurestatus not \fi found}} - {}}% -}% + \doifsomething\@@efcurrentpath + {\doifnotinset\@@effiletype{\c!tex,\c!tmp} + {\doiffileelse\@@efcurrentfile + {\edef\@@effilenametype{\@@effilename.\@@efcurrenttype}% + \@@eftrace{running texutil on \@@effilenametype}% + \def\@@efloadname{\f!utilityfilename.\f!temporaryextension}% + \executesystemcommand{texutil --fig --out=\@@efloadname\space\@@effilenametype}% + \@@eftrace{analyzing \@@efloadname\space on \@@effilenametype}% + \pushendofline + \startreadingfile + \let\presetfigure\presetfigureB + \readsetfile{.}\@@efloadname\donothing\donothing + \stopreadingfile + \popendofline + \@@eftrace{\ifcase\figurestatus not \fi found}} + {}}}% \fi\fi \fi\fi} @@ -503,19 +501,17 @@ \def\doanalyzefigurefilesB {\ifconsultutilityfile\ifcase\figurestatus\ifcase\figurefilemode\else -\doifsomething\@@efcurrentpath -{% - \assignfullfilename\@@efcurrentpath\@@exfile\to\@@efloadname - \edef\@@effilenametype{\@@effilename.\figureextension{\@@efcurrenttype}}% - \@@eftrace{analyzing \@@efloadname\space on \@@efcurrentpath\space for \@@effilenametype}% - \pushendofline - \startreadingfile - \let\presetfigure\presetfigureC - \readsetfile\@@efcurrentpath\@@exfile\donothing\donothing - \stopreadingfile - \popendofline - \@@eftrace{\ifcase\figurestatus not \fi found}% -}% + \doifsomething\@@efcurrentpath + {\assignfullfilename\@@efcurrentpath\@@exfile\to\@@efloadname + \edef\@@effilenametype{\@@effilename.\figureextension{\@@efcurrenttype}}% + \@@eftrace{analyzing \@@efloadname\space on \@@efcurrentpath\space for \@@effilenametype}% + \pushendofline + \startreadingfile + \let\presetfigure\presetfigureC + \readsetfile\@@efcurrentpath\@@exfile\donothing\donothing + \stopreadingfile + \popendofline + \@@eftrace{\ifcase\figurestatus not \fi found}}% \fi\fi\fi} \def\presetfigureC[#1][#2]% @@ -523,7 +519,7 @@ \@EA\DOIF\@EA{\@@effilenametype}{#1} {\getparameters[\??ep][#2]% \doif\@@epe\@@efcurrenttype - {\chardef\figurestatus4 + {\chardef\figurestatus\plusfour \let\@@eftype\@@efcurrenttype \let\@@effullname\@@efcurrentfile}}% \else @@ -535,18 +531,16 @@ \def\doanalyzefigurefilesC {\ifconsultutilityfile\ifcase\figurestatus\ifcase\figurefilemode\else -\doifsomething\@@efcurrentpath -{% - \assignfullfilename\@@efcurrentpath\@@exfile\to\@@efloadname - \@@eftrace{analyzing \@@efloadname\space on \@@efcurrentpath\space for \@@effilename.* surrogate}% - \pushendofline - \startreadingfile - \let\presetfigure\presetfigureD - \readsetfile\@@efcurrentpath\@@exfile\donothing\donothing - \stopreadingfile - \popendofline - \@@eftrace{\ifcase\figurestatus not \fi found}% -}% + \doifsomething\@@efcurrentpath + {\assignfullfilename\@@efcurrentpath\@@exfile\to\@@efloadname + \@@eftrace{analyzing \@@efloadname\space on \@@efcurrentpath\space for \@@effilename.* surrogate}% + \pushendofline + \startreadingfile + \let\presetfigure\presetfigureD + \readsetfile\@@efcurrentpath\@@exfile\donothing\donothing + \stopreadingfile + \popendofline + \@@eftrace{\ifcase\figurestatus not \fi found}}% \fi\fi\fi} \def\presetfigureD[#1][#2]% diff --git a/tex/context/base/spec-dpx.tex b/tex/context/base/spec-dpx.tex index 2e4aaa6f1..f317a3887 100644 --- a/tex/context/base/spec-dpx.tex +++ b/tex/context/base/spec-dpx.tex @@ -853,7 +853,7 @@ %D 7. Copied codes from \type{spec-dvi} -% coming pdftex versions will provide pos support +% coming pdftex versions will provide pos support in dvi mode (untested) % \ifnum\pdftexversion>140 .. \fi @@ -869,11 +869,21 @@ \let\flushDVIpositionpapersize\relax \definespecial\dosetpositionpapersize#1#2% - {\xdef\flushDVIpositionpapersize% + {\xdef\flushDVIpositionpapersize {\special{pos:papersize #1 #2}% \noexpand\installprogram{dvipos -o \jobname.tuo \jobname.dvi }% \global\noexpand\let\noexpand\flushDVIpositionpapersize\relax}} +\beginXETEX + + \definespecial\dosetpositionpapersize#1#2% + {\xdef\flushDVIpositionpapersize + {\special{pos:papersize #1 #2}% + \noexpand\installprogram{dvipos -o \jobname.tuo \jobname.xdv }% + \global\noexpand\let\noexpand\flushDVIpositionpapersize\relax}} + +\endXETEX + \prependtoksonce \flushDVIpositionpapersize \to \everyshipout \stopspecials |