home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1410 < prev    next >
Internet Message Format  |  1990-12-28  |  53KB

  1. From: fs@uwasa.fi (Filip Sawicki LAKE)
  2. Newsgroups: alt.sources
  3. Subject: Fchart part 03/04
  4. Message-ID: <1990Jun4.125243.1277@uwasa.fi>
  5. Date: 4 Jun 90 12:52:43 GMT
  6.  
  7. Submitted-by: fs@chyde
  8. Archive-name: Fchart/part03
  9.  
  10. #!/bin/sh
  11. # This is part 03 of Fchart
  12. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  13.  then TOUCH=touch
  14.  else TOUCH=true
  15. fi
  16. # ============= flblarr.c ==============
  17. echo "x - extracting flblarr.c (Text)"
  18. sed 's/^X//' << 'SHAR_EOF' > flblarr.c &&
  19. X/*
  20. X *
  21. X *  Fchart  --  flblarr.c
  22. X *
  23. X *  Copyright (C) 1990 Piotr Filip Sawicki
  24. X *
  25. X * Permission to use, copy, and distribute this software and its
  26. X * documentation for any purpose with or without fee is hereby granted,
  27. X * provided that the above copyright notice appear in all copies and
  28. X * that both that copyright notice and this permission notice appear
  29. X * in supporting documentation.
  30. X *
  31. X * Permission to modify the software is granted, but not the right to
  32. X * distribute the modified code.  Modifications are to be distributed
  33. X * as patches to released version.
  34. X *
  35. X *  Please e-mail any useful additions to fs@uwasa.fi so they may be
  36. X *  included in later releases.
  37. X *
  38. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  39. X */
  40. X
  41. X#include <stdio.h>
  42. X#include <math.h>
  43. X#include "plot.h"
  44. X#include "fchart.h"
  45. X    
  46. Xstruct label_def *first_label = NULL;
  47. Xstruct linearrow_def *first_arrow = NULL;
  48. X
  49. Xextern char *strcpy(),*strcat();
  50. Xextern int strlen();
  51. X
  52. X/* input data, parsing variables */
  53. Xextern struct lexical_unit token[];
  54. Xextern char input_line[];
  55. Xextern int num_tokens, c_token;
  56. X
  57. Xextern double real();
  58. X
  59. X/******** Local functions ********/
  60. Xstatic int assign_label_tag();
  61. Xstatic int assign_arrow_tag();
  62. Xstatic void delete_label();
  63. Xstatic void delete_arrow();
  64. X
  65. X/* not static: used by fcmd.c */
  66. Xvoid show_labels(), show_arrow();        
  67. Xvoid set_label();
  68. Xvoid set_nolabel();
  69. Xvoid set_arrow();
  70. Xvoid set_noarrow();
  71. X
  72. X/* process a 'set label' command */
  73. X/* set label {tag} {label_text} {at {page|picture} x,y} {pos} {height h} {width w} */
  74. Xvoid
  75. Xset_label()
  76. X{
  77. X    struct label_def *this_label = NULL;
  78. X    struct label_def *new_label = NULL;
  79. X    struct label_def *prev_label = NULL;
  80. X    double x, y, h, w, a;
  81. X    char text[MAX_LINE_LEN+1];
  82. X    enum JUSTIFY just = LEFT;
  83. X    enum LAB_ROT rot;
  84. X    int tag;
  85. X    BOOLEAN set_text, set_position, set_just=FALSE, set_h, set_w, set_r;
  86. X    BOOLEAN page_label;
  87. X    
  88. X    /* get tag */
  89. X    if (!END_OF_COMMAND && isnumber(c_token)) {
  90. X        tag = (int)real(c_token);
  91. X        if (tag == 0)
  92. X            int_error("tag must be > zero", c_token);
  93. X        c_token++;
  94. X    } else
  95. X        tag = assign_label_tag(); /* default next tag */
  96. X    
  97. X    /* get text */
  98. X    if (!END_OF_COMMAND && isstring(c_token)) {
  99. X        quote_str(text, c_token);
  100. X        c_token++;
  101. X        set_text = TRUE;
  102. X    } else {
  103. X        text[0] = '\0';        /* default no text */
  104. X        set_text = FALSE;
  105. X    }
  106. X        
  107. X    /* get justification -- why not here ? */
  108. X    if (!END_OF_COMMAND) {
  109. X        if (almost_equals(c_token,"l$eft")) {
  110. X            just = LEFT;
  111. X            set_just = TRUE;
  112. X            c_token++;
  113. X        }
  114. X        else if (almost_equals(c_token,"c$entre")
  115. X                 || almost_equals(c_token,"c$enter")) {
  116. X            just = CENTRE;
  117. X            set_just = TRUE;
  118. X            c_token++;
  119. X        }
  120. X        else if (almost_equals(c_token,"ri$ght")) {
  121. X            just = RIGHT;
  122. X            set_just = TRUE;
  123. X            c_token++;
  124. X        }
  125. X    }
  126. X
  127. X    /* get position */
  128. X    if (!END_OF_COMMAND && equals(c_token, "at")) {
  129. X        c_token++;
  130. X        if (END_OF_COMMAND)
  131. X            int_error("coordinates expected", c_token);
  132. X        if (almost_equals(c_token, "pa$ge")) {
  133. X            c_token++;
  134. X            page_label = TRUE;
  135. X        }
  136. X        else if (almost_equals(c_token, "pi$cture")) {
  137. X            c_token++;
  138. X            page_label = FALSE;
  139. X        }
  140. X        else if (!isnumber(c_token))
  141. X            int_error("'page' or 'picture' expected", c_token);
  142. X        else
  143. X            page_label = FALSE;
  144. X        x = real(c_token++);
  145. X        if (!equals(c_token,","))
  146. X            int_error("',' expected", c_token);
  147. X        else
  148. X            c_token++;
  149. X        y = real(c_token++);
  150. X        set_position = TRUE;
  151. X    } else {
  152. X        x = y = 0;            /* default at origin */
  153. X        page_label = FALSE;
  154. X        set_position = FALSE;
  155. X    }
  156. X    
  157. X    /* get justification */
  158. X    if (!END_OF_COMMAND) {
  159. X        if (almost_equals(c_token,"l$eft")) {
  160. X            if (set_just)
  161. X                int_error("only one justification is allowed", c_token);
  162. X            just = LEFT;
  163. X            set_just = TRUE;
  164. X            c_token++;
  165. X        }
  166. X        else if (almost_equals(c_token,"c$entre")
  167. X                 || almost_equals(c_token,"c$enter")) {
  168. X            if (set_just)
  169. X                int_error("only one justification is allowed", c_token);
  170. X            just = CENTRE;
  171. X            set_just = TRUE;
  172. X            c_token++;
  173. X        }
  174. X        else if (almost_equals(c_token,"ri$ght")) {
  175. X            if (set_just)
  176. X                int_error("only one justification is allowed", c_token);
  177. X            just = RIGHT;
  178. X            set_just = TRUE;
  179. X            c_token++;
  180. X        }
  181. X    }
  182. X
  183. X    /* get height */
  184. X    if (!END_OF_COMMAND && almost_equals(c_token, "he$ight")) {
  185. X        c_token++;
  186. X        h = real(c_token++);
  187. X        set_h = TRUE;
  188. X    }
  189. X    else {
  190. X        h = 0.0;
  191. X        set_h = FALSE;
  192. X    }
  193. X
  194. X    /* get width */
  195. X    if (!END_OF_COMMAND && almost_equals(c_token, "wi$dth")) {
  196. X        c_token++;
  197. X        w = real(c_token++);
  198. X        set_w = TRUE;
  199. X    }
  200. X    else {
  201. X        w = 0.0;
  202. X        set_w = FALSE;
  203. X    }
  204. X
  205. X    /* get angle */
  206. X    if (!END_OF_COMMAND && almost_equals(c_token, "ro$tation")) {
  207. X        int sign = 1;
  208. X        c_token++;
  209. X        if (equals(c_token, "-")) {
  210. X            c_token++;
  211. X            sign = -1;
  212. X        }
  213. X        a = (double)sign * real(c_token++);
  214. X        rot = L_RANDOM;
  215. X        set_r = TRUE;
  216. X    }
  217. X    else if (!END_OF_COMMAND) {
  218. X        if (almost_equals(c_token, "di$rection")) {
  219. X            c_token++;
  220. X            set_r = TRUE;        /* empty direction defaults to normal */
  221. X        }
  222. X        else
  223. X            set_r = FALSE;
  224. X        if (!END_OF_COMMAND && (almost_equals(c_token, "n$orth") ||
  225. X            almost_equals(c_token, "v$ertical") || almost_equals(c_token, "u$p"))) {
  226. X            c_token++;
  227. X            rot = L_BOTTOM;
  228. X            set_r = TRUE;
  229. X        }
  230. X        else if (!END_OF_COMMAND && (almost_equals(c_token, "s$outh") ||
  231. X                 almost_equals(c_token, "do$wn"))) {
  232. X            c_token++;
  233. X            rot = L_TOP;
  234. X            set_r = TRUE;
  235. X        }
  236. X        else if (!END_OF_COMMAND && (almost_equals(c_token, "we$st") ||
  237. X                 almost_equals(c_token, "l$eft"))) {
  238. X            c_token++;
  239. X            rot = L_UPSIDE;
  240. X            set_r = TRUE;
  241. X        }
  242. X        else if (!END_OF_COMMAND && (almost_equals(c_token, "ho$rizontal") ||
  243. X                 almost_equals(c_token, "e$ast") || almost_equals(c_token, "ri$ght"))) {
  244. X            c_token++;
  245. X            rot = L_NORMAL;
  246. X            set_r = TRUE;
  247. X        }
  248. X        else {
  249. X            rot = L_NORMAL;
  250. X        }
  251. X    }
  252. X    else {
  253. X        rot = L_NORMAL;
  254. X        set_r = FALSE;
  255. X    }
  256. X        
  257. X    if (!END_OF_COMMAND)
  258. X        int_error("extraneous or out-of-order arguments in set label", c_token);
  259. X    
  260. X    /* OK! add label */
  261. X    if (first_label != NULL) { /* skip to last label */
  262. X        for (this_label = first_label; this_label != NULL ; 
  263. X             prev_label = this_label, this_label = this_label->next)
  264. X            /* is this the label we want? */
  265. X            if (tag <= this_label->tag)
  266. X                break;
  267. X    }
  268. X    if (this_label != NULL && tag == this_label->tag) {
  269. X        /* changing the label */
  270. X        if (set_position) {
  271. X            this_label->x = x;
  272. X            this_label->y = y;
  273. X            this_label->paged = page_label;
  274. X        }
  275. X        if (set_text)
  276. X            (void) strcpy(this_label->text, text);
  277. X        if (set_just)
  278. X            this_label->pos = just;
  279. X        if (set_h)
  280. X            this_label->h = h;
  281. X        if (set_w)
  282. X            this_label->w = w;
  283. X        if (set_r) {
  284. X            this_label->rot = rot;
  285. X            this_label->a = a;
  286. X        }
  287. X    } else {
  288. X        /* adding the label */
  289. X        new_label = (struct label_def *) 
  290. X            alloc ( (unsigned int) sizeof(struct label_def), "label");
  291. X        if (prev_label != NULL)
  292. X            prev_label->next = new_label; /* add it to end of list */
  293. X        else 
  294. X            first_label = new_label; /* make it start of list */
  295. X        new_label->tag = tag;
  296. X        new_label->next = this_label;
  297. X        new_label->x = x;
  298. X        new_label->y = y;
  299. X        (void) strcpy(new_label->text, text);
  300. X        new_label->pos = just;
  301. X        new_label->h = h;
  302. X        new_label->w = w;
  303. X        new_label->rot = rot;
  304. X        new_label->a = a;
  305. X        new_label->paged = page_label;
  306. X    }
  307. X}
  308. X
  309. X/* process 'set nolabel' command */
  310. X/* set nolabel {tag} */
  311. Xvoid
  312. Xset_nolabel()
  313. X{
  314. X    struct label_def *this_label;
  315. X    struct label_def *prev_label; 
  316. X    int tag;
  317. X    
  318. X    if (END_OF_COMMAND) {        /* delete all labels */
  319. X        while (first_label != NULL)
  320. X            delete_label((struct label_def *)NULL, first_label);
  321. X    }
  322. X    else {
  323. X        tag = (int)real(c_token++);
  324. X        if (!END_OF_COMMAND)
  325. X            int_error("extraneous arguments to set nolabel", c_token);
  326. X        for (this_label = first_label, prev_label = NULL;
  327. X             this_label != NULL;
  328. X             prev_label = this_label, this_label = this_label->next) {
  329. X            if (this_label->tag == tag) {
  330. X                delete_label(prev_label, this_label);
  331. X                return;        /* exit, our job is done */
  332. X            }
  333. X        }
  334. X        int_error("label not found", c_token);
  335. X    }
  336. X}
  337. X
  338. X/* assign a new label tag */
  339. X/* labels are kept sorted by tag number, so this is easy */
  340. Xstatic int                /* the lowest unassigned tag number */
  341. Xassign_label_tag()
  342. X{
  343. X    struct label_def *this_label;
  344. X    int last = 0;            /* previous tag value */
  345. X    
  346. X    for (this_label = first_label; this_label != NULL;
  347. X         this_label = this_label->next)
  348. X        if (this_label->tag == last+1)
  349. X            last++;
  350. X        else
  351. X            break;
  352. X    
  353. X    return (last+1);
  354. X}
  355. X
  356. X/* delete label from linked list started by first_label.
  357. X * called with pointers to the previous label (prev) and the 
  358. X * label to delete (this).
  359. X * If there is no previous label (the label to delete is
  360. X * first_label) then call with prev = NULL.
  361. X */
  362. Xstatic void
  363. Xdelete_label(prev,this)
  364. Xstruct label_def *prev, *this;
  365. X{
  366. X    if (this!=NULL)    {        /* there really is something to delete */
  367. X        if (prev!=NULL)        /* there is a previous label */
  368. X            prev->next = this->next; 
  369. X        else                /* this = first_label so change first_label */
  370. X            first_label = this->next;
  371. X        free((char *)this);
  372. X    }
  373. X}
  374. X
  375. X
  376. X/* process a 'set arrow' and 'set line' command */
  377. X/* set arrow|line {tag} {from { {page|picture} x,y} {to {page|picture} x,y} */
  378. Xvoid
  379. Xset_arrow(arrow)
  380. XBOOLEAN arrow;
  381. X{
  382. X    struct linearrow_def *this_arrow = NULL;
  383. X    struct linearrow_def *new_arrow = NULL;
  384. X    struct linearrow_def *prev_arrow = NULL;
  385. X    double sx, sy;
  386. X    double ex, ey;
  387. X    int tag;
  388. X    BOOLEAN set_start, set_end;
  389. X    BOOLEAN sp, ep;
  390. X    
  391. X    /* get tag */
  392. X    if (!END_OF_COMMAND && isnumber(c_token)) {
  393. X        tag = (int)real(c_token++);
  394. X        if (tag == 0)
  395. X            int_error("tag must be > zero", c_token);
  396. X    } else
  397. X        tag = assign_arrow_tag(); /* default next tag */
  398. X    
  399. X    /* get start position */
  400. X    if (!END_OF_COMMAND && almost_equals(c_token, "f$rom")) {
  401. X        c_token++;
  402. X        if (END_OF_COMMAND)
  403. X            int_error("start coordinates expected", c_token);
  404. X        else if (almost_equals(c_token, "pa$ge")) {
  405. X            c_token++;
  406. X            sp = TRUE;
  407. X        }
  408. X        else if (almost_equals(c_token, "pi$cture")) {
  409. X            c_token++;
  410. X            sp = FALSE;
  411. X        }
  412. X        else
  413. X            sp = FALSE;
  414. X
  415. X        sx = real(c_token++);
  416. X        if (!equals(c_token,","))
  417. X            int_error("',' expected",c_token);
  418. X        c_token++;
  419. X        sy = real(c_token++);
  420. X        set_start = TRUE;
  421. X    } else {
  422. X        sx = sy = 0;            /* default at origin */
  423. X        sp = FALSE;
  424. X        set_start = FALSE;
  425. X    }
  426. X    
  427. X    /* get end position */
  428. X    if (!END_OF_COMMAND && almost_equals(c_token, "t$o")) {
  429. X        c_token++;
  430. X        if (END_OF_COMMAND)
  431. X            int_error("end coordinates expected", c_token);
  432. X        else if (almost_equals(c_token, "pa$ge")) {
  433. X            c_token++;
  434. X            ep = TRUE;
  435. X        }
  436. X        else if (almost_equals(c_token, "pi$cture")) {
  437. X            c_token++;
  438. X            ep = FALSE;
  439. X        }
  440. X        else
  441. X            ep = FALSE;
  442. X
  443. X        ex = real(c_token++);
  444. X        if (!equals(c_token,","))
  445. X            int_error("',' expected",c_token);
  446. X        c_token++;
  447. X        ey = real(c_token++);
  448. X        set_end = TRUE;
  449. X    } else {
  450. X        ex = ey = 0;            /* default at origin */
  451. X        ep = FALSE;
  452. X        set_end = FALSE;
  453. X    }
  454. X    
  455. X    /* get start position - what the heck, either order is ok */
  456. X    if (!END_OF_COMMAND && almost_equals(c_token, "f$rom")) {
  457. X        if (set_start)
  458. X            int_error("only one 'from' is allowed", c_token);
  459. X        c_token++;
  460. X        if (END_OF_COMMAND)
  461. X            int_error("start coordinates expected", c_token);
  462. X        else if (almost_equals(c_token, "pa$ge")) {
  463. X            c_token++;
  464. X            sp = TRUE;
  465. X        }
  466. X        else if (almost_equals(c_token, "pi$cture")) {
  467. X            c_token++;
  468. X            sp = FALSE;
  469. X        }
  470. X        else
  471. X            sp = FALSE;
  472. X
  473. X        sx = real(c_token++);
  474. X        if (!equals(c_token,","))
  475. X            int_error("',' expected",c_token);
  476. X        c_token++;
  477. X        sy = real(c_token++);
  478. X        set_start = TRUE;
  479. X    }
  480. X    
  481. X    if (!END_OF_COMMAND)
  482. X        int_error("extraneous or out-of-order arguments in set arrow/line", c_token);
  483. X    
  484. X    /* OK! add arrow */
  485. X    if (first_arrow != NULL) { /* skip to last arrow */
  486. X        for (this_arrow = first_arrow; this_arrow != NULL ; 
  487. X             prev_arrow = this_arrow, this_arrow = this_arrow->next)
  488. X            /* is this the arrow we want? */
  489. X            if (tag <= this_arrow->tag)
  490. X                break;
  491. X    }
  492. X    if (this_arrow != NULL && tag == this_arrow->tag) {
  493. X        /* changing the arrow */
  494. X        if (set_start) {
  495. X            this_arrow->sx = sx;
  496. X            this_arrow->sy = sy;
  497. X            this_arrow->startp = sp;
  498. X        }
  499. X        if (set_end) {
  500. X            this_arrow->ex = ex;
  501. X            this_arrow->ey = ey;
  502. X            this_arrow->endp = ep;
  503. X        }
  504. X        this_arrow->arrow = arrow;
  505. X    } else {
  506. X        /* adding the arrow */
  507. X        new_arrow = (struct linearrow_def *) 
  508. X            alloc ( (unsigned int) sizeof(struct linearrow_def), "arrow");
  509. X        if (prev_arrow != NULL)
  510. X            prev_arrow->next = new_arrow; /* add it to end of list */
  511. X        else 
  512. X            first_arrow = new_arrow; /* make it start of list */
  513. X        new_arrow->tag = tag;
  514. X        new_arrow->next = this_arrow;
  515. X        new_arrow->sx = sx;
  516. X        new_arrow->sy = sy;
  517. X        new_arrow->startp = sp;
  518. X        new_arrow->ex = ex;
  519. X        new_arrow->ey = ey;
  520. X        new_arrow->endp = ep;
  521. X        new_arrow->arrow = arrow;
  522. X    }
  523. X}
  524. X
  525. X/* process 'set noarrow' and 'set noline' command */
  526. X/* set noarrow {tag} */
  527. Xvoid
  528. Xset_noarrow()
  529. X{
  530. X    struct linearrow_def *this_arrow;
  531. X    struct linearrow_def *prev_arrow; 
  532. X    int tag;
  533. X    
  534. X    if (END_OF_COMMAND) {
  535. X        /* delete all arrows */
  536. X        while (first_arrow != NULL)
  537. X            delete_arrow((struct linearrow_def *)NULL,first_arrow);
  538. X    }
  539. X    else {
  540. X        /* get tag */
  541. X        tag = (int)real(c_token++);
  542. X        if (!END_OF_COMMAND)
  543. X            int_error("extraneous arguments to set noarrow/noline", c_token);
  544. X        for (this_arrow = first_arrow, prev_arrow = NULL;
  545. X             this_arrow != NULL;
  546. X             prev_arrow = this_arrow, this_arrow = this_arrow->next) {
  547. X            if (this_arrow->tag == tag) {
  548. X                delete_arrow(prev_arrow, this_arrow);
  549. X                return;        /* exit, our job is done */
  550. X            }
  551. X        }
  552. X        int_error("arrow/line not found", c_token);
  553. X    }
  554. X}
  555. X
  556. X/* assign a new arrow tag */
  557. X/* arrows are kept sorted by tag number, so this is easy */
  558. Xstatic int                /* the lowest unassigned tag number */
  559. Xassign_arrow_tag()
  560. X{
  561. X    struct linearrow_def *this_arrow;
  562. X    int last = 0;            /* previous tag value */
  563. X    
  564. X    for (this_arrow = first_arrow; this_arrow != NULL;
  565. X         this_arrow = this_arrow->next)
  566. X        if (this_arrow->tag == last+1)
  567. X            last++;
  568. X        else
  569. X            break;
  570. X    
  571. X    return (last+1);
  572. X}
  573. X
  574. X/* delete arrow from linked list started by first_arrow.
  575. X * called with pointers to the previous arrow (prev) and the 
  576. X * arrow to delete (this).
  577. X * If there is no previous arrow (the arrow to delete is
  578. X * first_arrow) then call with prev = NULL.
  579. X */
  580. Xstatic void
  581. Xdelete_arrow(prev,this)
  582. Xstruct linearrow_def *prev, *this;
  583. X{
  584. X    if (this!=NULL)    {        /* there really is something to delete */
  585. X        if (prev!=NULL)        /* there is a previous arrow */
  586. X            prev->next = this->next; 
  587. X        else                /* this = first_arrow so change first_arrow */
  588. X            first_arrow = this->next;
  589. X        free((char *)this);
  590. X    }
  591. X}
  592. X
  593. Xvoid
  594. Xshow_labels(tag, fp, save)
  595. Xint tag;                /* 0 means show all */
  596. XFILE *fp;
  597. XBOOLEAN save;
  598. X{
  599. X    struct label_def *this_label;
  600. X    BOOLEAN showed = FALSE;
  601. X    
  602. X    for (this_label = first_label; this_label != NULL;
  603. X         this_label = this_label->next) {
  604. X        if (tag == 0 || tag == this_label->tag) {
  605. X            showed = TRUE;
  606. X            fprintf(fp,"%slabel %d \"%s\" %s at %s %lg,%lg",
  607. X                    save ? "set " : "\t",
  608. X                    this_label->tag, this_label->text,
  609. X                    (this_label->pos==LEFT ? "left" : (this_label->pos==RIGHT ? "right" : "centre")),
  610. X                    this_label->paged ? "page" : "picture",
  611. X                    this_label->x, this_label->y);
  612. X            if (this_label->h != 0.0)
  613. X                fprintf(fp, " height %lg", this_label->h);
  614. X            if (this_label->w != 0.0)
  615. X                fprintf(fp, " width %lg", this_label->w);
  616. X            switch(this_label->rot) {
  617. X                case L_NORMAL: {
  618. X                    break;
  619. X                }
  620. X                case L_UPSIDE: {
  621. X                    fprintf(fp, " direction left");
  622. X                    break;
  623. X                }
  624. X                case L_BOTTOM: {
  625. X                    fprintf(fp, " vertical");
  626. X                    break;
  627. X                }
  628. X                case L_TOP: {
  629. X                    fprintf(fp, " direction down");
  630. X                    break;
  631. X                }
  632. X                case L_RANDOM: {
  633. X                    fprintf(fp, " rotation %lg", this_label->a);
  634. X                    break;
  635. X                }
  636. X            }
  637. X            fputc('\n',fp);
  638. X        }
  639. X    }
  640. X    if (tag > 0 && !showed)
  641. X        int_error("label not found", c_token);
  642. X}
  643. X
  644. Xvoid
  645. Xshow_arrow(tag, fp, save)
  646. Xint tag;                /* 0 means show all */
  647. XFILE *fp;
  648. XBOOLEAN save;
  649. X{
  650. X    struct linearrow_def *this_arrow;
  651. X    BOOLEAN showed = FALSE;
  652. X    
  653. X    for (this_arrow = first_arrow; this_arrow != NULL;
  654. X         this_arrow = this_arrow->next) {
  655. X        if (tag == 0 || tag == this_arrow->tag) {
  656. X            showed = TRUE;
  657. X            fprintf(fp,"%s%s %d from %s %lg,%lg to %s %lg,%lg\n",
  658. X                    save ? "set " : "\t",
  659. X                    this_arrow->arrow ? "arrow" : "line",
  660. X                    this_arrow->tag,
  661. X                    this_arrow->startp ? "page" : "picture",
  662. X                    this_arrow->sx, this_arrow->sy,
  663. X                    this_arrow->endp ? "page" : "picture",
  664. X                    this_arrow->ex, this_arrow->ey);
  665. X        }
  666. X    }
  667. X    if (tag > 0 && !showed)
  668. X        int_error("arrow not found", c_token);
  669. X}
  670. X
  671. X
  672. X
  673. X
  674. X
  675. X
  676. X
  677. X
  678. X
  679. SHAR_EOF
  680. $TOUCH -am 0604152590 flblarr.c &&
  681. chmod 0666 flblarr.c ||
  682. echo "restore of flblarr.c failed"
  683. set `wc -c flblarr.c`;Wc_c=$1
  684. if test "$Wc_c" != "16228"; then
  685.     echo original size 16228, current size $Wc_c
  686. fi
  687. # ============= fmisc.c ==============
  688. echo "x - extracting fmisc.c (Text)"
  689. sed 's/^X//' << 'SHAR_EOF' > fmisc.c &&
  690. X/* Fchart - fmisc.c */
  691. X/*
  692. X * Gnuplot code
  693. X * Copyright (C) 1986, 1987, 1990   Thomas Williams, Colin Kelley
  694. X *
  695. X * Permission to use, copy, and distribute this software and its
  696. X * documentation for any purpose with or without fee is hereby granted,
  697. X * provided that the above copyright notice appear in all copies and
  698. X * that both that copyright notice and this permission notice appear
  699. X * in supporting documentation.
  700. X *
  701. X * Permission to modify the software is granted, but not the right to
  702. X * distribute the modified code.  Modifications are to be distributed
  703. X * as patches to released version.
  704. X *
  705. X * This software  is provided "as is" without express or implied warranty.
  706. X *
  707. X *
  708. X * AUTHORS
  709. X *
  710. X *   Original Software:
  711. X *     Thomas Williams,  Colin Kelley.
  712. X *
  713. X *   Gnuplot 2.0 additions:
  714. X *       Russell Lang, Dave Kotz, John Campbell.
  715. X *
  716. X *   Fchart changes and additions:
  717. X *       Piotr Filip Sawicki
  718. X *
  719. X * send your comments or suggestions to fs@uwasa.fi
  720. X *
  721. X */
  722. X
  723. X#include <stdio.h>
  724. X#include "plot.h"
  725. X#include "fchart.h"
  726. X#include "help.h"
  727. X
  728. X#ifdef __TURBOC__
  729. X#include <graphics.h>
  730. X#endif
  731. X
  732. Xextern BOOLEAN autoscale;
  733. Xextern BOOLEAN auto_label;
  734. Xextern BOOLEAN log_y;
  735. Xextern BOOLEAN b_clockwise, p_clockwise;
  736. Xextern BOOLEAN draw_border;
  737. Xextern FILE* outfile;
  738. Xextern char outstr[];
  739. Xextern int samples;
  740. Xextern int term;
  741. Xextern double zero;
  742. Xextern double base;
  743. Xextern double radexp;
  744. Xextern double b_wid, b_spc, b_int;
  745. Xextern float xsize, ysize;
  746. Xextern double roff, loff, toff, boff;
  747. Xextern enum GRAV_DIR gravity, explode;
  748. Xextern enum INP_STYLE inp_style;
  749. Xextern enum DRAW_STYLE data_style;
  750. Xextern enum FONT_STYLE vect_font;
  751. Xextern struct pair data_place, label_plac;
  752. Xextern int HLitem;
  753. Xextern struct dfile data_head;
  754. Xextern int xmin, xmax;
  755. Xextern double treshold;
  756. Xextern char thrname[];
  757. Xextern char tic_form[];
  758. Xextern int strunc;
  759. X
  760. Xextern BOOLEAN screen_ok;
  761. X
  762. Xextern int c_token, num_tokens;
  763. Xextern struct termentry term_tbl[];
  764. X
  765. Xextern char *sprintf(),*strcpy();
  766. Xstatic char *grav_name();
  767. X
  768. Xextern void show_labels(), show_arrow();
  769. X
  770. Xchar *alloc(size, message)
  771. Xunsigned size;
  772. Xchar *message;
  773. X{
  774. X    char *malloc();
  775. X    char *p;                /* the new allocation */
  776. X    char errbuf[100];       /* error message string */
  777. X    extern char *malloc();
  778. X
  779. X    p = malloc(size);
  780. X    if (p == (char *)NULL) {
  781. X
  782. X#ifndef VMS
  783. X       FreeHelp();          /* out of memory, try to make some room */
  784. X#endif
  785. X
  786. X       p = malloc(size);        /* try again */
  787. X       if (p == (char *)NULL) {
  788. X          /* really out of memory */
  789. X          if (message != NULL) {
  790. X             (void) sprintf(errbuf, "out of memory for %s", message);
  791. X             int_error(errbuf, NO_CARET);
  792. X             /* NOTREACHED */
  793. X          }
  794. X          /* else we return NULL */
  795. X       }
  796. X    }
  797. X
  798. X    return(p);
  799. X}
  800. X    
  801. Xdestroy(p)        /* destroy dfile structure p and all the following */
  802. Xstruct dfile *p;
  803. X{
  804. Xstruct dfile *t;
  805. Xstruct chunk *a, *b;
  806. Xint i;
  807. X
  808. X    while (p) {
  809. X        for (a=p->data; a; ) {
  810. X            free((char *)a->dval);
  811. X            if (a->vlbl) {
  812. X                for (i=0; i<a->used; i++)
  813. X                    if (a->vlbl[i])
  814. X                        free(a->vlbl[i]);
  815. X                free((char *)a->vlbl);
  816. X            }
  817. X            b = a;
  818. X            a = a->next;
  819. X            free((char *)b);
  820. X        }
  821. X        if (p->fname) free(p->fname);
  822. X        t = p;
  823. X        p = p->dnxt;
  824. X        free((char *)t);
  825. X    }
  826. X}
  827. X
  828. Xload_file(fp)
  829. XFILE *fp;
  830. X{
  831. X    register int len;
  832. X    extern char input_line[];
  833. X    int start, left, more, stop = FALSE;
  834. X
  835. X    if (!fp)
  836. X        os_error("Cannot open load file",c_token);
  837. X    
  838. X    while (!stop) {      /* read all commands in file */
  839. X        /* read one command */
  840. X        left = MAX_LINE_LEN;
  841. X        start = 0;
  842. X        more = TRUE;
  843. X        
  844. X        while (more) {
  845. X            if (fgets(&(input_line[start]), left, fp) == NULL) {
  846. X                stop = TRUE; /* EOF in file */
  847. X                input_line[start] = '\0';
  848. X                more = FALSE;
  849. X            } else {
  850. X                len = strlen(input_line) - 1;
  851. X                if (input_line[len] == '\n') { /* remove any newline */
  852. X                    input_line[len] = '\0';
  853. X                    /* Look, len was 1-1 = 0 before, take care here! */
  854. X                    if (len > 0) --len;
  855. X                } else if (len+1 >= left)
  856. X                    int_error("Input line too long",NO_CARET);
  857. X                
  858. X                if (input_line[len] == '\\') { /* line continuation */
  859. X                    start = len;
  860. X                    left -= len;
  861. X                } else
  862. X                    more = FALSE;
  863. X            }
  864. X        }
  865. X        
  866. X        if (strlen(input_line) > 0) {
  867. X            screen_ok = FALSE; /* make sure command line is
  868. X                                  echoed on error */
  869. X            do_line();
  870. X        }
  871. X    }
  872. X}
  873. X
  874. Xsave_sets(fp)        /* save all current settings */
  875. XFILE *fp;
  876. X{
  877. X    char comm[MAX_LINE_LEN+1];
  878. X    
  879. X    if (!fp)
  880. X        os_error("Cannot open save file",c_token);
  881. X
  882. X    for(c_token++; !END_OF_COMMAND; c_token++) {
  883. X        if (equals(c_token,",")) continue;
  884. X        if (!isstring(c_token)) break;        /* causes error, but later */
  885. X        quote_str(comm, c_token);
  886. X        fprintf(fp,"# %s\n",comm);
  887. X    }
  888. X
  889. X    (void) putc('\n',fp);
  890. X    fprintf(fp,"set %sautolabel\n", auto_label ? "" : "no");
  891. X    fprintf(fp,"set %struncate", strunc==-1 ? "no" : "");
  892. X    if (strunc>0)
  893. X        fprintf(fp," %d", strunc);
  894. X    (void) putc('\n',fp);
  895. X    fprintf(fp,"set cust ");
  896. X    if (data_place.from != -1) {
  897. X        show_segment(data_place.from,data_place.upto,fp);
  898. X        (void) putc(' ',fp);
  899. X        if (label_plac.from != -1)
  900. X            show_segment(label_plac.from,label_plac.upto,fp);
  901. X    }
  902. X    (void) putc('\n',fp);
  903. X    fprintf(fp,"set font ");
  904. X    switch (vect_font) {
  905. X        case F_NEVER: {
  906. X            fprintf(fp,"never\n");
  907. X            break;
  908. X        }
  909. X        case F_WHENN: {
  910. X            fprintf(fp,"when_needed\n");
  911. X            break;
  912. X        }
  913. X        case F_ROTAT: {
  914. X            fprintf(fp,"rotated\n");
  915. X            break;
  916. X        }
  917. X        case F_ALWYS: {
  918. X            fprintf(fp,"always\n");
  919. X            break;
  920. X        }
  921. X    }
  922. X    fprintf(fp,"set format \"%s\"\n", tic_form);
  923. X    fprintf(fp,"set %sframe\n", draw_border ? "" : "no");
  924. X    fprintf(fp,"set highlight ");
  925. X    switch (HLitem) {
  926. X        case HL_MIN: {
  927. X            fprintf(fp,"min\n");
  928. X            break;
  929. X        }
  930. X        case HL_MAX: {
  931. X            fprintf(fp,"max\n");
  932. X            break;
  933. X        }
  934. X        case HL_NON: {
  935. X            fprintf(fp,"none\n");
  936. X            break;
  937. X        }
  938. X        default: {
  939. X            fprintf(fp,"%d\n",HLitem);
  940. X            break;
  941. X        }
  942. X    }
  943. X    fprintf(fp,"set input ");
  944. X    switch (inp_style) {
  945. X        case GNUPLOT: {
  946. X            fprintf(fp,"gnuplot\n");
  947. X            break;
  948. X        }
  949. X        case PRIVATE: {
  950. X            fprintf(fp,"private\n");
  951. X            break;
  952. X        }
  953. X        case CUSTOMD: {
  954. X            fprintf(fp,"customized\n");
  955. X            break;
  956. X        }
  957. X    }
  958. X    fprintf(fp,"set %slogscale\n", log_y ? "" : "no");
  959. X    fprintf(fp,"set offsets %lg, %lg, %lg, %lg\n", loff, roff, toff, boff);
  960. X    fprintf(fp,"set output %s\n", strcmp(outstr,"STDOUT") ? outstr : "");
  961. X    fprintf(fp,"set size %g, %g\n", xsize, ysize);
  962. X    fprintf(fp,"set style ");
  963. X    switch (data_style) {
  964. X        case ABARS:        fprintf(fp,"adj\n"); break;
  965. X        case SBAR:        fprintf(fp,"sta\n"); break;
  966. X        case LAYB:        fprintf(fp,"lay\n"); break;
  967. X        case PIECHART:    fprintf(fp,"pie\n"); break;
  968. X    }
  969. X    fprintf(fp,"set term %s\n", term_tbl[term].name);
  970. X    fprintf(fp,"set title ");
  971. X    if (data_head.fname) fprintf(fp,"\"%s\"\n", data_head.fname);
  972. X    else (void) putc('\n',fp);
  973. X    show_labels(0, fp, TRUE);
  974. X    show_arrow(0, fp, TRUE);
  975. X    fprintf(fp,"set range ");
  976. X    if (xmin != -1) show_segment(xmin,xmax,fp);
  977. X    (void) putc('\n',fp);
  978. X    fprintf(fp,"set zero %lg\n", zero);
  979. X
  980. X    (void) putc('\n',fp);
  981. X    
  982. X    fprintf(fp,"set bar %sautoscale\n", autoscale ? "" : "no");
  983. X    fprintf(fp,"set bar base %lg\n", base);
  984. X    fprintf(fp,"set bar %sclock\n", b_clockwise ? "" : "counter_");
  985. X    fprintf(fp,"set bar grav %s\n", grav_name(gravity));
  986. X    fprintf(fp,"set bar width %lg, %lg, %lg\n", b_wid, b_int, b_spc);
  987. X
  988. X    (void) putc('\n',fp);
  989. X
  990. X    fprintf(fp,"set pie expl %s\n", grav_name(explode));
  991. X    fprintf(fp,"set pie %sclockwise\n", p_clockwise ? "" : "counter_");
  992. X    fprintf(fp,"set pie radius %lg\n", radexp);
  993. X    fprintf(fp,"set pie samples %d\n", samples);
  994. X    fprintf(fp,"set pie threshold %lg \"%s\"\n", treshold, thrname);
  995. X
  996. X    (void) fclose(fp);
  997. X}
  998. X
  999. Xint instring(str, c)
  1000. Xchar *str;
  1001. Xchar c;
  1002. X{
  1003. X    int pos = 0;
  1004. X    
  1005. X    while (str != NULL && *str != '\0' && c != *str) {
  1006. X        str++;
  1007. X        pos++;
  1008. X    }
  1009. X    return (pos);
  1010. X}
  1011. X
  1012. Xshow_style()
  1013. X{
  1014. X    fprintf(stderr,"\tdata are plotted with ");
  1015. X    switch (data_style) {
  1016. X        case ABARS: fprintf(stderr,"adjacent bars\n"); break;
  1017. X        case LAYB: fprintf(stderr,"layer bars\n"); break;
  1018. X        case SBAR: fprintf(stderr,"stacked bars\n"); break;
  1019. X        case PIECHART: fprintf(stderr,"piechart\n"); break;
  1020. X    }
  1021. X}
  1022. X
  1023. Xshow_range()
  1024. X{
  1025. X    if (xmin==-1)
  1026. X        fprintf(stderr,"\twhole file is processed");
  1027. X    else {
  1028. X        fprintf(stderr,"\tdata range is: ");
  1029. X        show_segment(xmin,xmax,stderr);
  1030. X    }
  1031. X    (void) putc('\n',stderr);
  1032. X}
  1033. X
  1034. Xshow_zero()
  1035. X{
  1036. X    fprintf(stderr,"\tzero/epsilon is %lg\n",zero);
  1037. X}
  1038. X
  1039. Xshow_offsets()
  1040. X{
  1041. X    fprintf(stderr,"\toffsets are %lg, %lg, %lg, %lg\n",loff,roff,toff,boff);
  1042. X}
  1043. X
  1044. Xshow_samples()
  1045. X{
  1046. X    fprintf(stderr,"\tsampling rate for piechart is %d\n",samples);
  1047. X}
  1048. X
  1049. Xshow_output()
  1050. X{
  1051. X    fprintf(stderr,"\toutput is sent to %s\n",outstr);
  1052. X}
  1053. X
  1054. Xshow_term()
  1055. X{
  1056. X    fprintf(stderr,"\tterminal type is %s\n",term_tbl[term].name);
  1057. X}
  1058. X
  1059. Xshow_autoscale()
  1060. X{
  1061. X    fprintf(stderr,"\tbar autoscaling is %s\n",(autoscale)? "ON" : "OFF");
  1062. X}
  1063. X
  1064. Xshow_logscale()
  1065. X{
  1066. X    if (log_y)
  1067. X        fprintf(stderr,"\tlogscaling is ON\n");
  1068. X    else
  1069. X        fprintf(stderr,"\tno logscaling\n");
  1070. X}
  1071. X
  1072. Xshow_version()
  1073. X{
  1074. Xextern char version[];
  1075. Xextern char date[];
  1076. Xstatic char *authors[] = {"Thomas Williams","Colin Kelley"};
  1077. Xextern int patchlevel;
  1078. Xextern char bug_email[];
  1079. Xint x;
  1080. Xlong time();
  1081. X
  1082. X    x = time((long *)NULL) & 1;
  1083. X    fprintf(stderr,"\n\t%s\n\t%sversion %s patchlevel %d\n\tlast modified %s\n",
  1084. X        PROGRAM, OS, version, patchlevel, date);
  1085. X    fprintf(stderr,"\tGnuplot v.1.x Copyright (C) 1986, 1987  %s, %s\n",
  1086. X        authors[x],authors[1-x]);
  1087. X    fprintf(stderr,"\tGnuplot v.2.0 John Campbell, David Kotz, Russell Lang\n");
  1088. X    fprintf(stderr,"\t%s Copyright (C) 1990 Piotr Filip Sawicki\n",PROGRAM);
  1089. X#ifdef __TURBOC__
  1090. X    fprintf(stderr,"\tCreated using Turbo C, Copyright Borland 1987, 1988\n");
  1091. X#endif
  1092. X    fprintf(stderr, "\n\tSend bugs and comments to %s\n\n", bug_email);
  1093. X}
  1094. X
  1095. Xstatic char *grav_name(what)
  1096. Xenum GRAV_DIR what;
  1097. X{
  1098. X    static char buf[20];
  1099. X    switch (what) {
  1100. X        case(SOUTH)   : (void) strcpy(buf,"bottom"); break;
  1101. X        case(NORTH)   : (void) strcpy(buf,"top"); break;
  1102. X        case(EAST)    : (void) strcpy(buf,"right"); break;
  1103. X        case(WEST)    : (void) strcpy(buf,"left"); break;
  1104. X        case(DEFAULT) : buf[0] = '\0'; break;
  1105. X    }
  1106. X    return(buf);
  1107. X}
  1108. X
  1109. Xshow_gravity()
  1110. X{
  1111. X    fprintf(stderr,"\tbar gravitation to the %s\n", grav_name(gravity));
  1112. X}
  1113. X
  1114. Xshow_explode()
  1115. X{
  1116. X    fprintf(stderr,"\thighlited slice explodes %s\n",
  1117. X            explode == DEFAULT
  1118. X                ? "where it should"
  1119. X                : grav_name(explode));
  1120. X}
  1121. X
  1122. Xshow_HLset()
  1123. X{
  1124. X    switch (HLitem) {
  1125. X        case(HL_NON): fprintf(stderr,"\tno item"); break;
  1126. X        case(HL_MIN): fprintf(stderr,"\tminimal item"); break;
  1127. X        case(HL_MAX): fprintf(stderr,"\tmaximal item"); break;
  1128. X        default     : fprintf(stderr,"\titem no. %d",HLitem); break;
  1129. X    }
  1130. X    fprintf(stderr," is highlited\n");
  1131. X}
  1132. X
  1133. Xshow_base()
  1134. X{
  1135. X    fprintf(stderr,"\tbase for bars is %lg\n",base);
  1136. X}    
  1137. X
  1138. Xshow_input()
  1139. X{
  1140. X    switch (inp_style) {
  1141. X        case(GNUPLOT) : fprintf(stderr,"\tgnuplot-compatible"); break;
  1142. X        case(PRIVATE) : fprintf(stderr,"\tstandard"); break;
  1143. X        case(CUSTOMD) : fprintf(stderr,"\tcustomized"); break;
  1144. X    }
  1145. X    fprintf(stderr," data input style\n");
  1146. X}
  1147. X
  1148. Xshow_custom()
  1149. X{
  1150. X    if (data_place.from == -1) 
  1151. X        fprintf(stderr,"\tcustomized input format not given\n");
  1152. X    else {
  1153. X        fprintf(stderr,"\tcustomized input format:\n");
  1154. X        fprintf(stderr,"\t\tvalue: ");
  1155. X        show_segment(data_place.from,data_place.upto,stderr);
  1156. X        if (label_plac.from == -1) fprintf(stderr,"\n\t\tno label position");
  1157. X        else {
  1158. X            fprintf(stderr,"\n\t\tlabel: ");
  1159. X            show_segment(label_plac.from,label_plac.upto,stderr);
  1160. X        }
  1161. X        (void) putc('\n',stderr);
  1162. X    }
  1163. X}
  1164. X
  1165. Xstatic show_segment(l,r,fp)
  1166. Xint l,r;
  1167. XFILE *fp;
  1168. X{
  1169. X    (void) putc('[',fp);
  1170. X    if (l) fprintf(fp,"%d",l);
  1171. X    fprintf(fp," : ");
  1172. X    if (r>-1) fprintf(fp,"%d",r);
  1173. X    (void) putc(']',fp);
  1174. X}
  1175. X
  1176. Xshow_label()
  1177. X{
  1178. X    fprintf(stderr,"\tlabels are%s auto-generated\n",
  1179. X            auto_label ? "" : "n't");
  1180. X}
  1181. X
  1182. Xshow_clock(pie)
  1183. XBOOLEAN pie;
  1184. X{
  1185. X    if (pie)
  1186. X        fprintf(stderr,"\tpies are drawn %sclockwise\n",
  1187. X                p_clockwise ? "" : "counter-");
  1188. X    else
  1189. X        fprintf(stderr,"\tbars are drawn %sclockwise\n",
  1190. X                b_clockwise ? "" : "counter-");
  1191. X}
  1192. X
  1193. Xshow_width()
  1194. X{
  1195. X    fprintf(stderr,"\tbar width params are %lg, %lg, %lg\n",b_wid,b_int,b_spc);
  1196. X}
  1197. X
  1198. Xshow_radius()
  1199. X{
  1200. X    fprintf(stderr,"\texplosion radius ratio is %lg\n",radexp);
  1201. X}
  1202. X
  1203. Xshow_border()
  1204. X{
  1205. X    fprintf(stderr,"\tpicture frame is%s drawn\n",draw_border?"":" not");
  1206. X}
  1207. X
  1208. Xshow_size()
  1209. X{
  1210. X    fprintf(stderr,"\tsize is scaled by %g, %g\n",xsize,ysize);
  1211. X}
  1212. X
  1213. Xshow_title()
  1214. X{
  1215. X    if (!data_head.fname || !*(data_head.fname))
  1216. X        fprintf(stderr,"\tpicture has no title\n");
  1217. X    else
  1218. X        fprintf(stderr,"\ttitle for picture is: \"%s\"\n",data_head.fname);
  1219. X}
  1220. X
  1221. Xshow_tresh()
  1222. X{
  1223. X    fprintf(stderr,"\tslices glue threshold is %lg with name \"%s\"\n", treshold, thrname);
  1224. X}
  1225. X
  1226. Xshow_format()
  1227. X{
  1228. X    fprintf(stderr,"\tformat for numbers is: \"%s\"\n", tic_form);
  1229. X}
  1230. X
  1231. Xshow_font()
  1232. X{
  1233. X    fprintf(stderr,"\tvector font is ");
  1234. X    switch (vect_font) {
  1235. X        case F_NEVER: fprintf(stderr,"never used\n"); break;
  1236. X        case F_WHENN: fprintf(stderr,"used when needed\n"); break;
  1237. X        case F_ROTAT: fprintf(stderr,"for rotated text\n"); break;
  1238. X        case F_ALWYS: fprintf(stderr,"always used\n"); break;
  1239. X    }
  1240. X}
  1241. X
  1242. Xshow_trunc()
  1243. X{
  1244. X    fprintf(stderr,"\tlabels are%s truncated", strunc==-1 ? " not" : "");
  1245. X    if (strunc>0)
  1246. X        fprintf(stderr," at char no. %d", strunc);
  1247. X    fprintf(stderr,"\n");
  1248. X}
  1249. SHAR_EOF
  1250. $TOUCH -am 0604152590 fmisc.c &&
  1251. chmod 0666 fmisc.c ||
  1252. echo "restore of fmisc.c failed"
  1253. set `wc -c fmisc.c`;Wc_c=$1
  1254. if test "$Wc_c" != "12994"; then
  1255.     echo original size 12994, current size $Wc_c
  1256. fi
  1257. # ============= font.c ==============
  1258. echo "x - extracting font.c (Text)"
  1259. sed 's/^X//' << 'SHAR_EOF' > font.c &&
  1260. X/* Fchart - font.c */
  1261. X/*
  1262. X * Copyright (C) 1990 Piotr Filip Sawicki
  1263. X *
  1264. X * Permission to use, copy, and distribute this software and its
  1265. X * documentation for any purpose with or without fee is hereby granted,
  1266. X * provided that the above copyright notice appear in all copies and
  1267. X * that both that copyright notice and this permission notice appear
  1268. X * in supporting documentation.
  1269. X *
  1270. X * Permission to modify the software is granted, but not the right to
  1271. X * distribute the modified code.  Modifications are to be distributed
  1272. X * as patches to released version.
  1273. X *
  1274. X * This software  is provided "as is" without express or implied warranty.
  1275. X *
  1276. X * send your comments or suggestions to fs@uwasa.fi
  1277. X *
  1278. X ***********************************************************************
  1279. X * This file contains two vector fonts:
  1280. X *   - nonstandard my private one
  1281. X *   - public-domain Hershey Roman
  1282. X *       courtesy Joe Felsenstein, joe@genetics.washington.edu
  1283. X * Currently the latter is used, though the former has better digits.
  1284. X * To use my font, add the following line to the "fchart.h":
  1285. X * #define NO_ROMAN_FONT
  1286. X * and rebuild the entire application.
  1287. X ***********************************************************************
  1288. X *
  1289. X */
  1290. X
  1291. X#include <stdio.h>
  1292. X#include <math.h>
  1293. X#include "plot.h"
  1294. X#include "fchart.h"
  1295. X
  1296. X#ifdef NO_ROMAN_FONT
  1297. X
  1298. X/* character height: 256, character width: 20-256 */    
  1299. X
  1300. Xstatic unsigned char I_shape[] = { 10,20 , 10,220 , 0 };
  1301. Xstatic unsigned char P_shape[] = { 10,220 , 150,220 , 200,190 , 200,160 , 150,130 , 10,130 , 0 };
  1302. Xstatic unsigned char B_shape[] = { 150,130 , 200,90 , 200,55 , 150,20 , 10,20 , 0 };
  1303. Xstatic unsigned char R_shape[] = { 150,130 , 200,90 , 200,20 , 0 };
  1304. Xstatic unsigned char D_shape[] = { 10,220 , 150,220 , 200,190 , 200,55 , 150,20 , 10,20 , 0 };
  1305. Xstatic unsigned char t_shape[] = { 150,220 , 10,220 , 0 };
  1306. Xstatic unsigned char m_shape[] = { 10,120 , 150,120 , 0 };
  1307. Xstatic unsigned char l_shape[] = { 150,20 , 10,20 , 0 };
  1308. Xstatic unsigned char L_shape[] = { 10,220 , 10,20 , 150,20 , 0 };
  1309. Xstatic unsigned char i_shape[] = { 150,20 , 150,220 , 0 };
  1310. Xstatic unsigned char b_shape[] = { 10,220 , 150,20 , 0 };
  1311. Xstatic unsigned char s_shape[] = { 10,20 , 150,220 , 0 };
  1312. Xstatic unsigned char u_shape[] = { 5,10 , 105,10 , 0 };
  1313. Xstatic unsigned char T_shape[] = { 80,20 , 80,220 , 0 };
  1314. Xstatic unsigned char d1shape[] = { 80,220 , 10,170 , 0 };
  1315. Xstatic unsigned char J_shape[] = { 80,220 , 80,55 , 50,20 , 20,20 , 10,35 , 0 };
  1316. Xstatic unsigned char V_shape[] = { 80,20 , 10,220 , 0 };
  1317. Xstatic unsigned char d7shape[] = { 80,20 , 150,220 , 0 };
  1318. Xstatic unsigned char d4shape[] = { 10,220 , 10,100 , 100,100 , 0 };
  1319. Xstatic unsigned char M_shape[] = { 10,220 , 125,20 , 240,220 , 240,20 , 0 };
  1320. Xstatic unsigned char W_shape[] = { 10,220 , 80,20 , 130,130 , 180,20 , 250,220 , 0 };
  1321. Xstatic unsigned char K_shape[] = { 200,220 , 10,100 , 200,20 , 0 };        /* wrong !!! */
  1322. Xstatic unsigned char C_shape[] = { 200,190 , 150,220 , 60,220 , 10,190 , 10,55 , 60,20 , 150,20 , 200,55 , 0 };
  1323. Xstatic unsigned char O_shape[] = { 200,55 , 200,190 , 0 };
  1324. Xstatic unsigned char G_shape[] = { 200,20 , 200,120 , 120,120 , 0 };
  1325. Xstatic unsigned char Q_shape[] = { 130,55 , 190,10 , 0 };
  1326. Xstatic unsigned char d0shape[] = { 10,55 , 60,20 , 100,20 , 150,55 , 150,190 , 100,220 , 60,220 , 10,190 , 10,55 , 150,190 , 0 };
  1327. Xstatic unsigned char p_shape[] = { 10,20 , 10,20 , 0 };
  1328. Xstatic unsigned char S_shape[] = { 200,190 , 150,220 , 60,220 , 10,190 , 10,160 , 60,130 , 150,120 , 200,90 , 200,55 , 150,20 , 60,20 , 10,55 , 0 };
  1329. Xstatic unsigned char U_shape[] = { 10,220 , 10,55 , 60,20 , 100,20 , 150,55 , 150,220 , 0 };
  1330. Xstatic unsigned char A_shape[] = { 10,20 , 80,220 , 150,20 , 0 };
  1331. Xstatic unsigned char a_shape[] = { 45,100 , 115,100 , 0 };
  1332. Xstatic unsigned char Y_shape[] = { 150,220 , 80,100 , 80,20 , 0 };
  1333. Xstatic unsigned char y_shape[] = { 10,220 , 80,100 , 0 };
  1334. Xstatic unsigned char d_shape[] = { 150,180 , 100,210 , 60,210 , 10,180 , 10,150, 60,130 , 100,110 , 150,95 , 150,65 , 100,30 , 60,30 , 10,65 , 0 };
  1335. Xstatic unsigned char d2shape[] = { 10,190 , 60,220 , 100,220 , 150,190 , 150,160 , 10,55 , 10,20 , 150,20 , 0 };
  1336. Xstatic unsigned char d3shape[] = { 10,190 , 60,220 , 100,220 , 150,190 , 150,160 , 100,130 , 150,90 , 150,55 , 100,20 , 60,20 , 10,55 , 0 };
  1337. Xstatic unsigned char x_shape[] = { 80,50 , 80,190 , 0 };
  1338. Xstatic unsigned char d5shape[] = { 150,220 , 10,220 , 10,120 , 100,120 , 150,90 , 150,55 , 100,20 , 60,20 , 10,55 , 0 };
  1339. Xstatic unsigned char d6shape[] = { 150,190 , 100,220 , 60,220 , 10,190 , 10,90 , 60,120 , 100,120 , 150,90 , 150,55 , 100,20 , 60,20 , 10,55 , 10,90 , 0 };
  1340. Xstatic unsigned char d9shape[] = { 10,55 , 60,20 , 100,20 , 150,55 , 150,160 , 100,130 , 60,130 , 10,160 , 10,190 , 60,220 , 100,220 , 150,190 , 150,160 , 0 };
  1341. Xstatic unsigned char d8shape[] = { 60,130 , 100,130 , 150,160 , 150,190 , 100,220 , 60,220 , 10,190 , 10,160 , 60,130 , 10,90 , 10,55 , 60,20 , 100,20 , 150,55 , 150,90 , 100,130 , 0 };
  1342. Xstatic unsigned char pLshape[] = { 60,220 , 10,160 , 10,55 , 60,20 , 0 };
  1343. Xstatic unsigned char pRshape[] = { 10,220 , 60,160 , 60,55 , 10,20 , 0 };
  1344. X
  1345. Xstruct Char trt[128] = {
  1346. X/* . */ { 20 , p_shape , NULL , NULL }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 },
  1347. X        { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 },
  1348. X        { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 },
  1349. X        { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 },
  1350. X/*   */ {  20 , NULL , NULL , NULL }, { 0 }, { 0 }, { 0 }, 
  1351. X/* $ */ { 160 , T_shape , d_shape , NULL }, { 0 }, { 0 }, { 0 },
  1352. X/* ( */ {  70 , pLshape , NULL , NULL },
  1353. X/* ) */ {  70 , pRshape , NULL , NULL },
  1354. X        { 0 },
  1355. X/* + */ { 160 , m_shape , x_shape , NULL },
  1356. X        { 0 }, 
  1357. X/* - */ { 160 , m_shape , NULL , NULL },
  1358. X/* . */ { 20 , p_shape , NULL , NULL }, 
  1359. X/* / */ { 160 , s_shape , NULL , NULL },
  1360. X/* 0 */ { 160 , d0shape , NULL , NULL },
  1361. X/* 1 */ {  90 , T_shape , d1shape , NULL },
  1362. X/* 2 */ { 160 , d2shape , NULL , NULL },
  1363. X/* 3 */ { 160 , d3shape , NULL , NULL },
  1364. X/* 4 */ { 110 , T_shape , d4shape , NULL },
  1365. X/* 5 */ { 160 , d5shape , NULL , NULL },
  1366. X/* 6 */ { 160 , d6shape , NULL , NULL },
  1367. X/* 7 */ { 160 , d7shape , t_shape , NULL },
  1368. X/* 8 */ { 160 , d8shape , NULL , NULL },
  1369. X/* 9 */ { 160 , d9shape , NULL , NULL }, { 0 }, { 0 },
  1370. X        { 0 }, { 0 }, { 0 }, { 0 },
  1371. X        { 0 }, 
  1372. X/* A */ { 160 , A_shape , a_shape , NULL },
  1373. X/* B */ { 210 , I_shape , P_shape , B_shape },
  1374. X/* C */ { 210 , C_shape , NULL , NULL },
  1375. X/* D */ { 210 , I_shape , D_shape , NULL },
  1376. X/* E */ { 160 , t_shape , L_shape , m_shape },
  1377. X/* F */ { 160 , t_shape , I_shape , m_shape },
  1378. X/* G */ { 210 , C_shape , G_shape , NULL },
  1379. X/* H */ { 160 , I_shape , m_shape , i_shape },
  1380. X/* I */ {  20 , I_shape , NULL , NULL },
  1381. X/* J */ {  90 , J_shape , NULL , NULL },
  1382. X/* K */ { 210 , I_shape , K_shape , NULL },
  1383. X/* L */ { 160 , L_shape , NULL , NULL },
  1384. X/* M */ { 250 , I_shape , M_shape , NULL },
  1385. X/* N */ { 160 , I_shape , b_shape , i_shape },
  1386. X/* O */ { 210 , C_shape , O_shape , NULL },
  1387. X/* P */ { 210 , I_shape , P_shape , NULL },
  1388. X/* Q */ { 210 , C_shape , O_shape , Q_shape },
  1389. X/* R */ { 210 , I_shape , P_shape , R_shape },
  1390. X/* S */ { 210 , S_shape , NULL , NULL },
  1391. X/* T */ { 160 , T_shape , t_shape , NULL },
  1392. X/* U */ { 160 , U_shape , NULL , NULL },
  1393. X/* V */ { 160 , V_shape , d7shape , NULL },
  1394. X/* W */ { 260 , W_shape , NULL , NULL },
  1395. X/* X */ { 160 , b_shape , s_shape , NULL },
  1396. X/* Y */ { 160 , Y_shape , y_shape , NULL },
  1397. X/* Z */ { 160 , l_shape , s_shape , t_shape }, { 0 },
  1398. X/* \ */ { 160 , b_shape , NULL , NULL }, { 0 }, { 0 }, /* _ */ { 110 , u_shape , NULL , NULL },
  1399. X        { 0 },
  1400. X/* A */ { 160 , A_shape , a_shape , NULL },
  1401. X/* B */ { 210 , I_shape , P_shape , B_shape },
  1402. X/* C */ { 210 , C_shape , NULL , NULL },
  1403. X/* D */ { 210 , I_shape , D_shape , NULL },
  1404. X/* E */ { 160 , t_shape , L_shape , m_shape },
  1405. X/* F */ { 160 , t_shape , I_shape , m_shape },
  1406. X/* G */ { 210 , C_shape , G_shape , NULL },
  1407. X/* H */ { 160 , I_shape , m_shape , i_shape },
  1408. X/* I */ {  20 , I_shape , NULL , NULL },
  1409. X/* J */ {  90 , J_shape , NULL , NULL },
  1410. X/* K */ { 210 , I_shape , K_shape , NULL },
  1411. X/* L */ { 160 , L_shape , NULL , NULL },
  1412. X/* M */ { 250 , I_shape , M_shape , NULL },
  1413. X/* N */ { 160 , I_shape , b_shape , i_shape },
  1414. X/* O */ { 210 , C_shape , O_shape , NULL },
  1415. X/* P */ { 210 , I_shape , P_shape , NULL },
  1416. X/* Q */ { 210 , C_shape , O_shape , Q_shape },
  1417. X/* R */ { 210 , I_shape , P_shape , R_shape },
  1418. X/* S */ { 210 , S_shape , NULL , NULL },
  1419. X/* T */ { 160 , T_shape , t_shape , NULL },
  1420. X/* U */ { 160 , U_shape , NULL , NULL },
  1421. X/* V */ { 160 , V_shape , d7shape , NULL },
  1422. X/* W */ { 260 , W_shape , NULL , NULL },
  1423. X/* X */ { 160 , b_shape , s_shape , NULL },
  1424. X/* Y */ { 160 , Y_shape , y_shape , NULL },
  1425. X/* Z */ { 160 , l_shape , s_shape , t_shape }, { 0 },
  1426. X/* | */ {  90 , T_shape , NULL , NULL }, { 0 }, { 0 }, { 0 }
  1427. X    } ;
  1428. X
  1429. X#else        /* use roman font */
  1430. X
  1431. X/* character height: 80, character width: ~30 */    
  1432. X
  1433. Xstatic int char_32[2] = { -2600, 0 };
  1434. Xstatic int char_33[9] = { -1531, 1517, -1512, 1411, 1510, 1611, 1512, -2000, 0 };
  1435. Xstatic int char_40[12] = { -2135, 1933, 1730, 1526, 1421, 1417, 1512, 1708, 1905, 2103, -2400, 0 };
  1436. Xstatic int char_41[12] = { -1335, 1533, 1730, 1926, 2021, 2017, 1912, 1708, 1505, 1303, -2400, 0 };
  1437. Xstatic int char_42[8] = { -1825, 1813, -1322, 2316, -2322, 1316, -2600, 0 };
  1438. Xstatic int char_44[10] = { -1611, 1510, 1411, 1512, 1611, 1609, 1507, 1406, -2000, 0 };
  1439. Xstatic int char_45[4] = { -1419, 3219, -3600, 0 };
  1440. Xstatic int char_46[7] = { -1512, 1411, 1510, 1611, 1512, -2000, 0 };
  1441. Xstatic int char_47[4] = { -3035, 1203, -3200, 0 };
  1442. Xstatic int char_0[19] = { -1931, 1630, 1427, 1322, 1319, 1414, 1611, 1910, 2110, 2411, 2614, 2719, 2722, 2627, 2430, 2131, 1931, -3000, 0 };
  1443. Xstatic int char_1[6] = { -1627, 1828, 2131, 2110, -3000, 0 };
  1444. Xstatic int char_2[16] = { -1426, 1427, 1529, 1630, 1831, 2231, 2430, 2529, 2627, 2625, 2523, 2320, 1310, 2710, -3000, 0 };
  1445. Xstatic int char_3[17] = { -1531, 2631, 2023, 2323, 2522, 2621, 2718, 2716, 2613, 2411, 2110, 1810, 1511, 1412, 1314, -3000, 0 };
  1446. Xstatic int char_4[7] = { -2331, 1317, 2817, -2331, 2310, -3000, 0 };
  1447. Xstatic int char_5[19] = { -2531, 1531, 1422, 1523, 1824, 2124, 2423, 2621, 2718, 2716, 2613, 2411, 2110, 1810, 1511, 1412, 1314, -3000, 0 };
  1448. Xstatic int char_6[25] = { -2628, 2530, 2231, 2031, 1730, 1527, 1422, 1417, 1513, 1711, 2010, 2110, 2411, 2613, 2716, 2717, 2620, 2422, 2123, 2023, 1722, 1520, 1417, -3000, 0 };
  1449. Xstatic int char_7[6] = { -2731, 1710, -1331, 2731, -3000, 0 };
  1450. Xstatic int char_8[31] = { -1831, 1530, 1428, 1426, 1524, 1723, 2122, 2421, 2619, 2717, 2714, 2612, 2511, 2210, 1810, 1511, 1412, 1314, 1317, 1419, 1621, 1922, 2323, 2524, 2626, 2628, 2530, 2231, 1831, -3000, 0 };
  1451. Xstatic int char_9[25] = { -2624, 2521, 2319, 2018, 1918, 1619, 1421, 1324, 1325, 1428, 1630, 1931, 2031, 2330, 2528, 2624, 2619, 2514, 2311, 2010, 1810, 1511, 1413, -3000, 0 };
  1452. Xstatic int char_58[12] = { -1524, 1423, 1522, 1623, 1524, -1512, 1411, 1510, 1611, 1512, -2000, 0 };
  1453. Xstatic int char_59[15] = { -1524, 1423, 1522, 1623, 1524, -1611, 1510, 1411, 1512, 1611, 1609, 1507, 1406, -2000, 0 };
  1454. Xstatic int char_63[21] = { -1326, 1327, 1429, 1530, 1731, 2131, 2330, 2429, 2527, 2525, 2423, 2322, 1920, 1917, -1912, 1811, 1910, 2011, 1912, -2800, 0 };
  1455. Xstatic int char_A[8] = { -1931, 1110, -1931, 2710, -1417, 2417, -2800, 0 };
  1456. Xstatic int char_B[23] = { -1431, 1410, -1431, 2331, 2630, 2729, 2827, 2825, 2723, 2622, 2321, -1421, 2321, 2620, 2719, 2817, 2814, 2712, 2611, 2310, 1410, -3100, 0 };
  1457. Xstatic int char_C[20] = { -2826, 2728, 2530, 2331, 1931, 1730, 1528, 1426, 1323, 1318, 1415, 1513, 1711, 1910, 2310, 2511, 2713, 2815, -3100, 0 };
  1458. Xstatic int char_D[16] = { -1431, 1410, -1431, 2131, 2430, 2628, 2726, 2823, 2818, 2715, 2613, 2411, 2110, 1410, -3100, 0 };
  1459. Xstatic int char_E[10] = { -1431, 1410, -1431, 2731, -1421, 2221, -1410, 2710, -2900, 0 };
  1460. Xstatic int char_F[8] = { -1431, 1410, -1431, 2731, -1421, 2221, -2800, 0 };
  1461. Xstatic int char_G[23] = { -2826, 2728, 2530, 2331, 1931, 1730, 1528, 1426, 1323, 1318, 1415, 1513, 1711, 1910, 2310, 2511, 2713, 2815, 2818, -2318, 2818, -3100, 0 };
  1462. Xstatic int char_H[8] = { -1431, 1410, -2831, 2810, -1421, 2821, -3200, 0 };
  1463. Xstatic int char_I[4] = { -1431, 1410, -1800, 0 };
  1464. Xstatic int char_J[12] = { -2231, 2215, 2112, 2011, 1810, 1610, 1411, 1312, 1215, 1217, -2600, 0 };
  1465. Xstatic int char_K[8] = { -1431, 1410, -2831, 1417, -1922, 2810, -3100, 0 };
  1466. Xstatic int char_L[6] = { -1431, 1410, -1410, 2610, -2700, 0 };
  1467. Xstatic int char_M[10] = { -1431, 1410, -1431, 2210, -3031, 2210, -3031, 3010, -3400, 0 };
  1468. Xstatic int char_N[8] = { -1431, 1410, -1431, 2810, -2831, 2810, -3200, 0 };
  1469. Xstatic int char_O[23] = { -1931, 1730, 1528, 1426, 1323, 1318, 1415, 1513, 1711, 1910, 2310, 2511, 2713, 2815, 2918, 2923, 2826, 2728, 2530, 2331, 1931, -3200, 0 };
  1470. Xstatic int char_P[14] = { -1431, 1410, -1431, 2331, 2630, 2729, 2827, 2824, 2722, 2621, 2320, 1420, -3100, 0 };
  1471. Xstatic int char_Q[25] = { -1931, 1730, 1528, 1426, 1323, 1318, 1415, 1513, 1711, 1910, 2310, 2511, 2713, 2815, 2918, 2923, 2826, 2728, 2530, 2331, 1931, -2214, 2808, -3200, 0 };
  1472. Xstatic int char_R[16] = { -1431, 1410, -1431, 2331, 2630, 2729, 2827, 2825, 2723, 2622, 2321, 1421, -2121, 2810, -3100, 0 };
  1473. Xstatic int char_S[22] = { -2728, 2530, 2231, 1831, 1530, 1328, 1326, 1424, 1523, 1722, 2320, 2519, 2618, 2716, 2713, 2511, 2210, 1810, 1511, 1313, -3000, 0 };
  1474. Xstatic int char_T[6] = { -1831, 1810, -1131, 2531, -2600, 0 };
  1475. Xstatic int char_U[12] = { -1431, 1416, 1513, 1711, 2010, 2210, 2511, 2713, 2816, 2831, -3200, 0 };
  1476. Xstatic int char_V[6] = { -1131, 1910, -2731, 1910, -2800, 0 };
  1477. Xstatic int char_W[10] = { -1231, 1710, -2231, 1710, -2231, 2710, -3231, 2710, -3400, 0 };
  1478. Xstatic int char_X[6] = { -1331, 2710, -2731, 1310, -3000, 0 };
  1479. Xstatic int char_Y[7] = { -1131, 1921, 1910, -2731, 1921, -2800, 0 };
  1480. Xstatic int char_Z[8] = { -2731, 1310, -1331, 2731, -1310, 2710, -3000, 0 };
  1481. Xstatic int char_a[18] = { -2524, 2510, -2521, 2323, 2124, 1824, 1623, 1421, 1318, 1316, 1413, 1611, 1810, 2110, 2311, 2513, -2900, 0 };
  1482. Xstatic int char_b[18] = { -1431, 1410, -1421, 1623, 1824, 2124, 2323, 2521, 2618, 2616, 2513, 2311, 2110, 1810, 1611, 1413, -2900, 0 };
  1483. Xstatic int char_c[16] = { -2521, 2323, 2124, 1824, 1623, 1421, 1318, 1316, 1413, 1611, 1810, 2110, 2311, 2513, -2800, 0 };
  1484. Xstatic int char_d[18] = { -2531, 2510, -2521, 2323, 2124, 1824, 1623, 1421, 1318, 1316, 1413, 1611, 1810, 2110, 2311, 2513, -2900, 0 };
  1485. Xstatic int char_e[19] = { -1318, 2518, 2520, 2422, 2323, 2124, 1824, 1623, 1421, 1318, 1316, 1413, 1611, 1810, 2110, 2311, 2513, -2800, 0 };
  1486. Xstatic int char_f[9] = { -2031, 1831, 1630, 1527, 1510, -1224, 1924, -2200, 0 };
  1487. Xstatic int char_g[23] = { -2524, 2508, 2405, 2304, 2103, 1803, 1604, -2521, 2323, 2124, 1824, 1623, 1421, 1318, 1316, 1413, 1611, 1810, 2110, 2311, 2513, -2900, 0 };
  1488. Xstatic int char_h[11] = { -1431, 1410, -1420, 1723, 1924, 2224, 2423, 2520, 2510, -2900, 0 };
  1489. Xstatic int char_i[9] = { -1331, 1430, 1531, 1432, 1331, -1424, 1410, -1800, 0 };
  1490. Xstatic int char_j[12] = { -1531, 1630, 1731, 1632, 1531, -1624, 1607, 1504, 1303, 1103, -2000, 0 };
  1491. Xstatic int char_k[8] = { -1431, 1410, -2424, 1414, -1818, 2510, -2700, 0 };
  1492. Xstatic int char_l[4] = { -1431, 1410, -1800, 0 };
  1493. Xstatic int char_m[18] = { -1424, 1410, -1420, 1723, 1924, 2224, 2423, 2520, 2510, -2520, 2823, 3024, 3324, 3523, 3620, 3610, -4000, 0 };
  1494. Xstatic int char_n[11] = { -1424, 1410, -1420, 1723, 1924, 2224, 2423, 2520, 2510, -2900, 0 };
  1495. Xstatic int char_o[19] = { -1824, 1623, 1421, 1318, 1316, 1413, 1611, 1810, 2110, 2311, 2513, 2616, 2618, 2521, 2323, 2124, 1824, -2900, 0 };
  1496. Xstatic int char_p[18] = { -1424, 1403, -1421, 1623, 1824, 2124, 2323, 2521, 2618, 2616, 2513, 2311, 2110, 1810, 1611, 1413, -2900, 0 };
  1497. Xstatic int char_q[18] = { -2524, 2503, -2521, 2323, 2124, 1824, 1623, 1421, 1318, 1316, 1413, 1611, 1810, 2110, 2311, 2513, -2900, 0 };
  1498. Xstatic int char_r[9] = { -1424, 1410, -1418, 1521, 1723, 1924, 2224, -2300, 0 };
  1499. Xstatic int char_s[19] = { -2421, 2323, 2024, 1724, 1423, 1321, 1419, 1618, 2117, 2316, 2414, 2413, 2311, 2010, 1710, 1411, 1313, -2700, 0 };
  1500. Xstatic int char_t[9] = { -1531, 1514, 1611, 1810, 2010, -1224, 1924, -2200, 0 };
  1501. Xstatic int char_u[11] = { -1424, 1414, 1511, 1710, 2010, 2211, 2514, -2524, 2510, -2900, 0 };
  1502. Xstatic int char_v[6] = { -1224, 1810, -2424, 1810, -2600, 0 };
  1503. Xstatic int char_w[10] = { -1324, 1710, -2124, 1710, -2124, 2510, -2924, 2510, -3200, 0 };
  1504. Xstatic int char_x[6] = { -1324, 2410, -2424, 1310, -2700, 0 };
  1505. Xstatic int char_y[10] = { -1224, 1810, -2424, 1810, 1606, 1404, 1203, 1103, -2600, 0 };
  1506. Xstatic int char_z[8] = { -2424, 1310, -1324, 2424, -1310, 2410, -2700, 0 };
  1507. Xstruct Char trt[128] = {
  1508. X/* ^@ */     { 10 , char_46 },
  1509. X/* ^A */     { 10 , char_46 },
  1510. X/* ^B */     { 10 , char_46 },
  1511. X/* ^C */     { 10 , char_46 },
  1512. X/* ^D */     { 10 , char_46 },
  1513. X/* ^E */     { 10 , char_46 },
  1514. X/* ^F */     { 10 , char_46 },
  1515. X/* ^G */     { 10 , char_46 },
  1516. X/* ^H */     { 10 , char_46 },
  1517. X/* ^I */     { 10 , char_46 },
  1518. X/* ^J */     { 10 , char_46 },
  1519. X/* ^K */     { 10 , char_46 },
  1520. X/* ^L */     { 10 , char_46 },
  1521. X/* ^M */     { 10 , char_46 },
  1522. X/* ^N */     { 10 , char_46 },
  1523. X/* ^O */     { 10 , char_46 },
  1524. X/* ^P */     { 10 , char_46 },
  1525. X/* ^Q */     { 10 , char_46 },
  1526. X/* ^R */     { 10 , char_46 },
  1527. X/* ^S */     { 10 , char_46 },
  1528. X/* ^T */     { 10 , char_46 },
  1529. X/* ^U */     { 10 , char_46 },
  1530. X/* ^V */     { 10 , char_46 },
  1531. X/* ^W */     { 10 , char_46 },
  1532. X/* ^X */     { 10 , char_46 },
  1533. X/* ^Y */     { 10 , char_46 },
  1534. X/* ^Z */     { 10 , char_46 },
  1535. X/* ^[ */     { 10 , char_46 },
  1536. X/* ^\ */     { 10 , char_46 },
  1537. X/* ^] */     { 10 , char_46 },
  1538. X/* ^^ */     { 10 , char_46 },
  1539. X/* ^_ */     { 10 , char_46 },
  1540. X/*    */     { 16 , char_32 },
  1541. X/*  ! */     { 10 , char_33 },
  1542. X/*  " */     { 10 , char_46 },
  1543. X/*  # */     { 10 , char_46 },
  1544. X/*  $ */     { 10 , char_46 },
  1545. X/*  % */     { 10 , char_46 },
  1546. X/*  & */     { 10 , char_46 },
  1547. X/*  ' */     { 10 , char_46 },
  1548. X/*  ( */     { 14 , char_40 },
  1549. X/*  ) */     { 14 , char_41 },
  1550. X/*  * */     { 16 , char_42 },
  1551. X/*  + */     { 10 , char_46 },
  1552. X/*  , */     { 10 , char_44 },
  1553. X/*  - */     { 26 , char_45 },
  1554. X/*  . */     { 10 , char_46 },
  1555. X/*  / */     { 22 , char_47 },
  1556. X/*  0 */     { 20 , char_0 },
  1557. X/*  1 */     { 20 , char_1 },
  1558. X/*  2 */     { 20 , char_2 },
  1559. X/*  3 */     { 20 , char_3 },
  1560. X/*  4 */     { 20 , char_4 },
  1561. X/*  5 */     { 20 , char_5 },
  1562. X/*  6 */     { 20 , char_6 },
  1563. X/*  7 */     { 20 , char_7 },
  1564. X/*  8 */     { 20 , char_8 },
  1565. X/*  9 */     { 20 , char_9 },
  1566. X/*  : */     { 10 , char_58 },
  1567. X/*  ; */     { 10 , char_59 },
  1568. X/*  < */     { 10 , char_46 },
  1569. X/*  = */     { 10 , char_46 },
  1570. X/*  > */     { 10 , char_46 },
  1571. X/*  ? */     { 18 , char_63 },
  1572. X/*  @ */     { 10 , char_46 },
  1573. X/*  A */     { 18 , char_A },
  1574. X/*  B */     { 21 , char_B },
  1575. X/*  C */     { 21 , char_C },
  1576. X/*  D */     { 21 , char_D },
  1577. X/*  E */     { 19 , char_E },
  1578. X/*  F */     { 18 , char_F },
  1579. X/*  G */     { 21 , char_G },
  1580. X/*  H */     { 22 , char_H },
  1581. X/*  I */     {  8 , char_I },
  1582. X/*  J */     { 16 , char_J },
  1583. X/*  K */     { 21 , char_K },
  1584. X/*  L */     { 17 , char_L },
  1585. X/*  M */     { 24 , char_M },
  1586. X/*  N */     { 22 , char_N },
  1587. X/*  O */     { 22 , char_O },
  1588. X/*  P */     { 21 , char_P },
  1589. X/*  Q */     { 22 , char_Q },
  1590. X/*  R */     { 21 , char_R },
  1591. X/*  S */     { 20 , char_S },
  1592. X/*  T */     { 16 , char_T },
  1593. X/*  U */     { 22 , char_U },
  1594. X/*  V */     { 18 , char_V },
  1595. X/*  W */     { 24 , char_W },
  1596. X/*  X */     { 20 , char_X },
  1597. X/*  Y */     { 18 , char_Y },
  1598. X/*  Z */     { 20 , char_Z },
  1599. X/*  [ */     { 10 , char_46 },
  1600. X/*  \ */     { 10 , char_46 },
  1601. X/*  ] */     { 10 , char_46 },
  1602. X/*  ^ */     { 10 , char_46 },
  1603. X/*  _ */     { 10 , char_46 },
  1604. X/*  ` */     { 10 , char_46 },
  1605. X/*  a */     { 19 , char_a },
  1606. X/*  b */     { 19 , char_b },
  1607. X/*  c */     { 18 , char_c },
  1608. X/*  d */     { 19 , char_d },
  1609. X/*  e */     { 18 , char_e },
  1610. X/*  f */     { 12 , char_f },
  1611. X/*  g */     { 19 , char_g },
  1612. X/*  h */     { 19 , char_h },
  1613. X/*  i */     {  8 , char_i },
  1614. X/*  j */     { 10 , char_j },
  1615. X/*  k */     { 17 , char_k },
  1616. X/*  l */     {  8 , char_l },
  1617. X/*  m */     { 30 , char_m },
  1618. X/*  n */     { 19 , char_n },
  1619. X/*  o */     { 19 , char_o },
  1620. X/*  p */     { 19 , char_p },
  1621. X/*  q */     { 19 , char_q },
  1622. X/*  r */     { 13 , char_r },
  1623. X/*  s */     { 17 , char_s },
  1624. X/*  t */     { 12 , char_t },
  1625. X/*  u */     { 19 , char_u },
  1626. X/*  v */     { 16 , char_v },
  1627. X/*  w */     { 22 , char_w },
  1628. X/*  x */     { 17 , char_x },
  1629. X/*  y */     { 16 , char_y },
  1630. X/*  z */     { 17 , char_z },
  1631. X/*  { */     { 10 , char_46 },
  1632. X/*  | */     { 10 , char_46 },
  1633. X/*  } */     { 10 , char_46 },
  1634. X/*  ~ */     { 10 , char_46 },
  1635. X/* 46 */     { 10 , char_46 }
  1636. X};
  1637. X
  1638. X#endif         /* NO_ROMAN_FONT */
  1639. X
  1640. X/* procedures for vector fonts */
  1641. X
  1642. Xtransp(tx, ty, A)
  1643. Xint tx, ty;
  1644. XMATRIX A;
  1645. X/* transpose */
  1646. X{
  1647. X    register int i, j;
  1648. X    for (i=0; i<3; i++) {
  1649. X        for (j=0; j<3; j++)
  1650. X            A[i][j] = 0.0;
  1651. X        A[i][i] = 1.0;
  1652. X    }
  1653. X    A[0][2] = -tx;
  1654. X    A[1][2] = -ty;
  1655. X}
  1656. X
  1657. Xscale(sx, sy, A)
  1658. Xdouble sx, sy;
  1659. XMATRIX A;
  1660. X/* scale */
  1661. X{
  1662. X    register int i, j;
  1663. X    for (i=0; i<3; i++)
  1664. X        for (j=0; j<3; j++)
  1665. X            A[i][j] = 0.0;
  1666. X    A[0][0] = sx;
  1667. X    A[1][1] = sy;
  1668. X    A[2][2] = 1.0;
  1669. X}
  1670. X
  1671. Xrotat(al, A)
  1672. Xdouble al;
  1673. XMATRIX A;
  1674. X/* rotate */
  1675. X{
  1676. X    register int i;
  1677. X    double s;
  1678. X    for (i=0; i<2; i++)
  1679. X        A[i][2] = A[2][i] = 0.0;
  1680. X    A[2][2] = 1.0;
  1681. X    s = sin(al);
  1682. X    A[0][0] = A[1][1] = cos(al);
  1683. X    A[0][1] = s;
  1684. X    A[1][0] = -s;
  1685. X}
  1686. X
  1687. Xmulti(A, B, C)
  1688. XMATRIX A, B, C;
  1689. X/* multiply matrices */
  1690. X{
  1691. X    register int i, j, k;
  1692. X    register double db;
  1693. X    for (i=0; i<3; i++) 
  1694. X        for (j=0; j<3; j++) {
  1695. X            for (k=0, db=0.0; k<3; k++)
  1696. X                db += A[i][k] * B[k][j];
  1697. X            C[i][j] = db;
  1698. X        }
  1699. X}
  1700. SHAR_EOF
  1701. $TOUCH -am 0604152590 font.c &&
  1702. chmod 0666 font.c ||
  1703. echo "restore of font.c failed"
  1704. set `wc -c font.c`;Wc_c=$1
  1705. if test "$Wc_c" != "20937"; then
  1706.     echo original size 20937, current size $Wc_c
  1707. fi
  1708. echo "End of part 3, continue with part 4"
  1709. exit 0
  1710.