-
Notifications
You must be signed in to change notification settings - Fork 2
/
mimetex.c
2102 lines (2073 loc) · 109 KB
/
mimetex.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/****************************************************************************
*
* Copyright(c) 2002-2009, John Forkosh Associates, Inc. All rights reserved.
* http://www.forkosh.com mailto: [email protected]
* --------------------------------------------------------------------------
* This file is part of mimeTeX, which is free software. You may redistribute
* and/or modify it under the terms of the GNU General Public License,
* version 3 or later, as published by the Free Software Foundation.
* MimeTeX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY, not even the implied warranty of MERCHANTABILITY.
* See the GNU General Public License for specific details.
* By using mimeTeX, you warrant that you have read, understood and
* agreed to these terms and conditions, and that you possess the legal
* right and ability to enter into this agreement and to use mimeTeX
* in accordance with it.
* Your mimetex.zip distribution file should contain the file COPYING,
* an ascii text copy of the GNU General Public License, version 3.
* If not, point your browser to http://www.gnu.org/licenses/
* or write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
* --------------------------------------------------------------------------
*
* Purpose: o MimeTeX, licensed under the gpl, lets you easily embed
* LaTeX math in your html pages. It parses a LaTeX math
* expression and immediately emits the corresponding gif
* image, rather than the usual TeX dvi. And mimeTeX is an
* entirely separate little program that doesn't use TeX or
* its fonts in any way. It's just one cgi that you put in
* your site's cgi-bin/ directory, with no other dependencies.
* So mimeTeX is very easy to install. And it's equally
* easy to use. Just place an html <img> tag in your document
* wherever you want to see the corresponding LaTeX expression.
* For example,
* <img src="../cgi-bin/mimetex.cgi?\int_{-\infty}^xe^{-t^2}dt"
* alt="" border=0 align=middle>
* immediately generates the corresponding gif image on-the-fly,
* displaying the rendered expression wherever you put that
* <img> tag.
* MimeTeX doesn't need intermediate dvi-to-gif conversion,
* and it doesn't clutter up your filesystem with separate
* little gif files for each converted expression.
* But image caching is available by using mimeTeX's
* -DCACHEPATH=\"path/\" compile option (see below).
* There's also no inherent need to repeatedly write the
* cumbersome <img> tag illustrated above. You can write
* your own custom tags, or write a wrapper script around
* mimeTeX to simplify the notation.
* Further discussion about mimeTeX's features and
* usage is available on its homepage,
* http://www.forkosh.com/mimetex.html
* and similarly in mimetex.html included with your mimetex.zip
* distribution file. (Note: http://www.forkosh.com/mimetex.html
* is a "quickstart" version of the the full mimetex.html manual
* included in your mimetex.zip distribution file.)
*
* Functions: The following "table of contents" lists each function
* comprising mimeTeX in the order it appears in this file.
* See individual function entry points for specific comments
* about its purpose, calling sequence, side effects, etc.
* (All these functions eventually belong in several
* different modules, possibly along the lines suggested
* by the divisions below. But until the best decomposition
* becomes clear, it seems better to keep mimetex.c
* neatly together, avoiding a bad decomposition that
* becomes permanent by default.)
* ===================== Raster Functions ======================
* PART2 --- raster constructor functions ---
* new_raster(width,height,pixsz) allocation (and constructor)
* new_subraster(width,height,pixsz)allocation (and constructor)
* new_chardef() allocate chardef struct
* delete_raster(rp) deallocate raster (rp = raster ptr)
* delete_subraster(sp) deallocate subraster (sp=subraster ptr)
* delete_chardef(cp) deallocate chardef (cp = chardef ptr)
* --- primitive (sub)raster functions ---
* rastcpy(rp) allocate new copy of rp
* subrastcpy(sp) allocate new copy of sp
* rastrot(rp) new raster rotated right 90 degrees to rp
* rastref(rp,axis) new raster reflected (axis 1=horz,2=vert)
* rastput(target,source,top,left,isopaque) overlay src on trgt
* rastcompose(sp1,sp2,offset2,isalign,isfree) sp2 on top of sp1
* rastcat(sp1,sp2,isfree) concatanate sp1||sp2
* rastack(sp1,sp2,base,space,iscenter,isfree)stack sp2 atop sp1
* rastile(tiles,ntiles) create composite raster from tiles
* rastsmash(sp1,sp2,xmin,ymin) calc #smash pixels sp1||sp2
* rastsmashcheck(term) check if term is "safe" to smash
* --- raster "drawing" functions ---
* accent_subraster(accent,width,height) draw \hat\vec\etc
* arrow_subraster(width,height,drctn,isBig) left/right arrow
* uparrow_subraster(width,height,drctn,isBig) up/down arrow
* rule_raster(rp,top,left,width,height,type) draw rule in rp
* line_raster(rp,row0,col0,row1,col1,thickness) draw line in rp
* line_recurse(rp,row0,col0,row1,col1,thickness) recurse line
* circle_raster(rp,row0,col0,row1,col1,thickness,quads) ellipse
* circle_recurse(rp,row0,col0,row1,col1,thickness,theta0,theta1)
* bezier_raster(rp,r0,c0,r1,c1,rt,ct) draw bezier recursively
* border_raster(rp,ntop,nbot,isline,isfree)put border around rp
* backspace_raster(rp,nback,pback,minspace,isfree) neg space
* --- raster (and chardef) output functions ---
* type_raster(rp,fp) emit ascii dump of rp on file ptr fp
* type_bytemap(bp,grayscale,width,height,fp) dump bytemap on fp
* xbitmap_raster(rp,fp) emit mime xbitmap of rp on fp
* type_pbmpgm(rp,ptype,file) pbm or pgm image of rp to file
* cstruct_chardef(cp,fp,col1) emit C struct of cp on fp
* cstruct_raster(rp,fp,col1) emit C struct of rp on fp
* hex_bitmap(rp,fp,col1,isstr)emit hex dump of rp->pixmap on fp
* --- ancillary output functions ---
* emit_string(fp,col1,string,comment) emit string and C comment
* gftobitmap(rp) convert .gf-like pixmap to bitmap image
* ====================== Font Functions =======================
* --- font lookup functions ---
* get_symdef(symbol) return mathchardef for symbol
* get_ligature(expr,family) return symtable index for ligature
* get_chardef(symdef,size) return chardef for symdef,size
* get_charsubraster(symdef,size) wrap subraster around chardef
* get_symsubraster(symbol,size) returns subraster for symbol
* --- ancillary font functions ---
* get_baseline(gfdata) determine baseline (in our coords)
* get_delim(symbol,height,family) delim just larger than height
* make_delim(symbol,height) construct delim exactly height size
* ================= Tokenize/Parse Functions ==================
* texchar(expression,chartoken) retruns next char or \sequence
* texsubexpr(expr,subexpr,maxsubsz,left,right,isescape,isdelim)
* texleft(expr,subexpr,maxsubsz,ldelim,rdelim) \left...\right
* texscripts(expression,subscript,superscript,which)get scripts
* --- ancillary parse functions ---
* isbrace(expression,braces,isescape) check for leading brace
* preamble(expression,size,subexpr) parse preamble
* mimeprep(expression) preprocessor converts \left( to \(, etc.
* strchange(nfirst,from,to) change nfirst chars of from to to
* strreplace(string,from,to,nreplace) change from to to in str
* strwstr(string,substr,white,sublen) find substr in string
* strdetex(s,mode) replace math chars like \^_{} for display
* strtexchr(string,texchr) find texchr in string
* findbraces(expression,command) find opening { or closing }
* isstrstr(string,snippets,iscase) are any snippets in string?
* unescape_url(url,isescape), x2c(what) xlate %xx url-encoded
* PART3 =========== Rasterize an Expression (recursively) ===========
* --- here's the primary entry point for all of mimeTeX ---
* rasterize(expression,size) parse and rasterize expression
* --- explicitly called handlers that rasterize... ---
* rastparen(subexpr,size,basesp) parenthesized subexpr
* rastlimits(expression,size,basesp) dispatch super/sub call
* rastscripts(expression,size,basesp) super/subscripted exprssn
* rastdispmath(expression,size,sp) scripts for displaymath
* --- table-driven handlers that rasterize... ---
* rastleft(expression,size,basesp,ildelim,arg2,arg3)\left\right
* rastright(expression,size,basesp,ildelim,arg2,arg3) ...\right
* rastmiddle(expression,size,basesp,arg1,arg2,arg3) \middle
* rastflags(expression,size,basesp,flag,value,arg3) set flag
* rastspace(expression,size,basesp,width,isfill,isheight)\,\:\;
* rastnewline(expression,size,basesp,arg1,arg2,arg3) \\
* rastarrow(expression,size,basesp,width,height,drctn) \longarr
* rastuparrow(expression,size,basesp,width,height,drctn)up/down
* rastoverlay(expression,size,basesp,overlay,arg2,arg3) \not
* rastfrac(expression,size,basesp,isfrac,arg2,arg3) \frac \atop
* rastackrel(expression,size,basesp,base,arg2,arg3) \stackrel
* rastmathfunc(expression,size,basesp,base,arg2,arg3) \lim,\etc
* rastsqrt(expression,size,basesp,arg1,arg2,arg3) \sqrt
* rastaccent(expression,size,basesp,accent,isabove,isscript)
* rastfont(expression,size,basesp,font,arg2,arg3) \cal{},\scr{}
* rastbegin(expression,size,basesp,arg1,arg2,arg3) \begin{}
* rastarray(expression,size,basesp,arg1,arg2,arg3) \array
* rastpicture(expression,size,basesp,arg1,arg2,arg3) \picture
* rastline(expression,size,basesp,arg1,arg2,arg3) \line
* rastrule(expression,size,basesp,arg1,arg2,arg3) \rule
* rastcircle(expression,size,basesp,arg1,arg2,arg3) \circle
* rastbezier(expression,size,basesp,arg1,arg2,arg3) \bezier
* rastraise(expression,size,basesp,arg1,arg2,arg3) \raisebox
* rastrotate(expression,size,basesp,arg1,arg2,arg3) \rotatebox
* rastreflect(expression,size,basesp,arg1,arg2,arg3)\reflectbox
* rastfbox(expression,size,basesp,arg1,arg2,arg3) \fbox
* rastinput(expression,size,basesp,arg1,arg2,arg3) \input
* rastcounter(expression,size,basesp,arg1,arg2,arg3) \counter
* rasttoday(expression,size,basesp,arg1,arg2,arg3) \today
* rastcalendar(expression,size,basesp,arg1,arg2,arg3) \calendar
* rastenviron(expression,size,basesp,arg1,arg2,arg3) \environ
* rastmessage(expression,size,basesp,arg1,arg2,arg3) \message
* rastnoop(expression,size,basesp,arg1,arg2,arg3) flush \escape
* --- helper functions for handlers ---
* rastopenfile(filename,mode) opens filename[.tex] in mode
* sanitize_pathname(filename) edit filename (for security)
* rastreadfile(filename,islock,tag,value) read <tag>...</tag>
* rastwritefile(filename,tag,value,isstrict)write<tag>...</tag>
* calendar(year,month,day) formats one-month calendar string
* timestamp(tzdelta,ifmt) formats timestamp string
* tzadjust(tzdelta,year,month,day,hour) adjust date/time
* daynumber(year,month,day) #days since Monday, Jan 1, 1973
* strwrap(s,linelen,tablen)insert \n's and spaces to wrap lines
* strnlower(s,n) lowercase the first n chars of string s
* urlprune(url,n) http://abc.def.ghi.com/etc-->abc.def.ghi.com
* urlncmp(url1,url2,n) compares topmost n levels of two url's
* dbltoa(d,npts) double to comma-separated ascii
* === Anti-alias completed raster (lowpass) or symbols (ss) ===
* aalowpass(rp,bytemap,grayscale) lowpass grayscale bytemap
* aapnm(rp,bytemap,grayscale) lowpass based on pnmalias.c
* aapnmlookup(rp,bytemap,grayscale) aapnm based on aagridnum()
* aapatterns(rp,irow,icol,gridnum,patternum,grayscale) call 19,
* aapattern1124(rp,irow,icol,gridnum,grayscale)antialias pattrn
* aapattern19(rp,irow,icol,gridnum,grayscale) antialias pattern
* aapattern20(rp,irow,icol,gridnum,grayscale) antialias pattern
* aapattern39(rp,irow,icol,gridnum,grayscale) antialias pattern
* aafollowline(rp,irow,icol,direction) looks for a "turn"
* aagridnum(rp,irow,icol) calculates gridnum, 0-511
* aapatternnum(gridnum) looks up pattern#, 1-51, for gridnum
* aalookup(gridnum) table lookup for all possible 3x3 grids
* aalowpasslookup(rp,bytemap,grayscale) driver for aalookup()
* aasupsamp(rp,aa,sf,grayscale) or by supersampling
* aacolormap(bytemap,nbytes,colors,colormap)make colors,colormap
* aaweights(width,height) builds "canonical" weight matrix
* aawtpixel(image,ipixel,weights,rotate) weight image at ipixel
* === miscellaneous ===
* mimetexsetmsg(newmsglevel,newmsgfp) set msglevel and msgfp
* PART1 ========================== Driver ===========================
* main(argc,argv) parses math expression and emits mime xbitmap
* CreateGifFromEq(expression,gifFileName) entry pt for win dll
* ismonth(month) is month current month ("jan"-"dec")?
* logger(fp,msglevel,logvars) logs environment variables
* emitcache(cachefile,maxage,valign,isbuffer) emit cachefile
* readcachefile(cachefile,buffer) read cachefile into buffer
* md5str(instr) md5 hash library functions
* GetPixel(x,y) callback function for gifsave library
*
* Source: mimetex.c (needs mimetex.h and texfonts.h to compile,
* and also needs gifsave.c when compiled with -DAA or -DGIF)
*
* --------------------------------------------------------------------------
* Notes o See individual function entry points for specific comments
* about the purpose, calling sequence, side effects, etc
* of each mimeTeX function listed above.
* o See bottom of file for main() driver (and "friends"),
* and compile as
* cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi
* to produce an executable that emits gif images with
* anti-aliasing (see Notes below). You may also compile
* cc -DGIF mimetex.c gifsave.c -lm -o mimetex.cgi
* to produce an executable that emits gif images without
* anti-aliasing. Alternatively, compile mimeTeX as
* cc -DXBITMAP mimetex.c -lm -o mimetex.cgi
* to produce an executable that just emits mime xbitmaps.
* In either case you'll need mimetex.h and texfonts.h,
* and with -DAA or -DGIF you'll also need gifsave.c
* o The font information in texfonts.h was produced by multiple
* runs of gfuntype, one run per struct (i.e., one run per font
* family at a particular size). Compile gfuntype as
* cc gfuntype.c mimetex.c -lm -o gfuntype
* See gfuntype.c, and also mimetex.html#fonts, for details.
* o For gif images, the gifsave.c library by Sverre H. Huseby
* <http://shh.thathost.com> slightly modified by me to allow
* (a)sending output to stdout or returning it in memory,
* and (b)specifying a transparent background color index,
* is included with mimeTeX, and it's documented in
* mimetex.html#gifsave
* o MimeTeX's principal reusable function is rasterize(),
* which takes a string like "f(x)=\int_{-\infty}^xe^{-t^2}dt"
* and returns a (sub)raster representing it as a bit or bytemap.
* Your application can do anything it likes with this pixel map.
* MimeTeX just outputs it, either as a mime xbitmap or as a gif.
* See mimetex.html#makeraster for further discussion
* and examples.
* o File mimetex.c also contains library functions implementing
* a raster datatype, functions to manipulate rasterized .mf
* fonts (see gfuntype.c which rasterizes .mf fonts), functions
* to parse LaTeX expressions, etc. As already mentioned,
* a complete list of mimetex.c functions is above. See their
* individual entry points below for further comments.
* As also mentioned, these functions eventually belong in
* several different modules, possibly along the lines suggested
* by the divisions above. But until the best decomposition
* becomes clear, it seems better to keep mimetex.c
* neatly together, avoiding a bad decomposition that
* becomes permanent by default.
* o Optional compile-line -D defined symbols are documented
* in mimetex.html#options . They include (additional -D
* switches are discussed at mimetex.html#options)...
* -DAA
* Turns on gif anti-aliasing with default values
* (CENTERWT=32, ADJACENTWT=3, CORNERWT=1)
* for the following anti-aliasing parameters...
* -DCENTERWT=n
* -DADJACENTWT=j
* -DCORNERWT=k
* *** Note: Ignore these three switches because
* *** mimeTeX's current anti-aliasing algorithm
* *** no longer uses them (as of version 1.60).
* MimeTeX currently provides a lowpass filtering
* algorithm for anti-aliasing, which is applied to the
* existing set of bitmap fonts. This lowpass filter
* applies default weights
* 1 2 1
* 2 8 2
* 1 2 1
* to neighboring pixels. The defaults weights are
* CENTERWT=8, ADJACENTWT=2 and CORNERWT=1,
* which you can adjust to control anti-aliasing.
* Lower CENTERWT values will blur/spread out lines
* while higher values will tend to sharpen lines.
* Experimentation is recommended to determine
* what value works best for you.
* -DCACHEPATH=\"path/\"
* This option saves each rendered image to a file
* in directory path/ which mimeTeX reads rather than
* re-rendering the same image every time it's given
* the same LaTeX expression. Sometimes mimeTeX disables
* caching, e.g., expressions containing \input{ } are
* re-rendered since the contents of the inputted file
* may have changed. If compiled without -DCACHEPATH
* mimeTeX always re-renders expressions. This usually
* isn't too cpu intensive, but if you have unusually
* high hit rates then image caching may be helpful.
* The path/ is relative to mimetex.cgi, and must
* be writable by it. Files created under path/ are
* named filename.gif, where filename is the 32-character
* MD5 hash of the LaTeX expression.
* -DDEFAULTSIZE=n
* MimeTeX currently has eight font sizes numbered 0-7,
* and always starts in DEFAULTSIZE whose default value
* is 3 (corresponding to \large). Specify -DDEFAULTSIZE=4
* on the compile line if you prefer mimeTeX to start in
* larger default size 4 (corresponding to \Large), etc.
* -DDISPLAYSIZE=n
* By default, operator limits like \int_a^b are rendered
* \textstyle at font sizes \normalsize and smaller,
* and rendered \displaystyle at font sizes \large and
* larger. This default corresponds to -DDISPLAYSIZE=3,
* which you can adjust; e.g., -DDISPLAYSIZE=0 always
* defaults to \displaystyle, and 99 (or any large number)
* always defaults to \textstyle. Note that explicit
* \textstyle, \displaystyle, \limits or \nolimits
* directives in an expression always override
* the DISPLAYSIZE default.
* -DERRORSTATUS=n
* The default, 0, means mimeTeX always exits with status 0,
* regardless of whether or not it detects error(s) while
* trying to render your expression. Specify any non-zero
* value (typically -1) if you write a script/plugin for
* mimeTeX that traps non-zero exit statuses. MimeTeX then
* exits with its own non-zero status when it detects an
* error it can identify, or with your ERRORSTATUS value
* for errors it can't specifically identify.
* -DREFERER=\"domain\" -or-
* -DREFERER=\"domain1,domain2,etc\"
* Blocks mimeTeX requests from unauthorized domains that
* may be using your server's mimetex.cgi without permission.
* If REFERER is defined, mimeTeX checks for the environment
* variable HTTP_REFERER and, if it exists, performs a
* case-insensitive test to make sure it contains 'domain'
* as a substring. If given several 'domain's (second form)
* then HTTP_REFERER must contain either 'domain1' or
* 'domain2', etc, as a (case-insensitive) substring.
* If HTTP_REFERER fails to contain a substring matching
* any of these domain(s), mimeTeX emits an error message
* image corresponding to the expression specified by
* the invalid_referer_msg string defined in main().
* Note: if HTTP_REFERER is not an environment variable,
* mimeTeX correctly generates the requested expression
* (i.e., no referer error).
* -DWARNINGS=n -or-
* -DNOWARNINGS
* If an expression submitted to mimeTeX contains an
* unrecognzied escape sequence, e.g., "y=x+\abc+1", then
* mimeTeX generates a gif image containing an embedded
* warning in the form "y=x+[\abc?]+1". If you want these
* warnings suppressed, -DWARNINGS=0 or -DNOWARNINGS tells
* mimeTeX to ignore unrecognized symbols, and the rendered
* image is "y=x++1" instead.
* -DWHITE
* MimeTeX usually renders black symbols on a white
* background. This option renders white symbols on
* a black background instead.
* --------------------------------------------------------------------------
* Revision History:
* 09/18/02 J.Forkosh Installation.
* 12/11/02 J.Forkosh Version 1.00 released.
* 07/04/03 J.Forkosh Version 1.01 released.
* 10/17/03 J.Forkosh Version 1.20 released.
* 12/21/03 J.Forkosh Version 1.30 released.
* 02/01/04 J.Forkosh Version 1.40 released.
* 10/02/04 J.Forkosh Version 1.50 released.
* 11/30/04 J.Forkosh Version 1.60 released.
* 10/11/05 J.Forkosh Version 1.64 released.
* 11/30/06 J.Forkosh Version 1.65 released.
* 09/06/08 J.Forkosh Version 1.70 released.
* 03/23/09 J.Forkosh Version 1.71 released.
* 06/17/09 J.Forkosh Most recent revision (also see REVISIONDATE).
*
****************************************************************************/
/* ------------------------------------------------------------
header files and macros
------------------------------------------------------------ */
/* --- standard headers --- */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include "mimetex_priv.h"
#include "mimetex.h"
/* --- anti-aliasing parameter values by font weight --- */
aaparameters aaparams[] = {
/* ------------------------------------------------------------
centerwt adj corner minadj max fgalias,only,bgalias,only
------------------------------------------------------------ */
{ 64, 1, 1, 6, 8, 1, 0, 0, 0 }, /* 0 = light */
/* below is { CENTERWT, ADJACENTWT, CORNERWT, MINADJACENT, MAXADJACENT, 1, 0, 0, 0 }, */
{ 8, 2, 1, 6, 8, 1, 0, 0, 0 },
{ 8, 1, 1, 5, 8, 1, 0, 0, 0 }, /* 2 = semibold */
{ 8, 2, 1, 4, 9, 1, 0, 0, 0 } /* 3 = bold */
}; /* --- end-of-aaparams[] --- */
/* ------------------------------------------------------------
other variables
------------------------------------------------------------ */
/* --- "smash" margin (0 means no smashing) --- */
#ifndef SMASHMARGIN
#ifdef NOSMASH
#define SMASHMARGIN 0
#else
#define SMASHMARGIN 3
#endif
#endif
#ifndef SMASHCHECK
#define SMASHCHECK 0
#endif
/* --- textwidth --- */
#ifndef TEXTWIDTH
#define TEXTWIDTH (400)
#endif
/* --- treat +'s in query string as blanks? --- */
#ifdef PLUSBLANK /* + always interpreted as blank */
#define ISPLUSBLANK 1
#else
#ifdef PLUSNOTBLANK /* + never interpreted as blank */
#define ISPLUSBLANK 0
#else
/* program tries to determine */
#define ISPLUSBLANK (-1)
#endif
#endif
/* --- security and logging (inhibit message logging, etc) --- */
#ifndef SECURITY
#define SECURITY 999 /* default highest security level */
#endif
#if !defined(NODUMPENVP) && !defined(DUMPENVP)
#define DUMPENVP /* assume char *envp[] available */
#endif
/* --- check whether or not \input, \counter, \environment permitted --- */
#ifdef DEFAULTSECURITY /* default security specified */
#define EXPLICITDEFSECURITY /* don't override explicit default */
#else
/* defualt security not specified */
#define DEFAULTSECURITY (8) /* so set default security level */
#endif
#ifndef INPUTPATH /* \input{} paths permitted for... */
#define INPUTPATH NULL /* ...any referer */
#endif
/* ------------------------------------------------------------
debugging and logging / error reporting
------------------------------------------------------------ */
/* --- debugging and error reporting --- */
#ifndef MSGLEVEL
#define MSGLEVEL 1
#endif
#define DBGLEVEL 9 /* debugging if mctx->msglevel>=DBGLEVEL */
#define LOGLEVEL 3 /* logging if mctx->msglevel>=LOGLEVEL */
#ifndef ERRORSTATUS /* exit(ERRORSTATUS) for any error */
#define ERRORSTATUS 0 /* default doesn't signal errors */
#endif
/* --- embed warnings in rendered expressions, [\xxx?] if \xxx unknown --- */
#ifdef WARNINGS
#define WARNINGLEVEL WARNINGS
#else
#ifdef NOWARNINGS
#define WARNINGLEVEL 0
#else
#define WARNINGLEVEL 1
#endif
#endif
int nfontinfo = 8;
struct fontinfo_struct fontinfo[] = {/* --- name family istext class --- */
{ "\\math", 0, 0, 0 }, /*(0) default math mode */
{ "\\mathcal", CMSY10, 0, 1 }, /*(1) calligraphic, uppercase */
{ "\\mathscr", RSFS10, 0, 1 }, /*(2) rsfs/script, uppercase */
{ "\\textrm", CMR10, 1, -1 }, /*(3) \rm,\text{abc} --> {\textrm~abc}*/
{ "\\textit", CMMI10, 1, -1 }, /*(4) \it,\textit{abc}-->{\textit~abc}*/
{ "\\mathbb", BBOLD10, 0, -1 }, /*(5) \bb,\mathbb{abc}-->{\mathbb~abc}*/
{ "\\mathbf", CMMIB10, 0, -1 }, /*(6) \bf,\mathbf{abc}-->{\mathbf~abc}*/
{ "\\mathrm", CMR10, 0, -1 }, /*(7) \mathrm */
{ "\\cyr", CYR10, 1, -1 }, /*(8) \cyr (defaults as text mode) */
{ NULL, 0, 0, 0 }
}; /* --- end-of-fonts[] --- */
/* ---
* space between adjacent symbols, e.g., symspace[RELATION][VARIABLE]
* ------------------------------------------------------------------ */
int symspace[11][11] = {
/* -----------------------------------------------------------------------
Right... ORD OPER BIN REL OPEN CLOS PUNC VAR DISP SPACE unused
Left... -------------------------------------------------------------- */
/*ORDINARY*/ { 2, 3, 3, 5, 3, 2, 2, 2, 3, 0, 0 },
/*OPERATOR*/ { 3, 1, 1, 5, 3, 2, 2, 2, 3, 0, 0 },
/*BINARYOP*/ { 2, 1, 1, 5, 3, 2, 2, 2, 3, 0, 0 },
/*RELATION*/ { 5, 5, 5, 2, 5, 5, 2, 5, 5, 0, 0 },
/*OPENING*/ { 2, 2, 2, 5, 2, 4, 2, 2, 3, 0, 0 },
/*CLOSING*/ { 2, 3, 3, 5, 4, 2, 1, 2, 3, 0, 0 },
/*PUNCTION*/ { 2, 2, 2, 5, 2, 2, 1, 2, 2, 0, 0 },
/*VARIABLE*/ { 2, 2, 2, 5, 2, 2, 1, 2, 2, 0, 0 },
/*DISPOPER*/ { 2, 3, 3, 5, 2, 3, 2, 2, 2, 0, 0 },
/*SPACEOPER*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/*unused*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
}; /* --- end-of-symspace[][] --- */
#include "texfonts.h"
/* ---
* font families (by size), just a table of preceding font info
* ------------------------------------------------------------ */
/* --- for low-pass anti-aliasing --- */
fontfamily aafonttable[] = {
/* -----------------------------------------------------------------------------------------
family size=0, 1, 2, 3, 4, 5, 6, 7
----------------------------------------------------------------------------------------- */
{ CMR10, { cmr83, cmr100, cmr118, cmr131, cmr160, cmr180, cmr210, cmr250}},
{ CMMI10, { cmmi83, cmmi100, cmmi118, cmmi131, cmmi160, cmmi180, cmmi210, cmmi250}},
{ CMMIB10, { cmmib83, cmmib100, cmmib118, cmmib131, cmmib160, cmmib180, cmmib210, cmmib250}},
{ CMSY10, { cmsy83, cmsy100, cmsy118, cmsy131, cmsy160, cmsy180, cmsy210, cmsy250}},
{ CMEX10, { cmex83, cmex100, cmex118, cmex131, cmex160, cmex180, cmex210, cmex250}},
{ RSFS10, { rsfs83, rsfs100, rsfs118, rsfs131, rsfs160, rsfs180, rsfs210, rsfs250}},
{ BBOLD10, { bbold83, bbold100, bbold118, bbold131, bbold160, bbold180, bbold210, bbold250}},
{STMARY10, {stmary83, stmary100, stmary118, stmary131, stmary160, stmary180, stmary210, stmary250}},
{ CYR10, { wncyr83, wncyr100, wncyr118, wncyr131, wncyr160, wncyr180, wncyr210, wncyr250}},
{ -999, { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}}
}; /* --- end-of-aafonttable[] --- */
/*supersampling mctx->shrinkfactor by size*/
int shrinkfactors[]= {
3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
static mathchardef handlers[] = {
/* ---------- c o m m a n d h a n d l e r s --------------
symbol arg1 arg2 arg3 function
-------------------------------------------------------- */
/* --- commands --- */
{ "\\left", NOVALUE, NOVALUE, NOVALUE, rastleft },
{ "\\middle", NOVALUE, NOVALUE, NOVALUE, rastmiddle },
{ "\\frac", 1, NOVALUE, NOVALUE, rastfrac },
{ "\\over", 1, NOVALUE, NOVALUE, rastfrac },
{ "\\atop", 0, NOVALUE, NOVALUE, rastfrac },
{ "\\choose", 0, NOVALUE, NOVALUE, rastfrac },
{ "\\not", 1, 0, NOVALUE, rastoverlay },
{ "\\Not", 2, 0, NOVALUE, rastoverlay },
{ "\\widenot", 2, 0, NOVALUE, rastoverlay },
{ "\\sout", 3, NOVALUE, NOVALUE, rastoverlay },
{ "\\strikeout", 3, NOVALUE, NOVALUE, rastoverlay },
{ "\\compose", NOVALUE, NOVALUE, NOVALUE, rastoverlay },
{ "\\stackrel", 2, NOVALUE, NOVALUE, rastackrel },
{ "\\relstack", 1, NOVALUE, NOVALUE, rastackrel },
{ "\\sqrt", NOVALUE, NOVALUE, NOVALUE, rastsqrt },
{ "\\overbrace", OVERBRACE, 1, 1, rastaccent },
{ "\\underbrace", UNDERBRACE, 0, 1, rastaccent },
{ "\\overline", BARACCENT, 1, 0, rastaccent },
{ "\\underline", UNDERBARACCENT, 0, 0, rastaccent },
{ "\\begin", NOVALUE, NOVALUE, NOVALUE, rastbegin },
{ "\\array", NOVALUE, NOVALUE, NOVALUE, rastarray },
{ "\\matrix", NOVALUE, NOVALUE, NOVALUE, rastarray },
{ "\\tabular", NOVALUE, NOVALUE, NOVALUE, rastarray },
{ "\\picture", NOVALUE, NOVALUE, NOVALUE, rastpicture },
{ "\\line", NOVALUE, NOVALUE, NOVALUE, rastline },
{ "\\rule", NOVALUE, NOVALUE, NOVALUE, rastrule },
{ "\\circle", NOVALUE, NOVALUE, NOVALUE, rastcircle },
{ "\\bezier", NOVALUE, NOVALUE, NOVALUE, rastbezier },
{ "\\qbezier", NOVALUE, NOVALUE, NOVALUE, rastbezier },
{ "\\raisebox", NOVALUE, NOVALUE, NOVALUE, rastraise },
{ "\\rotatebox", NOVALUE, NOVALUE, NOVALUE, rastrotate },
{ "\\reflectbox", NOVALUE, NOVALUE, NOVALUE, rastreflect },
{ "\\fbox", NOVALUE, NOVALUE, NOVALUE, rastfbox },
{ "\\today", NOVALUE, NOVALUE, NOVALUE, rasttoday },
{ "\\calendar", NOVALUE, NOVALUE, NOVALUE, rastcalendar },
/* --- spaces --- */
{ "\\/", 1, NOVALUE, NOVALUE, rastspace },
{ "\\,", 2, NOVALUE, NOVALUE, rastspace },
{ "\\:", 4, NOVALUE, NOVALUE, rastspace },
{ "\\;", 6, NOVALUE, NOVALUE, rastspace },
{ "\\\n", 3, NOVALUE, NOVALUE, rastspace },
{ "\\\r", 3, NOVALUE, NOVALUE, rastspace },
{ "\\\t", 3, NOVALUE, NOVALUE, rastspace },
/*{ "\\~",5,NOVALUE,NOVALUE,rastspace },*/
{ "~", 5, NOVALUE, NOVALUE, rastspace },
{ "\\ ", 5, NOVALUE, NOVALUE, rastspace },
{ " ", 5, NOVALUE, NOVALUE, rastspace },
{ "\\!", -2, NOVALUE, NOVALUE, rastspace },
/*{ "\\!*", -2, 99,NOVALUE, rastspace },*/
{ "\\quad", 6, NOVALUE, NOVALUE, rastspace },
{ "\\qquad", 10, NOVALUE, NOVALUE, rastspace },
{ "\\hspace", 0, NOVALUE, NOVALUE, rastspace },
{ "\\hspace*", 0, 99, NOVALUE, rastspace },
{ "\\vspace", 0, NOVALUE, 1, rastspace },
{ "\\hfill", 0, 1, NOVALUE, rastspace },
/* --- newline --- */
{ "\\\\", NOVALUE, NOVALUE, NOVALUE, rastnewline },
/* --- arrows --- */
{ "\\longrightarrow", 1, 0, NOVALUE, rastarrow },
{ "\\Longrightarrow", 1, 1, NOVALUE, rastarrow },
{ "\\longleftarrow", -1, 0, NOVALUE, rastarrow },
{ "\\Longleftarrow", -1, 1, NOVALUE, rastarrow },
{ "\\longleftrightarrow", 0, 0, NOVALUE, rastarrow },
{ "\\Longleftrightarrow", 0, 1, NOVALUE, rastarrow },
{ "\\longuparrow", 1, 0, NOVALUE, rastuparrow },
{ "\\Longuparrow", 1, 1, NOVALUE, rastuparrow },
{ "\\longdownarrow", -1, 0, NOVALUE, rastuparrow },
{ "\\Longdownarrow", -1, 1, NOVALUE, rastuparrow },
{ "\\longupdownarrow", 0, 0, NOVALUE, rastuparrow },
{ "\\Longupdownarrow", 0, 1, NOVALUE, rastuparrow },
/* --- modes and values --- */
{ "\\cal", 1, NOVALUE, NOVALUE, rastfont },
{ "\\mathcal", 1, NOVALUE, NOVALUE, rastfont },
{ "\\scr", 2, NOVALUE, NOVALUE, rastfont },
{ "\\mathscr", 2, NOVALUE, NOVALUE, rastfont },
{ "\\mathfrak", 2, NOVALUE, NOVALUE, rastfont },
{ "\\mathbb", 5, NOVALUE, NOVALUE, rastfont },
{ "\\rm", 3, NOVALUE, NOVALUE, rastfont },
{ "\\text", 3, NOVALUE, NOVALUE, rastfont },
{ "\\textrm", 3, NOVALUE, NOVALUE, rastfont },
{ "\\mathrm", 7, NOVALUE, NOVALUE, rastfont },
{ "\\cyr", 8, NOVALUE, NOVALUE, rastfont },
{ "\\mathbf", 6, NOVALUE, NOVALUE, rastfont },
{ "\\bf", 6, NOVALUE, NOVALUE, rastfont },
{ "\\mathtt", 3, NOVALUE, NOVALUE, rastfont },
{ "\\mathsf", 3, NOVALUE, NOVALUE, rastfont },
{ "\\mbox", 3, NOVALUE, NOVALUE, rastfont },
{ "\\operatorname", 3, NOVALUE, NOVALUE, rastfont },
{ "\\it", 4, NOVALUE, NOVALUE, rastfont },
{ "\\textit", 4, NOVALUE, NOVALUE, rastfont },
{ "\\mathit", 4, NOVALUE, NOVALUE, rastfont },
{ "\\rm", ISFONTFAM, 3, NOVALUE, rastflags },
{ "\\it", ISFONTFAM, 4, NOVALUE, rastflags },
{ "\\sl", ISFONTFAM, 4, NOVALUE, rastflags },
{ "\\bb", ISFONTFAM, 5, NOVALUE, rastflags },
{ "\\bf", ISFONTFAM, 6, NOVALUE, rastflags },
{ "\\text", ISFONTFAM, 3, NOVALUE, rastflags },
{ "\\math", ISFONTFAM, 0, NOVALUE, rastflags },
{ "\\ascii", ISSTRING, 1, NOVALUE, rastflags },
{ "\\image", ISSTRING, 0, NOVALUE, rastflags },
{ "\\limits", ISDISPLAYSTYLE, 2, NOVALUE, rastflags },
{ "\\nolimits", ISDISPLAYSTYLE, 0, NOVALUE, rastflags },
{ "\\displaystyle", ISDISPLAYSTYLE, 2, NOVALUE, rastflags },
{ "\\textstyle", ISDISPLAYSTYLE, 0, NOVALUE, rastflags },
{ "\\displaysize", ISDISPLAYSIZE, NOVALUE, NOVALUE, rastflags},
{ "\\tiny", ISFONTSIZE, 0, NOVALUE, rastflags },
{ "\\scriptsize", ISFONTSIZE, 0, NOVALUE, rastflags },
{ "\\footnotesize", ISFONTSIZE, 1, NOVALUE, rastflags },
{ "\\small", ISFONTSIZE, 1, NOVALUE, rastflags },
{ "\\normalsize", ISFONTSIZE, 2, NOVALUE, rastflags },
{ "\\large", ISFONTSIZE, 3, NOVALUE, rastflags },
{ "\\Large", ISFONTSIZE, 4, NOVALUE, rastflags },
{ "\\LARGE", ISFONTSIZE, 5, NOVALUE, rastflags },
{ "\\huge", ISFONTSIZE, 6, NOVALUE, rastflags },
{ "\\Huge", ISFONTSIZE, 7, NOVALUE, rastflags },
{ "\\HUGE", ISFONTSIZE, 7, NOVALUE, rastflags },
{ "\\fontsize", ISFONTSIZE, NOVALUE, NOVALUE, rastflags },
{ "\\fs", ISFONTSIZE, NOVALUE, NOVALUE, rastflags },
{ "\\light", ISWEIGHT, 0, NOVALUE, rastflags },
{ "\\regular", ISWEIGHT, 1, NOVALUE, rastflags },
{ "\\semibold", ISWEIGHT, 2, NOVALUE, rastflags },
{ "\\bold", ISWEIGHT, 3, NOVALUE, rastflags },
{ "\\fontweight", ISWEIGHT, NOVALUE, NOVALUE, rastflags },
{ "\\fw", ISWEIGHT, NOVALUE, NOVALUE, rastflags },
{ "\\centerwt", ISCENTERWT, NOVALUE, NOVALUE, rastflags },
{ "\\adjacentwt", ISADJACENTWT, NOVALUE, NOVALUE, rastflags },
{ "\\cornerwt", ISCORNERWT, NOVALUE, NOVALUE, rastflags },
{ "\\aaalg", ISAAALGORITHM, NOVALUE, NOVALUE, rastflags },
{ "\\pnmparams", PNMPARAMS, NOVALUE, NOVALUE, rastflags },
{ "\\gammacorrection", ISGAMMA, NOVALUE, NOVALUE, rastflags },
{ "\\nocontenttype", ISCONTENTTYPE, 0, NOVALUE, rastflags },
{ "\\opaque", ISOPAQUE, 0, NOVALUE, rastflags },
{ "\\transparent", ISOPAQUE, 1, NOVALUE, rastflags },
{ "\\squash", ISSMASH, 3, 1, rastflags },
{ "\\smash", ISSMASH, 3, 1, rastflags },
{ "\\nosquash", ISSMASH, 0, NOVALUE, rastflags },
{ "\\nosmash", ISSMASH, 0, NOVALUE, rastflags },
{ "\\squashmargin", ISSMASH, NOVALUE, NOVALUE, rastflags },
{ "\\smashmargin", ISSMASH, NOVALUE, NOVALUE, rastflags },
{ "\\unitlength", UNITLENGTH, NOVALUE, NOVALUE, rastflags },
{ "\\reverse", ISREVERSE, NOVALUE, NOVALUE, rastflags },
{ "\\reversefg", ISREVERSE, 1, NOVALUE, rastflags },
{ "\\reversebg", ISREVERSE, 2, NOVALUE, rastflags },
{ "\\color", ISCOLOR, NOVALUE, NOVALUE, rastflags },
{ "\\red", ISCOLOR, 1, NOVALUE, rastflags },
{ "\\green", ISCOLOR, 2, NOVALUE, rastflags },
{ "\\blue", ISCOLOR, 3, NOVALUE, rastflags },
{ "\\black", ISCOLOR, 0, NOVALUE, rastflags },
{ "\\white", ISCOLOR, 7, NOVALUE, rastflags },
/* --- accents --- */
{ "\\vec", VECACCENT, 1, 0, rastaccent },
{ "\\widevec", VECACCENT, 1, 0, rastaccent },
{ "\\bar", BARACCENT, 1, 0, rastaccent },
{ "\\widebar", BARACCENT, 1, 0, rastaccent },
{ "\\hat", HATACCENT, 1, 0, rastaccent },
{ "\\widehat", HATACCENT, 1, 0, rastaccent },
{ "\\tilde", TILDEACCENT, 1, 0, rastaccent },
{ "\\widetilde", TILDEACCENT, 1, 0, rastaccent },
{ "\\dot", DOTACCENT, 1, 0, rastaccent },
{ "\\widedot", DOTACCENT, 1, 0, rastaccent },
{ "\\ddot", DDOTACCENT, 1, 0, rastaccent },
{ "\\wideddot", DDOTACCENT, 1, 0, rastaccent },
/* --- math functions --- */
{ "\\arccos", 1, 0, NOVALUE, rastmathfunc },
{ "\\arcsin", 2, 0, NOVALUE, rastmathfunc },
{ "\\arctan", 3, 0, NOVALUE, rastmathfunc },
{ "\\arg", 4, 0, NOVALUE, rastmathfunc },
{ "\\cos", 5, 0, NOVALUE, rastmathfunc },
{ "\\cosh", 6, 0, NOVALUE, rastmathfunc },
{ "\\cot", 7, 0, NOVALUE, rastmathfunc },
{ "\\coth", 8, 0, NOVALUE, rastmathfunc },
{ "\\csc", 9, 0, NOVALUE, rastmathfunc },
{ "\\deg", 10, 0, NOVALUE, rastmathfunc },
{ "\\det", 11, 1, NOVALUE, rastmathfunc },
{ "\\dim", 12, 0, NOVALUE, rastmathfunc },
{ "\\exp", 13, 0, NOVALUE, rastmathfunc },
{ "\\gcd", 14, 1, NOVALUE, rastmathfunc },
{ "\\hom", 15, 0, NOVALUE, rastmathfunc },
{ "\\inf", 16, 1, NOVALUE, rastmathfunc },
{ "\\ker", 17, 0, NOVALUE, rastmathfunc },
{ "\\lg", 18, 0, NOVALUE, rastmathfunc },
{ "\\lim", 19, 1, NOVALUE, rastmathfunc },
{ "\\liminf", 20, 1, NOVALUE, rastmathfunc },
{ "\\limsup", 21, 1, NOVALUE, rastmathfunc },
{ "\\ln", 22, 0, NOVALUE, rastmathfunc },
{ "\\log", 23, 0, NOVALUE, rastmathfunc },
{ "\\max", 24, 1, NOVALUE, rastmathfunc },
{ "\\min", 25, 1, NOVALUE, rastmathfunc },
{ "\\Pr", 26, 1, NOVALUE, rastmathfunc },
{ "\\sec", 27, 0, NOVALUE, rastmathfunc },
{ "\\sin", 28, 0, NOVALUE, rastmathfunc },
{ "\\sinh", 29, 0, NOVALUE, rastmathfunc },
{ "\\sup", 30, 1, NOVALUE, rastmathfunc },
{ "\\tan", 31, 0, NOVALUE, rastmathfunc },
{ "\\tanh", 32, 0, NOVALUE, rastmathfunc },
{ "\\tr", 33, 0, NOVALUE, rastmathfunc },
{ "\\pmod", 34, 0, NOVALUE, rastmathfunc },
/* --- flush -- recognized but not yet handled by mimeTeX --- */
{ "\\nooperation", 0, NOVALUE, NOVALUE, rastnoop },
{ "\\bigskip", 0, NOVALUE, NOVALUE, rastnoop },
{ "\\phantom", 1, NOVALUE, NOVALUE, rastnoop },
{ "\\nocaching", 0, NOVALUE, NOVALUE, rastnoop },
{ "\\noconten", 0, NOVALUE, NOVALUE, rastnoop },
{ "\\nonumber", 0, NOVALUE, NOVALUE, rastnoop },
/* { "\\!", 0, NOVALUE,NOVALUE, rastnoop }, */
{ "\\cydot", 0, NOVALUE, NOVALUE, rastnoop },
{ NULL, -999, -999, -999, NULL }
};
static mathchardef symbols_cmmi10[] = {
/* --------------------- C M M I --------------------------
symbol charnum family class function
-------------------------------------------------------- */
/* --- uppercase greek letters --- */
{ "\\Gamma", 0, CMMI10, VARIABLE, NULL },
{ "\\Delta", 1, CMMI10, VARIABLE, NULL },
{ "\\Theta", 2, CMMI10, VARIABLE, NULL },
{ "\\Lambda", 3, CMMI10, VARIABLE, NULL },
{ "\\Xi", 4, CMMI10, VARIABLE, NULL },
{ "\\Pi", 5, CMMI10, VARIABLE, NULL },
{ "\\Sigma", 6, CMMI10, VARIABLE, NULL },
{ "\\smallsum", 6, CMMI10, OPERATOR, NULL },
{ "\\Upsilon", 7, CMMI10, VARIABLE, NULL },
{ "\\Phi", 8, CMMI10, VARIABLE, NULL },
{ "\\Psi", 9, CMMI10, VARIABLE, NULL },
{ "\\Omega", 10, CMMI10, VARIABLE, NULL },
/* --- lowercase greek letters --- */
{ "\\alpha", 11, CMMI10, VARIABLE, NULL },
{ "\\beta", 12, CMMI10, VARIABLE, NULL },
{ "\\gamma", 13, CMMI10, VARIABLE, NULL },
{ "\\delta", 14, CMMI10, VARIABLE, NULL },
{ "\\epsilon", 15, CMMI10, VARIABLE, NULL },
{ "\\zeta", 16, CMMI10, VARIABLE, NULL },
{ "\\eta", 17, CMMI10, VARIABLE, NULL },
{ "\\theta", 18, CMMI10, VARIABLE, NULL },
{ "\\iota", 19, CMMI10, VARIABLE, NULL },
{ "\\kappa", 20, CMMI10, VARIABLE, NULL },
{ "\\lambda", 21, CMMI10, VARIABLE, NULL },
{ "\\mu", 22, CMMI10, VARIABLE, NULL },
{ "\\nu", 23, CMMI10, VARIABLE, NULL },
{ "\\xi", 24, CMMI10, VARIABLE, NULL },
{ "\\pi", 25, CMMI10, VARIABLE, NULL },
{ "\\rho", 26, CMMI10, VARIABLE, NULL },
{ "\\sigma", 27, CMMI10, VARIABLE, NULL },
{ "\\tau", 28, CMMI10, VARIABLE, NULL },
{ "\\upsilon", 29, CMMI10, VARIABLE, NULL },
{ "\\phi", 30, CMMI10, VARIABLE, NULL },
{ "\\chi", 31, CMMI10, VARIABLE, NULL },
{ "\\psi", 32, CMMI10, VARIABLE, NULL },
{ "\\omega", 33, CMMI10, VARIABLE, NULL },
{ "\\varepsilon", 34, CMMI10, VARIABLE, NULL },
{ "\\vartheta", 35, CMMI10, VARIABLE, NULL },
{ "\\varpi", 36, CMMI10, VARIABLE, NULL },
{ "\\varrho", 37, CMMI10, VARIABLE, NULL },
{ "\\varsigma", 38, CMMI10, VARIABLE, NULL },
{ "\\varphi", 39, CMMI10, VARIABLE, NULL },
/* --- arrow relations --- */
{ "\\leftharpoonup", 40, CMMI10, ARROW, NULL },
{ "\\leftharpoondown", 41, CMMI10, ARROW, NULL },
{ "\\rightharpoonup", 42, CMMI10, ARROW, NULL },
{ "\\rightharpoondown", 43, CMMI10, ARROW, NULL },
/* --- punctuation --- */
{ "`", 44, CMMI10, PUNCTION, NULL },
{ "\'", 45, CMMI10, PUNCTION, NULL },
/* --- triangle binary relations --- */
{ "\\triangleright", 46, CMMI10, RELATION, NULL },
{ "\\triangleleft", 47, CMMI10, RELATION, NULL },
/* --- digits 0-9 --- */
{ "\\0", 48, CMMI10, ORDINARY, NULL },
{ "\\1", 49, CMMI10, ORDINARY, NULL },
{ "\\2", 50, CMMI10, ORDINARY, NULL },
{ "\\3", 51, CMMI10, ORDINARY, NULL },
{ "\\4", 52, CMMI10, ORDINARY, NULL },
{ "\\5", 53, CMMI10, ORDINARY, NULL },
{ "\\6", 54, CMMI10, ORDINARY, NULL },
{ "\\7", 55, CMMI10, ORDINARY, NULL },
{ "\\8", 56, CMMI10, ORDINARY, NULL },
{ "\\9", 57, CMMI10, ORDINARY, NULL },
/* --- punctuation --- */
{ ".", 58, CMMI10, PUNCTION, NULL },
{ ",", 59, CMMI10, PUNCTION, NULL },
/* --- operations (some ordinary) --- */
{ "<", 60, CMMI10, OPENING, NULL },
{ "\\<", 60, CMMI10, OPENING, NULL },
{ "\\lt", 60, CMMI10, OPENING, NULL },
{ "/", 61, CMMI10, BINARYOP, NULL },
{ ">", 62, CMMI10, CLOSING, NULL },
{ "\\>", 62, CMMI10, CLOSING, NULL },
{ "\\gt", 62, CMMI10, CLOSING, NULL },
{ "\\star", 63, CMMI10, BINARYOP, NULL },
{ "\\partial", 64, CMMI10, VARIABLE, NULL },
/* --- uppercase letters --- */
{ "A", 65, CMMI10, VARIABLE, NULL },
{ "B", 66, CMMI10, VARIABLE, NULL },
{ "C", 67, CMMI10, VARIABLE, NULL },
{ "D", 68, CMMI10, VARIABLE, NULL },
{ "E", 69, CMMI10, VARIABLE, NULL },
{ "F", 70, CMMI10, VARIABLE, NULL },
{ "G", 71, CMMI10, VARIABLE, NULL },
{ "H", 72, CMMI10, VARIABLE, NULL },
{ "I", 73, CMMI10, VARIABLE, NULL },
{ "J", 74, CMMI10, VARIABLE, NULL },
{ "K", 75, CMMI10, VARIABLE, NULL },
{ "L", 76, CMMI10, VARIABLE, NULL },
{ "M", 77, CMMI10, VARIABLE, NULL },
{ "N", 78, CMMI10, VARIABLE, NULL },
{ "O", 79, CMMI10, VARIABLE, NULL },
{ "P", 80, CMMI10, VARIABLE, NULL },
{ "Q", 81, CMMI10, VARIABLE, NULL },
{ "R", 82, CMMI10, VARIABLE, NULL },
{ "S", 83, CMMI10, VARIABLE, NULL },
{ "T", 84, CMMI10, VARIABLE, NULL },
{ "U", 85, CMMI10, VARIABLE, NULL },
{ "V", 86, CMMI10, VARIABLE, NULL },
{ "W", 87, CMMI10, VARIABLE, NULL },
{ "X", 88, CMMI10, VARIABLE, NULL },
{ "Y", 89, CMMI10, VARIABLE, NULL },
{ "Z", 90, CMMI10, VARIABLE, NULL },
/* --- miscellaneous symbols and relations --- */
{ "\\flat", 91, CMMI10, ORDINARY, NULL },
{ "\\natural", 92, CMMI10, ORDINARY, NULL },
{ "\\sharp", 93, CMMI10, ORDINARY, NULL },
{ "\\smile", 94, CMMI10, RELATION, NULL },
{ "\\frown", 95, CMMI10, RELATION, NULL },
{ "\\ell", 96, CMMI10, ORDINARY, NULL },
/* --- lowercase letters --- */
{ "a", 97, CMMI10, VARIABLE, NULL },
{ "b", 98, CMMI10, VARIABLE, NULL },
{ "c", 99, CMMI10, VARIABLE, NULL },
{ "d", 100, CMMI10, VARIABLE, NULL },
{ "e", 101, CMMI10, VARIABLE, NULL },
{ "f", 102, CMMI10, VARIABLE, NULL },
{ "g", 103, CMMI10, VARIABLE, NULL },
{ "h", 104, CMMI10, VARIABLE, NULL },
{ "i", 105, CMMI10, VARIABLE, NULL },
{ "j", 106, CMMI10, VARIABLE, NULL },
{ "k", 107, CMMI10, VARIABLE, NULL },
{ "l", 108, CMMI10, VARIABLE, NULL },
{ "m", 109, CMMI10, VARIABLE, NULL },
{ "n", 110, CMMI10, VARIABLE, NULL },
{ "o", 111, CMMI10, VARIABLE, NULL },
{ "p", 112, CMMI10, VARIABLE, NULL },
{ "q", 113, CMMI10, VARIABLE, NULL },
{ "r", 114, CMMI10, VARIABLE, NULL },
{ "s", 115, CMMI10, VARIABLE, NULL },
{ "t", 116, CMMI10, VARIABLE, NULL },
{ "u", 117, CMMI10, VARIABLE, NULL },
{ "v", 118, CMMI10, VARIABLE, NULL },
{ "w", 119, CMMI10, VARIABLE, NULL },
{ "x", 120, CMMI10, VARIABLE, NULL },
{ "y", 121, CMMI10, VARIABLE, NULL },
{ "z", 122, CMMI10, VARIABLE, NULL },
/* --- miscellaneous symbols and relations --- */
{ "\\imath", 123, CMMI10, VARIABLE, NULL },
{ "\\jmath", 124, CMMI10, VARIABLE, NULL },
{ "\\wp", 125, CMMI10, ORDINARY, NULL },
{ "\\vec", 126, CMMI10, ORDINARY, NULL },
{ NULL, -999, -999, -999, NULL }
};
static mathchardef symbols_cmmib10[] = {
/* --------------------- C M M I B ------------------------
symbol charnum family class function
-------------------------------------------------------- */
/* --- uppercase greek letters --- */
{ "\\Gamma", 0, CMMIB10, VARIABLE, NULL },
{ "\\Delta", 1, CMMIB10, VARIABLE, NULL },
{ "\\Theta", 2, CMMIB10, VARIABLE, NULL },
{ "\\Lambda", 3, CMMIB10, VARIABLE, NULL },
{ "\\Xi", 4, CMMIB10, VARIABLE, NULL },
{ "\\Pi", 5, CMMIB10, VARIABLE, NULL },
{ "\\Sigma", 6, CMMIB10, VARIABLE, NULL },
{ "\\smallsum", 6, CMMIB10, OPERATOR, NULL },
{ "\\Upsilon", 7, CMMIB10, VARIABLE, NULL },
{ "\\Phi", 8, CMMIB10, VARIABLE, NULL },
{ "\\Psi", 9, CMMIB10, VARIABLE, NULL },
{ "\\Omega", 10, CMMIB10, VARIABLE, NULL },
/* --- lowercase greek letters --- */
{ "\\alpha", 11, CMMIB10, VARIABLE, NULL },
{ "\\beta", 12, CMMIB10, VARIABLE, NULL },
{ "\\gamma", 13, CMMIB10, VARIABLE, NULL },
{ "\\delta", 14, CMMIB10, VARIABLE, NULL },
{ "\\epsilon", 15, CMMIB10, VARIABLE, NULL },
{ "\\zeta", 16, CMMIB10, VARIABLE, NULL },
{ "\\eta", 17, CMMIB10, VARIABLE, NULL },
{ "\\theta", 18, CMMIB10, VARIABLE, NULL },
{ "\\iota", 19, CMMIB10, VARIABLE, NULL },
{ "\\kappa", 20, CMMIB10, VARIABLE, NULL },
{ "\\lambda", 21, CMMIB10, VARIABLE, NULL },
{ "\\mu", 22, CMMIB10, VARIABLE, NULL },
{ "\\nu", 23, CMMIB10, VARIABLE, NULL },
{ "\\xi", 24, CMMIB10, VARIABLE, NULL },
{ "\\pi", 25, CMMIB10, VARIABLE, NULL },
{ "\\rho", 26, CMMIB10, VARIABLE, NULL },
{ "\\sigma", 27, CMMIB10, VARIABLE, NULL },
{ "\\tau", 28, CMMIB10, VARIABLE, NULL },
{ "\\upsilon", 29, CMMIB10, VARIABLE, NULL },
{ "\\phi", 30, CMMIB10, VARIABLE, NULL },
{ "\\chi", 31, CMMIB10, VARIABLE, NULL },
{ "\\psi", 32, CMMIB10, VARIABLE, NULL },
{ "\\omega", 33, CMMIB10, VARIABLE, NULL },
{ "\\varepsilon", 34, CMMIB10, VARIABLE, NULL },
{ "\\vartheta", 35, CMMIB10, VARIABLE, NULL },
{ "\\varpi", 36, CMMIB10, VARIABLE, NULL },
{ "\\varrho", 37, CMMIB10, VARIABLE, NULL },
{ "\\varsigma", 38, CMMIB10, VARIABLE, NULL },
{ "\\varphi", 39, CMMIB10, VARIABLE, NULL },
/* --- arrow relations --- */
{ "\\bfleftharpoonup", 40, CMMIB10, ARROW, NULL },
{ "\\bfleftharpoondown", 41, CMMIB10, ARROW, NULL },
{ "\\bfrightharpoonup", 42, CMMIB10, ARROW, NULL },
{ "\\bfrightharpoondown", 43, CMMIB10, ARROW, NULL },
/* --- punctuation --- */
{ "`", 44, CMMIB10, PUNCTION, NULL },
{ "\'", 45, CMMIB10, PUNCTION, NULL },
/* --- triangle binary relations --- */
{ "\\triangleright", 46, CMMIB10, RELATION, NULL },
{ "\\triangleleft", 47, CMMIB10, RELATION, NULL },
/* --- digits 0-9 --- */
{ "\\0", 48, CMMIB10, ORDINARY, NULL },
{ "\\1", 49, CMMIB10, ORDINARY, NULL },
{ "\\2", 50, CMMIB10, ORDINARY, NULL },
{ "\\3", 51, CMMIB10, ORDINARY, NULL },
{ "\\4", 52, CMMIB10, ORDINARY, NULL },
{ "\\5", 53, CMMIB10, ORDINARY, NULL },
{ "\\6", 54, CMMIB10, ORDINARY, NULL },
{ "\\7", 55, CMMIB10, ORDINARY, NULL },
{ "\\8", 56, CMMIB10, ORDINARY, NULL },
{ "\\9", 57, CMMIB10, ORDINARY, NULL },
/* --- punctuation --- */
{ ".", 58, CMMIB10, PUNCTION, NULL },
{ ",", 59, CMMIB10, PUNCTION, NULL },
/* --- operations (some ordinary) --- */
{ "<", 60, CMMIB10, OPENING, NULL },
{ "\\lt", 60, CMMIB10, OPENING, NULL },
{ "/", 61, CMMIB10, BINARYOP, NULL },
{ ">", 62, CMMIB10, CLOSING, NULL },
{ "\\gt", 62, CMMIB10, CLOSING, NULL },
{ "\\star", 63, CMMIB10, BINARYOP, NULL },
{ "\\partial", 64, CMMIB10, VARIABLE, NULL },
/* --- uppercase letters --- */
{ "A", 65, CMMIB10, VARIABLE, NULL },
{ "B", 66, CMMIB10, VARIABLE, NULL },
{ "C", 67, CMMIB10, VARIABLE, NULL },
{ "D", 68, CMMIB10, VARIABLE, NULL },
{ "E", 69, CMMIB10, VARIABLE, NULL },
{ "F", 70, CMMIB10, VARIABLE, NULL },
{ "G", 71, CMMIB10, VARIABLE, NULL },
{ "H", 72, CMMIB10, VARIABLE, NULL },