-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfonts.h
224 lines (180 loc) · 4.3 KB
/
fonts.h
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#ifndef __fonts_h
#define __fonts_h 1
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <Xm/Xm.h>
#include <math.h>
#define FONTINFO_SUCCESS 1
#define FONTINFO_EMPTY 100
#define FONTINFO_FAIL 102
#define FONTINFO_NO_FILE 104
#define FONTINFO_NO_FONT 106
#define FONTINFO_NO_MEM 108
#define FONTINFO_SYNTAX 110
#define FONTINFO_BADSPEC 112
#define FONTINFO_TOOMANYSIZES 114
#define FONTINFO_MISSINGBRACE 116
#define FONTINFO_GROUPSYNTAX 118
#define FONTINFO_UNSUPPORTED 120
#define fontInfoClass_str1 (char *) "Error from avl_get_first\n"
#define fontInfoClass_str2 (char *) "Error from avl_get_next\n"
#define fontInfoClass_str3 (char *) "Expected default site font near line %-d\n"
#define fontInfoClass_str4 (char *) "Expected default text create font near line %-d\n"
#define fontInfoClass_str5 (char *) "Font file syntax error near line %-d\n"
#define fontInfoClass_str6 (char *) "No fonts were specified\n"
#define fontInfoClass_str7 (char *) "To many font sizes at line %-d\n"
#define fontInfoClass_str8 (char *) "No such font available: [%s]\n"
#define fontInfoClass_str9 (char *) "Last line processed: %-d\n"
#define fontInfoClass_str10 (char *) "Missing \"}\" in font group definition\n"
#define fontInfoClass_str11 (char *) "Internal error at line %-d in file %s\n"
#define fontInfoClass_str12 (char *) "Font group syntax error near line %-d\n"
#define fontInfoClass_str13 (char *) "Warning - duplicate font tag name: [%s], from line: %-d\n"
typedef struct fontNameListTag {
struct fontNameListTag *flink;
XFontStruct *fontStruct;
char *fullName;
char *name;
char *family;
int size;
float fsize;
char weight; // m or b
char slant; // r or i
char isScalable;
char fontLoaded;
int ascent;
int descent;
int height;
} fontNameListType, *fontNameListPtr;
typedef struct sizeListTag {
struct sizeListTag *flink;
int size;
float fsize;
} sizeListType, *sizeListPtr;
typedef struct familyListTag {
struct familyListTag *flink;
sizeListPtr sizeHead;
sizeListPtr sizeTail;
char *name;
} familyListType, *familyListPtr;
class fontInfoClass {
public:
fontInfoClass ( void ); // constructor
~fontInfoClass ( void ); // destructor
int InitializeXt( void );
char *getStrFromFile (
char *str,
int maxLen,
FILE *f
);
int parseFontSpec (
char *fontSpec,
char *foundary,
char *family,
char *weight,
char *slant,
char *pixelSize );
int resolveFont (
char *fontSpec,
fontNameListPtr ptr );
void setMediumString (
char *str
);
void setBoldString (
char *str
);
void setRegularString (
char *str
);
void setItalicString (
char *str
);
int resolveFont (
char *fontSpec,
char *userFontFamilyName,
fontNameListPtr ptr );
int resolveOneFont (
char *fontSpec,
fontNameListPtr ptr );
int checkSingleFontSpecGeneric (
XtAppContext app,
Display *d,
char *userFontFamilyName,
char *line,
int checkBestFont,
int major,
int minor,
int release );
int checkSingleFontSpec (
XtAppContext app,
Display *d,
char *userFontFamilyName,
char *line,
int major,
int minor,
int release );
int checkBestSingleFontSpec (
XtAppContext app,
Display *d,
char *userFontFamilyName,
char *line,
int major,
int minor,
int release );
int getSingleFontSpec (
XtAppContext app,
Display *d,
char *userFontFamilyName,
char *buf,
int major,
int minor,
int release );
int flushToBrace (
FILE *f );
int processFontGroup (
XtAppContext app,
Display *d,
char *userFontFamilyName,
FILE *f,
int major,
int minor,
int release );
int initFromFileVer3 (
XtAppContext app,
Display *d,
FILE *f,
int major,
int minor,
int release );
int initFromFile (
XtAppContext app,
Display *d,
const char *fileName );
XFontStruct *getXFontStruct (
char *name );
XmFontList getXmFontList ( void );
int loadFontTag (
char *name );
int getTextFontList (
char *name,
XmFontList *fontList );
int textWidth (
char *name,
char *string );
char *bestFittingFont (
int height );
int lineIsDefaultFontTag( const char * line );
private:
int initOK;
XmFontList fontList;
int fontListEmpty;
char mediumString[63+1], boldString[63+1], regularString[63+1],
italicString[63+1];
int lineNum, lastNonCommentLine;
int requireExactMatch;
Display *display;
XtAppContext appCtx;
};
extern const char * fontFileName;
#endif