ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Sanjoy Mahajan <sanjoy@mrao.cam.ac.uk>
Subject: Re: ConTeXt + asymptote
Date: Tue, 25 Apr 2006 00:36:15 -0400	[thread overview]
Message-ID: <E1FYFHb-00012B-Kw@approximate.corpus.cam.ac.uk> (raw)
In-Reply-To: Your message of "Mon, 24 Apr 2006 09:33:30 +0200." <444C7F4A.7010009@wxs.nl>

> context parses the ps code and converts it to pdf and in the process
> uses tex to do the fonts

Maybe then it's not worth finishing my modifications for asymptote to
use plain tex.  The following .asy file (labelbox.asy in the distributed
examples/):

  real margin=2mm;
  frame b1,b2;
  box(b1,Label("small box",(0,0)),margin);
  box(b2,Label("LARGER BOX",(0,-2cm)),margin);
  add(b1);
  add(b2);
  draw(point(b1,S)--point(b2,N),currentpen);

produces an 810-line .eps file that includes fonts (cmr12) and the
pstricks headers.  The actual page material is:

  %%Page: 1 1
   0 0.5 dtransform truncate idtransform setlinewidth pop
  1 setlinecap
  1 setlinejoin
  gsave
   0 0 translate
  newpath 273.998159 412.742829 moveto
   338.001841 412.742829 lineto
   338.001841 435.883567 lineto
   273.998159 435.883567 lineto
   273.998159 412.742829 lineto
   closepath
  [ 1 0 0 1 0 0] concat
   stroke
  grestore
  gsave
   0 0 translate
  newpath 258.635763 356.116433 moveto
   353.364237 356.116433 lineto
   353.364237 379.124359 lineto
   258.635763 379.124359 lineto
   258.635763 356.116433 lineto
   closepath
  [ 1 0 0 1 0 0] concat
   stroke
  grestore
  newpath 306 412.242829 moveto
   306 379.624359 lineto
   stroke
  showpage

But I've attached the half-working diff (some would say the glass is
half-broken), against asymptote 0.99.  The result is supposed to work as
follows:

  asy labelbox.asy  [make eps file; use latex for labels]
  asy -t latex labelbox.asy [same as above]
  asy -t tex labelbox.asy [make eps, use plain tex for labels]

My patches don't break the first or second uses, which is good, but the
third isn't working yet:

  $ asy -t tex labelbox.asy
  /usr/local/share/asymptote/shipout.asy: 73.10: runtime: camp: shipout failed

which is failing, I think, in this line from the intermediate
labelbox_.tex file:

  \setbox\ASYpsbox=\hbox{\epsfbox{labelbox_0.eps}}%

But I haven't figured out who generates labelbox_0.eps and why it isn't
being generated when using tex but is when using latex.  Obviously I
haven't found all the places where latex is hardwired into asymptote.

And even what I did is incomplete.  The latex interface code spits out
e.g. \fontsize{12}{14.4}, which I just ignore if plain tex is being
used.

Compared to the monster .eps files that asymptote produces, I now love
metapost's simple postscript files and one-line, easily parsed font
commands.

From: "Mojca Miklavec" <mojca.miklavec.lists@gmail.com>
> But I've given up once I saw how harcoded LaTeX was in there.

I've pretty much given up too.

> Metapost support in ConTeXt is much deeper and I wonder how much work
> should be invested into making as good support for Asymptote in
> ConTeXt as it is now for metapost.

Whoever is game can start with the diff below, but I'm also not sure
it's worth it.  My ideal figure program:

1. Agnostic about the tex engine (tex/latex/context), easy to integrate
   with any of them.  MP is good here.
2. 3D built in.
3. Modern color models (cmyk, transparency)
4. Decent syntax.  MP is a bit ghastly, and writing macros is horrible
   esp. with vardefs.  I prefer a non-macro language, and asymptote is
   good that way

But it's a lot of work to get it right.

-Sanjoy

`A society of sheep must in time beget a government of wolves.'
   - Bertrand de Jouvenal


diff -r 57c230047c98 base/babel.asy
--- a/base/babel.asy	Tue Feb 07 23:34:29 2006 -0500
+++ b/base/babel.asy	Tue Apr 25 00:28:42 2006 -0400
@@ -1,4 +1,6 @@ void babel(string s)
 void babel(string s) 
 {
+  if (texengine == "tex")
+    abort("No babel package in plain TeX.");
   texpreamble("\usepackage["+s+"]{babel}");
 }
diff -r 57c230047c98 base/fontsize.asy
--- a/base/fontsize.asy	Tue Feb 07 23:34:29 2006 -0500
+++ b/base/fontsize.asy	Tue Apr 25 00:28:42 2006 -0400
@@ -1,1 +1,3 @@ texpreamble("\usepackage{type1cm}");
+if (texengine == "tex")
+  abort("No fontsize package in plain TeX.");
 texpreamble("\usepackage{type1cm}");
diff -r 57c230047c98 base/latin1.asy
--- a/base/latin1.asy	Tue Feb 07 23:34:29 2006 -0500
+++ b/base/latin1.asy	Tue Apr 25 00:28:42 2006 -0400
@@ -1,2 +1,4 @@ texpreamble("\usepackage[T1]{fontenc}");
+if (texengine == "tex")
+  abort("No T1 or latin1 packages in plain TeX.");
 texpreamble("\usepackage[T1]{fontenc}");
 texpreamble("\usepackage[latin1]{inputenc}");
diff -r 57c230047c98 base/plain.asy
--- a/base/plain.asy	Tue Feb 07 23:34:29 2006 -0500
+++ b/base/plain.asy	Tue Apr 25 00:28:42 2006 -0400
@@ -7,6 +7,9 @@
  *****/
 
 include constants;
+
+// tex, latex, or none (for the future: or pdftex, pdflatex, context)
+public string texengine = TEXENGINE(); // what variant will typeset the labels
 
 access version;		    
 if(version.VERSION != VERSION()) {
diff -r 57c230047c98 base/strings.asy
--- a/base/strings.asy	Tue Feb 07 23:34:29 2006 -0500
+++ b/base/strings.asy	Tue Apr 25 00:28:42 2006 -0400
@@ -81,12 +81,16 @@ string math(string s)
 
 string includegraphics(string name, string options="")
 {
+  if (texengine == "tex")
+    return "\hbox{\epsfbox"+"{"+name+"}}";
   if(options != "") options="["+options+"]";
   return "\includegraphics"+options+"{"+name+"}";
 }
 
 string minipage(string s, real width=100pt)
 {
+  if (texengine == "tex")
+    abort("No minipage environment in plain TeX.");
   return "\begin{minipage}{"+(string) (width*pt)+"pt}"+s+"\end{minipage}";
 }
 
diff -r 57c230047c98 base/unicode.asy
--- a/base/unicode.asy	Tue Feb 07 23:34:29 2006 -0500
+++ b/base/unicode.asy	Tue Apr 25 00:28:42 2006 -0400
@@ -1,2 +1,4 @@ texpreamble("\usepackage{ucs}");
+if (texengine == "tex")
+  abort("No unicode (ucs,utf8x) packages in plain TeX.");
 texpreamble("\usepackage{ucs}");
 texpreamble("\usepackage[utf8x]{inputenc}");
diff -r 57c230047c98 doc/asy.1
--- a/doc/asy.1	Tue Feb 07 23:34:29 2006 -0500
+++ b/doc/asy.1	Tue Apr 25 00:28:42 2006 -0400
@@ -35,7 +35,7 @@ View output file.
 View output file.
 .TP
 .B -a, -align C|B|T|Z
-Center, Bottom, Top or Zero page alignment; Z => -notex.
+Center, Bottom, Top or Zero page alignment; Z => -tex none.
 .TP
 .B -autoplain
 Enable automatic importing of plain (default).
@@ -106,8 +106,8 @@ Convert cmyk colors to rgb.
 .B -safe
 Disable system call (default).
 .TP
-.B -tex
-Enable LaTeX label postprocessing (default).
+.B -t, -tex engine
+TeX engine for processing labels: one of latex (default), tex, none.
 .TP
 .B -s, -translate
 Translate test.
diff -r 57c230047c98 doc/asymptote.texi
--- a/doc/asymptote.texi	Tue Feb 07 23:34:29 2006 -0500
+++ b/doc/asymptote.texi	Tue Apr 25 00:28:42 2006 -0400
@@ -5286,7 +5286,7 @@ Usage: asy [options] [file ...]
 
 Options: 
 -V,-View              View output files
--a,-align C|B|T|Z     Center, Bottom, Top or Zero page alignment; Z => -notex
+-a,-align C|B|T|Z     Center, Bottom, Top or Zero page alignment; Z => -tex none
 -autoplain            Enable automatic importing of plain (default)
 -batchMask            Mask fpu exceptions in batch mode
 -batchView            View output files in batch mode
@@ -5310,7 +5310,7 @@ Options:
 -p,-parseonly         Parse test
 -rgb                  Convert cmyk colors to rgb
 -safe                 Disable system call (default)
--tex                  Enable LaTeX label postprocessing (default)
+-t, -tex engine       TeX engine for processing labels (default: latex).
 -s,-translate         Translate test
 -unsafe               Enable system call
 -v,-verbose           Increase verbosity level
diff -r 57c230047c98 drawlabel.cc
--- a/drawlabel.cc	Tue Feb 07 23:34:29 2006 -0500
+++ b/drawlabel.cc	Tue Apr 25 00:28:42 2006 -0400
@@ -70,7 +70,8 @@ void drawLabel::bounds(bbox& b, iopipest
 void drawLabel::bounds(bbox& b, iopipestream& tex, boxvector& labelbounds,
 		       bboxlist&)
 {
-  if(!settings::getSetting<bool>("tex")) {b += position; return;}
+  if(settings::getSetting<mem::string>("tex") == "none")
+    {b += position; return;}
   pair rotation=expi(radians(angle));
   pen Pentype=pentype;
   static const double fuzz=1.0+Pentype.size()/24.0;
@@ -79,9 +80,12 @@ void drawLabel::bounds(bbox& b, iopipest
     havebounds=true;
     if(Pentype.size() != lastpen.size() ||
        Pentype.Lineskip() != lastpen.Lineskip()) {
-      tex <<  "\\fontsize{" << Pentype.size() << "}{" << Pentype.Lineskip()
-	  << "}\\selectfont\n";
-      tex.wait("\n*","! ");
+      // need to fix if not using latex (change fontsize and baselineskip)
+      if(settings::getSetting<mem::string>("tex") == "latex") {
+	tex <<  "\\fontsize{" << Pentype.size() << "}{" << Pentype.Lineskip()
+	    << "}\\selectfont\n";
+	tex.wait("\n*","! ");
+      }
     }
     
     string font=Pentype.Font();
@@ -93,8 +97,10 @@ void drawLabel::bounds(bbox& b, iopipest
 	p += scaled.length();
 	fontscale=atof(font.substr(p,string::npos).c_str())/1000.0;
       }
-      tex <<  font << "\n";
-      tex.wait("\n*","! ");
+      if(settings::getSetting<mem::string>("tex") == "latex") {
+	tex <<  font << "\n";	// need to change fonts differently in tex
+	tex.wait("\n*","! ");
+      }
     }
     
     lastpen=Pentype;
diff -r 57c230047c98 examples/conicurv.asy
--- a/examples/conicurv.asy	Tue Feb 07 23:34:29 2006 -0500
+++ b/examples/conicurv.asy	Tue Apr 25 00:28:42 2006 -0400
@@ -4,7 +4,8 @@
 
 import three;
 import math;
-texpreamble("\usepackage{bm}");
+if (texengine != "tex")
+  texpreamble("\usepackage{bm}");
 
 size(300,0);
 
diff -r 57c230047c98 picture.cc
--- a/picture.cc	Tue Feb 07 23:34:29 2006 -0500
+++ b/picture.cc	Tue Apr 25 00:28:42 2006 -0400
@@ -83,7 +83,7 @@ bool picture::havelabels()
 bool picture::havelabels()
 {
   size_t n=nodes.size();
-  if(n > lastnumber && !labels && getSetting<bool>("tex")) {
+  if(n > lastnumber && !labels && getSetting<mem::string>("tex") != "none") {
     // Check to see if there are any labels yet
     nodelist::iterator p=nodes.begin();
     for(size_t i=0; i < lastnumber; ++i) ++p;
@@ -131,7 +131,9 @@ void picture::texinit()
     return;
   }
   
-  tex.open(getSetting<mem::string>("latex").c_str(),"latex","latex");
+  tex.open(getSetting<mem::string>("tex").c_str(),
+	   getSetting<mem::string>("tex").c_str(),
+	   getSetting<mem::string>("tex").c_str());
   texdocumentclass(tex,true);
   
   texdefines(tex,TeXpipepreamble,true);
@@ -152,12 +154,12 @@ bool picture::texprocess(const string& t
   if(outfile) {
     outfile.close();
     ostringstream cmd;
-    cmd << getSetting<mem::string>("latex") 
+    cmd << getSetting<mem::string>("tex") 
 	<< " \\scrollmode\\input " << texname;
     bool quiet=verbose <= 1;
-    status=System(cmd,quiet,true,"latex");
+    status=System(cmd,quiet,true,getSetting<mem::string>("tex").c_str());
     if(status) {
-      if(quiet) status=System(cmd,true,"latex");
+      if(quiet) status=System(cmd,true,getSetting<mem::string>("tex").c_str());
       return false;
     }
     
@@ -360,7 +362,8 @@ bool picture::shipout(picture *preamble,
       
   bbox bpos=b;
   
-  bool TeXmode=getSetting<bool>("inlinetex") && getSetting<bool>("tex");
+  bool TeXmode=getSetting<bool>("inlinetex") &&
+               (getSetting<mem::string>("tex") == "latex");
   bool Labels=labels || TeXmode;
   
   if(deconstruct) {
diff -r 57c230047c98 runtime.cc
--- a/runtime.cc	Tue Feb 07 23:34:29 2006 -0500
+++ b/runtime.cc	Tue Apr 25 00:28:42 2006 -0400
@@ -2599,8 +2599,16 @@ void gen226(stack *Stack)
   {Stack->push<string>(VERSION); return;}
 }
 
+// for exporting to the .asy world how labels are to be processed
+// string TEXENGINE();
+void gen227(stack *Stack)
+{
+
+  {Stack->push<string>(getSetting<mem::string>("tex")); return;}
+}
+
 // void quiet(bool v);
-void gen227(stack *Stack)
+void gen228(stack *Stack)
 {
   bool v = vm::pop<bool>(Stack);
 
@@ -2610,7 +2618,7 @@ void gen227(stack *Stack)
 }
 
 // void atexit(callable *f);
-void gen228(stack *Stack)
+void gen229(stack *Stack)
 {
   callable * f = vm::pop<callable *>(Stack);
 
@@ -2618,7 +2626,7 @@ void gen228(stack *Stack)
 }
 
 // callable* atexit();
-void gen229(stack *Stack)
+void gen230(stack *Stack)
 {
 
   {Stack->push<callable*>(atExitFunction); return;}
@@ -2627,7 +2635,7 @@ void gen229(stack *Stack)
 
 // Merge output files  
 // int merge(stringarray *files, string *args, string *format, bool keep);
-void gen230(stack *Stack)
+void gen231(stack *Stack)
 {
   bool keep = vm::pop<bool>(Stack);
   string * format = vm::pop<string *>(Stack);
@@ -2922,7 +2930,7 @@ void arraySequence(stack *Stack)
 
 // Return the array {0,1,...n-1}
 // intarray* sequence(int n);
-void gen251(stack *Stack)
+void gen252(stack *Stack)
 {
   int n = vm::pop<int>(Stack);
 
@@ -2951,7 +2959,7 @@ void arrayFunction(stack *Stack)
 }
 
 // bool all(boolarray *a);
-void gen253(stack *Stack)
+void gen254(stack *Stack)
 {
   boolarray * a = vm::pop<boolarray *>(Stack);
 
@@ -2963,7 +2971,7 @@ void gen253(stack *Stack)
 }
 
 // boolarray* !(boolarray* a);
-void gen254(stack *Stack)
+void gen255(stack *Stack)
 {
   boolarray* a = vm::pop<boolarray*>(Stack);
 
@@ -2975,7 +2983,7 @@ void gen254(stack *Stack)
 }
 
 // int sum(boolarray *a);
-void gen255(stack *Stack)
+void gen256(stack *Stack)
 {
   boolarray * a = vm::pop<boolarray *>(Stack);
 
@@ -3044,7 +3052,7 @@ void array2Transpose(stack *Stack)
 // In a boolean array, find the index of the nth true value or -1 if not found
 // If n is negative, search backwards.
 // int find(boolarray *a, int n=1);
-void gen260(stack *Stack)
+void gen261(stack *Stack)
 {
   int n = vm::pop<int>(Stack,1);
   boolarray * a = vm::pop<boolarray *>(Stack);
@@ -3103,7 +3111,7 @@ void arrayConditional(stack *Stack)
 // [                ...         ]
 // [       c[n-1] a[n-1] b[n-1] ]
 // realarray* tridiagonal(realarray *a, realarray *b, realarray *c, realarray *f);
-void gen262(stack *Stack)
+void gen263(stack *Stack)
 {
   realarray * f = vm::pop<realarray *>(Stack);
   realarray * c = vm::pop<realarray *>(Stack);
@@ -3232,7 +3240,7 @@ void pairArrayFFT(stack *Stack)
 
 // File operations
 // bool ==(file *a, file *b);
-void gen264(stack *Stack)
+void gen265(stack *Stack)
 {
   file * b = vm::pop<file *>(Stack);
   file * a = vm::pop<file *>(Stack);
@@ -3241,7 +3249,7 @@ void gen264(stack *Stack)
 }
 
 // bool !=(file *a, file *b);
-void gen265(stack *Stack)
+void gen266(stack *Stack)
 {
   file * b = vm::pop<file *>(Stack);
   file * a = vm::pop<file *>(Stack);
@@ -3262,7 +3270,7 @@ void nullFile(stack *Stack)
 }
 
 // file* input(string name, bool check=true, string comment=commentchar);
-void gen268(stack *Stack)
+void gen269(stack *Stack)
 {
   string comment = vm::pop<string>(Stack,commentchar);
   bool check = vm::pop<bool>(Stack,true);
@@ -3275,7 +3283,7 @@ void gen268(stack *Stack)
 }
 
 // file* output(string name, bool append=false);
-void gen269(stack *Stack)
+void gen270(stack *Stack)
 {
   bool append = vm::pop<bool>(Stack,false);
   string name = vm::pop<string>(Stack);
@@ -3286,7 +3294,7 @@ void gen269(stack *Stack)
 }
 
 // file* xinput(string name, bool check=true);
-void gen270(stack *Stack)
+void gen271(stack *Stack)
 {
   bool check = vm::pop<bool>(Stack,true);
   string name = vm::pop<string>(Stack);
@@ -3300,7 +3308,7 @@ void gen270(stack *Stack)
 }
 
 // file* xoutput(string name, bool append=false);
-void gen271(stack *Stack)
+void gen272(stack *Stack)
 {
   bool append = vm::pop<bool>(Stack,false);
   string name = vm::pop<string>(Stack);
@@ -3314,7 +3322,7 @@ void gen271(stack *Stack)
 }
 
 // bool eof(file *File);
-void gen272(stack *Stack)
+void gen273(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3322,7 +3330,7 @@ void gen272(stack *Stack)
 }
 
 // bool eol(file *File);
-void gen273(stack *Stack)
+void gen274(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3330,7 +3338,7 @@ void gen273(stack *Stack)
 }
 
 // bool error(file *File);
-void gen274(stack *Stack)
+void gen275(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3338,7 +3346,7 @@ void gen274(stack *Stack)
 }
 
 // void clear(file *File);
-void gen275(stack *Stack)
+void gen276(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3346,7 +3354,7 @@ void gen275(stack *Stack)
 }
 
 // void close(file *File);
-void gen276(stack *Stack)
+void gen277(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3354,7 +3362,7 @@ void gen276(stack *Stack)
 }
 
 // void precision(file *File, int digits);
-void gen277(stack *Stack)
+void gen278(stack *Stack)
 {
   int digits = vm::pop<int>(Stack);
   file * File = vm::pop<file *>(Stack);
@@ -3363,7 +3371,7 @@ void gen277(stack *Stack)
 }
 
 // void flush(file *File);
-void gen278(stack *Stack)
+void gen279(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3371,7 +3379,7 @@ void gen278(stack *Stack)
 }
 
 // string getc(file *File);
-void gen279(stack *Stack)
+void gen280(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3384,7 +3392,7 @@ void gen279(stack *Stack)
 
 // Set file dimensions
 // file* dimension(file *File, int nx);
-void gen280(stack *Stack)
+void gen281(stack *Stack)
 {
   int nx = vm::pop<int>(Stack);
   file * File = vm::pop<file *>(Stack);
@@ -3394,7 +3402,7 @@ void gen280(stack *Stack)
 }
 
 // file* dimension(file *File, int nx, int ny);
-void gen281(stack *Stack)
+void gen282(stack *Stack)
 {
   int ny = vm::pop<int>(Stack);
   int nx = vm::pop<int>(Stack);
@@ -3405,7 +3413,7 @@ void gen281(stack *Stack)
 }
 
 // file* dimension(file *File, int nx, int ny, int nz);
-void gen282(stack *Stack)
+void gen283(stack *Stack)
 {
   int nz = vm::pop<int>(Stack);
   int ny = vm::pop<int>(Stack);
@@ -3418,7 +3426,7 @@ void gen282(stack *Stack)
 
 // Set file to read comma-separated values
 // file* csv(file *File, bool b=true);
-void gen283(stack *Stack)
+void gen284(stack *Stack)
 {
   bool b = vm::pop<bool>(Stack,true);
   file * File = vm::pop<file *>(Stack);
@@ -3429,7 +3437,7 @@ void gen283(stack *Stack)
 
 // Set file to read arrays in line-at-a-time mode
 // file* line(file *File, bool b=true);
-void gen284(stack *Stack)
+void gen285(stack *Stack)
 {
   bool b = vm::pop<bool>(Stack,true);
   file * File = vm::pop<file *>(Stack);
@@ -3440,7 +3448,7 @@ void gen284(stack *Stack)
 
 // Set file to read/write single-precision XDR values.
 // file* single(file *File, bool b=true);
-void gen285(stack *Stack)
+void gen286(stack *Stack)
 {
   bool b = vm::pop<bool>(Stack,true);
   file * File = vm::pop<file *>(Stack);
@@ -3451,7 +3459,7 @@ void gen285(stack *Stack)
 
 // Set file to read an array1 (1 int size followed by a 1d array)
 // file* read1(file *File);
-void gen286(stack *Stack)
+void gen287(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3461,7 +3469,7 @@ void gen286(stack *Stack)
 
 // Set file to read an array2 (2 int sizes followed by a 2d array)
 // file* read2(file *File);
-void gen287(stack *Stack)
+void gen288(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3471,7 +3479,7 @@ void gen287(stack *Stack)
 
 // Set file to read an array3 (3 int sizes followed by a 3d array)
 // file* read3(file *File);
-void gen288(stack *Stack)
+void gen289(stack *Stack)
 {
   file * File = vm::pop<file *>(Stack);
 
@@ -3672,39 +3680,40 @@ void gen_base_venv(venv &ve)
   addFunc(ve, run::gen224, primReal(), "cubiclength", formal(primTriple(), "z0", false, false), formal(primTriple(), "z0p", false, false), formal(primTriple(), "z1m", false, false), formal(primTriple(), "z1", false, false), formal(primReal(), "goal", false, false));
   addFunc(ve, run::gen225, primPair(), "intersect", formal(tripleArray(), "pre1", false, false), formal(tripleArray(), "point1", false, false), formal(tripleArray(), "post1", false, false), formal(tripleArray(), "pre2", false, false), formal(tripleArray(), "point2", false, false), formal(tripleArray(), "post2", false, false), formal(primReal(), "fuzz", false, false));
   addFunc(ve, run::gen226, primString() , "VERSION");
-  addFunc(ve, run::gen227, primVoid(), "quiet", formal(primBoolean(), "v", false, false));
-  addFunc(ve, run::gen228, primVoid(), "atexit", formal(voidFunction(), "f", false, false));
-  addFunc(ve, run::gen229, voidFunction(), "atexit");
-  addFunc(ve, run::gen230, primInt(), "merge", formal(stringArray(), "files", false, false), formal(primString(), "args", false, false), formal(primString(), "format", false, false), formal(primBoolean(), "keep", false, false));
-  addFunc(ve, run::gen251, intArray(), "sequence", formal(primInt(), "n", false, false));
-  addFunc(ve, run::gen253, primBoolean(), "all", formal(boolArray(), "a", false, false));
-  addFunc(ve, run::gen254, boolArray(), "!", formal(boolArray(), "a", false, false));
-  addFunc(ve, run::gen255, primInt(), "sum", formal(boolArray(), "a", false, false));
-  addFunc(ve, run::gen260, primInt(), "find", formal(boolArray(), "a", false, false), formal(primInt(), "n", true, false));
-  addFunc(ve, run::gen262, realArray(), "tridiagonal", formal(realArray(), "a", false, false), formal(realArray(), "b", false, false), formal(realArray(), "c", false, false), formal(realArray(), "f", false, false));
-  addFunc(ve, run::gen264, primBoolean(), "==", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false));
-  addFunc(ve, run::gen265, primBoolean(), "!=", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false));
-  addFunc(ve, run::gen268, primFile(), "input", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false), formal(primString() , "comment", true, false));
-  addFunc(ve, run::gen269, primFile(), "output", formal(primString() , "name", false, false), formal(primBoolean(), "append", true, false));
-  addFunc(ve, run::gen270, primFile(), "xinput", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false));
-  addFunc(ve, run::gen271, primFile(), "xoutput", formal(primString() , "name", false, false), formal(primBoolean(), "append", true, false));
-  addFunc(ve, run::gen272, primBoolean(), "eof", formal(primFile(), "file", false, false));
-  addFunc(ve, run::gen273, primBoolean(), "eol", formal(primFile(), "file", false, false));
-  addFunc(ve, run::gen274, primBoolean(), "error", formal(primFile(), "file", false, false));
-  addFunc(ve, run::gen275, primVoid(), "clear", formal(primFile(), "file", false, false));
-  addFunc(ve, run::gen276, primVoid(), "close", formal(primFile(), "file", false, false));
-  addFunc(ve, run::gen277, primVoid(), "precision", formal(primFile(), "file", false, false), formal(primInt(), "digits", false, false));
-  addFunc(ve, run::gen278, primVoid(), "flush", formal(primFile(), "file", false, false));
-  addFunc(ve, run::gen279, primString() , "getc", formal(primFile(), "file", false, false));
-  addFunc(ve, run::gen280, primFile(), "dimension", formal(primFile(), "file", false, false), formal(primInt(), "nx", false, false));
-  addFunc(ve, run::gen281, primFile(), "dimension", formal(primFile(), "file", false, false), formal(primInt(), "nx", false, false), formal(primInt(), "ny", false, false));
-  addFunc(ve, run::gen282, primFile(), "dimension", formal(primFile(), "file", false, false), formal(primInt(), "nx", false, false), formal(primInt(), "ny", false, false), formal(primInt(), "nz", false, false));
-  addFunc(ve, run::gen283, primFile(), "csv", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false));
-  addFunc(ve, run::gen284, primFile(), "line", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false));
-  addFunc(ve, run::gen285, primFile(), "single", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false));
-  addFunc(ve, run::gen286, primFile(), "read1", formal(primFile(), "file", false, false));
-  addFunc(ve, run::gen287, primFile(), "read2", formal(primFile(), "file", false, false));
-  addFunc(ve, run::gen288, primFile(), "read3", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen227, primString() , "TEXENGINE");
+  addFunc(ve, run::gen228, primVoid(), "quiet", formal(primBoolean(), "v", false, false));
+  addFunc(ve, run::gen229, primVoid(), "atexit", formal(voidFunction(), "f", false, false));
+  addFunc(ve, run::gen230, voidFunction(), "atexit");
+  addFunc(ve, run::gen231, primInt(), "merge", formal(stringArray(), "files", false, false), formal(primString(), "args", false, false), formal(primString(), "format", false, false), formal(primBoolean(), "keep", false, false));
+  addFunc(ve, run::gen252, intArray(), "sequence", formal(primInt(), "n", false, false));
+  addFunc(ve, run::gen254, primBoolean(), "all", formal(boolArray(), "a", false, false));
+  addFunc(ve, run::gen255, boolArray(), "!", formal(boolArray(), "a", false, false));
+  addFunc(ve, run::gen256, primInt(), "sum", formal(boolArray(), "a", false, false));
+  addFunc(ve, run::gen261, primInt(), "find", formal(boolArray(), "a", false, false), formal(primInt(), "n", true, false));
+  addFunc(ve, run::gen263, realArray(), "tridiagonal", formal(realArray(), "a", false, false), formal(realArray(), "b", false, false), formal(realArray(), "c", false, false), formal(realArray(), "f", false, false));
+  addFunc(ve, run::gen265, primBoolean(), "==", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false));
+  addFunc(ve, run::gen266, primBoolean(), "!=", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false));
+  addFunc(ve, run::gen269, primFile(), "input", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false), formal(primString() , "comment", true, false));
+  addFunc(ve, run::gen270, primFile(), "output", formal(primString() , "name", false, false), formal(primBoolean(), "append", true, false));
+  addFunc(ve, run::gen271, primFile(), "xinput", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false));
+  addFunc(ve, run::gen272, primFile(), "xoutput", formal(primString() , "name", false, false), formal(primBoolean(), "append", true, false));
+  addFunc(ve, run::gen273, primBoolean(), "eof", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen274, primBoolean(), "eol", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen275, primBoolean(), "error", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen276, primVoid(), "clear", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen277, primVoid(), "close", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen278, primVoid(), "precision", formal(primFile(), "file", false, false), formal(primInt(), "digits", false, false));
+  addFunc(ve, run::gen279, primVoid(), "flush", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen280, primString() , "getc", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen281, primFile(), "dimension", formal(primFile(), "file", false, false), formal(primInt(), "nx", false, false));
+  addFunc(ve, run::gen282, primFile(), "dimension", formal(primFile(), "file", false, false), formal(primInt(), "nx", false, false), formal(primInt(), "ny", false, false));
+  addFunc(ve, run::gen283, primFile(), "dimension", formal(primFile(), "file", false, false), formal(primInt(), "nx", false, false), formal(primInt(), "ny", false, false), formal(primInt(), "nz", false, false));
+  addFunc(ve, run::gen284, primFile(), "csv", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false));
+  addFunc(ve, run::gen285, primFile(), "line", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false));
+  addFunc(ve, run::gen286, primFile(), "single", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false));
+  addFunc(ve, run::gen287, primFile(), "read1", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen288, primFile(), "read2", formal(primFile(), "file", false, false));
+  addFunc(ve, run::gen289, primFile(), "read3", formal(primFile(), "file", false, false));
 }
 
 } // namespace trans
diff -r 57c230047c98 runtime.in
--- a/runtime.in	Tue Feb 07 23:34:29 2006 -0500
+++ b/runtime.in	Tue Apr 25 00:28:42 2006 -0400
@@ -1878,6 +1878,12 @@ string VERSION()
   return VERSION;
 }
 \f
+// for exporting to the .asy world how labels are to be processed
+string TEXENGINE()
+{
+  return getSetting<mem::string>("tex");
+}
+\f
 void quiet(bool v)
 {
   Setting("interactiveView")=
diff -r 57c230047c98 settings.cc
--- a/settings.cc	Tue Feb 07 23:34:29 2006 -0500
+++ b/settings.cc	Tue Apr 25 00:28:42 2006 -0400
@@ -399,7 +399,7 @@ struct alignSetting : public argumentSet
       value=(int)BOTTOM;
     else if (str=="Z") {
       value=(int)ZERO;
-      Setting("tex")=false;
+      Setting("tex")="none";
     }
     else {
       error("invalid argument for option");
@@ -631,9 +631,11 @@ void initSettings() {
   addOption(new incrementSetting("verbose", 'v',
 				 "Increase verbosity level", &verbose));
   addOption(new boolSetting("keep", 'k', "Keep intermediate files"));
-  addOption(new boolSetting("tex", 0,
-			    "Enable LaTeX label postprocessing (default)",
-			    true));
+  // changing tex from bool to string means that '-notex' no longer works.
+  // instead: '-tex none'
+  addOption(new stringSetting("tex", 't', "engine",
+			   "TeX engine for labels: tex, latex (default), none",
+			    "latex"));
   addOption(new boolSetting("inlinetex", 0, ""));
   addOption(new boolSetting("parseonly", 'p', "Parse test"));
   addOption(new boolSetting("translate", 's', "Translate test"));
@@ -669,7 +671,6 @@ void initSettings() {
   addOption(new envSetting("pdfviewer", defaultPDFViewer));
   addOption(new envSetting("psviewer", defaultPSViewer));
   addOption(new envSetting("gs", defaultGhostscript));
-  addOption(new envSetting("latex", "latex"));
   addOption(new envSetting("dvips", "dvips"));
   addOption(new envSetting("convert", "convert"));
   addOption(new envSetting("display", defaultDisplay));
diff -r 57c230047c98 texfile.cc
--- a/texfile.cc	Tue Feb 07 23:34:29 2006 -0500
+++ b/texfile.cc	Tue Apr 25 00:28:42 2006 -0400
@@ -41,19 +41,39 @@ void texfile::prologue()
 void texfile::prologue()
 {
   texdefines(*out);
-  if(!getSetting<bool>("inlinetex"))
-    *out << "\\pagestyle{empty}" << newl
-	 << "\\textheight=2048pt" << newl
-	 << "\\textwidth=\\textheight" << newl
-	 << "\\begin{document}" << newl;
+  if(!getSetting<bool>("inlinetex")) {
+    if (getSetting<mem::string>("tex") == "tex")
+      *out << "\\nopagenumbers" << newl
+	   << "\\hsize=2048pt" << newl
+	   << "\\vsize=\\hsize" << newl;
+    else if (getSetting<mem::string>("tex") == "latex")
+      *out << "\\pagestyle{empty}" << newl
+	   << "\\textheight=2048pt" << newl
+	   << "\\textwidth=\\textheight" << newl
+	   << "\\begin{document}" << newl;
+    else {			// unknown engine
+      cerr << "Unknown engine: " << getSetting<mem::string>("tex") << newl;
+      abort();
+    }
+  }
   *out << "\\psset{unit=1pt}" << newl;
 }
     
 void texfile::beginlayer(const string& psname)
 {
-  *out << "\\setbox\\ASYpsbox=\\hbox{\\includegraphics{" << psname << "}}%"
+  string includecmd;
+
+  if (getSetting<mem::string>("tex") == "tex")
+    includecmd = "\\epsfbox{";
+  else if (getSetting<mem::string>("tex") == "latex")
+    includecmd = "\\includegraphics{";
+  else { 			//
+    cerr << "Unknown engine: " << getSetting<mem::string>("tex") << newl;
+    abort ();
+  }
+  *out << "\\setbox\\ASYpsbox=\\hbox{" << includecmd << psname << "}}%"
        << newl
-       << "\\includegraphics{" << psname << "}%" << newl;
+       << includecmd << psname << "}%" << newl;
 }
 
 void texfile::endlayer()
@@ -90,12 +110,13 @@ void texfile::setpen(pen p)
   }
   
   if(p.size() != lastpen.size() || p.Lineskip() != lastpen.Lineskip()) {
+    // need to fix if not using latex (change fontsize and baselineskip)
     *out << "\\fontsize{" << p.size() << "}{" << p.Lineskip()
 	 << "}\\selectfont" << newl;
   }
 
   if(p.Font() != lastpen.Font()) {
-    *out << p.Font() << "%" << newl;
+    *out << p.Font() << "%" << newl; // need to change fonts differently in tex
   }
 
   offset=pair(box.right,box.bottom);
diff -r 57c230047c98 texfile.h
--- a/texfile.h	Tue Feb 07 23:34:29 2006 -0500
+++ b/texfile.h	Tue Apr 25 00:28:42 2006 -0400
@@ -55,8 +55,14 @@ template<class T>
 template<class T>
 void texdocumentclass(T& out, bool pipe=false)
 {
-  if(pipe || !settings::getSetting<bool>("inlinetex"))
-    out << "\\documentclass[12pt]{article}" << newl;
+  if(pipe || !settings::getSetting<bool>("inlinetex")) {
+    if (settings::getSetting<mem::string>("tex") == "latex")
+      out << "\\documentclass[12pt]{article}" << newl;
+    else if (settings::getSetting<mem::string>("tex") != "tex") {
+      cerr << "Unknown engine: " << settings::getSetting<mem::string>("tex") << newl;
+      abort();
+    }
+  }
 }
   
 template<class T>
@@ -85,8 +91,17 @@ void texdefines(T& out, stringlist& prea
       << "\\def\\ASYscale(#1,#2)(#3,#4)(#5,#6)#7#8{%" << newl
       << "\\ASYalign(#1,#2)(#3,#4){#7}{\\scalebox{#5}[#6]{#8}}}%" << newl;
   
-  if(pipe || !settings::getSetting<bool>("inlinetex"))
-    out << "\\usepackage{pstricks,graphicx}" << newl;
+  if(pipe || !settings::getSetting<bool>("inlinetex")) {
+    if (settings::getSetting<mem::string>("tex") == "tex")
+      out << "\\input epsf" << newl
+	  << "\\input pstricks" << newl;
+    else if (settings::getSetting<mem::string>("tex") == "latex")
+      out << "\\usepackage{pstricks,graphicx}" << newl;
+    else {
+      cerr << "Unknown engine: " << settings::getSetting<mem::string>("tex") << newl;
+      abort ();
+    }      
+  }
 }
   
 class texfile : public gc {
diff -r 57c230047c98 .hgignore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Tue Apr 25 00:28:42 2006 -0400
@@ -0,0 +1,3 @@
+syntax: glob
+*~
+*.o

  reply	other threads:[~2006-04-25  4:36 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-21 15:49 Renaud AUBIN
2006-04-21 16:17 ` Renaud AUBIN
2006-04-21 16:45   ` Hans Hagen
2006-04-21 18:29     ` Jilani Khaldi
2006-04-21 18:52       ` Renaud AUBIN
2006-04-21 19:11         ` Hans Hagen
2006-04-21 19:13         ` Hans Hagen
2006-04-21 19:25           ` Renaud AUBIN
2006-04-22  8:38             ` Hans Hagen
2006-04-22  9:16               ` andrea valle
2006-04-21 19:10       ` Hans Hagen
2006-04-21 19:20         ` Renaud AUBIN
2006-04-21 19:52           ` Hans Hagen
2006-04-23 18:51             ` Renaud AUBIN
2006-04-23 20:28               ` Hans Hagen
2006-04-23 21:02                 ` Renaud AUBIN
2006-04-23 21:50                   ` Hans Hagen
2006-04-23 22:33                     ` Renaud AUBIN
2006-04-24  0:54                       ` Sanjoy Mahajan
2006-04-24  7:33                       ` Hans Hagen
2006-04-25  4:36                         ` Sanjoy Mahajan [this message]
2006-04-25  7:04                           ` Hans Hagen
2006-04-25  8:02                             ` Taco Hoekwater
2006-04-25 15:17                             ` Sanjoy Mahajan
2006-04-21 20:00         ` ConTeXt +Tioga Jilani Khaldi
2006-04-21 20:49           ` Sanjoy Mahajan
2006-04-22  7:47           ` Hans Hagen
2006-04-22  9:47             ` Taco Hoekwater
2006-04-22 12:12               ` Jilani Khaldi
2006-04-22 15:56                 ` andrea valle
2006-04-21 19:37     ` ConTeXt + asymptote Sanjoy Mahajan
2006-04-21 23:30       ` Mojca Miklavec
2006-04-25  7:52 ` Taco Hoekwater
2006-06-29 13:40 John Bowman
2006-06-29 18:05 ` Hans Hagen
2006-06-30  1:12 ` Sanjoy Mahajan
2006-06-30  8:16   ` Hans Hagen
2006-10-15  5:04 John Bowman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1FYFHb-00012B-Kw@approximate.corpus.cam.ac.uk \
    --to=sanjoy@mrao.cam.ac.uk \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).