home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume22 / transfig / part02 < prev    next >
Text File  |  1990-10-09  |  47KB  |  1,791 lines

  1. Subject:  v23i015:  Tools for creating TeX documents with portable graphics, Part02/06
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 7343b6b4 9f1c53a2 a3af18c4 d4688d13
  5.  
  6. Submitted-by: Micah Beck <beck@cs.cornell.edu>
  7. Posting-number: Volume 23, Issue 15
  8. Archive-name: transfig/part02
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 2 (of 6)."
  17. # Contents:  transfig/doc/fig2dev.1 transfig/fig2dev/bound.c
  18. #   transfig/fig2dev/fig2dev.c transfig/fig2dev/latex_line.c
  19. #   transfig/fig2dev/object.h transfig/fig2dev/read1_3.c
  20. # Wrapped by beck@rocky on Thu May 17 15:56:10 1990
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'transfig/doc/fig2dev.1' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'transfig/doc/fig2dev.1'\"
  24. else
  25. echo shar: Extracting \"'transfig/doc/fig2dev.1'\" \(6038 characters\)
  26. sed "s/^X//" >'transfig/doc/fig2dev.1' <<'END_OF_FILE'
  27. X.TH FIG2DEV 1 "7 May 1989"
  28. X.SH NAME
  29. Xfig2dev \- translates Fig code to various graphics languages
  30. X
  31. X.SH SYNOPSIS
  32. X.B fig2dev
  33. X.B \-L
  34. X.I language
  35. X[
  36. X.B \-m
  37. X.I mag
  38. X] [
  39. X.B \-f 
  40. X.I font
  41. X] [
  42. X.B \-s
  43. X.I fsize
  44. X] [
  45. X.I other options
  46. X] [
  47. X\fIfig-file\fR [ \fIout-file\fR ] ]
  48. X
  49. X.SH DESCRIPTION
  50. X.I Fig2dev
  51. Xtranslates fig code in the named
  52. X.I fig-file
  53. Xinto the specified graphics 
  54. X.I language
  55. Xand puts them in
  56. X.I out-file.
  57. XThe default
  58. X.I fig-file
  59. Xand
  60. X.I out-file
  61. Xare standard input and standard output, respectively
  62. X.LP
  63. XFig (Facility for Interactive Generation of figures) is a screen-oriented
  64. Xtool which allows the user to draw and manipulate objects interactively.
  65. XVarious versions of Fig run under the Suntools/Sunview window environment
  66. Xand under version 11 of the X Windows System.
  67. XFig2dev is compatible with Fig versions 1.3, 1.4-TFX, and 2.0.
  68. X
  69. X.SH OPTIONS
  70. X.TP
  71. X.B \-L
  72. XSet the output graphics language.
  73. XValid languages are
  74. X\fBbox, epic, eepic, eepicemu, latex, null, pic, pictex,\fR
  75. Xand
  76. X.B ps.
  77. X.TP
  78. X.B \-m
  79. XSet the magnification at which the figure is rendered to
  80. X.I mag.
  81. XThe default is 1.0.
  82. X.TP
  83. X.B \-f 
  84. XSet the default font used for text objects to
  85. X.I font.
  86. XThe default is Roman; the format of this option depends on the graphics
  87. X.I language
  88. Xin use.
  89. XIn TeX-based languages, the font is the base of the name given in lfonts.tex,
  90. Xfor instance \"cmr\" for Roman, or \"tt\" for teletype.
  91. XIn PostScript, it is any font name known to the printer or interpreter.
  92. X.TP
  93. X.B \-s
  94. XSet the default font size (in points) for text objects to
  95. X.I fsize.
  96. XThe default is 11*mag, and thus is scaled by the \fB-m\fR option.
  97. XIf there is no scaling, the default font is eleven point Roman."
  98. X.TP
  99. X.I other options
  100. XThe other options are specific to the choice of graphics
  101. X.I language,
  102. Xas described below.
  103. X
  104. X.SH EPIC OPTIONS
  105. XEPIC is an enhancement to LaTeX picture drawing environment.
  106. XIt was developed by Sunil Podar of Department of Computer Science
  107. Xin S.U.N.Y at Stony Brook.
  108. X.LP
  109. XEEPIC is an extension to EPIC and LaTeX picture drawing environment
  110. Xwhich uses tpic specials as a graphics mechanism.
  111. XIt was written by Conrad Kwok of Division of
  112. XComputer Science at University of California, Davis.
  113. X.LP
  114. XEEPIC-EMU is an EEPIC emulation package which does not use tpic specials.
  115. X.TP
  116. X.B \-S
  117. XSet the scale to which the figure is rendered.
  118. XThis option automatically sets the 
  119. X.I magnification
  120. Xand size to
  121. X.I scale
  122. X/ 12 and 
  123. X.I scale
  124. Xrespectively.
  125. X.TP
  126. X.B \-l
  127. XUse "\fB\\thicklines\fR" when width of the line is wider than 
  128. X.I lwidth.
  129. XThe default is 2.
  130. X.TP
  131. X.B \-v
  132. XInclude comments in the output file.
  133. X.TP
  134. X.B \-P
  135. XGenerate a complete LaTeX file. In other words, the ouput file can be
  136. Xformatted without requiring any changes. The additional text inserted
  137. Xin the beginning and at the end of the file is controlled by the
  138. Xconfiguration parameter "Preamble" and "Postamble".
  139. X.TP
  140. X.B \-W
  141. XEnable variable line width
  142. X.TP
  143. X.B \-w
  144. XDisable variable line width. Only "\fB\\thicklines\fR" and/or
  145. X"\fB\\thinlines\fR" commands will be generated in the output file.
  146. X.LP
  147. XWhen variable line width option is enabled, "\fB\\thinlines\fR"
  148. Xcommand is still used when line width is less than
  149. X\fILineThick\fR. One potential problem is that the width of
  150. X"\fB\\thinlines\fR" is 0.4pt
  151. Xbut the resolution of Fig is 1/80 inch (approx. 1pt). If
  152. X\fILineThick\fR is set to 2, normal lines will be drawn in 0.4pt
  153. Xwide lines but the next line width is already 2pt. One possible
  154. Xsolution is to set \fILineThick\fR to 1 and set the width of the
  155. Xthose lines you want to be drawn in "\fB\\thinlines\fR"  to 0.
  156. X
  157. XDue to this problem, Varible line width \fIVarWidth\fR
  158. Xis defaulted to be false.
  159. X
  160. X.SH LATEX OPTIONS
  161. X.TP
  162. X.B \-l
  163. XSets the threshold between LaTeX thin and thick lines to 
  164. X.I lwidth
  165. Xpixels.
  166. XLaTeX supports only two different line width: \\thinlines and \\thicklines.
  167. XLines of width greater than
  168. X.I lwidth
  169. Xpixels are drawn as \\thicklines.
  170. XAlso affects the size of dots in dotted line style.
  171. XThe default is 0.
  172. X.TP
  173. X.B \-d
  174. XSet a seperate magnification for the length of line dashes to
  175. X.I dmag.
  176. X.TP
  177. X.B \-v
  178. XVerbose mode.
  179. X.LP
  180. XLaTeX cannot accurately represent all the graphics objects which can
  181. Xbe described by Fig.
  182. XFor example, the possible slopes which lines may have are limited.
  183. XSome objects, such as spline curves, cannot be drawn at all.
  184. XFig2latex chooses the closest possible line slope, and prints error
  185. Xmessages when objects cannot be drawn accurately
  186. X
  187. X.SH PICTEX OPTIONS
  188. X.B \-p 
  189. XSet the symbol used by PiCTeX for plotting lines and curves to 
  190. X.I psymbol.
  191. XThe default is "\fB\\sevrm .\fR"
  192. X.TP
  193. X.B \-l 
  194. XSet the width of any rules used to draw lines and boxes within the picture to 
  195. X.I lwidth.
  196. XThe default is "\fB0.7pt\fR".
  197. X.LP
  198. XIn order to include PiCTeX pictures into a document, it is necessary to
  199. Xload the PiCTeX macros.
  200. X.LP
  201. XPiCTeX uses TeX integer register arithmetic to generate curves,
  202. Xand so it is very slow.
  203. XPiCTeX draws curves by \fB\\put\fR-ing the \fIpsymbol\fR repeatedly,
  204. Xand so requires a large amount of TeX's internal memory,
  205. Xand generates large DVI files.
  206. XThe size of TeX's memory limits the number of plot symbols in a picture.
  207. XAs a result, it is best to use PiCTeX to generate small pictures.
  208. X
  209. X.SH POSTSCRIPT OPTIONS
  210. X.TP
  211. X.B -c
  212. Xoption centers the figure on the page.
  213. XThe centering may not be accurate if there are texts in the
  214. X.I fig_file
  215. Xthat extends too far to the right of other objects.
  216. X.TP
  217. X.B -P
  218. Xindicates that the figure describes a full page which will not
  219. Xnecessarily be inserted into a document, but can be sent directly
  220. Xto a PS printer.
  221. XThis ensures that a showpage command is inserted at the end of
  222. Xthe figure, and inhibits translation of the figure coordinate system.
  223. X.TP
  224. X.B -l
  225. XRotate figure to landscape mode.
  226. X
  227. X.SH "SEE ALSO"
  228. X[x]fig(1),
  229. Xpic(1)
  230. Xpic2fig(1),
  231. Xtransfig(1)
  232. X.SH AUTHORS
  233. XMicah Beck (beck@svax.cs.cornell.edu)
  234. X.br
  235. XCornell University
  236. X.br
  237. XMay 7 1989
  238. X.sp
  239. Xand Frank Schmuck (then of Cornell University)
  240. X.br
  241. Xand Conrad Kwok (then of the U.C. Davis).
  242. X.sp
  243. XModified from f2p (fig to PIC), by the author of Fig
  244. X.br
  245. XSupoj Sutanthavibul (supoj@sally.utexas.edu)
  246. X.br
  247. XUniversity of Texas at Austin. 
  248. X
  249. END_OF_FILE
  250. if test 6038 -ne `wc -c <'transfig/doc/fig2dev.1'`; then
  251.     echo shar: \"'transfig/doc/fig2dev.1'\" unpacked with wrong size!
  252. fi
  253. # end of 'transfig/doc/fig2dev.1'
  254. fi
  255. if test -f 'transfig/fig2dev/bound.c' -a "${1}" != "-c" ; then 
  256.   echo shar: Will not clobber existing file \"'transfig/fig2dev/bound.c'\"
  257. else
  258. echo shar: Extracting \"'transfig/fig2dev/bound.c'\" \(9753 characters\)
  259. sed "s/^X//" >'transfig/fig2dev/bound.c' <<'END_OF_FILE'
  260. X#include <stdio.h>
  261. X#include <math.h>
  262. X#include "pi.h"
  263. X#include "object.h"
  264. X
  265. X#define        Ninety_deg        M_PI_2
  266. X#define        One_eighty_deg        M_PI
  267. X#define        Two_seventy_deg        (M_PI + M_PI_2)
  268. X#define        Three_sixty_deg        (M_PI + M_PI)
  269. X#define        round(x)        ((int) ((x) + ((x >= 0)? 0.5: -0.5)))
  270. X#define        half(z1 ,z2)        ((z1+z2)/2.0)
  271. X#define        max(a, b)        (((a) > (b)) ? (a) : (b))
  272. X#define        min(a, b)        (((a) < (b)) ? (a) : (b))
  273. X
  274. Xarc_bound(arc, xmin, ymin, xmax, ymax)
  275. XF_arc    *arc;
  276. Xint    *xmin, *ymin, *xmax, *ymax;
  277. X{
  278. X    double    alpha, beta;
  279. X    double    dx, dy, radius;
  280. X    int    bx, by, sx, sy;
  281. X
  282. X    dx = arc->point[0].x - arc->center.x;
  283. X    dy = arc->center.y - arc->point[0].y;
  284. X    alpha = atan2(dy, dx);
  285. X    if (alpha < 0.0) alpha += Three_sixty_deg;
  286. X    /* compute_angle returns value between 0 to 2PI */
  287. X    
  288. X    radius = hypot(dx, dy);
  289. X
  290. X    dx = arc->point[2].x - arc->center.x;
  291. X    dy = arc->center.y - arc->point[2].y;
  292. X    beta = atan2(dy, dx);
  293. X    if (beta < 0.0) beta += Three_sixty_deg;
  294. X
  295. X    bx = max(arc->point[0].x, arc->point[1].x);
  296. X    bx = max(arc->point[2].x, bx);
  297. X    by = max(arc->point[0].y, arc->point[1].y);
  298. X    by = max(arc->point[2].y, by);
  299. X    sx = min(arc->point[0].x, arc->point[1].x);
  300. X    sx = min(arc->point[2].x, sx);
  301. X    sy = min(arc->point[0].y, arc->point[1].y);
  302. X    sy = min(arc->point[2].y, sy);
  303. X
  304. X    if (arc->direction == 1) { /* counter clockwise */
  305. X        if (alpha > beta) {
  306. X        if (alpha <= 0 || 0 <= beta)
  307. X            bx = (int)(arc->center.x + radius + 1.0);
  308. X        if (alpha <= Ninety_deg || Ninety_deg <= beta)
  309. X            sy = (int)(arc->center.y - radius - 1.0);
  310. X        if (alpha <= One_eighty_deg || One_eighty_deg <= beta)
  311. X            sx = (int)(arc->center.x - radius - 1.0);
  312. X        if (alpha <= Two_seventy_deg || Two_seventy_deg <= beta)
  313. X            by = (int)(arc->center.y + radius + 1.0);
  314. X        }
  315. X        else {
  316. X        if (0 <= beta && alpha <= 0)
  317. X            bx = (int)(arc->center.x + radius + 1.0);
  318. X        if (Ninety_deg <= beta && alpha <= Ninety_deg)
  319. X            sy = (int)(arc->center.y - radius - 1.0);
  320. X        if (One_eighty_deg <= beta && alpha <= One_eighty_deg)
  321. X            sx = (int)(arc->center.x - radius - 1.0);
  322. X        if (Two_seventy_deg <= beta && alpha <= Two_seventy_deg)
  323. X            by = (int)(arc->center.y + radius + 1.0);
  324. X        }
  325. X        }
  326. X    else {    /* clockwise    */
  327. X        if (alpha > beta) {
  328. X        if (beta <= 0 && 0 <= alpha)
  329. X            bx = (int)(arc->center.x + radius + 1.0);
  330. X        if (beta <= Ninety_deg && Ninety_deg <= alpha)
  331. X            sy = (int)(arc->center.y - radius - 1.0);
  332. X        if (beta <= One_eighty_deg && One_eighty_deg <= alpha)
  333. X            sx = (int)(arc->center.x - radius - 1.0);
  334. X        if (beta <= Two_seventy_deg && Two_seventy_deg <= alpha)
  335. X            by = (int)(arc->center.y + radius + 1.0);
  336. X        }
  337. X        else {
  338. X        if (0 <= alpha || beta <= 0)
  339. X            bx = (int)(arc->center.x + radius + 1.0);
  340. X        if (Ninety_deg <= alpha || beta <= Ninety_deg)
  341. X            sy = (int)(arc->center.y - radius - 1.0);
  342. X        if (One_eighty_deg <= alpha || beta <= One_eighty_deg)
  343. X            sx = (int)(arc->center.x - radius - 1.0);
  344. X        if (Two_seventy_deg <= alpha || beta <= Two_seventy_deg)
  345. X            by = (int)(arc->center.y + radius + 1.0);
  346. X        }
  347. X        }
  348. X    *xmax = bx; *ymax = by;
  349. X    *xmin = sx; *ymin = sy;
  350. X    }
  351. X
  352. Xcompound_bound(compound, xmin, ymin, xmax, ymax, include)
  353. XF_compound    *compound;
  354. Xint        *xmin, *ymin, *xmax, *ymax;
  355. Xint        include;
  356. X{
  357. X    F_arc        *a;
  358. X    F_ellipse    *e;
  359. X    F_compound    *c;
  360. X    F_spline    *s;
  361. X    F_line        *l;
  362. X    F_text        *t;
  363. X    int        bx, by, sx, sy, first = 1;
  364. X    int        llx, lly, urx, ury;
  365. X
  366. X    for (a = compound->arcs; a != NULL; a = a->next) {
  367. X        arc_bound(a, &sx, &sy, &bx, &by);
  368. X        if (first) {
  369. X        first = 0;
  370. X        llx = sx; lly = sy;
  371. X        urx = bx; ury = by;
  372. X        }
  373. X        else {
  374. X        llx = min(llx, sx); lly = min(lly, sy);
  375. X        urx = max(urx, bx); ury = max(ury, by);
  376. X        }
  377. X        }
  378. X
  379. X    for (c = compound->compounds; c != NULL; c = c->next) {
  380. X        compound_bound(c, &sx, &sy, &bx, &by);
  381. X        if (first) {
  382. X        first = 0;
  383. X        llx = sx; lly = sy;
  384. X        urx = bx; ury = by;
  385. X        }
  386. X        else {
  387. X        llx = min(llx, sx); lly = min(lly, sy);
  388. X        urx = max(urx, bx); ury = max(ury, by);
  389. X        }
  390. X        }
  391. X
  392. X    for (e = compound->ellipses; e != NULL; e = e->next) {
  393. X        ellipse_bound(e, &sx, &sy, &bx, &by);
  394. X        if (first) {
  395. X        first = 0;
  396. X        llx = sx; lly = sy;
  397. X        urx = bx; ury = by;
  398. X        }
  399. X        else {
  400. X        llx = min(llx, sx); lly = min(lly, sy);
  401. X        urx = max(urx, bx); ury = max(ury, by);
  402. X        }
  403. X        }
  404. X
  405. X    for (l = compound->lines; l != NULL; l = l->next) {
  406. X        line_bound(l, &sx, &sy, &bx, &by);
  407. X        if (first) {
  408. X        first = 0;
  409. X        llx = sx; lly = sy;
  410. X        urx = bx; ury = by;
  411. X        }
  412. X        else {
  413. X        llx = min(llx, sx); lly = min(lly, sy);
  414. X        urx = max(urx, bx); ury = max(ury, by);
  415. X        }
  416. X        }
  417. X
  418. X    for (s = compound->splines; s != NULL; s = s->next) {
  419. X        spline_bound(s, &sx, &sy, &bx, &by);
  420. X        if (first) {
  421. X        first = 0;
  422. X        llx = sx; lly = sy;
  423. X        urx = bx; ury = by;
  424. X        }
  425. X        else {
  426. X        llx = min(llx, sx); lly = min(lly, sy);
  427. X        urx = max(urx, bx); ury = max(ury, by);
  428. X        }
  429. X        }
  430. X
  431. X    for (t = compound->texts; t != NULL; t = t->next) {
  432. X        text_bound(t, &sx, &sy, &bx, &by, include);
  433. X        if (first) {
  434. X        first = 0;
  435. X        llx = sx; lly = sy;
  436. X        urx = bx; ury = by;
  437. X        }
  438. X        else {
  439. X        llx = min(llx, sx); lly = min(lly, sy);
  440. X        urx = max(urx, bx); ury = max(ury, by);
  441. X        }
  442. X        }
  443. X
  444. X    *xmin = llx; *ymin = lly;
  445. X    *xmax = urx; *ymax = ury;
  446. X    }
  447. X
  448. Xellipse_bound(e, xmin, ymin, xmax, ymax)
  449. XF_ellipse    *e;
  450. Xint        *xmin, *ymin, *xmax, *ymax;
  451. X{
  452. X    *xmin = e->center.x - e->radiuses.x;
  453. X    *ymin = e->center.y - e->radiuses.y;
  454. X    *xmax = e->center.x + e->radiuses.x;
  455. X    *ymax = e->center.y + e->radiuses.y;
  456. X    }
  457. X
  458. Xline_bound(l, xmin, ymin, xmax, ymax)
  459. XF_line    *l;
  460. Xint    *xmin, *ymin, *xmax, *ymax;
  461. X{
  462. X    points_bound(l->points, xmin, ymin, xmax, ymax);
  463. X    }
  464. X
  465. Xspline_bound(s, xmin, ymin, xmax, ymax)
  466. XF_spline    *s;
  467. Xint        *xmin, *ymin, *xmax, *ymax;
  468. X{
  469. X    if (int_spline(s)) {
  470. X        int_spline_bound(s, xmin, ymin, xmax, ymax);
  471. X        }
  472. X    else {
  473. X        normal_spline_bound(s, xmin, ymin, xmax, ymax);
  474. X        }
  475. X    }
  476. X
  477. Xint_spline_bound(s, xmin, ymin, xmax, ymax)
  478. XF_spline    *s;
  479. Xint        *xmin, *ymin, *xmax, *ymax;
  480. X{
  481. X    F_point        *p1, *p2;
  482. X    F_control    *cp1, *cp2;
  483. X    double        x0, y0, x1, y1, x2, y2, x3, y3, sx1, sy1, sx2, sy2;
  484. X    double        tx, ty, tx1, ty1, tx2, ty2;
  485. X    double        sx, sy, bx, by;
  486. X
  487. X    p1 = s->points;
  488. X    sx = bx = p1->x;
  489. X    sy = by = p1->y;
  490. X    cp1 = s->controls;
  491. X    for (p2 = p1->next, cp2 = cp1->next; p2 != NULL;
  492. X        p1 = p2, cp1 = cp2, p2 = p2->next, cp2 = cp2->next) {
  493. X        x0 = p1->x; y0 = p1->y;
  494. X        x1 = cp1->rx; y1 = cp1->ry;
  495. X        x2 = cp2->lx; y2 = cp2->ly;
  496. X        x3 = p2->x; y3 = p2->y;
  497. X        tx = half(x1, x2); ty = half(y1, y2);
  498. X        sx1 = half(x0, x1); sy1 = half(y0, y1);
  499. X        sx2 = half(sx1, tx); sy2 = half(sy1, ty);
  500. X        tx2 = half(x2, x3); ty2 = half(y2, y3);
  501. X        tx1 = half(tx2, tx); ty1 = half(ty2, ty);
  502. X
  503. X        sx = min(x0, sx); sy = min(y0, sy);
  504. X        sx = min(sx1, sx); sy = min(sy1, sy);
  505. X        sx = min(sx2, sx); sy = min(sy2, sy);
  506. X        sx = min(tx1, sx); sy = min(ty1, sy);
  507. X        sx = min(tx2, sx); sy = min(ty2, sy);
  508. X        sx = min(x3, sx); sy = min(y3, sy);
  509. X
  510. X        bx = max(x0, bx); by = max(y0, by);
  511. X        bx = max(sx1, bx); by = max(sy1, by);
  512. X        bx = max(sx2, bx); by = max(sy2, by);
  513. X        bx = max(tx1, bx); by = max(ty1, by);
  514. X        bx = max(tx2, bx); by = max(ty2, by);
  515. X        bx = max(x3, bx); by = max(y3, by);
  516. X        }
  517. X    *xmin = round(sx);
  518. X    *ymin = round(sy);
  519. X    *xmax = round(bx);
  520. X    *ymax = round(by);
  521. X    }
  522. X
  523. Xnormal_spline_bound(s, xmin, ymin, xmax, ymax)
  524. XF_spline    *s;
  525. Xint        *xmin, *ymin, *xmax, *ymax;
  526. X{
  527. X    F_point    *p;
  528. X    double    cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
  529. X    double    x1, y1, x2, y2, sx, sy, bx, by;
  530. X    double    px, py, qx, qy;
  531. X
  532. X    p = s->points;
  533. X    x1 = p->x;  y1 = p->y;
  534. X    p = p->next;
  535. X    x2 = p->x;  y2 = p->y;
  536. X    cx1 = (x1 + x2) / 2.0;   cy1 = (y1 + y2) / 2.0;
  537. X    cx2 = (cx1 + x2) / 2.0;  cy2 = (cy1 + y2) / 2.0;
  538. X    if (closed_spline(s)) {
  539. X        x1 = (cx1 + x1) / 2.0;
  540. X        y1 = (cy1 + y1) / 2.0;
  541. X        }
  542. X    sx = min(x1, cx2); sy = min(y1, cy2);
  543. X    bx = max(x1, cx2); by = max(y1, cy2);
  544. X
  545. X    for (p = p->next; p != NULL; p = p->next) {
  546. X        x1 = x2;  y1 = y2;
  547. X        x2 = p->x;  y2 = p->y;
  548. X        cx4 = (x1 + x2) / 2.0; cy4 = (y1 + y2) / 2.0;
  549. X        cx3 = (x1 + cx4) / 2.0; cy3 = (y1 + cy4) / 2.0;
  550. X        cx2 = (cx4 + x2) / 2.0;  cy2 = (cy4 + y2) / 2.0;
  551. X
  552. X        px = min(cx2, cx3); py = min(cy2, cy3);
  553. X        qx = max(cx2, cx3); qy = max(cy2, cy3);
  554. X
  555. X        sx = min(sx, px); sy = min(sy, py);
  556. X        bx = max(bx, qx); by = max(by, qy);
  557. X        }
  558. X    if (closed_spline(s)) {
  559. X        *xmin = round(sx); *ymin = round(sy);
  560. X        *xmax = round(bx); *ymax = round(by);
  561. X        }
  562. X    else {
  563. X        *xmin = round(min(sx, x2)); *ymin = round(min(sy, y2));
  564. X        *xmax = round(max(bx, x2)); *ymax = round(max(by, y2));
  565. X        }
  566. X    }
  567. X
  568. Xtext_bound(t, xmin, ymin, xmax, ymax, include)
  569. XF_text    *t;
  570. Xint    *xmin, *ymin, *xmax, *ymax;
  571. Xint    include;
  572. X{
  573. X    if (t->type == T_CENTER_JUSTIFIED) {
  574. X        *xmin = t->base_x - t->length / 2;
  575. X        *xmax = t->base_x + t->length / 2;
  576. X    } else if (t->type == T_RIGHT_JUSTIFIED) {
  577. X        *xmin = t->base_x - t->length;
  578. X        *xmax = t->base_x;
  579. X    } else {
  580. X        *xmin = t->base_x;
  581. X        *xmax = t->base_x + (include ? t->length : 0);
  582. X    }
  583. X    *ymax = t->base_y;
  584. X    *ymin = t->base_y - t->height;
  585. X    }
  586. X
  587. Xpoints_bound(points, xmin, ymin, xmax, ymax)
  588. XF_point    *points;
  589. Xint    *xmin, *ymin, *xmax, *ymax;
  590. X{
  591. X    int    bx, by, sx, sy;
  592. X    F_point    *p;
  593. X
  594. X    bx = sx = points->x; by = sy = points->y;
  595. X    for (p = points->next; p != NULL; p = p->next) {
  596. X        sx = min(sx, p->x); sy = min(sy, p->y);
  597. X        bx = max(bx, p->x); by = max(by, p->y);
  598. X        }
  599. X    *xmin = sx; *ymin = sy;
  600. X    *xmax = bx; *ymax = by;
  601. X    }
  602. X
  603. Xcontrol_points_bound(cps, xmin, ymin, xmax, ymax)
  604. XF_control    *cps;
  605. Xint        *xmin, *ymin, *xmax, *ymax;
  606. X{
  607. X    F_control    *c;
  608. X    double        bx, by, sx, sy;
  609. X
  610. X    bx = sx = cps->lx;
  611. X    by = sy = cps->ly;
  612. X    sx = min(sx, cps->rx); sy = min(sy, cps->ry);
  613. X    bx = max(bx, cps->rx); by = max(by, cps->ry);
  614. X    for (c = cps->next; c != NULL; c = c->next) {
  615. X        sx = min(sx, c->lx); sy = min(sy, c->ly);
  616. X        bx = max(bx, c->lx); by = max(by, c->ly);
  617. X        sx = min(sx, c->rx); sy = min(sy, c->ry);
  618. X        bx = max(bx, c->rx); by = max(by, c->ry);
  619. X        }
  620. X    *xmin = round(sx); *ymin = round(sy);
  621. X    *xmax = round(bx); *ymax = round(by);
  622. X    }
  623. END_OF_FILE
  624. if test 9753 -ne `wc -c <'transfig/fig2dev/bound.c'`; then
  625.     echo shar: \"'transfig/fig2dev/bound.c'\" unpacked with wrong size!
  626. fi
  627. # end of 'transfig/fig2dev/bound.c'
  628. fi
  629. if test -f 'transfig/fig2dev/fig2dev.c' -a "${1}" != "-c" ; then 
  630.   echo shar: Will not clobber existing file \"'transfig/fig2dev/fig2dev.c'\"
  631. else
  632. echo shar: Extracting \"'transfig/fig2dev/fig2dev.c'\" \(5666 characters\)
  633. sed "s/^X//" >'transfig/fig2dev/fig2dev.c' <<'END_OF_FILE'
  634. X/* 
  635. X *    Fig2dev : General Fig code translation program
  636. X *
  637. X*/
  638. X#ifdef hpux
  639. X#include <sys/types.h>
  640. X#endif
  641. X#include <sys/file.h>
  642. X#include <stdio.h>
  643. X#include <ctype.h>
  644. X#include "object.h"
  645. X#include "fig2dev.h"
  646. X#include "drivers.h"
  647. X
  648. Xextern int getopt();
  649. Xextern char *optarg;
  650. Xextern int optind;
  651. X
  652. X#define DEFAULT_FONT_SIZE 11
  653. X
  654. Xstruct driver *dev = NULL;
  655. X
  656. Xchar        Usage[] = "Usage: %s [-L language] [-f font] [-s size] [-m scale] [input [output]]\n";
  657. Xchar        Err_badarg[] = "Argument -%c unkown to %s driver.";
  658. Xchar        Err_incomp[] = "Incomplete %s object at line %d.";
  659. Xchar        Err_mem[] = "Running out of memory.";
  660. X
  661. Xchar        *prog;
  662. Xchar        *from = NULL, *to = NULL;
  663. Xint        font_size = 0;
  664. Xdouble        mag = 1.0;
  665. XFILE        *tfp = NULL;
  666. Xint        llx = 0, lly = 0, urx = 0, ury = 0;
  667. X
  668. Xstruct obj_rec {
  669. X    void (*gendev)();
  670. X    char *obj;
  671. X    int depth;
  672. X};
  673. X
  674. Xput_msg(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  675. Xchar   *format, *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7, *arg8;
  676. X{
  677. X    fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
  678. X    fprintf(stderr, "\n");
  679. X    }
  680. X
  681. Xget_args(argc, argv)
  682. Xint     argc;
  683. Xchar    *argv[];
  684. X{
  685. X      int    c, i;
  686. X    double    atof();
  687. X
  688. X    prog = *argv;
  689. X/* add :? */
  690. X    while ((c = getopt(argc, argv, "cd:f:l:L:m:Pp:s:S:vwW:?")) != EOF) {
  691. X
  692. X      /* generic option handling */
  693. X      switch (c) {
  694. X
  695. X        case 'L':            /* set output language */
  696. X            for (i=0; *drivers[i].name; i++) 
  697. X            if (!strcmp(optarg, drivers[i].name))
  698. X                dev = drivers[i].dev;
  699. X            if (!dev) {
  700. X            fprintf(stderr,
  701. X                "Unknown graphics language %s\n", optarg);
  702. X            fprintf(stderr,"Known languages are:\n");
  703. X            /* display available languages - 23/01/90 */
  704. X            for (i=0; *drivers[i].name; i++)
  705. X                fprintf(stderr,"%s ",drivers[i].name);
  706. X            fprintf(stderr,"\n");
  707. X            exit(1);
  708. X            }
  709. X            break;
  710. X
  711. X        case 's':            /* set default font size */
  712. X            font_size = atoi(optarg);
  713. X            break;
  714. X
  715. X        case 'm':            /* set magnification */
  716. X            mag = atof(optarg);
  717. X            break;
  718. X
  719. X        case '?':            /* usage         */
  720. X            fprintf(stderr,Usage,prog);
  721. X            exit(1);
  722. X        }
  723. X
  724. X        /* pass options through to driver */
  725. X        if (!dev) {
  726. X        fprintf(stderr, "No graphics language specified.\n");
  727. X        exit(1);
  728. X        }
  729. X        dev->option(c, optarg);
  730. X      }
  731. X
  732. X    /* default font size is scaled if not specified */
  733. X    if (!font_size) font_size = DEFAULT_FONT_SIZE*mag + 0.5;
  734. X
  735. X    if (optind < argc) from = argv[optind++];  /*  from file  */
  736. X    if (optind < argc) to   = argv[optind];  /*  to file    */
  737. X}
  738. X
  739. Xmain(argc, argv)
  740. Xint     argc;
  741. Xchar    *argv[];
  742. X{
  743. X    F_compound    objects;
  744. X    int        status;
  745. X
  746. X    get_args(argc, argv);
  747. X
  748. X    if (to == NULL)
  749. X        tfp = stdout;
  750. X    else if ((tfp = fopen(to, "w")) == NULL) {
  751. X        fprintf(stderr, "Couldn't open %s", to);
  752. X        fprintf(stderr, Usage, prog);
  753. X        exit(1);
  754. X        }
  755. X
  756. X    if (from)
  757. X        status = read_fig(from, &objects);
  758. X    else    /* read from stdin */
  759. X        status = readfp_fig(stdin, &objects);
  760. X
  761. X    if (status != 0) {
  762. X        if (from) read_fail_message(from, status);
  763. X        exit(1);
  764. X        }
  765. X    gendev_objects(&objects, dev);
  766. X    if (tfp != stdout) (void)fclose(tfp);
  767. X    exit(0);
  768. X    }
  769. X
  770. X/* count primitive objects & create pointer array */
  771. Xstatic int compound_dump(com, array, count, dev)
  772. XF_compound *com;
  773. Xstruct obj_rec *array;
  774. Xint count;
  775. Xstruct driver *dev;
  776. X{
  777. X      F_arc        *a;
  778. X    F_compound    *c;
  779. X    F_ellipse    *e;
  780. X    F_line        *l;
  781. X    F_spline    *s;
  782. X    F_text        *t;
  783. X
  784. X    for (c = com->compounds; c != NULL; c = c->next)
  785. X      count = compound_dump(c, array, count, dev);
  786. X    for (a = com->arcs; a != NULL; a = a->next) {
  787. X      if (array) {
  788. X        array[count].gendev = dev->arc;
  789. X        array[count].obj = (char *)a;
  790. X        array[count].depth = a->depth;
  791. X      }
  792. X      count += 1;
  793. X    }
  794. X    for (e = com->ellipses; e != NULL; e = e->next) {
  795. X      if (array) {
  796. X        array[count].gendev = dev->ellipse;
  797. X        array[count].obj = (char *)e;
  798. X        array[count].depth = e->depth;
  799. X      }
  800. X      count += 1;
  801. X    }
  802. X    for (l = com->lines; l != NULL; l = l->next) {
  803. X      if (array) {
  804. X        array[count].gendev = dev->line;
  805. X        array[count].obj = (char *)l;
  806. X        array[count].depth = l->depth;
  807. X      }
  808. X      count += 1;
  809. X    }
  810. X    for (s = com->splines; s != NULL; s = s->next) {
  811. X      if (array) {
  812. X        array[count].gendev = dev->spline;
  813. X        array[count].obj = (char *)s;
  814. X        array[count].depth = s->depth;
  815. X      }
  816. X      count += 1;
  817. X    }
  818. X    for (t = com->texts; t != NULL; t = t->next) {
  819. X      if (array) {
  820. X        array[count].gendev = dev->text;
  821. X        array[count].obj = (char *)t;
  822. X        array[count].depth = t->depth;
  823. X      }
  824. X      count += 1;
  825. X    }
  826. X    return count;
  827. X}
  828. X
  829. Xgendev_objects(objects, dev)
  830. XF_compound    *objects;
  831. Xstruct driver *dev;
  832. X{
  833. X    F_arc        *a;
  834. X    F_compound    *c;
  835. X    F_ellipse    *e;
  836. X    F_line        *l;
  837. X    F_spline    *s;
  838. X    F_text        *t;
  839. X
  840. X    int obj_count, rec_comp();
  841. X    struct obj_rec *rec_array, *r; 
  842. X
  843. X    if (0 == (double)objects->nwcorner.x) {
  844. X        fprintf(stderr, "Resolution is zero!! default to 80 ppi\n");
  845. X        objects->nwcorner.x = 80;
  846. X        }
  847. X    if (objects->nwcorner.y != 1 && objects->nwcorner.y != 2) {
  848. X        fprintf(stderr, "Wrong coordinate system; cannot continue\n");
  849. X        return;
  850. X        }
  851. X
  852. X    /* Compute bounding box of objects, supressing texts if indicated */
  853. X    compound_bound(objects, &llx, &lly, &urx, &ury, dev->text_include);
  854. X
  855. X    /* dump object pointers to an array */
  856. X    obj_count = compound_dump(objects, 0, 0, dev);
  857. X    if (!obj_count) {
  858. X        fprintf(stderr, "No object");
  859. X        return;
  860. X        }
  861. X    rec_array = (struct obj_rec *)malloc(obj_count*sizeof(struct obj_rec));
  862. X    (void)compound_dump(objects, rec_array, 0, dev);
  863. X
  864. X    /* sort object array by depth */
  865. X    qsort(rec_array, obj_count, sizeof(struct obj_rec), rec_comp);
  866. X
  867. X    /* generate header */
  868. X    (*dev->start)(objects);
  869. X
  870. X    /* generate objects in sorted order */
  871. X    for (r = rec_array; r<rec_array+obj_count; r++)
  872. X        (*(r->gendev))(r->obj);
  873. X
  874. X    /* generate trailer */
  875. X    (*dev->end)();
  876. X}
  877. X
  878. Xint rec_comp(r1, r2)
  879. Xstruct obj_rec *r1, *r2;
  880. X{
  881. X    return (r2->depth - r1->depth);
  882. X}
  883. X
  884. X/* null operation */
  885. Xvoid gendev_null() {};
  886. END_OF_FILE
  887. if test 5666 -ne `wc -c <'transfig/fig2dev/fig2dev.c'`; then
  888.     echo shar: \"'transfig/fig2dev/fig2dev.c'\" unpacked with wrong size!
  889. fi
  890. # end of 'transfig/fig2dev/fig2dev.c'
  891. fi
  892. if test -f 'transfig/fig2dev/latex_line.c' -a "${1}" != "-c" ; then 
  893.   echo shar: Will not clobber existing file \"'transfig/fig2dev/latex_line.c'\"
  894. else
  895. echo shar: Extracting \"'transfig/fig2dev/latex_line.c'\" \(4499 characters\)
  896. sed "s/^X//" >'transfig/fig2dev/latex_line.c' <<'END_OF_FILE'
  897. X#include <stdio.h>
  898. X#include <math.h>
  899. X/* 
  900. X *    latex_line.c: 
  901. X *        Subroutines for drawing and translating lines for the LaTeX
  902. X *        picture environment.
  903. X *    Written by Frank Schmuck (schmuck@svax.cs.cornell.edu)
  904. X *    June 1988
  905. X *
  906. X *    The LaTeX picture environment allows generating pictures in standard
  907. X *    LaTeX.  However, some restrictions apply:  lines and vectors (a vector
  908. X *    is a line with an arrow at the end) can only be drawn with a finite
  909. X *    number of slopes.  The available slopes are given by dy/dx where
  910. X *    dx and dy must be integers <= 6 for lines and <= 4 for vectors.
  911. X *
  912. X *    The subroutines in this file are used in fig2latex to approximate
  913. X *    an arbitrary line or vector by a LaTeX line/vector, and in fig to 
  914. X *    restrict line drawing to slopes supported by LaTeX.
  915. X */
  916. X
  917. X/*
  918. X * Constant for converting from radian to degrees
  919. X */
  920. Xdouble rad2deg = 57.295779513082320877;
  921. X
  922. Xint  pgcd(a,b)
  923. X    int a, b;
  924. X/*
  925. X *  compute greatest common divisor, assuming 0 < a <= b
  926. X */
  927. X{
  928. X    b = b % a;
  929. X    return (b)? gcd(b, a): a;
  930. X}
  931. X
  932. Xint  gcd(a, b)
  933. X    int a, b;
  934. X/*
  935. X *  compute greatest common divisor
  936. X */
  937. X{
  938. X    if (a < 0) a = -a;
  939. X    if (b < 0) b = -b;
  940. X    return (a <= b)? pgcd(a, b): pgcd(b, a);
  941. X}
  942. X
  943. Xint  lcm(a, b)
  944. X    int a, b;
  945. X/*
  946. X *  Compute least common multiple
  947. X */
  948. X{
  949. X    return abs(a*b)/gcd(a,b);
  950. X}
  951. X
  952. X/*
  953. X *  Tables of line and vector slopes supported by LaTeX
  954. X */
  955. Xstruct angle_table {
  956. X    int    x, y;
  957. X    double angle;
  958. X};
  959. X
  960. X#define N_LINE 25
  961. X
  962. Xstruct angle_table line_angles[N_LINE] =
  963. X  { {0, 1, 90.0}, 
  964. X    {1, 0,  0.0},
  965. X    {1, 1, 45.0}, 
  966. X    {1, 2, 63.434948822922010648},
  967. X    {1, 3, 71.565051177077989351},
  968. X    {1, 4, 75.963756532073521417},
  969. X    {1, 5, 78.690067525979786913},
  970. X    {1, 6, 80.537677791974382609},
  971. X    {2, 1, 26.565051177077989351},
  972. X    {2, 3, 56.309932474020213086},
  973. X    {2, 5, 68.198590513648188229}, 
  974. X    {3, 1, 18.434948822922010648},
  975. X    {3, 2, 33.690067525979786913},
  976. X    {3, 4, 53.130102354155978703},
  977. X    {3, 5, 59.036243467926478582},
  978. X    {4, 1, 14.036243467926478588},
  979. X    {4, 3, 36.869897645844021297},
  980. X    {4, 5, 51.340191745909909396},
  981. X    {5, 1, 11.309932474020213086},
  982. X    {5, 2, 21.801409486351811770},
  983. X    {5, 3, 30.963756532073521417},
  984. X    {5, 4, 38.659808254090090604},
  985. X    {5, 6, 50.194428907734805993},
  986. X    {6, 1, 9.4623222080256173906},
  987. X    {6, 5, 39.805571092265194006}
  988. X  };
  989. X
  990. X#define N_ARROW 13
  991. X
  992. Xstruct angle_table arrow_angles[N_ARROW] =
  993. X  { {0, 1, 90.0}, 
  994. X    {1, 0,  0.0},
  995. X    {1, 1, 45.0}, 
  996. X    {1, 2, 63.434948822922010648},
  997. X    {1, 3, 71.565051177077989351},
  998. X    {1, 4, 75.963756532073521417},
  999. X    {2, 1, 26.565051177077989351},
  1000. X    {2, 3, 56.309932474020213086},
  1001. X    {3, 1, 18.434948822922010648},
  1002. X    {3, 2, 33.690067525979786913},
  1003. X    {3, 4, 53.130102354155978703},
  1004. X    {4, 1, 14.036243467926478588},
  1005. X    {4, 3, 36.869897645844021297},
  1006. X  };
  1007. X
  1008. Xget_slope(dx, dy, sxp, syp, arrow)
  1009. X    int  dx, dy, *sxp, *syp, arrow;
  1010. X/*
  1011. X *  Find the LaTeX line slope that is closest to the one given by dx, dy.
  1012. X *  Result is returned in *sxp, *syp.  If (arrow != 0) the closest LaTeX
  1013. X *  vector slope is selected.
  1014. X */
  1015. X{
  1016. X    double angle;
  1017. X    int    i, s, max;
  1018. X    double d, d1;
  1019. X    struct angle_table *st;
  1020. X
  1021. X    if (dx == 0) {
  1022. X    *sxp = 0;
  1023. X    *syp = (dy < 0)? -1: 1;
  1024. X    return;
  1025. X    }
  1026. X    angle = atan((double)abs(dy) / (double)abs(dx)) * rad2deg;
  1027. X    if (arrow) {
  1028. X    st = arrow_angles;
  1029. X    max = N_ARROW;
  1030. X    } else {
  1031. X    st = line_angles;
  1032. X    max = N_LINE;
  1033. X    }
  1034. X    s = 0;
  1035. X    d = 9.9e9;
  1036. X    for (i = 0; i < max; i++) {
  1037. X    d1 = fabs(angle - st[i].angle);
  1038. X    if (d1 < d) {
  1039. X        s = i;
  1040. X        d = d1;
  1041. X    } 
  1042. X    }
  1043. X    *sxp = st[s].x;
  1044. X    if (dx < 0) *sxp = -*sxp;
  1045. X    *syp = st[s].y;
  1046. X    if (dy < 0) *syp = -*syp;
  1047. X}
  1048. X
  1049. Xlatex_endpoint(x1, y1, x2, y2, xout, yout, arrow, magnet)
  1050. X    int  x1, y1, x2, y2;
  1051. X    int  *xout, *yout;
  1052. X    int  arrow, magnet;
  1053. X/*
  1054. X *  Computes a point "close" to (x2,y2) that is reachable from (x1,y1)
  1055. X *  by a LaTeX line (LaTeX vector if arrow != 0).  The result is returned
  1056. X *  in *xout, *yout.  If (magnet > 1) the point returned is selected such that
  1057. X *  (*xout - x1) and (*yout - y1) are both multiples of magnet.
  1058. X */
  1059. X{
  1060. X    int    dx, dy, sx, sy, ds, dsx, dsy;
  1061. X
  1062. X    dx = x2-x1;
  1063. X    dy = y2-y1;
  1064. X    get_slope(dx, dy, &sx, &sy, arrow);
  1065. X    if (abs(sx) >= abs(sy)) {
  1066. X    ds = lcm(sx, magnet*gcd(sx,magnet));
  1067. X    dsx = (2*abs(dx)/ds + 1)/2;
  1068. X    dsx = (dx >= 0)? dsx*ds: -dsx*ds;
  1069. X    *xout = x1 + dsx;
  1070. X    *yout = y1 + dsx*sy/sx;
  1071. X    } else {
  1072. X    ds = lcm(sy, magnet*gcd(sy,magnet));
  1073. X    dsy = (2*abs(dy)/ds + 1)/2;
  1074. X    dsy = (dy >= 0)? dsy*ds: -dsy*ds;
  1075. X    *yout = y1 + dsy;
  1076. X    *xout = x1 + dsy*sx/sy;
  1077. X    }
  1078. X}
  1079. END_OF_FILE
  1080. if test 4499 -ne `wc -c <'transfig/fig2dev/latex_line.c'`; then
  1081.     echo shar: \"'transfig/fig2dev/latex_line.c'\" unpacked with wrong size!
  1082. fi
  1083. # end of 'transfig/fig2dev/latex_line.c'
  1084. fi
  1085. if test -f 'transfig/fig2dev/object.h' -a "${1}" != "-c" ; then 
  1086.   echo shar: Will not clobber existing file \"'transfig/fig2dev/object.h'\"
  1087. else
  1088. echo shar: Extracting \"'transfig/fig2dev/object.h'\" \(4954 characters\)
  1089. sed "s/^X//" >'transfig/fig2dev/object.h' <<'END_OF_FILE'
  1090. X#define                    DEFAULT            (-1)
  1091. X
  1092. Xtypedef        struct f_pattern {
  1093. X            int            w, h;
  1094. X            int            *p;
  1095. X            }
  1096. X        F_pattern;
  1097. X
  1098. Xtypedef        struct f_pen {
  1099. X            int            x, y;
  1100. X            int            *p;
  1101. X            }
  1102. X        F_pen;
  1103. X
  1104. Xtypedef        struct f_point {
  1105. X            int            x, y;
  1106. X            struct f_point        *next;
  1107. X            }
  1108. X        F_point;
  1109. X
  1110. Xtypedef        struct f_pos {
  1111. X            int            x, y;
  1112. X            }
  1113. X        F_pos;
  1114. X
  1115. Xtypedef        struct f_arrow {
  1116. X            int            type;
  1117. X            int            style;
  1118. X            double            thickness;
  1119. X            double            wid;
  1120. X            double            ht;
  1121. X            }
  1122. X        F_arrow;
  1123. X
  1124. Xtypedef        struct f_ellipse {
  1125. X            int            type;
  1126. X#define                    T_ELLIPSE_BY_RAD    1
  1127. X#define                    T_ELLIPSE_BY_DIA    2
  1128. X#define                    T_CIRCLE_BY_RAD        3
  1129. X#define                    T_CIRCLE_BY_DIA        4
  1130. X            int            style;
  1131. X            int            thickness;
  1132. X            int            color;
  1133. X#define                    BLACK            0
  1134. X            int            depth;
  1135. X            int            direction;
  1136. X            double            style_val;
  1137. X            double            angle;
  1138. X            struct f_pen        *pen;
  1139. X            struct f_pattern    *area_fill;
  1140. X#define                           UNFILLED    (F_pattern *)0
  1141. X#define                           BLACK_FILL    (F_pattern *)1
  1142. X#define                           DARK_GRAY_FILL    (F_pattern *)2
  1143. X#define                           MED_GRAY_FILL    (F_pattern *)3
  1144. X#define                           LIGHT_GRAY_FILL    (F_pattern *)4
  1145. X#define                           WHITE_FILL    (F_pattern *)5
  1146. X            struct f_pos        center;
  1147. X            struct f_pos        radiuses;
  1148. X            struct f_pos        start;
  1149. X            struct f_pos        end;
  1150. X            struct f_ellipse    *next;
  1151. X            }
  1152. X        F_ellipse;
  1153. X
  1154. Xtypedef        struct f_arc {
  1155. X            int            type;
  1156. X#define                    T_3_POINTS_ARC        1
  1157. X            int            style;
  1158. X            int            thickness;
  1159. X            int            color;
  1160. X            int            depth;
  1161. X            struct f_pen        *pen;
  1162. X            struct f_pattern    *area_fill;
  1163. X            double            style_val;
  1164. X            int            direction;
  1165. X            struct f_arrow        *for_arrow;
  1166. X            struct f_arrow        *back_arrow;
  1167. X            struct {double x, y;}    center;
  1168. X            struct f_pos        point[3];
  1169. X            struct f_arc        *next;
  1170. X            }
  1171. X        F_arc;
  1172. X
  1173. Xtypedef        struct f_line {
  1174. X            int            type;
  1175. X#define                    T_POLYLINE    1
  1176. X#define                    T_BOX        2
  1177. X#define                    T_POLYGON    3
  1178. X#define                                    T_ARC_BOX       4
  1179. X/* JNT */
  1180. X            int            style;
  1181. X            int            thickness;
  1182. X            int            color;
  1183. X            int            depth;
  1184. X            double            style_val;
  1185. X            int            radius;    /* for T_ARC_BOX */
  1186. X            struct f_pen        *pen;
  1187. X            struct f_pattern    *area_fill;
  1188. X            struct f_arrow        *for_arrow;
  1189. X            struct f_arrow        *back_arrow;
  1190. X            struct f_point        *points;
  1191. X            struct f_line        *next;
  1192. X            }
  1193. X        F_line;
  1194. X
  1195. Xtypedef        struct f_text {
  1196. X            int            type;
  1197. X#define                    T_LEFT_JUSTIFIED    0
  1198. X#define                    T_CENTER_JUSTIFIED    1
  1199. X#define                    T_RIGHT_JUSTIFIED    2
  1200. X            int            font;
  1201. X#define                    DEFAULT_FONT        0
  1202. X#define                    ROMAN_FONT        1
  1203. X#define                    BOLD_FONT        2
  1204. X#define                    ITALIC_FONT        3
  1205. X#define                    MODERN_FONT        4
  1206. X#define                    TYPEWRITER_FONT        5
  1207. X            int            size;    /* point size */
  1208. X            int            color;
  1209. X            int            depth;
  1210. X            double            angle;    /* in radian */
  1211. X            int            style;
  1212. X#define                    PLAIN        1
  1213. X#define                    ITALIC        2
  1214. X#define                    BOLD        4
  1215. X#define                    OUTLINE        8
  1216. X#define                    SHADOW        16
  1217. X            int            height;    /* pixels */
  1218. X            int            length;    /* pixels */
  1219. X            int            base_x;
  1220. X            int            base_y;
  1221. X            struct f_pen        *pen;
  1222. X            char            *cstring;
  1223. X            struct f_text        *next;
  1224. X            }
  1225. X        F_text;
  1226. X
  1227. Xtypedef        struct f_control {
  1228. X            double            lx, ly, rx, ry;
  1229. X            struct f_control    *next;
  1230. X            }
  1231. X        F_control;
  1232. X
  1233. X#define        int_spline(s)        (s->type & 0x2)
  1234. X#define        normal_spline(s)    (!(s->type & 0x2))
  1235. X#define        closed_spline(s)    (s->type & 0x1)
  1236. X#define        open_spline(s)        (!(s->type & 0x1))
  1237. X
  1238. Xtypedef        struct f_spline {
  1239. X            int            type;
  1240. X#define                    T_OPEN_NORMAL        0
  1241. X#define                    T_CLOSED_NORMAL        1
  1242. X#define                    T_OPEN_INTERPOLATED    2
  1243. X#define                    T_CLOSED_INTERPOLATED    3
  1244. X            int            style;
  1245. X            int            thickness;
  1246. X            int            color;
  1247. X            int            depth;
  1248. X            double            style_val;
  1249. X            struct f_pen        *pen;
  1250. X            struct f_pattern    *area_fill;
  1251. X            struct f_arrow        *for_arrow;
  1252. X            struct f_arrow        *back_arrow;
  1253. X            /*
  1254. X            For T_OPEN_NORMAL and T_CLOSED_NORMAL points
  1255. X            are control points while they are knots for
  1256. X            T_OPEN_INTERPOLATED and T_CLOSED_INTERPOLTED
  1257. X            whose control points are stored in controls.
  1258. X            */
  1259. X            struct f_point        *points;
  1260. X            struct f_control    *controls;
  1261. X            struct f_spline        *next;
  1262. X            }
  1263. X        F_spline;
  1264. X
  1265. Xtypedef        struct f_compound {
  1266. X            struct f_pos        nwcorner;
  1267. X            struct f_pos        secorner;
  1268. X            struct f_line        *lines;
  1269. X            struct f_ellipse    *ellipses;
  1270. X            struct f_spline        *splines;
  1271. X            struct f_text        *texts;
  1272. X            struct f_arc        *arcs;
  1273. X            struct f_compound    *compounds;
  1274. X            struct f_compound    *next;
  1275. X            }
  1276. X        F_compound;
  1277. X
  1278. X#define        ARROW_SIZE        sizeof(struct f_arrow)
  1279. X#define        POINT_SIZE        sizeof(struct f_point)
  1280. X#define        CONTROL_SIZE        sizeof(struct f_control)
  1281. X#define        ELLOBJ_SIZE        sizeof(struct f_ellipse)
  1282. X#define        ARCOBJ_SIZE        sizeof(struct f_arc)
  1283. X#define        LINOBJ_SIZE        sizeof(struct f_line)
  1284. X#define        TEXOBJ_SIZE        sizeof(struct f_text)
  1285. X#define        SPLOBJ_SIZE        sizeof(struct f_spline)
  1286. X#define        COMOBJ_SIZE        sizeof(struct f_compound)
  1287. X
  1288. X/**********************  object codes  **********************/
  1289. X
  1290. X#define        O_ELLIPSE        1
  1291. X#define        O_POLYLINE        2
  1292. X#define        O_SPLINE        3
  1293. X#define        O_TEXT            4
  1294. X#define        O_ARC            5
  1295. X#define        O_COMPOUND        6
  1296. X#define        O_END_COMPOUND        (-O_COMPOUND)
  1297. X#define        O_ALL_OBJECT        99
  1298. X
  1299. X/************  object styles (except for f_text)  ************/
  1300. X
  1301. X#define        SOLID_LINE        0
  1302. X#define        DASH_LINE        1
  1303. X#define        DOTTED_LINE        2
  1304. X
  1305. X#define        CLOSED_PATH        0
  1306. X#define        OPEN_PATH        1
  1307. END_OF_FILE
  1308. if test 4954 -ne `wc -c <'transfig/fig2dev/object.h'`; then
  1309.     echo shar: \"'transfig/fig2dev/object.h'\" unpacked with wrong size!
  1310. fi
  1311. # end of 'transfig/fig2dev/object.h'
  1312. fi
  1313. if test -f 'transfig/fig2dev/read1_3.c' -a "${1}" != "-c" ; then 
  1314.   echo shar: Will not clobber existing file \"'transfig/fig2dev/read1_3.c'\"
  1315. else
  1316. echo shar: Extracting \"'transfig/fig2dev/read1_3.c'\" \(9833 characters\)
  1317. sed "s/^X//" >'transfig/fig2dev/read1_3.c' <<'END_OF_FILE'
  1318. X/*******************************************************************/
  1319. X/***************       Read version 1.3 format       ***************/
  1320. X/*******************************************************************/
  1321. X#include <stdio.h>
  1322. X#include <sys/types.h>
  1323. X#include <sys/stat.h>
  1324. X#include <errno.h>
  1325. X#include "alloc.h"
  1326. X#include "object.h"
  1327. X
  1328. X/*******    Fig 1.3 subtype of objects    *******/
  1329. X#define            DRAW_ELLIPSE_BY_RAD     1
  1330. X#define            DRAW_ELLIPSE_BY_DIA     2
  1331. X#define            DRAW_CIRCLE_BY_RAD     3
  1332. X#define            DRAW_CIRCLE_BY_DIA     4
  1333. X#define            DRAW_CIRCULAR_ARC    5
  1334. X#define            DRAW_POLYLINE        6
  1335. X#define            DRAW_BOX        7
  1336. X#define            DRAW_POLYGON        8
  1337. X#define            DRAW_TEXT        9
  1338. X#define            DRAW_SPLINE        10
  1339. X#define            DRAW_CLOSEDSPLINE    11
  1340. X#define            DRAW_COMPOUND        13
  1341. X
  1342. Xextern F_arrow        *forward_arrow(), *backward_arrow();
  1343. Xextern int        figure_modified;
  1344. Xextern int        errno;
  1345. Xextern char        *sys_errlist[];
  1346. Xextern int        sys_nerr, errno;
  1347. X
  1348. Xstatic F_ellipse    *read_ellipseobject();
  1349. Xstatic F_line        *read_lineobject();
  1350. Xstatic F_text        *read_textobject();
  1351. Xstatic F_spline        *read_splineobject();
  1352. Xstatic F_arc        *read_arcobject();
  1353. Xstatic F_compound    *read_compoundobject();
  1354. X
  1355. Xextern int        line_no;
  1356. Xextern int        num_object;
  1357. X
  1358. Xint
  1359. Xread_1_3_objects(fp, obj)
  1360. XFILE        *fp;
  1361. XF_compound    *obj;
  1362. X{
  1363. X    F_ellipse    *e, *le = NULL;
  1364. X    F_line        *l, *ll = NULL;
  1365. X    F_text        *t, *lt = NULL;
  1366. X    F_spline    *s, *ls = NULL;
  1367. X    F_arc        *a, *la = NULL;
  1368. X    F_compound    *c, *lc = NULL;
  1369. X    int         n;
  1370. X    int         object, pixperinch, canvaswid, canvasht, coord_sys;
  1371. X
  1372. X    n = fscanf(fp,"%d%d%d%d\n", &pixperinch, &coord_sys, &canvaswid, &canvasht);
  1373. X    if (n != 4) {
  1374. X        put_msg("Incorrect format in the first line in input file");
  1375. X        return(-1);
  1376. X        }
  1377. X    obj->nwcorner.x = pixperinch;
  1378. X    obj->nwcorner.y = coord_sys;
  1379. X    while (fscanf(fp, "%d", &object) == 1) {
  1380. X        switch (object) {
  1381. X        case O_POLYLINE :
  1382. X            if ((l = read_lineobject(fp)) == NULL) return(-1);
  1383. X            if (ll)
  1384. X            ll = (ll->next = l);
  1385. X            else
  1386. X            ll = obj->lines = l;
  1387. X            num_object++;
  1388. X            break;
  1389. X        case O_SPLINE :
  1390. X            if ((s = read_splineobject(fp)) == NULL) return(-1);
  1391. X            if (ls)
  1392. X            ls = (ls->next = s);
  1393. X            else
  1394. X            ls = obj->splines = s;
  1395. X            num_object++;
  1396. X            break;
  1397. X        case O_ELLIPSE :
  1398. X            if ((e = read_ellipseobject(fp)) == NULL) return(-1);
  1399. X            if (le)
  1400. X            le = (le->next = e);
  1401. X            else
  1402. X            le = obj->ellipses = e;
  1403. X            num_object++;
  1404. X            break;
  1405. X        case O_ARC :
  1406. X            if ((a = read_arcobject(fp)) == NULL) return(-1);
  1407. X            if (la)
  1408. X            la = (la->next = a);
  1409. X            else
  1410. X            la = obj->arcs = a;
  1411. X            num_object++;
  1412. X            break;
  1413. X        case O_TEXT :
  1414. X            if ((t = read_textobject(fp)) == NULL) return(-1);
  1415. X            if (lt)
  1416. X            lt = (lt->next = t);
  1417. X            else
  1418. X            lt = obj->texts = t;
  1419. X            num_object++;
  1420. X            break;
  1421. X        case O_COMPOUND :
  1422. X            if ((c = read_compoundobject(fp)) == NULL) return(-1);
  1423. X            if (lc)
  1424. X            lc = (lc->next = c);
  1425. X            else
  1426. X            lc = obj->compounds = c;
  1427. X            num_object++;
  1428. X            break;
  1429. X        default:
  1430. X            put_msg("Incorrect object code %d", object);
  1431. X            return(-1);
  1432. X        } /*  switch */
  1433. X        } /*  while */
  1434. X    if (feof(fp))
  1435. X        return(0);
  1436. X    else
  1437. X        return(errno);
  1438. X    }
  1439. X
  1440. Xstatic F_arc *
  1441. Xread_arcobject(fp)
  1442. XFILE    *fp;
  1443. X{
  1444. X    F_arc    *a;
  1445. X    int    f, b, h, w, n;
  1446. X
  1447. X    Arc_malloc(a);
  1448. X    a->type = T_3_POINTS_ARC;
  1449. X    a->color = BLACK;
  1450. X    a->depth = 0;
  1451. X    a->pen = NULL;
  1452. X    a->for_arrow = NULL;
  1453. X    a->back_arrow = NULL;
  1454. X    a->next = NULL;
  1455. X    n = fscanf(fp, " %d %d %d %lf %d %d %d %d %d %lf %lf %d %d %d %d %d %d\n",
  1456. X        &a->type, &a->style, &a->thickness, 
  1457. X        &a->style_val, &a->direction, &f, &b,
  1458. X        &h, &w, &a->center.x, &a->center.y, 
  1459. X        &a->point[0].x, &a->point[0].y, 
  1460. X        &a->point[1].x, &a->point[1].y, 
  1461. X        &a->point[2].x, &a->point[2].y);
  1462. X    if (n != 17) {
  1463. X        put_msg("incomplete arc data");
  1464. X        free((char*)a);
  1465. X        return(NULL);
  1466. X        }
  1467. X    if (f) {
  1468. X        a->for_arrow = forward_arrow();
  1469. X        a->for_arrow->wid = w;
  1470. X        a->for_arrow->ht = h;
  1471. X        }
  1472. X    if (b) {
  1473. X        a->back_arrow = backward_arrow();
  1474. X        a->back_arrow->wid = w;
  1475. X        a->back_arrow->ht = h;
  1476. X        }
  1477. X    return(a);
  1478. X    }
  1479. X
  1480. Xstatic F_compound *
  1481. Xread_compoundobject(fp)
  1482. XFILE    *fp;
  1483. X{
  1484. X    F_arc        *a, *la = NULL;
  1485. X    F_ellipse    *e, *le = NULL;
  1486. X    F_line        *l, *ll = NULL;
  1487. X    F_spline    *s, *ls = NULL;
  1488. X    F_text        *t, *lt = NULL;
  1489. X    F_compound    *com, *c, *lc = NULL;
  1490. X    int         n, object;
  1491. X
  1492. X    Compound_malloc(com);
  1493. X    com->arcs = NULL;
  1494. X    com->ellipses = NULL;
  1495. X    com->lines = NULL;
  1496. X    com->splines = NULL;
  1497. X    com->texts = NULL;
  1498. X    com->compounds = NULL;
  1499. X    com->next = NULL;
  1500. X    n = fscanf(fp, " %d %d %d %d\n", &com->nwcorner.x, &com->nwcorner.y,
  1501. X        &com->secorner.x, &com->secorner.y);
  1502. X    if (n != 4) {
  1503. X        put_msg("Incorrect compound object format");
  1504. X        return(NULL);
  1505. X        }
  1506. X    while (fscanf(fp, "%d", &object) == 1) {
  1507. X        switch (object) {
  1508. X        case O_POLYLINE :
  1509. X            if ((l = read_lineobject(fp)) == NULL) { 
  1510. X            free_line(&l);
  1511. X            return(NULL);
  1512. X            }
  1513. X            if (ll)
  1514. X            ll = (ll->next = l);
  1515. X            else
  1516. X            ll = com->lines = l;
  1517. X            break;
  1518. X        case O_SPLINE :
  1519. X            if ((s = read_splineobject(fp)) == NULL) { 
  1520. X            free_spline(&s);
  1521. X            return(NULL);
  1522. X            }
  1523. X            if (ls)
  1524. X            ls = (ls->next = s);
  1525. X            else
  1526. X            ls = com->splines = s;
  1527. X            break;
  1528. X        case O_ELLIPSE :
  1529. X            if ((e = read_ellipseobject(fp)) == NULL) { 
  1530. X            free_ellipse(&e);
  1531. X            return(NULL);
  1532. X            }
  1533. X            if (le)
  1534. X            le = (le->next = e);
  1535. X            else
  1536. X            le = com->ellipses = e;
  1537. X            break;
  1538. X        case O_ARC :
  1539. X            if ((a = read_arcobject(fp)) == NULL) { 
  1540. X            free_arc(&a);
  1541. X            return(NULL);
  1542. X            }
  1543. X            if (la)
  1544. X            la = (la->next = a);
  1545. X            else
  1546. X            la = com->arcs = a;
  1547. X            break;
  1548. X        case O_TEXT :
  1549. X            if ((t = read_textobject(fp)) == NULL) { 
  1550. X            free_text(&t);
  1551. X            return(NULL);
  1552. X            }
  1553. X            if (lt)
  1554. X            lt = (lt->next = t);
  1555. X            else
  1556. X            lt = com->texts = t;
  1557. X            break;
  1558. X        case O_COMPOUND :
  1559. X            if ((c = read_compoundobject(fp)) == NULL) { 
  1560. X            free_compound(&c);
  1561. X            return(NULL);
  1562. X            }
  1563. X            if (lc)
  1564. X            lc = (lc->next = c);
  1565. X            else
  1566. X            lc = com->compounds = c;
  1567. X            break;
  1568. X        case O_END_COMPOUND :
  1569. X            return(com);
  1570. X        } /*  switch */
  1571. X        }
  1572. X    if (feof(fp))
  1573. X        return(com);
  1574. X    else {
  1575. X        put_msg("Format error: %s", sys_errlist[errno]);
  1576. X        return(NULL);
  1577. X        }
  1578. X    }
  1579. X
  1580. Xstatic F_ellipse *
  1581. Xread_ellipseobject(fp)
  1582. XFILE    *fp;
  1583. X{
  1584. X    F_ellipse    *e;
  1585. X    int        n, t;
  1586. X
  1587. X    Ellipse_malloc(e);
  1588. X    e->color = BLACK;
  1589. X    e->angle = 0.0;
  1590. X    e->depth = 0;
  1591. X    e->pen = NULL;
  1592. X    e->area_fill = NULL;
  1593. X    e->next = NULL;
  1594. X    n = fscanf(fp," %d %d %d %lf %d %d %d %d %d %d %d %d %d\n", 
  1595. X        &t, &e->style,
  1596. X        &e->thickness, &e->style_val, &e->direction, 
  1597. X        &e->center.x, &e->center.y, 
  1598. X        &e->radiuses.x, &e->radiuses.y, 
  1599. X        &e->start.x, &e->start.y, 
  1600. X        &e->end.x, &e->end.y);
  1601. X    if (n != 13) {
  1602. X        put_msg("incomplete ellipse data");
  1603. X        free((char*)e);
  1604. X        return(NULL);
  1605. X        }
  1606. X    if (t == DRAW_ELLIPSE_BY_RAD)
  1607. X        e->type = T_ELLIPSE_BY_RAD;
  1608. X    else if (t == DRAW_ELLIPSE_BY_DIA)
  1609. X        e->type = T_ELLIPSE_BY_DIA;
  1610. X    else if (t == DRAW_CIRCLE_BY_RAD)
  1611. X        e->type = T_CIRCLE_BY_RAD;
  1612. X    else
  1613. X        e->type = T_CIRCLE_BY_DIA;
  1614. X    return(e);
  1615. X    }
  1616. X
  1617. Xstatic F_line *
  1618. Xread_lineobject(fp)
  1619. XFILE            *fp;
  1620. X{
  1621. X    F_line    *l;
  1622. X    F_point    *p, *q;
  1623. X    int    f, b, h, w, n, t, x, y;
  1624. X
  1625. X    Line_malloc(l);
  1626. X    l->color = BLACK;
  1627. X    l->depth = 0;
  1628. X    l->pen = NULL;
  1629. X    l->area_fill = NULL;
  1630. X    l->for_arrow = NULL;
  1631. X    l->back_arrow = NULL;
  1632. X    l->next = NULL;
  1633. X    l->points = Point_malloc(p);
  1634. X    n = fscanf(fp, " %d %d %d %lf %d %d %d %d %d %d", &t, 
  1635. X        &l->style, &l->thickness, &l->style_val,
  1636. X        &f, &b, &h, &w, &p->x, &p->y);
  1637. X    if (n != 10) {
  1638. X        put_msg("incomplete line data");
  1639. X        free((char*)l);
  1640. X        return(NULL);
  1641. X        }
  1642. X    if (t == DRAW_POLYLINE)
  1643. X        l->type = T_POLYLINE;
  1644. X    else if (t == DRAW_POLYGON)
  1645. X        l->type = T_POLYGON;
  1646. X    else
  1647. X        l->type = T_BOX;
  1648. X    if (f) {
  1649. X        l->for_arrow = forward_arrow();
  1650. X        l->for_arrow->wid = w;
  1651. X        l->for_arrow->ht = h;
  1652. X        }
  1653. X    if (b) {
  1654. X        l->back_arrow = backward_arrow();
  1655. X        l->back_arrow->wid = w;
  1656. X        l->back_arrow->ht = h;
  1657. X        }
  1658. X    for (;;) {
  1659. X        if (fscanf(fp, " %d %d", &x, &y) != 2) {
  1660. X        put_msg("incomplete line object");
  1661. X        free_linestorage(l);
  1662. X        return(NULL);
  1663. X        }
  1664. X        if (x == 9999) break;
  1665. X        Point_malloc(q);
  1666. X        q->x = x;
  1667. X        q->y = y;
  1668. X        q->next = NULL;
  1669. X        p->next = q;
  1670. X        p = q;
  1671. X        }
  1672. X    return(l);
  1673. X    }
  1674. X
  1675. Xstatic F_spline *
  1676. Xread_splineobject(fp)
  1677. XFILE    *fp;
  1678. X{
  1679. X    F_spline    *s;
  1680. X    F_point        *p, *q;
  1681. X    int        f, b, h, w, n, t, x, y;
  1682. X
  1683. X    Spline_malloc(s);
  1684. X    s->color = BLACK;
  1685. X    s->depth = 0;
  1686. X    s->pen = NULL;
  1687. X    s->area_fill = NULL;
  1688. X    s->for_arrow = NULL;
  1689. X    s->back_arrow = NULL;
  1690. X    s->controls = NULL;
  1691. X    s->next = NULL;
  1692. X    s->points = Point_malloc(p);
  1693. X    n = fscanf(fp, " %d %d %d %lf %d %d %d %d %d %d", 
  1694. X            &t, &s->style, &s->thickness, &s->style_val,
  1695. X            &f, &b,
  1696. X            &h, &w, &p->x, &p->y);
  1697. X    if (n != 10) {
  1698. X        put_msg("incomplete spline data");
  1699. X        free((char*)s);
  1700. X        return(NULL);
  1701. X        }
  1702. X    if (t == DRAW_CLOSEDSPLINE)
  1703. X        s->type = T_CLOSED_NORMAL;
  1704. X    else
  1705. X        s->type = T_OPEN_NORMAL;
  1706. X    if (f) {
  1707. X        s->for_arrow = forward_arrow();
  1708. X        s->for_arrow->wid = w;
  1709. X        s->for_arrow->ht = h;
  1710. X        }
  1711. X    if (b) {
  1712. X        s->back_arrow = backward_arrow();
  1713. X        s->back_arrow->wid = w;
  1714. X        s->back_arrow->ht = h;
  1715. X        }
  1716. X    for (;;) {
  1717. X        if (fscanf(fp, " %d %d", &x, &y) != 2) {
  1718. X        put_msg("incomplete spline object");
  1719. X        free_splinestorage(s);
  1720. X        return(NULL);
  1721. X        };
  1722. X        if (x == 9999) break;
  1723. X        Point_malloc(q);
  1724. X        q->x = x;
  1725. X        q->y = y;
  1726. X        q->next = NULL;
  1727. X        p->next = q;
  1728. X        p = q;
  1729. X        }
  1730. X    return(s);
  1731. X    }
  1732. X
  1733. Xstatic F_text *
  1734. Xread_textobject(fp)
  1735. XFILE    *fp;
  1736. X{
  1737. X    F_text    *t;
  1738. X    int    n;
  1739. X    char    buf[128];
  1740. X
  1741. X    Text_malloc(t);
  1742. X    t->type = T_LEFT_JUSTIFIED;
  1743. X    t->style = PLAIN;
  1744. X    t->color = BLACK;
  1745. X    t->depth = 0;
  1746. X    t->pen = NULL;
  1747. X    t->angle = 0.0;
  1748. X    t->next = NULL;
  1749. X    n = fscanf(fp," %d %d %d %d %d %d %d %[^\n]", &t->font, 
  1750. X        &t->size, &t->style, &t->height, &t->length, 
  1751. X        &t->base_x, &t->base_y, buf);
  1752. X    if (n != 8) {
  1753. X        put_msg("incomplete text data");
  1754. X        free((char*)t);
  1755. X        return(NULL);
  1756. X        }
  1757. X    t->cstring = (char *) calloc((unsigned)(strlen(buf)+1), sizeof(char));
  1758. X    if (t->cstring == NULL) {
  1759. X        put_msg(Err_mem);
  1760. X        free((char*) t);
  1761. X        return(NULL);
  1762. X        }
  1763. X    (void)strcpy(t->cstring, buf);
  1764. X    if (t->size == 0) t->size = 18;
  1765. X    return(t);
  1766. X    }
  1767. END_OF_FILE
  1768. if test 9833 -ne `wc -c <'transfig/fig2dev/read1_3.c'`; then
  1769.     echo shar: \"'transfig/fig2dev/read1_3.c'\" unpacked with wrong size!
  1770. fi
  1771. # end of 'transfig/fig2dev/read1_3.c'
  1772. fi
  1773. echo shar: End of archive 2 \(of 6\).
  1774. cp /dev/null ark2isdone
  1775. MISSING=""
  1776. for I in 1 2 3 4 5 6 ; do
  1777.     if test ! -f ark${I}isdone ; then
  1778.     MISSING="${MISSING} ${I}"
  1779.     fi
  1780. done
  1781. if test "${MISSING}" = "" ; then
  1782.     echo You have unpacked all 6 archives.
  1783.     rm -f ark[1-9]isdone
  1784. else
  1785.     echo You still need to unpack the following archives:
  1786.     echo "        " ${MISSING}
  1787. fi
  1788. ##  End of shell archive.
  1789. exit 0
  1790.