[BACK]Return to metafont.trm CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / term

Annotation of OpenXM_contrib/gnuplot/term/metafont.trm, Revision 1.1.1.3

1.1       maekawa     1: /*
1.1.1.3 ! ohara       2:  * $Id: metafont.trm,v 1.8.2.1 2002/01/26 19:05:34 lhecking Exp $
1.1       maekawa     3:  */
                      4:
                      5: /* GNUPLOT - metafont.trm */
                      6:
                      7: /*[
                      8:  * Copyright 1986 - 1993, 1998   Thomas Williams, Colin Kelley
                      9:  *
                     10:  * Permission to use, copy, and distribute this software and its
                     11:  * documentation for any purpose with or without fee is hereby granted,
                     12:  * provided that the above copyright notice appear in all copies and
                     13:  * that both that copyright notice and this permission notice appear
                     14:  * in supporting documentation.
                     15:  *
                     16:  * Permission to modify the software is granted, but not the right to
                     17:  * distribute the complete modified source code.  Modifications are to
                     18:  * be distributed as patches to the released version.  Permission to
                     19:  * distribute binaries produced by compiling modified sources is granted,
                     20:  * provided you
                     21:  *   1. distribute the corresponding source modifications from the
                     22:  *    released version in the form of a patch file along with the binaries,
                     23:  *   2. add special version identification to distinguish your version
                     24:  *    in addition to the base release version number,
                     25:  *   3. provide your name and address as the primary contact for the
                     26:  *    support of your modified version, and
                     27:  *   4. retain our contact information in regard to use of the base
                     28:  *    software.
                     29:  * Permission to distribute the released version of the source code along
                     30:  * with corresponding source modifications in the form of a patch file is
                     31:  * granted with same provisions 2 through 4 for binary distributions.
                     32:  *
                     33:  * This software is provided "as is" without express or implied warranty
                     34:  * to the extent permitted by applicable law.
                     35: ]*/
                     36:
                     37: /*
                     38:  *                       GNUPLOT -- mf.trm
                     39:  *
                     40:  *                 This terminal driver supports:
                     41:  *                    Metafont Plot Commands
                     42:  *
                     43:  * Written by : Pl Hedne
                     44:  *             Trondheim, Norway
                     45:  *             Pal.Hedne@termo.unit.no
                     46:  */
                     47:
                     48: /*
                     49:  * Improvements and bug fixes by Carsten Steger:
                     50:  * - Set default plot size to 5 by 3 inches as in the latex- and eepic-
                     51:  *   drivers
                     52:  * - Fixed some bugs concerning resolution dependent output
                     53:  * - Added MF_scale function
                     54:  * - Added MF_justify_text function and modified MF_put_text function and
                     55:  *   put_text macro accordingly
                     56:  * - Modified MF_move and MF_vector to make output shorter and modified
                     57:  *   MF_text accordingly
                     58:  * - Added various linetypes by plotting dashed lines; had to modify
                     59:  *   MF_linetype and MF_vector for this
                     60:  * - Added MF_arrow function
                     61:  * - All global variables and #define'd names begin with MF_ now
                     62:  * As a consequence almost nothing of the original code by Pl Hedne remains
                     63:  * but credit goes to him for the ingenious trick of storing the character
                     64:  * images into picture variables, without which this driver would have been
                     65:  * impossible for me to write.
                     66:  *
                     67:  * 10/03/95: Converted to new terminal layout by Carsten Steger.
                     68:  */
                     69:
                     70: #include "driver.h"
                     71:
                     72: #ifdef TERM_REGISTER
                     73: register_term(mf)
                     74: #endif
                     75:
                     76: #ifdef TERM_PROTO
                     77:
                     78: #define MF_DPI (300)
                     79: /* resolution of printer we expect to use; the value itself is not
                     80:  * particularly important... it is here only for compatibility to the
                     81:  * LaTeX-driver and to get the spacing right. */
                     82:
                     83: /* 5 inches wide by 3 inches high (default) */
                     84: #define MF_XSIZE 5.0
                     85: #define MF_YSIZE 3.0
                     86: #define MF_XMAX (MF_XSIZE*MF_DPI)
                     87: #define MF_YMAX (MF_YSIZE*MF_DPI)
                     88:
                     89: #define MF_HTIC (5*MF_DPI/72)
                     90: #define MF_VTIC (5*MF_DPI/72)
                     91: #define MF_HCHAR (MF_DPI*53/10/72)
                     92: #define MF_VCHAR (MF_DPI*11/72)
                     93:
                     94: TERM_PUBLIC void MF_init __PROTO((void));
                     95: TERM_PUBLIC void MF_graphics __PROTO((void));
                     96: TERM_PUBLIC void MF_text __PROTO((void));
                     97: TERM_PUBLIC int MF_justify_text __PROTO((enum JUSTIFY mode));
                     98: TERM_PUBLIC int MF_text_angle __PROTO((int ang));
                     99: TERM_PUBLIC void MF_linetype __PROTO((int linetype));
                    100: TERM_PUBLIC void MF_move __PROTO((unsigned int x, unsigned int y));
                    101: TERM_PUBLIC void MF_vector __PROTO((unsigned int x, unsigned int y));
                    102: TERM_PUBLIC void MF_arrow __PROTO((unsigned int sx, unsigned int sy,
                    103:                                   unsigned int ex, unsigned int ey,
                    104:                                   TBOOLEAN head));
                    105: TERM_PUBLIC void MF_put_text __PROTO((unsigned int x, unsigned int y, char *str));
                    106: TERM_PUBLIC void MF_reset __PROTO((void));
                    107:
1.1.1.3 ! ohara     108: /* from util.c */
        !           109: extern char *gp_strdup __PROTO((char *));
        !           110:
1.1       maekawa   111: #define GOT_MF_PROTO
                    112:
                    113: #endif /* TERM_PROTO */
                    114:
                    115:
                    116: #ifndef TERM_PROTO_ONLY
                    117:
                    118: #ifdef TERM_BODY
                    119:
                    120:
                    121: /* Plot size in inches */
                    122: static double MF_xsize = MF_XSIZE;
                    123: static double MF_ysize = MF_YSIZE;
                    124: static int MF_char_code;
                    125: static int MF_ang;
                    126: static int MF_line_type;
                    127: static enum JUSTIFY MF_justify;
                    128: static double MF_dist_left;
                    129: static int MF_is_solid;
                    130: static int MF_picked_up_pen;
                    131: /*
                    132:  * We keep track of where we are with respect to dashed lines by using
                    133:  * the next five variables. MF_dash_index indicates which element of
                    134:  * MF_lines[..].dashlen should be used. The MF_last.. variables keep
                    135:  * track of the position of the pen.
                    136:  */
                    137: static int MF_dash_index;
                    138: static unsigned int MF_last_x, MF_last_y;
                    139:
                    140: static struct {
                    141:     int solid;                 /* Is the line solid? */
                    142:     float thickness;           /* Thickness of pen we are going to use */
                    143:     int dashlen[4];            /* Length of individual segments; even: line; odd: gap */
                    144: } MF_lines[10] =
                    145: {
                    146:     {
                    147:        1, 1.5, { 0, 0, 0, 0 }
                    148:     },
                    149:     {
                    150:        0, 1.0, { MF_DPI / 60, MF_DPI / 50, MF_DPI / 60, MF_DPI / 50 }
                    151:     },
                    152:     {
                    153:        1, 1.5, { 0, 0, 0, 0 }
                    154:     },
                    155:     {
                    156:        0, 1.5, { MF_DPI / 20, MF_DPI / 30, MF_DPI / 20, MF_DPI / 30 }
                    157:     },
                    158:     {
                    159:        0, 1.5, { MF_DPI / 30, MF_DPI / 20, MF_DPI / 30, MF_DPI / 20 }
                    160:     },
                    161:     {
                    162:        0, 1.5, { MF_DPI / 15, MF_DPI / 30, MF_DPI / 60, MF_DPI / 30 }
                    163:     },
                    164:     {
                    165:        0, 1.5, { MF_DPI / 30, MF_DPI / 50, MF_DPI / 30, MF_DPI / 50 }
                    166:     },
                    167:     {
                    168:        0, 1.5, { MF_DPI / 20, MF_DPI / 50, MF_DPI / 60, MF_DPI / 30 }
                    169:     },
                    170:     {
                    171:        0, 1.5, { MF_DPI / 30, MF_DPI / 50, MF_DPI / 30, MF_DPI / 30 }
                    172:     },
                    173:     {
                    174:        0, 1.5, { MF_DPI / 60, MF_DPI / 50, MF_DPI / 60, MF_DPI / 30 }
                    175:     }
                    176:     /* dash: line,     gap,      line,     gap      */
                    177: };
                    178:
                    179:
                    180:
1.1.1.3 ! ohara     181: TERM_PUBLIC void
        !           182: MF_init()
1.1       maekawa   183: {
                    184:     MF_char_code = 0;
                    185:     MF_ang = 0;
                    186:
                    187:     fputs("\
                    188: if unknown cmbase: input cmbase fi\n\n\
                    189: tracingstats:=1;\n\
                    190: picture r[];\n\
                    191: \ndef openit = openwindow currentwindow\n\
                    192:   from (0,0) to (400,800) at (-50,500) enddef;\n\
                    193: \nmode_setup;\n", gpoutfile);
                    194:
                    195:     fputs("\
                    196: \n%Include next eight lines if you have problems with the mode on your system..\n\
                    197: %proofing:=0;\n\
                    198: %fontmaking:=1;\n\
                    199: %tracingtitles:=0;\n\
                    200: %pixels_per_inch:=300;\n\
                    201: %blacker:=0;\n\
                    202: %fillin:=.2;\n\
                    203: %o_correction:=.6;\n\
                    204: %fix_units;\n", gpoutfile);
                    205:
                    206:     /* Next lines must be included if text support is needed (CM base used) */
                    207:     fputs("\
                    208: \ndef put_text(expr ts,xstart,ystart,rot,justification) =\n\
                    209:   begingroup\n\
1.1.1.3 ! ohara     210:     text_width:=0;text_height:=0;text_depth:=0;\n\
1.1       maekawa   211:     for ind:=0 step 1 until length(ts)-1:\n\
                    212:       dec_num:=ASCII substring (ind,ind+1) of ts;\n\
                    213:       if unknown r[dec_num]: dec_num:=32; fi\n\
                    214:       if dec_num=32: \n\
                    215:         text_width:=text_width+wd[65];\n\
1.1.1.3 ! ohara     216:         text_height:=max(text_height,ht[65]);\n\
        !           217:         text_depth:=max(text_depth,dp[65]);\n\
1.1       maekawa   218:       elseif dec_num>=0: \n\
                    219:         text_width:=text_width+wd[dec_num];\n\
1.1.1.3 ! ohara     220:         text_height:=max(text_height,ht[dec_num]);\n\
        !           221:         text_depth:=max(text_depth,dp[dec_num]);\n\
1.1       maekawa   222:       fi\n\
                    223:     endfor\n\
                    224:     if rot=90:\n\
                    225:       if justification=1: ynext:=ystart;\n\
                    226:       elseif justification=2: ynext:=round(ystart-text_width/2);\n\
                    227:       else: ynext:=round(ystart-text_width);\n\
                    228:       fi\n\
1.1.1.3 ! ohara     229:       xnext:=xstart+(text_height-text_depth)/2;\n\
1.1       maekawa   230:     else:\n\
                    231:       if justification=1: xnext:=xstart;\n\
                    232:       elseif justification=2: xnext:=round(xstart-text_width/2);\n\
                    233:       else: xnext:=round(xstart-text_width);\n\
                    234:       fi\n\
1.1.1.3 ! ohara     235:       ynext:=ystart-(text_height-text_depth)/2;\n\
1.1       maekawa   236:     fi\n\
                    237:     for ind:=0 step 1 until length(ts)-1:\n\
                    238:       dec_num:=ASCII substring (ind,ind+1) of ts;\n\
                    239:       if unknown r[dec_num]: dec_num:=32; fi\n\
                    240:       if dec_num=32: \n\
                    241:         xnext:=xnext+wd[65]*cosd rot;\n\
                    242:         ynext:=ynext+wd[65]*sind rot;\n\
                    243:       elseif dec_num>=0: \n\
                    244:         currentpicture:=currentpicture+r[dec_num] shifted(xnext,ynext)\n\
                    245:           rotatedaround ((xnext,ynext),rot); \n\
                    246:         xnext:=xnext+wd[dec_num]*cosd rot;\n\
                    247:         ynext:=ynext+wd[dec_num]*sind rot;\n\
                    248:       fi\n\
                    249:     endfor\n\
                    250:   endgroup \n\
                    251: enddef;\n", gpoutfile);
                    252:
                    253:     fputs("\
                    254: \ndef endchar =\n\
                    255:   r[charcode]:=currentpicture;\n\
                    256:   wd[charcode]:=w;ht[charcode]:=h;dp[charcode]:=d;\n\
                    257:   message \"Picture of charcode no.\" & decimal charcode;\n\
                    258:   endgroup;\n\
                    259: enddef;\n\
                    260: let endchar_ = endchar;\n\
                    261: let generate = relax;\n\
                    262: let roman = relax;\n", gpoutfile);
                    263:
                    264:     fputs("\
                    265: input cmr10.mf\n\
                    266: if ligs>1: font_coding_scheme:=\"TeX text\";\n\
                    267:   spanish_shriek=oct\"074\"; spanish_query=oct\"076\";\n\
                    268: else: font_coding_scheme:=\n\
                    269:   if ligs=0: \"TeX typewriter text\"\n\
                    270:   else: \"TeX text without f-ligatures\" fi;\n\
                    271:   spanish_shriek=oct\"016\"; spanish_query=oct\"017\"; fi\n\
                    272: font_setup;\n\
                    273: input romanu.mf %Roman uppercase.\n\
1.1.1.3 ! ohara     274: input romanl.mf %Roman lowercase.\n\
1.1       maekawa   275: input greeku.mf %Greek uppercase.\n\
                    276: input romand.mf %Numerals.\n\
                    277: input romanp.mf %Ampersand, question marks, currency sign.\n\
                    278: input romspl.mf %Lowercase specials (dotless \\i, ligature \\ae, etc.)\n\
                    279: input romspu.mf %Uppercase specials (\\AE, \\OE, \\O)\n\
                    280: input punct.mf %Punctuation symbols.\n\
                    281: \nminus=ASCII\"-\"; cmchar \"Minus sign\";\n\
                    282: beginarithchar(minus); \n\
                    283:   pickup rule.nib;\n\
                    284:   lft x1=hround 1.5u-eps;\n\
                    285:   x2=w-x1; y1=y2=math_axis;\n\
                    286:   draw z1--z2;  % bar\n\
                    287:   labels(1,2); \n\
                    288: endchar;\n", gpoutfile);
                    289:
                    290:     fputs("\
                    291: \ncmchar \"Period\";\n\
                    292:   numeric dot_diam#; dot_diam#:=if monospace: 5/4 fi\\ dot_size#;\n\
                    293:   define_whole_blacker_pixels(dot_diam);\n\
                    294:   beginchar(\".\",5u#,dot_diam#,0);\n\
                    295:   adjust_fit(0,0); pickup fine.nib;\n\
                    296:   pos1(dot_diam,0); pos2(dot_diam,90);\n\
                    297:   lft x1l=hround(.5w-.5dot_diam); bot y2l=0; z1=z2; dot(1,2);  % dot\n\
                    298:   penlabels(1,2);\n\
                    299: endchar;\n", gpoutfile);
                    300:
                    301:     fputs("\
                    302: \ndef endchar =\n\
                    303:   % Next line should probably be removed if CM base is used\n\
                    304:   l:=0; r:=w;\n\
                    305:   %Include the next two lines if you want to\n\
                    306:   %rotate the picture 90 deg.(Portrait to Landscape)\n\
                    307:   %currentpicture:=currentpicture rotated 90 shifted (h,0);\n\
                    308:   %tmp:=charht; charht:=charwd; charwd:=tmp;\n\
                    309:   scantokens extra_endchar;\n\
                    310:   if proofing>0: makebox(proofrule); fi\n\
                    311:   chardx:=w;\n\
                    312:   shipit;\n\
                    313:   if displaying>0: makebox(screenrule); showit; fi\n\
                    314:   endgroup \n\
                    315: enddef;\n\
                    316: let endchar_ = endchar;\n\
                    317: let generate = input;\n\
                    318: let roman = roman;\n", gpoutfile);
                    319:
                    320:     /* font_size must be bigger than em#/16 by METAFONT rules.
                    321:      * Therefore make it pretty big so big figures will be
                    322:      * handled correctly. Setting font_size to 72pt# lets us
                    323:      * handle characters up to 15.94 by 15.94 inches. */
                    324:     fputs("\
                    325: \n\nfont_identifier:=\"GNUPLOT\";\n\
                    326: font_size 72pt#;\n\
                    327: th#=0.4pt#; define_whole_pixels(th);\n\
                    328: \npath arrowhead;\n\
                    329: arrowhead = (-7pt,-2pt){dir30}..(-6pt,0pt)..\
                    330: {dir150}(-7pt,2pt) &\n\
                    331:   (-7pt,2pt)--(0pt,0pt)--(-7pt,-2pt) & cycle;\n", gpoutfile);
                    332: }
                    333:
                    334:
1.1.1.3 ! ohara     335: TERM_PUBLIC void
        !           336: MF_graphics()
1.1       maekawa   337: {
                    338:     register struct termentry *t = term;
                    339:
                    340:     fprintf(gpoutfile, "\n\nbeginchar(%d,%gin#,%gin#,0);\n",
                    341:            MF_char_code, MF_xsize, MF_ysize);
                    342:     MF_char_code++;
                    343:     fprintf(gpoutfile, "a:=w/%d;b:=h/%d;\n", t->xmax, t->ymax);
                    344:     MF_picked_up_pen = 0;
                    345: }
                    346:
                    347:
1.1.1.3 ! ohara     348: TERM_PUBLIC void
        !           349: MF_text()
1.1       maekawa   350: {
                    351:     fputs("endchar;\n", gpoutfile);
                    352: }
                    353:
                    354:
1.1.1.3 ! ohara     355: TERM_PUBLIC int
        !           356: MF_justify_text(mode)
1.1       maekawa   357: enum JUSTIFY mode;
                    358: {
                    359:     MF_justify = mode;
                    360:     return TRUE;
                    361: }
                    362:
                    363:
1.1.1.3 ! ohara     364: TERM_PUBLIC int
        !           365: MF_text_angle(ang)
1.1       maekawa   366: int ang;
                    367: {
                    368:     if (ang > 0)
                    369:        MF_ang = 90;
                    370:     else
                    371:        MF_ang = 0;
                    372:     return TRUE;
                    373: }
                    374:
                    375:
1.1.1.3 ! ohara     376: TERM_PUBLIC void
        !           377: MF_linetype(linetype)
1.1       maekawa   378: int linetype;
                    379: {
                    380:     if (linetype >= 8)
                    381:        linetype %= 8;
                    382:     linetype += 2;
                    383:     /* Only output change in pens if it actually affects the pen used */
                    384:     if ((MF_lines[linetype].thickness != MF_lines[MF_line_type].thickness) ||
                    385:        (!MF_picked_up_pen)) {
                    386:        fprintf(gpoutfile, "pickup pencircle scaled %gth;\n",
                    387:                MF_lines[linetype].thickness);
                    388:        MF_picked_up_pen = 1;
                    389:     }
                    390:     MF_line_type = linetype;
                    391:     MF_dash_index = 0;
                    392:     MF_dist_left = MF_lines[MF_line_type].dashlen[MF_dash_index];
                    393:     MF_is_solid = MF_lines[MF_line_type].solid;
                    394: }
                    395:
                    396:
1.1.1.3 ! ohara     397: TERM_PUBLIC void
        !           398: MF_move(x, y)
1.1       maekawa   399: unsigned int x, y;
                    400: {
                    401:     MF_last_x = x;
                    402:     MF_last_y = y;
                    403:     MF_dash_index = 0;
                    404:     MF_dist_left = MF_lines[MF_line_type].dashlen[MF_dash_index];
                    405: }
                    406:
                    407:
1.1.1.3 ! ohara     408: TERM_PUBLIC void
        !           409: MF_vector(x, y)
1.1       maekawa   410: unsigned int x, y;
                    411: {
                    412:     if (MF_is_solid) {
                    413:        if (x == MF_last_x && y == MF_last_y)
                    414:            fprintf(gpoutfile, "drawdot (%da,%db);\n", x, y);
                    415:        else
                    416:            fprintf(gpoutfile, "draw (%da,%db)--(%da,%db);\n",
                    417:                    MF_last_x, MF_last_y, x, y);
                    418:     } else {
                    419:        double dist_to_go, delta_x, delta_y, inc_x, inc_y;
                    420:        double last_x_d, last_y_d, next_x_d, next_y_d;
                    421:        unsigned int next_x, next_y;
                    422:
                    423:        if (x == MF_last_x && y == MF_last_y) {
                    424:            if (!(MF_dash_index & 1))
                    425:                fprintf(gpoutfile, "drawdot (%da,%db);\n", x, y);
                    426:        } else {
                    427:            last_x_d = MF_last_x;
                    428:            last_y_d = MF_last_y;
                    429:            delta_x = x - last_x_d;
                    430:            delta_y = y - last_y_d;
                    431:            dist_to_go = sqrt(delta_x * delta_x + delta_y * delta_y);
                    432:            inc_x = delta_x / dist_to_go;
                    433:            inc_y = delta_y / dist_to_go;
                    434:            while (MF_dist_left < dist_to_go) {
                    435:                next_x_d = last_x_d + inc_x * MF_dist_left;
                    436:                next_y_d = last_y_d + inc_y * MF_dist_left;
                    437:                next_x = floor(next_x_d + 0.5);
                    438:                next_y = floor(next_y_d + 0.5);
                    439:                /* MF_dash_index & 1 == 0 means: draw a line; otherwise just move */
                    440:                if (!(MF_dash_index & 1))
                    441:                    fprintf(gpoutfile, "draw (%da,%db)--(%da,%db);\n",
                    442:                            MF_last_x, MF_last_y, next_x, next_y);
                    443:                MF_last_x = next_x;
                    444:                MF_last_y = next_y;
                    445:                last_x_d = next_x_d;
                    446:                last_y_d = next_y_d;
                    447:                dist_to_go -= MF_dist_left;
                    448:                MF_dash_index = (MF_dash_index + 1) & 3;
                    449:                MF_dist_left = MF_lines[MF_line_type].dashlen[MF_dash_index];
                    450:            }
                    451:            delta_x = x - last_x_d;
                    452:            delta_y = y - last_y_d;
                    453:            MF_dist_left -= sqrt(delta_x * delta_x + delta_y * delta_y);
                    454:            if (!(MF_dash_index & 1)) {
                    455:                if (x == MF_last_x && y == MF_last_y)
                    456:                    fprintf(gpoutfile, "drawdot (%da,%db);\n", x, y);
                    457:                else
                    458:                    fprintf(gpoutfile, "draw (%da,%db)--(%da,%db);\n",
                    459:                            MF_last_x, MF_last_y, x, y);
                    460:            }
                    461:        }
                    462:     }
                    463:     MF_last_x = x;
                    464:     MF_last_y = y;
                    465: }
                    466:
                    467:
1.1.1.3 ! ohara     468: TERM_PUBLIC void
        !           469: MF_arrow(sx, sy, ex, ey, head)
1.1       maekawa   470: unsigned int sx, sy, ex, ey;
                    471: TBOOLEAN head;
                    472: {
                    473:     int delta_x, delta_y;
                    474:
                    475:     MF_move(sx, sy);
                    476:     MF_vector(ex, ey);
                    477:     if (head) {
                    478:        delta_x = ex - sx;
                    479:        delta_y = ey - sy;
                    480:        fprintf(gpoutfile, "fill arrowhead rotated angle(%d,%d) shifted (%da,%db);\n",
                    481:                delta_x, delta_y, ex, ey);
                    482:     }
                    483: }
                    484:
                    485:
1.1.1.3 ! ohara     486: TERM_PUBLIC void
        !           487: MF_put_text(x, y, str)
1.1       maekawa   488: unsigned int x, y;
                    489: char *str;
                    490: {
                    491:     int i, j = 0;
1.1.1.3 ! ohara     492:     char *text;
1.1       maekawa   493:
1.1.1.3 ! ohara     494:     /* ignore empty strings */
        !           495:     if (!str || !*str)
        !           496:        return;
        !           497:
        !           498:     /* F***. why do drivers need to modify string args? */
        !           499:     text = gp_strdup(str);
        !           500:
        !           501:     for (i = 0; i < strlen(text); i++)
        !           502:        if (text[i] == '"')
        !           503:            text[i] = '\'';     /* Replace " with ' */
1.1       maekawa   504:     switch (MF_justify) {
                    505:     case LEFT:
                    506:        j = 1;
                    507:        break;
                    508:     case CENTRE:
                    509:        j = 2;
                    510:        break;
                    511:     case RIGHT:
                    512:        j = 3;
                    513:        break;
                    514:     }
                    515:     fprintf(gpoutfile, "put_text(\"%s\",%da,%db,%d,%d);\n",
1.1.1.3 ! ohara     516:            text, x, y, MF_ang, j);
        !           517:     free(text);
1.1       maekawa   518: }
                    519:
                    520:
1.1.1.3 ! ohara     521: TERM_PUBLIC void
        !           522: MF_reset()
1.1       maekawa   523: {
                    524:     fputs("end.\n", gpoutfile);
                    525: }
                    526:
                    527:
                    528: #endif /* TERM_BODY */
                    529:
                    530: #ifdef TERM_TABLE
                    531:
                    532: TERM_TABLE_START(mf_driver)
                    533:     "mf", "Metafont plotting standard",
                    534:     MF_XMAX, MF_YMAX, MF_VCHAR, MF_HCHAR,
                    535:     MF_VTIC, MF_HTIC, options_null, MF_init, MF_reset,
                    536:     MF_text, null_scale, MF_graphics, MF_move, MF_vector,
                    537:     MF_linetype, MF_put_text, MF_text_angle,
                    538:     MF_justify_text, line_and_point, MF_arrow, set_font_null
                    539: TERM_TABLE_END(mf_driver)
                    540:
                    541: #undef LAST_TERM
                    542: #define LAST_TERM mf_driver
                    543:
                    544: #endif /* TERM_TABLE */
                    545: #endif /* TERM_PROTO_ONLY */
                    546:
                    547:
                    548: #ifdef TERM_HELP
                    549: START_HELP(mf)
                    550: "1 mf",
                    551: "?commands set terminal mf",
                    552: "?set terminal mf",
                    553: "?set term mf",
                    554: "?terminal mf",
                    555: "?term mf",
                    556: "?mf",
                    557: "?metafont",
1.1.1.3 ! ohara     558: " The `mf` terminal driver creates an input file to the METAFONT program.  Thus a",
1.1       maekawa   559: " figure may be used in the TeX document in the same way as is a character.",
                    560: "",
                    561: " To use a picture in a document, the METAFONT program must be run with the",
                    562: " output file from `gnuplot` as input.  Thus, the user needs a basic knowledge",
                    563: " of the font creating process and the procedure for including a new font in a",
                    564: " document.  However, if the METAFONT program is set up properly at the local",
                    565: " site, an unexperienced user could perform the operation without much trouble.",
                    566: "",
                    567: " The text support is based on a METAFONT character set.  Currently the",
                    568: " Computer Modern Roman font set is input, but the user is in principal free to",
1.1.1.3 ! ohara     569: " choose whatever fonts he or she needs.  The METAFONT source files for the",
1.1       maekawa   570: " chosen font must be available.  Each character is stored in a separate",
                    571: " picture variable in METAFONT.  These variables may be manipulated (rotated,",
                    572: " scaled etc.) when characters are needed.  The drawback is the interpretation",
                    573: " time in the METAFONT program.  On some machines (i.e. PC) the limited amount",
                    574: " of memory available may also cause problems if too many pictures are stored.",
                    575: "",
                    576: " The `mf` terminal has no options.",
                    577: "2 METAFONT Instructions",
                    578: "?commands set terminal mf detailed",
                    579: "?set terminal mf detailed",
                    580: "?set term mf detailed",
                    581: "?mf detailed",
                    582: "?metafont detailed",
                    583: "",
                    584: " - Set your terminal to METAFONT:",
                    585: "   set terminal mf",
                    586: " - Select an output-file, e.g.:",
                    587: "   set output \"myfigures.mf\"",
                    588: " - Create your pictures. Each picture will generate a separate character. Its",
                    589: " default size will be 5*3 inches. You can change the size by saying `set size",
                    590: " 0.5,0.5` or whatever fraction of the default size you want to have.",
                    591: "",
                    592: " - Quit `gnuplot`.",
                    593: "",
                    594: " - Generate a TFM and GF file by running METAFONT on the output of `gnuplot`.",
                    595: " Since the picture is quite large (5*3 in), you will have to use a version of",
                    596: " METAFONT that has a value of at least 150000 for memmax.  On Unix systems",
                    597: " these are conventionally installed under the name bigmf.  For the following",
                    598: " assume that the command virmf stands for a big version of METAFONT.  For",
                    599: " example:",
                    600: "",
                    601: " - Invoke METAFONT:",
                    602: "     virmf '&plain'",
                    603: " - Select the output device: At the METAFONT prompt ('*') type:",
                    604: "     \\mode:=CanonCX;     % or whatever printer you use",
                    605: " - Optionally select a magnification:",
                    606: "     mag:=1;             % or whatever you wish",
                    607: " - Input the `gnuplot`-file:",
                    608: "     input myfigures.mf",
                    609: " On a typical Unix machine there will usually be a script called \"mf\" that",
                    610: " executes virmf '&plain', so you probably can substitute mf for virmf &plain.",
                    611: " This will generate two files: mfput.tfm and mfput.$$$gf (where $$$ indicates",
                    612: " the resolution of your device).  The above can be conveniently achieved by",
                    613: " typing everything on the command line, e.g.:",
                    614: " virmf '&plain' '\\mode:=CanonCX; mag:=1; input myfigures.mf'",
                    615: " In this case the output files will be named myfigures.tfm and",
                    616: " myfigures.300gf.",
                    617: "",
                    618: " - Generate a PK file from the GF file using gftopk:",
                    619: "   gftopk myfigures.300gf myfigures.300pk",
                    620: " The name of the output file for gftopk depends on the DVI driver you use.",
                    621: " Ask your local TeX administrator about the naming conventions.  Next, either",
                    622: " install the TFM and PK files in the appropriate directories, or set your",
                    623: " environment variables properly.  Usually this involves setting TEXFONTS to",
                    624: " include the current directory and doing the same thing for the environment",
                    625: " variable that your DVI driver uses (no standard name here...).  This step is",
                    626: " necessary so that TeX will find the font metric file and your DVI driver will",
                    627: " find the PK file.",
                    628: "",
                    629: " - To include your pictures in your document you have to tell TeX the font:",
                    630: "   \\font\\gnufigs=myfigures",
                    631: " Each picture you made is stored in a single character.  The first picture is",
                    632: " character 0, the second is character 1, and so on...  After doing the above",
                    633: " step, you can use the pictures just like any other characters.  Therefore, to",
                    634: " place pictures 1 and 2 centered in your document, all you have to do is:",
                    635: "   \\centerline{\\gnufigs\\char0}",
                    636: "   \\centerline{\\gnufigs\\char1}",
                    637: " in plain TeX.  For LaTeX you can, of course, use the picture environment and",
                    638: " place the picture wherever you wish by using the \\makebox and \\put macros.",
                    639: "",
                    640: " This conversion saves you a lot of time once you have generated the font;",
                    641: " TeX handles the pictures as characters and uses minimal time to place them,",
                    642: " and the documents you make change more often than the pictures do.  It also",
                    643: " saves a lot of TeX memory.  One last advantage of using the METAFONT driver",
                    644: " is that the DVI file really remains device independent, because no \\special",
                    645: " commands are used as in the eepic and tpic drivers."
                    646: END_HELP(mf)
                    647: #endif /* TERM_HELP */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>