summaryrefslogtreecommitdiff
path: root/graphics/hpgl2ps/textps.c
blob: 035df13cbb1434346bf44389c6e529a5c187ee1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "defn.h"

#define MAXBUFSIZE 100

textps(type)
int     type;
{
    char    string[4];
    char    buffer[MAXBUFSIZE];
    float   Xch, Ych;
    int	    intval;
    int     i;

    end_draw();

    if (type == TEXT)
    {
	for (i = 0 ; i < MAXBUFSIZE; i++)	/* Clear buffer */
	    buffer[i] = NULL;

	i = 0;					/* Reset buffer counter */

	while (((ch = getc(stream)) != EOF)
			&& ch != CR && ch != LF && ch != EOL)
	{
	    buffer[i++] = ch;
/*	    printf("%g %g 1 %g (%c) Text\n", absX, absY, char_angle, ch);
 *	    absX += (char_width + char_space) * cos(char_angle * deg_rad);
 *	    absY += (char_width + char_space) * sin(char_angle * deg_rad);
 */
	}
	printf("%g %g 1 %g (%s) Text\n", absX, absY, char_angle, buffer);
    } else			/* Must be a MARK */
    {
	int     symb_num;

	if (SIGNED_NUMERIC)
	    symb_num = getval();
	else
	{
	    fprintf(stderr,
		    "Error: expecting a symbol number not %c (%d)",
		    symb_num, symb_num);
	    exit(1);
	}
	intval = (int)(getval() + 0.5);
	switch (intval)
	{
	case 0:
	    strcpy(string, "*");
	    break;

	case 1:
	    strcpy(string, "+");
	    break;

	case 2:
	    strcpy(string, "#");
	    break;

	case 3:
	    strcpy(string, "@");
	    break;

	case 4:
	    strcpy(string, "%");
	    break;

	case 5:
	    strcpy(string, "|");
	    break;

	case 6:
	    strcpy(string, "=");
	    break;

	case 7:
	    strcpy(string, "&");
	    break;

	case 9:
	    strcpy(string, "O");
	    break;

	case 10:
	    strcpy(string, "0");
	    break;

	case 11:
	    strcpy(string, "Y");
	    break;

	case 12:
	    strcpy(string, "X");
	    break;

	case 13:
	    strcpy(string, "Z");
	    break;

	case 14:
	    strcpy(string, "S");
	    break;

	case 15:
	    strcpy(string, "Q");
	    break;

	default:
	    fprintf(stderr, "Warning symbol number is %d\n", symb_num);
	    strcpy(string, "*");
	    break;
	}
	printf("%g %g 5 %g (%s) Text\n", absX, absY, char_angle, string);
    }
}