home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XFIG / TRANSFIG.2 / TRANSFIG / transfig / fig2dev / dev / genpstex.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-06  |  3.7 KB  |  166 lines

  1. /*
  2.  * TransFig: Facility for Translating Fig code
  3.  * Copyright (c) 1985 Supoj Sutantavibul
  4.  * Copyright (c) 1991 Micah Beck
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation. The authors make no representations about the suitability 
  11.  * of this software for any purpose.  It is provided "as is" without express 
  12.  * or implied warranty.
  13.  *
  14.  * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16.  * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  19.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  20.  * PERFORMANCE OF THIS SOFTWARE.
  21.  *
  22.  */
  23.  
  24. /* 
  25.  *    genpstex.c : psTeX and psTeX_t drivers for fig2dev
  26.  *
  27.  *    Author: Jose Alberto Fernandez R /Maryland CP 9/90
  28.  *     It uses the LaTeX and PostScript drivers to generate 
  29.  *      LaTeX processed text for a Postscript figure.
  30.  *
  31.  * The pstex_t driver is like a latex driver that only translates 
  32.  * text defined in the defaul font.
  33.  *
  34.  * The pstex driver is like a PostScript driver that translates 
  35.  * everything except for text in the default font.
  36.  *
  37.  * The option '-p file' added to the pstex_t translator specifies
  38.  * the name of the PostScript file to be called in the psfig macro.
  39.  * If not set or its value is null then no PS file will be inserted.
  40.  *
  41.  * Jose Alberto.
  42.  */
  43.  
  44. #if defined(hpux) || defined(SYSV)
  45. #include <sys/types.h>
  46. #endif
  47. #include <sys/file.h>
  48. #include <stdio.h>
  49. #include <math.h>
  50. #include "object.h"
  51. #include "fig2dev.h"
  52. #include "texfonts.h"
  53.  
  54. #ifndef fabs
  55. extern double fabs();
  56. #endif
  57. #ifndef sin
  58. extern double sin();
  59. #endif
  60. #ifndef cos
  61. extern double cos();
  62. #endif
  63. #ifndef acos
  64. extern double acos();
  65. #endif
  66. #ifndef atan
  67. extern double atan();
  68. #endif
  69. extern double rad2deg;
  70.  
  71. #ifdef hpux
  72. #define rint(a) floor((a)+0.5)     /* close enough? */
  73. #endif
  74.  
  75. #ifdef gould
  76. #define rint(a) floor((a)+0.5)     /* close enough? */
  77. #endif
  78.  
  79. extern void genlatex_start (),
  80.     gendev_null (),
  81.     genlatex_end (),
  82.          genps_option (),
  83.     genps_start (),
  84.     genps_arc (),
  85.     genps_ellipse (),
  86.     genps_line (),
  87.     genps_spline (),
  88.     genps_end (),
  89.         genlatex_option (),
  90.         genlatex_text (),
  91.         genps_text ();
  92.  
  93. static char pstex_file[1000] = "";
  94.  
  95. void genpstex_t_option(opt, optarg)
  96. char opt, *optarg;
  97. {
  98.        if (opt == 'p') strcpy(pstex_file, optarg);
  99.        else genlatex_option(opt, optarg);
  100. }
  101.  
  102.  
  103. void genpstex_t_start(objects)
  104. F_compound    *objects;
  105. {
  106.     /* Put PostScript Image if any*/
  107.         if (pstex_file[0] != '\0')
  108.         {
  109.         fprintf(tfp, "\\begin{picture}(0,0)%%\n");
  110.         fprintf(tfp, "\\special{psfile=%s}%%\n",pstex_file);
  111.         fprintf(tfp, "\\end{picture}%%\n");
  112.     }
  113.         genlatex_start(objects);
  114.  
  115. }
  116.  
  117. void genpstex_t_text(t)
  118. F_text    *t;
  119. {
  120.  
  121.     if (!special_text(t))
  122.       gendev_null(t);
  123.     else genlatex_text(t);
  124. }
  125.  
  126. void genpstex_text(t)
  127. F_text    *t;
  128. {
  129.  
  130.     if (!special_text(t))
  131.       genps_text(t);
  132.     else gendev_null(t);
  133. }
  134.  
  135. void genpstex_option(opt, optarg)
  136. char opt, *optarg;
  137. {
  138.        if (opt != 'p') genlatex_option(opt, optarg);
  139. }
  140.  
  141. struct driver dev_pstex_t = {
  142.          genpstex_t_option,
  143.     genpstex_t_start,
  144.     gendev_null,
  145.     gendev_null,
  146.     gendev_null,
  147.     gendev_null,
  148.     genpstex_t_text,
  149.     genlatex_end,
  150.     EXCLUDE_TEXT
  151. };
  152.  
  153. struct driver dev_pstex = {
  154.          genpstex_option,
  155.     genps_start,
  156.     genps_arc,
  157.     genps_ellipse,
  158.     genps_line,
  159.     genps_spline,
  160.     genpstex_text,
  161.     genps_end,
  162.     INCLUDE_TEXT
  163. };
  164.  
  165.  
  166.