aboutsummaryrefslogtreecommitdiff
path: root/sys/psio/psfont.x
blob: ca91b719fddb5c8767a782ae098c462725d8e605 (plain) (blame)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include <syserr.h>
include <psset.h>
include "psio.h"


# PS_SETFONT -- Set the font to be used.

procedure ps_setfont (ps, font)

pointer	ps					#I PSIO descriptor
int	font					#I font type

int	old_font
char	old_font_ch, ps_fontchar()
errchk	syserr

begin
	old_font = PS_CFONT(ps)
	old_font_ch = PS_CFONT_CH(ps)

	switch (font) {
	case F_ROMAN:
	    PS_CFONT(ps) = F_ROMAN
	    PS_CFONT_CH(ps) = 'R'
	    call fprintf (PS_FD(ps), "R ")
	case F_ITALIC:
	    PS_CFONT(ps) = F_ITALIC
	    PS_CFONT_CH(ps) = 'I'
	    call fprintf (PS_FD(ps), "I ")
	case F_BOLD:
	    PS_CFONT(ps) = F_BOLD
	    PS_CFONT_CH(ps) = 'B'
	    call fprintf (PS_FD(ps), "B ")
	case F_TELETYPE:
	    PS_CFONT(ps) = F_TELETYPE
	    PS_CFONT_CH(ps) = 'T'
	    call fprintf (PS_FD(ps), "T ")
	case F_PREVIOUS:
	    if (PS_SFONT(ps) != NULL) {
	        call fprintf (PS_FD(ps), "%c ")
		    call pargc (ps_fontchar (ps, PS_SFONT(ps)))
	    } else {
	        call fprintf (PS_FD(ps), "%c ")
		    call pargc (ps_fontchar (ps, PS_PFONT(ps)))
	    }
	default:
	    call syserr (SYS_PSFONT)
	}

	PS_PFONT(ps) = old_font
	PS_PFONT_CH(ps) = old_font_ch
end


# PS_SPFONT -- Set the special font to be used.

procedure ps_spfont (ps, font)

pointer	ps					#I PSIO descriptor
int	font					#I font type

errchk	syserr

begin
	if (font == NULL) {
	    PS_SFONT(ps) = NULL
	    PS_SFONT_CH(ps) = EOS
	    call fprintf (PS_FD(ps), "R ")
	    return
	}

	switch (font) {
	case F_ROMAN:
	    PS_SFONT(ps) = F_ROMAN
	    PS_SFONT_CH(ps) = 'R'
	    call fprintf (PS_FD(ps), "R ")
	case F_ITALIC:
	    PS_SFONT(ps) = F_ITALIC
	    PS_SFONT_CH(ps) = 'I'
	    call fprintf (PS_FD(ps), "I ")
	case F_BOLD:
	    PS_SFONT(ps) = F_BOLD
	    PS_SFONT_CH(ps) = 'B'
	    call fprintf (PS_FD(ps), "B ")
	case F_TELETYPE:
	    PS_SFONT(ps) = F_TELETYPE
	    PS_SFONT_CH(ps) = 'T'
	    call fprintf (PS_FD(ps), "T ")
	default:
	    call syserr (SYS_PSSPFONT)
	}
end


# PS_GETFONT -- Given the font character in a "\fN" string return the font
# type code. 

int procedure ps_getfont (ps, font_char)

pointer	ps					#I PSIO descriptor
char	font_char				#I font type character

begin
	switch (font_char) {
	case 'R':
	    return (F_ROMAN)
	case 'B':
	    return (F_BOLD)
	case 'I':
	    return (F_ITALIC)
	case 'T':
	    return (F_TELETYPE)
	case 'P':
	    return (F_PREVIOUS)
	default:
	    return (PS_CFONT(ps))
	}
end


# PS_FONTCHAR -- Given the font code return the character for it.

char procedure ps_fontchar (ps, font)

pointer	ps					#I PSTIO descriptor
int	font					#I font type character

begin
	switch (font) {
	case F_ROMAN:
	    return ('R')
	case F_BOLD:
	    return ('B')
	case F_ITALIC:
	    return ('I')
	case F_TELETYPE:
	    return ('T')
	case F_PREVIOUS:
	    return ('P')
	default:
	    return (PS_CFONT_CH(ps))
	}
end