From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/27452 Path: news.gmane.org!not-for-mail From: Sanjoy Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: ConTeXt + asymptote Date: Tue, 25 Apr 2006 00:36:15 -0400 Message-ID: References: <444C7F4A.7010009@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1145939808 26095 80.91.229.2 (25 Apr 2006 04:36:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 25 Apr 2006 04:36:48 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Tue Apr 25 06:36:43 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1FYFHz-0000lG-0T for gctc-ntg-context-518@m.gmane.org; Tue, 25 Apr 2006 06:36:39 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 4B562127C1; Tue, 25 Apr 2006 06:36:38 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 05213-09-2; Tue, 25 Apr 2006 06:36:30 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id E5FAA127B1; Tue, 25 Apr 2006 06:36:29 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 66103127B1 for ; Tue, 25 Apr 2006 06:36:29 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 05213-09 for ; Tue, 25 Apr 2006 06:36:26 +0200 (CEST) Original-Received: from smtpauth08.mail.atl.earthlink.net (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) by ronja.ntg.nl (Postfix) with SMTP id F2ECE127B0 for ; Tue, 25 Apr 2006 06:36:25 +0200 (CEST) Original-Received: from [24.41.6.91] (helo=approximate.corpus.cam.ac.uk) by smtpauth08.mail.atl.earthlink.net with asmtp (TLSv1:AES256-SHA:256) (Exim 4.34) id 1FYFHj-00036n-KR; Tue, 25 Apr 2006 00:36:24 -0400 Original-Received: from sanjoy by approximate.corpus.cam.ac.uk with local (Exim 4.60) (envelope-from ) id 1FYFHb-00012B-Kw; Tue, 25 Apr 2006 00:36:15 -0400 Original-To: mailing list for ConTeXt users In-Reply-To: Your message of "Mon, 24 Apr 2006 09:33:30 +0200." <444C7F4A.7010009@wxs.nl> X-Mailer: MH-E 7.93; nmh 1.1; GNU Emacs 21.4.1 X-ELNK-Trace: dcd19350f30646cc26f3bd1b5f75c9f474bf435c0eb9d4789de090ecffd5a975aaee2d2b7d91e81190817ba5d19eff9e350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 24.41.6.91 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:27452 Archived-At: > 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" > 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("tex")) {b += position; return;} + if(settings::getSetting("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("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("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("tex")) { + if(n > lastnumber && !labels && getSetting("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("latex").c_str(),"latex","latex"); + tex.open(getSetting("tex").c_str(), + getSetting("tex").c_str(), + getSetting("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("latex") + cmd << getSetting("tex") << " \\scrollmode\\input " << texname; bool quiet=verbose <= 1; - status=System(cmd,quiet,true,"latex"); + status=System(cmd,quiet,true,getSetting("tex").c_str()); if(status) { - if(quiet) status=System(cmd,true,"latex"); + if(quiet) status=System(cmd,true,getSetting("tex").c_str()); return false; } @@ -360,7 +362,8 @@ bool picture::shipout(picture *preamble, bbox bpos=b; - bool TeXmode=getSetting("inlinetex") && getSetting("tex"); + bool TeXmode=getSetting("inlinetex") && + (getSetting("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(VERSION); return;} } +// for exporting to the .asy world how labels are to be processed +// string TEXENGINE(); +void gen227(stack *Stack) +{ + + {Stack->push(getSetting("tex")); return;} +} + // void quiet(bool v); -void gen227(stack *Stack) +void gen228(stack *Stack) { bool v = vm::pop(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(Stack); @@ -2618,7 +2626,7 @@ void gen228(stack *Stack) } // callable* atexit(); -void gen229(stack *Stack) +void gen230(stack *Stack) { {Stack->push(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(Stack); string * format = vm::pop(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(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(Stack); @@ -2963,7 +2971,7 @@ void gen253(stack *Stack) } // boolarray* !(boolarray* a); -void gen254(stack *Stack) +void gen255(stack *Stack) { boolarray* a = vm::pop(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(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(Stack,1); boolarray * a = vm::pop(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(Stack); realarray * c = vm::pop(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(Stack); file * a = vm::pop(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(Stack); file * a = vm::pop(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(Stack,commentchar); bool check = vm::pop(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(Stack,false); string name = vm::pop(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(Stack,true); string name = vm::pop(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(Stack,false); string name = vm::pop(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(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(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(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(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(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(Stack); file * File = vm::pop(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(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(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(Stack); file * File = vm::pop(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(Stack); int nx = vm::pop(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(Stack); int ny = vm::pop(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(Stack,true); file * File = vm::pop(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(Stack,true); file * File = vm::pop(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(Stack,true); file * File = vm::pop(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(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(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(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; } +// for exporting to the .asy world how labels are to be processed +string TEXENGINE() +{ + return getSetting("tex"); +} + 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("inlinetex")) - *out << "\\pagestyle{empty}" << newl - << "\\textheight=2048pt" << newl - << "\\textwidth=\\textheight" << newl - << "\\begin{document}" << newl; + if(!getSetting("inlinetex")) { + if (getSetting("tex") == "tex") + *out << "\\nopagenumbers" << newl + << "\\hsize=2048pt" << newl + << "\\vsize=\\hsize" << newl; + else if (getSetting("tex") == "latex") + *out << "\\pagestyle{empty}" << newl + << "\\textheight=2048pt" << newl + << "\\textwidth=\\textheight" << newl + << "\\begin{document}" << newl; + else { // unknown engine + cerr << "Unknown engine: " << getSetting("tex") << newl; + abort(); + } + } *out << "\\psset{unit=1pt}" << newl; } void texfile::beginlayer(const string& psname) { - *out << "\\setbox\\ASYpsbox=\\hbox{\\includegraphics{" << psname << "}}%" + string includecmd; + + if (getSetting("tex") == "tex") + includecmd = "\\epsfbox{"; + else if (getSetting("tex") == "latex") + includecmd = "\\includegraphics{"; + else { // + cerr << "Unknown engine: " << getSetting("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 template void texdocumentclass(T& out, bool pipe=false) { - if(pipe || !settings::getSetting("inlinetex")) - out << "\\documentclass[12pt]{article}" << newl; + if(pipe || !settings::getSetting("inlinetex")) { + if (settings::getSetting("tex") == "latex") + out << "\\documentclass[12pt]{article}" << newl; + else if (settings::getSetting("tex") != "tex") { + cerr << "Unknown engine: " << settings::getSetting("tex") << newl; + abort(); + } + } } template @@ -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("inlinetex")) - out << "\\usepackage{pstricks,graphicx}" << newl; + if(pipe || !settings::getSetting("inlinetex")) { + if (settings::getSetting("tex") == "tex") + out << "\\input epsf" << newl + << "\\input pstricks" << newl; + else if (settings::getSetting("tex") == "latex") + out << "\\usepackage{pstricks,graphicx}" << newl; + else { + cerr << "Unknown engine: " << settings::getSetting("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