summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/ruby/base/tex.rb53
-rw-r--r--scripts/context/ruby/rlxtools.rb73
-rw-r--r--scripts/context/ruby/texexec.rb7
3 files changed, 108 insertions, 25 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')