001: /* s_test.c */
002: 
003: short S_FONT_SP[] = { 0 };
004: short S_FONT_A[] = { 4,     0,    0,  1000,    0,  1000, 3000,     0, 3414,
005:                      4,  1000, 1000,  3000, 1000,  3000, 2000,  1000, 2000,
006:                      4,  3000,    0,  4000,    0,  4000, 3414,  3000, 3000,
007:                      4,     0, 3414,  1000, 3000,  2000, 4000,  1586, 5000,
008:                      4,  3000, 3000,  4000, 3414,  2414, 5000,  2000, 4000,
009:                      3,  2000, 4000,  2414, 5000,  1586, 5000,
010:                      0 };
011: short S_FONT_B[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
012:                      4,  1000,    0,  3000,    0,  4000, 1000,  1000, 1000,
013:                      4,  1000, 4000,  4000, 4000,  3000, 5000,  1000, 5000,
014:                      4,  1000, 2000,  3000, 2000,  3000, 3000,  1000, 3000,
015:                      4,  3000, 1000,  3500, 1000,  3500, 4000,  3000, 4000,
016:                      4,  3500, 1000,  4000, 1000,  4000, 2000,  3500, 2500,
017:                      4,  3500, 2500,  4000, 3000,  4000, 4000,  3500, 4000,
018:                      0 };
019: short S_FONT_C[] = { 4,     0, 1000,  1000,    0,  1000, 5000,     0, 4000,
020:                      4,  1000, 4000,  4000, 4000,  3000, 5000,  1000, 5000,
021:                      4,  1000,    0,  3000,    0,  4000, 1000,  1000, 1000,
022:                      0 };
023: short S_FONT_D[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
024:                      4,  1000,    0,  3000,    0,  4000, 1000,  1000, 1000,
025:                      4,  1000, 4000,  4000, 4000,  3000, 5000,  1000, 5000,
026:                      4,  3000, 1000,  4000, 1000,  4000, 4000,  3000, 4000,
027:                      0 };
028: short S_FONT_E[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
029:                      4,  1000,    0,  4000,    0,  4000, 1000,  1000, 1000,
030:                      4,  1000, 2000,  3000, 2000,  3000, 3000,  1000, 3000,
031:                      4,  1000, 4000,  4000, 4000,  4000, 5000,  1000, 5000,
032:                      0 };
033: short S_FONT_F[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
034:                      4,  1000, 2000,  3000, 2000,  3000, 3000,  1000, 3000,
035:                      4,  1000, 4000,  4000, 4000,  4000, 5000,  1000, 5000,
036:                      0 };
037: short S_FONT_G[] = { 4,     0, 1000,  1000,    0,  1000, 5000,     0, 4000,
038:                      4,  1000, 4000,  4000, 4000,  3000, 5000,  1000, 5000,
039:                      4,  1000,    0,  3000,    0,  3000, 1000,  1000, 1000,
040:                      4,  3000,    0,  4000,    0,  4000, 2000,  3000, 2000,
041:                      4,  2000, 2000,  4000, 2000,  4000, 3000,  2000, 3000,
042:                      0 };
043: short S_FONT_H[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
044:                      4,  3000,    0,  4000,    0,  4000, 5000,  3000, 5000,
045:                      4,  1000, 2000,  3000, 2000,  3000, 3000,  1000, 3000,
046:                      0 };
047: short S_FONT_I[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
048:                      0 };
049: short S_FONT_J[] = { 4,     0, 4000,  4000, 4000,  4000, 5000,     0, 5000,
050:                      4,  1000,    0,  3000,    0,  4000, 1000,     0, 1000,
051:                      4,  3000, 1000,  4000, 1000,  4000, 4000,  3000, 4000,
052:                      0 };
053: short S_FONT_L[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
054:                      4,  1000,    0,  3500,    0,  3500, 1000,  1000, 1000,
055:                      0 };
056: short S_FONT_N[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
057:                      4,  3000,    0,  4000,    0,  4000, 5000,  3000, 5000,
058:                      4,  1000, 2833,  3000,  500,  3000, 2167,  1000, 4500,
059:                      0 };
060: short S_FONT_O[] = { 4,     0, 1000,  1000,    0,  1000, 5000,     0, 4000,
061:                      4,  3000,    0,  4000, 1000,  4000, 4000,  3000, 5000,
062:                      4,  1000,    0,  3000,    0,  3000, 1000,  1000, 1000,
063:                      4,  1000, 4000,  3000, 4000,  3000, 5000,  1000, 5000,
064:                      0 };
065: short S_FONT_P[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
066:                      4,  1000, 2000,  3000, 2000,  4000, 3000,  1000, 3000,
067:                      4,  1000, 4000,  4000, 4000,  3000, 5000,  1000, 5000,
068:                      4,  3000, 3000,  4000, 3000,  4000, 4000,  3000, 4000,
069:                      0 };
070: short S_FONT_R[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
071:                      4,  1000, 2000,  3000, 2000,  4000, 3000,  1000, 3000,
072:                      4,  1000, 4000,  4000, 4000,  3000, 5000,  1000, 5000,
073:                      4,  3000, 3000,  4000, 3000,  4000, 4000,  3000, 4000,
074:                      4,  2750,    0,  4000,    0,  2500, 2000,  1250, 2000,
075:                      0 };
076: short S_FONT_S[] = { 4,     0, 4000,  4000, 4000,  3000, 5000,  1000, 5000,
077:                      4,  1000, 2000,  4000, 2000,  3000, 3000,     0, 3000,
078:                      4,  1000,    0,  3000,    0,  4000, 1000,     0, 1000,
079:                      4,  3000, 1000,  4000, 1000,  4000, 2000,  3000, 2000,
080:                      4,     0, 3000,  1000, 3000,  1000, 4000,     0, 4000,
081:                      0 };
082: short S_FONT_K[] = { 4,     0,    0,  1000,    0,  1000, 5000,     0, 5000,
083:                      4,  1000, 1000,  4000, 4000,  3586, 5000,  1000, 2414,
084:                      3,  4000, 4000,  4000, 5000,  3586, 5000,
085:                      4,  1500, 1500,  3000,    0,  4000,  414,  2207, 2207,
086:                      3,  3000,    0,  4000,    0,  4000,  414,
087:                      0 };
088: short S_FONT_T[] = { 4,  1500,    0,  2500,    0,  2500, 4000,  1500, 4000,
089:                      4,     0, 4000,  4000, 4000,  4000, 5000,     0, 5000,
090:                      0 };
091: short S_FONT_U[] = { 4,     0, 1000,  1000,    0,  1000, 5000,     0, 5000,
092:                      4,  3000,    0,  4000, 1000,  4000, 5000,  3000, 5000,
093:                      4,  1000,    0,  3000,    0,  3000, 1000,  1000, 1000,
094:                      0 };
095: short S_FONT_V[] = { 4,  1213,    0,  2000, 1000,  1029, 5000,     0, 5000,
096:                      4,  2000, 1000,  2786,    0,  4000, 5000,  2971, 5000,
097:                      3,  1213,    0,  2786,    0,  2000, 1000,
098:                      0 };
099: short S_FONT_W[] = { 4,     0, 1000,  1000,    0,  1000, 5000,     0, 5000,
100:                      4,  1000,    0,  2000,    0,  2000, 1000,  1000, 1000,
101:                      4,  2000,    0,  2500,  500,  2500, 4000,  2000, 4000,
102:                      4,  2500,  500,  3000,    0,  3000, 4000,  2500, 4000,
103:                      4,  3000,    0,  4000,    0,  4000, 1000,  3000, 1000,
104:                      4,  4000,    0,  5000, 1000,  5000, 5000,  4000, 5000,
105:                      0 };
106: short S_FONT_e[] = { 4,     0, 3000,  3000, 3000,  2000, 4000,  1000, 4000,
107:                      4,     0, 1500,  3000, 1500,  3000, 2500,     0, 2500,
108:                      4,  1000,    0,  2000,    0,  3000, 1000,     0, 1000,
109:                      4,     0, 1000,  1000, 1000,  1000, 1500,     0, 1500,
110:                      4,     0, 2500,  1000, 2500,  1000, 3000,     0, 3000,
111:                      4,  2000, 2500,  3000, 2500,  3000, 3000,  2000, 3000,
112:                      0 };
113: short S_FONT_i[] = { 4,     0,    0,  1000,    0,  1000, 3500,     0, 3500,
114:                      4,     0, 4000,  1000, 4000,  1000, 5000,     0, 5000,
115:                      0 };
116: short S_FONT_n[] = { 4,     0,    0,  1000,    0,  1000, 4000,     0, 4000,
117:                      4,  1000, 3000,  2000, 3000,  2000, 4000,  1000, 4000,
118:                      4,  2000,    0,  3000,    0,  3000, 3000,  2000, 4000,
119:                      0 };
120: short S_FONT_o[] = { 4,     0, 3000,  3000, 3000,  2000, 4000,  1000, 4000,
121:                      4,  1000,    0,  2000,    0,  3000, 1000,     0, 1000,
122:                      4,  2000, 1000,  3000, 1000,  3000, 3000,  2000, 3000,
123:                      4,     0, 1000,  1000, 1000,  1000, 3000,     0, 3000,
124:                      0 };
125: short S_FONT_p[] = { 4,     0,-1000,  1000,-1000,  1000, 4000,     0, 4000,
126:                      4,  1000,    0,  2000,    0,  3000, 1000,  1000, 1000,
127:                      4,  1000, 3000,  3000, 3000,  2000, 4000,  1000, 4000,
128:                      4,  2000, 1000,  3000, 1000,  3000, 3000,  2000, 3000,
129:                      0 };
130: short S_FONT_r[] = { 4,     0,    0,  1000,    0,  1000, 4000,     0, 4000,
131:                      4,  1000, 3000,  2500, 3000,  2500, 3500,  1000, 3500,
132:                      4,  1000, 3500,  2500, 3500,  2000, 4000,  1500, 4000,
133:                      0 };
134: short S_FONT_s[] = { 4,     0, 3000,  3000, 3000,  2000, 4000,  1000, 4000,
135:                      4,  1000, 1500,  3000, 1500,  2000, 2500,     0, 2500,
136:                      4,  1000,    0,  2000,    0,  3000, 1000,     0, 1000,
137:                      4,  2000, 1000,  3000, 1000,  3000, 1500,  2000, 1500,
138:                      4,     0, 2500,  1000, 2500,  1000, 3000,     0, 3000,
139:                      0 };
140: short S_FONT_pkt[] = { 4,     0,    0,  1000,    0,  1000, 1000,     0, 1000, 
141:                        0 };
142: short S_FONT_komma[] = { 4,     0,-1000,  1000,    0,  1000, 1000,     0, 1000, 
143:                          0 };
144: short S_FONT_minus[] = { 4,     0, 1500,  3000, 1500,  3000, 2500,     0, 1500, 
145:                          0 };
146: short S_FONT_0[] = { 4,     0, 1000,  1000,    0,  1000, 5000,     0, 4000,
147:                      4,  2000,    0,  3000, 1000,  3000, 4000,  2000, 5000,
148:                      4,  1000,    0,  2000,    0,  2000, 1000,  1000, 1000,
149:                      4,  1000, 4000,  2000, 4000,  2000, 5000,  1000, 5000,
150:                      0 };
151: short S_FONT_1[] = { 4,  1000, 1000,  2000, 1000,  2000, 4000,  1000, 4000,
152:                      4,     0,    0,  3000,    0,  3000, 1000,     0, 1000,
153:                      4,     0, 4000,  2000, 4000,  2000, 5000,  1000, 5000,
154:                      0 };
155: short S_FONT_2[] = { 4,     0, 4000,  3000, 4000,  2000, 5000,  1000, 5000,
156:                      4,     0, 2000,  2000, 2000,  3000, 3000,  1000, 3000,
157:                      4,     0,    0,  3000,    0,  3000, 1000,     0, 1000,
158:                      4,     0, 1000,  1000, 1000,  1000, 2000,     0, 2000,
159:                      4,  2000, 3000,  3000, 3000,  3000, 4000,  2000, 4000,
160:                      0 };
161: short S_FONT_3[] = { 4,     0, 4000,  3000, 4000,  2000, 5000,  1000, 5000,
162:                      4,  1000,    0,  2000,    0,  3000, 1000,     0, 1000,
163:                      4,   500, 2000,  2000, 2000,  2000, 3000,   500, 3000,
164:                      4,  2000, 1000,  2500, 1000,  2500, 4000,  2000, 4000,
165:                      4,  2500, 1000,  3000, 1000,  3000, 2000,  2500, 2500,
166:                      4,  2500, 2500,  3000, 3000,  3000, 4000,  2500, 4000,
167:                      0 };
168: short S_FONT_4[] = { 4,     0, 1000,  3000, 1000,  3000, 2000,     0, 2000,
169:                      4,  1500,    0,  2500,    0,  2500, 1000,  1500, 1000,
170:                      4,  1500, 2000,  2500, 2000,  2500, 3000,  1500, 3000,
171:                      4,     0, 2000,  1000, 2000,  1000, 3000,     0, 3414,
172:                      4,     0, 3414,  1000, 3000,  3000, 5000,  1586, 5000,
173:                      0 };
174: short S_FONT_5[] = { 4,     0, 4000,  3000, 4000,  3000, 5000,     0, 5000,
175:                      4,     0, 2500,  3000, 2500,  2000, 3500,     0, 3500,
176:                      4,  1000,    0,  2000,    0,  3000, 1000,     0, 1000,
177:                      4,     0, 3500,  1000, 3500,  1000, 4000,     0, 4000,
178:                      4,  2000, 1000,  3000, 1000,  3000, 2500,  2000, 2500,
179:                      0 };
180: short S_FONT_6[] = { 4,     0, 4000,  3000, 4000,  2000, 5000,  1000, 5000,
181:                      4,  1000,    0,  2000,    0,  3000, 1000,     0, 1000,
182:                      4,     0, 1000,  1000, 1000,  1000, 4000,     0, 4000,
183:                      4,  1000, 2500,  3000, 2500,  2000, 3500,  1000, 3500,
184:                      4,  2000, 1000,  3000, 1000,  3000, 2500,  2000, 2500,
185:                      0 };
186: short S_FONT_7[] = { 4,     0, 4000,  3000, 4000,  3000, 5000,     0, 5000,
187:                      4,     0, 3500,  1000, 3500,  1000, 4000,     0, 4000,
188:                      4,  2000, 3303,  3000, 3000,  3000, 4000,  2000, 4000,
189:                      4,  1000,    0,  3000, 3000,  2000, 3303,     0,  303,
190:                      3,     0,    0,  1000,    0,     0,  303,
191:                      0 };
192: short S_FONT_8[] = { 4,     0, 4000,  3000, 4000,  2000, 5000,  1000, 5000,
193:                      4,  1000,    0,  2000,    0,  3000, 1000,     0, 1000,
194:                      4,  2000, 1000,  2500, 1000,  2500, 4000,  2000, 4000,
195:                      4,  2500, 1000,  3000, 1000,  3000, 2000,  2500, 2500,
196:                      4,  2500, 2500,  3000, 3000,  3000, 4000,  2500, 4000,
197:                      4,   500, 1000,  1000, 1000,  1000, 4000,   500, 4000,
198:                      4,     0, 1000,   500, 1000,   500, 2500,     0, 2000,
199:                      4,     0, 3000,   500, 2500,   500, 4000,     0, 4000,
200:                      4,  1000, 2000,  2000, 2000,  2000, 3000,  1000, 3000,
201:                      0 };
202: short S_FONT_9[] = { 4,     0, 4000,  3000, 4000,  2000, 5000,  1000, 5000,
203:                      4,  1000,    0,  2000,    0,  3000, 1000,     0, 1000,
204:                      4,  2000, 1000,  3000, 1000,  3000, 4000,  2000, 4000,
205:                      4,  1000, 1500,  2000, 1500,  2000, 2500,     0, 2500,
206:                      4,     0, 2500,  1000, 2500,  1000, 4000,     0, 4000,
207:                      0 };
208: 
209: struct {
210:   wchar_t Zeichen;
211:   short   Breite, *Flaechen;
212: } S_FONT[] = {
213:   { ' '   , 3000, S_FONT_SP },
214:   { 'A'   , 4000, S_FONT_A },
215:   { 'B'   , 4000, S_FONT_B },
216:   { 'C'   , 4000, S_FONT_C },
217:   { 'D'   , 4000, S_FONT_D },
218:   { 'E'   , 4000, S_FONT_E },
219:   { 'F'   , 4000, S_FONT_F },
220:   { 'G'   , 4000, S_FONT_G },
221:   { 'H'   , 4000, S_FONT_H },
222:   { 'I'   , 1000, S_FONT_I },
223:   { 'J'   , 4000, S_FONT_J },
224:   { 'K'   , 4000, S_FONT_K },
225:   { 'L'   , 3500, S_FONT_L },
226:   { 'N'   , 4000, S_FONT_N },
227:   { 'O'   , 4000, S_FONT_O },
228:   { 'P'   , 4000, S_FONT_P },
229:   { 'R'   , 4000, S_FONT_R },
230:   { 'S'   , 4000, S_FONT_S },
231:   { 'T'   , 4000, S_FONT_T },
232:   { 'U'   , 4000, S_FONT_U },
233:   { 'V'   , 4000, S_FONT_V },
234:   { 'W'   , 5000, S_FONT_W },
235:   { 'e'   , 3000, S_FONT_e },
236:   { 'i'   , 1000, S_FONT_i },
237:   { 'n'   , 3000, S_FONT_n },
238:   { 'o'   , 3000, S_FONT_o },
239:   { 'p'   , 3000, S_FONT_p },
240:   { 'r'   , 2500, S_FONT_r },
241:   { 's'   , 3000, S_FONT_s },
242:   { '.'   , 1000, S_FONT_pkt },
243:   { ','   , 1000, S_FONT_komma },
244:   { '-'   , 3000, S_FONT_minus },
245:   { '0'   , 3000, S_FONT_0 },
246:   { '1'   , 3000, S_FONT_1 },
247:   { '2'   , 3000, S_FONT_2 },
248:   { '3'   , 3000, S_FONT_3 },
249:   { '4'   , 3000, S_FONT_4 },
250:   { '5'   , 3000, S_FONT_5 },
251:   { '6'   , 3000, S_FONT_6 },
252:   { '7'   , 3000, S_FONT_7 },
253:   { '8'   , 3000, S_FONT_8 },
254:   { '9'   , 3000, S_FONT_9 },
255:   { 0xffff,   -1, NULL }
256: };
257: 
258: float S_FONT_stringwidth(float Versalhoehe, float x_scale, wchar_t *Text)
259: { long wsum;
260:   int ct, p;
261:   wsum = (wcslen(Text) - 1) * 1000;
262:   if (wsum < 0) wsum = 0;
263:   for (ct = 0; Text[ct]; ct++) {
264:     p = 0;
265:     while ((p >= 0) && (S_FONT[p].Zeichen != 0xffff)) {
266:       if (S_FONT[p].Zeichen == Text[ct]) {
267:         wsum += (long) S_FONT[p].Breite;
268:         p = -1;
269:       } else {
270:         p++;
271:       }
272:     }
273:   }
274:   return (0.0002F * wsum * Versalhoehe * x_scale);
275: }
276: 
277: void S_FONT_strokechar(float Versalhoehe, float x_scale, float x, float y, float z,
278:                        long start, short *Fl, int fill)
279: { int p;
280:   for (p = 0; Fl[p];) {
281:     switch (Fl[p]) {
282:       case 0: return;
283:       case 3:
284:         if (fill) glBegin(GL_TRIANGLES); else glBegin(GL_LINE_LOOP);
285:         glNormal3f(0.0, 0.0, 1.0);
286:         glVertex3f(x + 0.0002F * Versalhoehe * (start + Fl[p + 1]) * x_scale,
287:                    y + 0.0002F * Versalhoehe * Fl[p + 2],
288:                    z);
289:         glVertex3f(x + 0.0002F * Versalhoehe * (start + Fl[p + 3]) * x_scale,
290:                    y + 0.0002F * Versalhoehe * Fl[p + 4],
291:                    z);
292:         glVertex3f(x + 0.0002F * Versalhoehe * (start + Fl[p + 5]) * x_scale,
293:                    y + 0.0002F * Versalhoehe * Fl[p + 6],
294:                    z);
295:         glEnd();
296:         break;
297:       case 4:
298:         if (fill) glBegin(GL_QUADS); else glBegin(GL_LINE_LOOP);
299:         glNormal3f(0.0, 0.0, 1.0);
300:         glVertex3f(x + 0.0002F * Versalhoehe * (start + Fl[p + 1]) * x_scale,
301:                    y + 0.0002F * Versalhoehe * Fl[p + 2],
302:                    z);
303:         glVertex3f(x + 0.0002F * Versalhoehe * (start + Fl[p + 3]) * x_scale,
304:                    y + 0.0002F * Versalhoehe * Fl[p + 4],
305:                    z);
306:         glVertex3f(x + 0.0002F * Versalhoehe * (start + Fl[p + 5]) * x_scale,
307:                    y + 0.0002F * Versalhoehe * Fl[p + 6],
308:                    z);
309:         glVertex3f(x + 0.0002F * Versalhoehe * (start + Fl[p + 7]) * x_scale,
310:                    y + 0.0002F * Versalhoehe * Fl[p + 8],
311:                    z);
312:         glEnd();
313:         break;
314:     }
315:     p += 1 + 2 * Fl[p];
316:   }
317: }
318: 
319: void S_FONT_stroketext(float Versalhoehe, float x_scale,
320:                        float x, float y, float z, wchar_t *Text, int fill)
321: { long wsum;
322:   int ct, p;
323:   wsum = 0;
324:   for (ct = 0; Text[ct]; ct++) {
325:     p = 0;
326:     while ((p >= 0) && (S_FONT[p].Zeichen != 0xffff)) {
327:       if (S_FONT[p].Zeichen == Text[ct]) {
328:         S_FONT_strokechar(Versalhoehe, x_scale, x, y, z, wsum, S_FONT[p].Flaechen, fill);
329:         wsum += (long) S_FONT[p].Breite;
330:         p = -1;
331:       } else {
332:         p++;
333:       }
334:     }
335:     wsum += 1000;
336:   }
337: }