FS2_Open
Open source remastering of the Freespace 2 engine
font.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifdef _WIN32
13 #include <windows.h>
14 #include <windowsx.h>
15 #endif
16 
17 #include <stdio.h>
18 #include <stdarg.h>
19 #include <limits.h>
20 
21 #include "bmpman/bmpman.h"
22 #include "cfile/cfile.h"
23 #include "globalincs/def_files.h"
24 #include "globalincs/systemvars.h"
25 #include "graphics/2d.h"
26 #include "graphics/font.h"
27 #include "io/key.h"
28 #include "localization/localize.h"
29 #include "palman/palman.h"
30 #include "parse/parselo.h"
31 
32 
33 
34 int Num_fonts = 0;
37 
38 
48 int gr_force_fit_string(char *str, int max_str, int max_width)
49 {
50  int w;
51 
52  gr_get_string_size(&w, NULL, str);
53  if (w > max_width) {
54  if ((int) strlen(str) > max_str - 3) {
55  Assert(max_str >= 3);
56  str[max_str - 3] = 0;
57  }
58 
59  strcpy(str + strlen(str) - 1, "...");
60  gr_get_string_size(&w, NULL, str);
61  while (w > max_width) {
62  Assert(strlen(str) >= 4); // if this is hit, a bad max_width was passed in and the calling function needs fixing.
63  strcpy(str + strlen(str) - 4, "...");
64  gr_get_string_size(&w, NULL, str);
65  }
66  }
67 
68  return w;
69 }
70 
75 int get_char_width(ubyte c1,ubyte c2,int *width,int *spacing)
76 {
77  int i, letter;
78 
79  Assert ( Current_font != NULL );
80  letter = c1-Current_font->first_ascii;
81 
82  if (letter<0 || letter>=Current_font->num_chars) { //not in font, draw as space
83  *width=0;
84  *spacing = Current_font->w;
85  return -1;
86  }
87 
88  *width = Current_font->char_data[letter].byte_width;
89  *spacing = Current_font->char_data[letter].spacing;
90 
91  i = Current_font->char_data[letter].kerning_entry;
92  if ( i > -1) {
93  if (!(c2==0 || c2=='\n')) {
94  int letter2;
95 
96  letter2 = c2-Current_font->first_ascii;
97 
98  if ((letter2>=0) && (letter2<Current_font->num_chars) ) { //not in font, draw as space
99  font_kernpair *k = &Current_font->kern_data[i];
100  while( (k->c1 == (char)letter) && (k->c2<(char)letter2) && (i<Current_font->num_kern_pairs-1) ) {
101  i++;
102  k++;
103  }
104  if ( k->c2 == (char)letter2 ) {
105  *spacing += k->offset;
106  }
107  }
108  }
109  }
110  return letter;
111 }
112 
113 // NOTE: this returns an unscaled size for non-standard resolutions
114 int get_centered_x(const char *s, bool scaled)
115 {
116  int w,w2,s2;
117 
118  for (w=0;*s!=0 && *s!='\n';s++) {
119  get_char_width(s[0],s[1],&w2,&s2);
120  w += s2;
121  }
122 
123  return (((scaled ? gr_screen.clip_width : gr_screen.clip_width_unscaled) - w) / 2);
124 }
125 
129 void gr_char_centered(int x, int y, char chr, ubyte sc1, int resize_mode)
130 {
131  char str[2];
132  int w;
133 
134  if (chr == '1')
135  chr = (char)sc1;
136 
137  str[0] = chr;
138  str[1] = 0;
139  gr_get_string_size(&w, NULL, str);
140  gr_string(x - w / 2, y, str, resize_mode);
141 }
142 
143 void gr_print_timestamp(int x, int y, fix timestamp, int resize_mode)
144 {
145  char h[2], m[3], s[3];
146  int w, c, font_num;
147  ubyte sc;
148 
149  int time = (int)f2fl(timestamp); // convert to seconds
150 
151  // format the time information into strings
152  sprintf(h, "%.1d", (time / 3600));
153  sprintf(m, "%.2d", (time / 60) % 60);
154  sprintf(s, "%.2d", time % 60);
155 
156  gr_get_string_size(&w, NULL, "0");
157  gr_get_string_size(&c, NULL, ":");
158 
159  gr_string(x + w, y, ":", resize_mode);
160  gr_string(x + w * 3 + c, y, ":", resize_mode);
161 
162  font_num = gr_get_current_fontnum();
163  if (font_num == -1) {
164  Warning(LOCATION, "Font not set - timestamps may not work correctly");
165  sc = 0;
166  } else {
167  sc = lcl_get_font_index(font_num);
168  }
169  if (sc == 0) {
170  sc = ubyte ('1'); // make do with non-mono-spaced 1
171  } else {
172  sc += 1;
173  }
174 
175  x += w / 2;
176  gr_char_centered(x, y, h[0], sc, resize_mode);
177  x += w + c;
178  gr_char_centered(x, y, m[0], sc, resize_mode);
179  x += w;
180  gr_char_centered(x, y, m[1], sc, resize_mode);
181  x += w + c;
182  gr_char_centered(x, y, s[0], sc, resize_mode);
183  x += w;
184  gr_char_centered(x, y, s[1], sc, resize_mode);
185 }
186 
188 {
189  if (Current_font) {
190  return Current_font->h;
191  } else {
192  return 16;
193  }
194 }
195 
196 void gr_get_string_size(int *w1, int *h1, const char *text, int len)
197 {
198  int longest_width;
199  int width,spacing;
200  int w, h;
201 
202  if (!Current_font) {
203  if ( w1)
204  *w1 = 16;
205 
206  if ( h1 )
207  *h1 = 16;
208 
209  return;
210  }
211 
212  w = 0;
213  h = 0;
214  longest_width = 0;
215 
216  if (text != NULL ) {
217  h += Current_font->h;
218  while (*text && (len>0) ) {
219 
220  // Process one or more
221  while ((*text == '\n') && (len>0) ) {
222  text++;
223  len--;
224  if ( *text ) {
225  h += Current_font->h;
226  }
227  w = 0;
228  }
229 
230  if (*text == 0) {
231  break;
232  }
233 
234  get_char_width(text[0], text[1], &width, &spacing);
235  w += spacing;
236  if (w > longest_width)
237  longest_width = w;
238 
239  text++;
240  len--;
241  }
242  }
243 
244  if ( h1 )
245  *h1 = h;
246 
247  if ( w1 )
248  *w1 = longest_width;
249 }
250 
251 
252 MONITOR( FontChars )
253 
254 #ifdef _WIN32
255 HFONT MyhFont = NULL;
256 HDC hDibDC = NULL;
257 
258 void gr_string_win(int x, int y, const char *s)
259 {
260  int old_bitmap = gr_screen.current_bitmap;
262  gr_string(x,y,s);
263  gr_screen.current_bitmap = old_bitmap;
264 }
265 
266 void gr_get_string_size_win(int *w, int *h, const char *text)
267 {
268  const char *ptr;
269  SIZE size;
270 
271  ptr = strchr(text, '\n');
272 
273  if (MyhFont==NULL) {
274  if (w) *w = 0;
275  if (h) *h = 0;
276  return;
277  }
278 
279  SelectObject( hDibDC, MyhFont );
280 
281  if (!ptr) {
282  GetTextExtentPoint32( hDibDC, text, strlen(text), &size);
283  if (w) *w = size.cx;
284  if (h) *h = size.cy;
285  return;
286  }
287 
288  GetTextExtentPoint32(hDibDC, text, ptr - text, &size);
289  gr_get_string_size_win(w, h, ptr+1);
290  if (w && (size.cx > *w) )
291  *w = size.cx;
292 
293  if (h)
294  *h += size.cy;
295 }
296 #endif // ifdef _WIN32
297 
298 char grx_printf_text[2048];
299 
300 void _cdecl gr_printf( int x, int y, const char * format, ... )
301 {
302  va_list args;
303 
304  if ( !Current_font ) return;
305 
306  va_start(args, format);
307  vsnprintf(grx_printf_text, sizeof(grx_printf_text)-1, format, args);
308  va_end(args);
309  grx_printf_text[sizeof(grx_printf_text)-1] = '\0';
310 
311  gr_string(x,y,grx_printf_text);
312 }
313 
314 void _cdecl gr_printf_menu( int x, int y, const char * format, ... )
315 {
316  va_list args;
317 
318  if ( !Current_font ) return;
319 
320  va_start(args, format);
321  vsnprintf(grx_printf_text, sizeof(grx_printf_text)-1, format, args);
322  va_end(args);
323  grx_printf_text[sizeof(grx_printf_text)-1] = '\0';
324 
325  gr_string(x,y,grx_printf_text,GR_RESIZE_MENU);
326 }
327 
328 void _cdecl gr_printf_menu_zoomed( int x, int y, const char * format, ... )
329 {
330  va_list args;
331 
332  if ( !Current_font ) return;
333 
334  va_start(args, format);
335  vsnprintf(grx_printf_text, sizeof(grx_printf_text)-1, format, args);
336  va_end(args);
337  grx_printf_text[sizeof(grx_printf_text)-1] = '\0';
338 
339  gr_string(x,y,grx_printf_text,GR_RESIZE_MENU_ZOOMED);
340 }
341 
342 void _cdecl gr_printf_no_resize( int x, int y, const char * format, ... )
343 {
344  va_list args;
345 
346  if ( !Current_font ) return;
347 
348  va_start(args, format);
349  vsnprintf(grx_printf_text, sizeof(grx_printf_text)-1, format, args);
350  va_end(args);
351  grx_printf_text[sizeof(grx_printf_text)-1] = '\0';
352 
353  gr_string(x,y,grx_printf_text,GR_RESIZE_NONE);
354 }
355 
357 {
358  font *fnt;
359  int i;
360 
361  fnt = Fonts;
362 
363  for (i=0; i<Num_fonts; i++) {
364  if (fnt->kern_data) {
365  vm_free(fnt->kern_data);
366  fnt->kern_data = NULL;
367  }
368 
369  if (fnt->char_data) {
370  vm_free(fnt->char_data);
371  fnt->char_data = NULL;
372  }
373 
374  if (fnt->pixel_data) {
375  vm_free(fnt->pixel_data);
376  fnt->pixel_data = NULL;
377  }
378 
379  if (fnt->bm_data) {
380  vm_free(fnt->bm_data);
381  fnt->bm_data = NULL;
382  }
383 
384  if (fnt->bm_u) {
385  vm_free(fnt->bm_u);
386  fnt->bm_u = NULL;
387  }
388 
389  if (fnt->bm_v) {
390  vm_free(fnt->bm_v);
391  fnt->bm_v = NULL;
392  }
393 
394  fnt++;
395  }
396 }
397 
401 int gr_create_font(char * typeface)
402 {
403  CFILE *fp;
404  font *fnt;
405  int n, fontnum;
406 
407  fnt = Fonts;
408  n = -1;
409  for (fontnum=0; fontnum<Num_fonts; fontnum++ ) {
410  if (fnt->id != 0 ) {
411  if ( !_strnicmp( fnt->filename, typeface, MAX_FILENAME_LEN ) ) {
412  return fontnum;
413  }
414  } else {
415  if ( n < 0 ) {
416  n = fontnum;
417  }
418  }
419  fnt++;
420  }
421 
422  if ( fontnum == MAX_FONTS ) {
423  Warning( LOCATION, "Too many fonts!\nSee John, or change MAX_FONTS in Graphics\\Font.h\n" );
424  return -1;
425  }
426 
427  if ( fontnum == Num_fonts ) {
428  Num_fonts++;
429  }
430 
431  bool localize = true;
432 
433  fp = cfopen( typeface, "rb", CFILE_NORMAL, CF_TYPE_ANY, localize );
434  if ( fp == NULL ) return -1;
435 
436  strcpy_s( fnt->filename, typeface );
437  cfread( &fnt->id, 4, 1, fp );
438  cfread( &fnt->version, sizeof(int), 1, fp );
439  cfread( &fnt->num_chars, sizeof(int), 1, fp );
440  cfread( &fnt->first_ascii, sizeof(int), 1, fp );
441  cfread( &fnt->w, sizeof(int), 1, fp );
442  cfread( &fnt->h, sizeof(int), 1, fp );
443  cfread( &fnt->num_kern_pairs, sizeof(int), 1, fp );
444  cfread( &fnt->kern_data_size, sizeof(int), 1, fp );
445  cfread( &fnt->char_data_size, sizeof(int), 1, fp );
446  cfread( &fnt->pixel_data_size, sizeof(int), 1, fp );
447 
448  fnt->id = INTEL_SHORT( fnt->id ); //-V570
449  fnt->version = INTEL_INT( fnt->version ); //-V570
450  fnt->num_chars = INTEL_INT( fnt->num_chars ); //-V570
451  fnt->first_ascii = INTEL_INT( fnt->first_ascii ); //-V570
452  fnt->w = INTEL_INT( fnt->w ); //-V570
453  fnt->h = INTEL_INT( fnt->h ); //-V570
454  fnt->num_kern_pairs = INTEL_INT( fnt->num_kern_pairs ); //-V570
455  fnt->kern_data_size = INTEL_INT( fnt->kern_data_size ); //-V570
456  fnt->char_data_size = INTEL_INT( fnt->char_data_size ); //-V570
457  fnt->pixel_data_size = INTEL_INT( fnt->pixel_data_size ); //-V570
458 
459  if ( fnt->kern_data_size ) {
461  Assert(fnt->kern_data!=NULL);
462  cfread( fnt->kern_data, fnt->kern_data_size, 1, fp );
463  } else {
464  fnt->kern_data = NULL;
465  }
466  if ( fnt->char_data_size ) {
467  fnt->char_data = (font_char *)vm_malloc( fnt->char_data_size );
468  Assert( fnt->char_data != NULL );
469  cfread( fnt->char_data, fnt->char_data_size, 1, fp );
470 
471  for (int i=0; i<fnt->num_chars; i++) {
472  fnt->char_data[i].spacing = INTEL_INT( fnt->char_data[i].spacing ); //-V570
473  fnt->char_data[i].byte_width = INTEL_INT( fnt->char_data[i].byte_width ); //-V570
474  fnt->char_data[i].offset = INTEL_INT( fnt->char_data[i].offset ); //-V570
475  fnt->char_data[i].kerning_entry = INTEL_INT( fnt->char_data[i].kerning_entry ); //-V570
476  fnt->char_data[i].user_data = INTEL_SHORT( fnt->char_data[i].user_data ); //-V570
477  }
478  } else {
479  fnt->char_data = NULL;
480  }
481  if ( fnt->pixel_data_size ) {
482  fnt->pixel_data = (ubyte *)vm_malloc( fnt->pixel_data_size );
483  Assert(fnt->pixel_data!=NULL);
484  cfread( fnt->pixel_data, fnt->pixel_data_size, 1, fp );
485  } else {
486  fnt->pixel_data = NULL;
487  }
488  cfclose(fp);
489 
490  // Create a bitmap for hardware cards.
491  // JAS: Try to squeeze this into the smallest square power of two texture.
492  // This should probably be done at font generation time, not here.
493  int w, h;
494  if ( fnt->pixel_data_size*4 < 64*64 ) {
495  w = h = 64;
496  } else if ( fnt->pixel_data_size*4 < 128*128 ) {
497  w = h = 128;
498  } else if ( fnt->pixel_data_size*4 < 256*256 ) {
499  w = h = 256;
500  } else if ( fnt->pixel_data_size*4 < 512*512 ) {
501  w = h = 512;
502  } else {
503  w = h = 1024;
504  }
505 
506  fnt->bm_w = w;
507  fnt->bm_h = h;
508  fnt->bm_data = (ubyte *)vm_malloc(fnt->bm_w*fnt->bm_h);
509  fnt->bm_u = (int *)vm_malloc(sizeof(int)*fnt->num_chars);
510  fnt->bm_v = (int *)vm_malloc(sizeof(int)*fnt->num_chars);
511 
512  memset( fnt->bm_data, 0, fnt->bm_w * fnt->bm_h );
513 
514  int i,x,y;
515  x = y = 0;
516  for (i=0; i<fnt->num_chars; i++ ) {
517  ubyte * ubp;
518  int x1, y1;
519  ubp = &fnt->pixel_data[fnt->char_data[i].offset];
520  if ( x + fnt->char_data[i].byte_width >= fnt->bm_w ) {
521  x = 0;
522  y += fnt->h + 2;
523  if ( y+fnt->h > fnt->bm_h ) {
524  Error( LOCATION, "Font too big!\n" );
525  }
526  }
527  fnt->bm_u[i] = x;
528  fnt->bm_v[i] = y;
529 
530  for( y1=0; y1<fnt->h; y1++ ) {
531  for (x1=0; x1<fnt->char_data[i].byte_width; x1++ ) {
532  uint c = *ubp++;
533  if ( c > 14 ) c = 14;
534  fnt->bm_data[(x+x1)+(y+y1)*fnt->bm_w] = (unsigned char)(c);
535  }
536  }
537  x += fnt->char_data[i].byte_width + 2;
538  }
539 
540  fnt->bitmap_id = bm_create( 8, fnt->bm_w, fnt->bm_h, fnt->bm_data, BMP_AABITMAP );
541 
542  return fontnum;
543 }
544 
546 {
547  if (Current_font == NULL) {
548  return -1;
549  } else {
550  return (Current_font - &Fonts[0]);
551  }
552 }
553 
554 int gr_get_fontnum(const char *filename)
555 {
556  int i;
557  for(i = 0; i < Num_fonts; i++)
558  {
559  if(!strextcmp(Fonts[i].filename, filename))
560  return i;
561  }
562 
563  return -1;
564 }
565 
566 void gr_set_font(int fontnum)
567 {
568  if ( fontnum < 0 ) {
569  Current_font = NULL;
570  Lcl_special_chars = 0;
571  return;
572  }
573 
574  if ( fontnum >= 0 && fontnum < Num_fonts) {
575  Current_font = &Fonts[fontnum];
577  }
578 }
579 
580 void parse_fonts_tbl(char *only_parse_first_font, size_t only_parse_first_font_size)
581 {
582  int i;
583  char *filename;
584 
585  // choose file name
586  // (this can be done within the function, as opposed to being passed as a parameter,
587  // because fonts.tbl doesn't have a modular counterpart)
588  if ( cf_exists_full("fonts.tbl", CF_TYPE_TABLES) ) {
589  filename = "fonts.tbl";
590  } else {
591  filename = NULL;
592  }
593 
594  try
595  {
596  if (filename != NULL) {
597  read_file_text(filename, CF_TYPE_TABLES);
598  }
599  else {
601  }
602 
603  reset_parse();
604 
605  // start parsing
606  required_string("#Fonts");
607 
608  // read fonts
609  while (required_string_either("#End", "$Font:")) {
610  char font_filename[MAX_FILENAME_LEN];
611 
612  // grab font
613  required_string("$Font:");
614  stuff_string(font_filename, F_NAME, MAX_FILENAME_LEN);
615 
616  // if we only need the first font, copy it and bail
617  if (only_parse_first_font != NULL) {
618  strcpy_s(only_parse_first_font, only_parse_first_font_size, font_filename);
619  return;
620  }
621 
622  // create font
623  int font_id = gr_create_font(font_filename);
624  if (font_id < 0) {
625  Warning(LOCATION, "Could not create font from typeface '%s'!", font_filename);
626  skip_to_start_of_string_either("#End", "$Font:");
627  }
628  else {
629  // max allowed special char index; i.e. 7 special chars in retail fonts 1 & 3
630  static const int MAX_SPECIAL_CHAR_IDX = UCHAR_MAX - 6;
631 
632  // 'default' special char index for all languages using this font
633  int default_special_char_index = 0;
634  if (optional_string("+Default Special Character Index:")) {
635  stuff_int(&default_special_char_index);
636 
637  if (default_special_char_index < 0 || default_special_char_index >= MAX_SPECIAL_CHAR_IDX) {
638  Error(LOCATION, "Default special character index (%d) for font (%s), must be 0 - %u", default_special_char_index, font_filename, MAX_SPECIAL_CHAR_IDX);
639  }
640 
641  for (i = 0; i < (int)Lcl_languages.size(); ++i) {
642  Lcl_languages[i].special_char_indexes[font_id] = (ubyte)default_special_char_index;
643  }
644  }
645 
646  while (optional_string("+Language:")) {
647  char lang_name[LCL_LANG_NAME_LEN + 1];
648  int special_char_index, lang_idx = -1;
649 
650  stuff_string(lang_name, F_NAME, LCL_LANG_NAME_LEN + 1);
651 
652  // find language and set the index, or if not found move to the next one
653  for (i = 0; i < (int)Lcl_languages.size(); ++i) {
654  if (!strcmp(Lcl_languages[i].lang_name, lang_name)) {
655  lang_idx = i;
656  break;
657  }
658  }
659 
660  if (lang_idx == -1) {
661  Warning(LOCATION, "Ignoring invalid language (%s) specified by font (%s); not built-in or in strings.tbl", lang_name, font_filename);
662  skip_to_start_of_string_either("+Language:", "$Font:", "#End");
663  continue;
664  }
665 
666  if (optional_string("+Special Character Index:")) {
667  stuff_int(&special_char_index);
668 
669  if (special_char_index < 0 || special_char_index >= MAX_SPECIAL_CHAR_IDX) {
670  Error(LOCATION, "Special character index (%d) for font (%s), language (%s) is invalid, must be 0 - %u", special_char_index, font_filename, lang_name, MAX_SPECIAL_CHAR_IDX);
671  }
672 
673  Lcl_languages[lang_idx].special_char_indexes[font_id] = (ubyte)special_char_index;
674  }
675  }
676  }
677  }
678 
679  // done parsing
680  required_string("#End");
681 
682  // double check
683  if (Num_fonts < 3) {
684  Error(LOCATION, "There must be at least three fonts in %s!", (filename) ? filename : NOX("<default fonts.tbl>"));
685  }
686  }
687  catch (const parse::ParseException& e)
688  {
689  mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", (filename) ? filename : NOX("<default fonts.tbl>"), e.what()));
690  return;
691  }
692 }
693 
694 void gr_stuff_first_font(char *first_font, size_t first_font_size )
695 {
696  parse_fonts_tbl( first_font, first_font_size );
697 }
698 
700 {
701  parse_fonts_tbl( NULL, 0 );
702  gr_set_font(0);
703 }
GLenum GLsizei GLenum format
Definition: Gl.h:1509
void parse_fonts_tbl(char *only_parse_first_font, size_t only_parse_first_font_size)
Definition: font.cpp:580
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
int gr_get_fontnum(const char *filename)
Definition: font.cpp:554
int timestamp(int delta_ms)
Definition: timer.cpp:226
int gr_get_current_fontnum()
Definition: font.cpp:545
#define CFILE_NORMAL
Definition: cfile.h:89
void _cdecl gr_printf(int x, int y, const char *format,...)
Definition: font.cpp:300
int i
Definition: multi_pxo.cpp:466
#define vm_free(ptr)
Definition: pstypes.h:548
int pixel_data_size
Definition: font.h:47
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
void gr_char_centered(int x, int y, char chr, ubyte sc1, int resize_mode)
Definition: font.cpp:129
void gr_string_win(int x, int y, const char *s)
#define GR_RESIZE_MENU
Definition: 2d.h:684
int gr_get_font_height()
Definition: font.cpp:187
int cfread(void *buf, int elsize, int nelem, CFILE *fp)
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
Definition: Glext.h:7779
int get_char_width(ubyte c1, ubyte c2, int *width, int *spacing)
Definition: font.cpp:75
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
Assert(pm!=NULL)
int clip_width_unscaled
Definition: 2d.h:379
SCP_vector< lang_info > Lcl_languages
Definition: localize.cpp:32
#define mprintf(args)
Definition: pstypes.h:238
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:769
void gr_font_close()
Definition: font.cpp:356
#define INTEL_SHORT(x)
Definition: pstypes.h:389
int char_data_size
Definition: font.h:46
const char * defaults_get_file(const char *filename)
Definition: def_files.cpp:103
Definition: cfile.h:28
int first_ascii
Definition: font.h:41
#define f2fl(fx)
Definition: floating.h:37
void gr_print_timestamp(int x, int y, fix timestamp, int resize_mode)
Definition: font.cpp:143
int gr_create_font(char *typeface)
Definition: font.cpp:401
GLsizeiptr size
Definition: Glext.h:5496
void gr_font_init()
Definition: font.cpp:699
int required_string_either(char *str1, char *str2)
Checks for one of two required strings.
Definition: parselo.cpp:673
#define GR_RESIZE_NONE
Definition: 2d.h:681
int byte_width
Definition: font.h:25
#define BMP_AABITMAP
antialiased bitmap
Definition: bmpman.h:52
void gr_get_string_size_win(int *w, int *h, const char *text)
GLint GLsizei width
Definition: Gl.h:1505
int strextcmp(const char *s1, const char *s2)
Definition: parselo.cpp:4013
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
Definition: font.h:36
void _cdecl gr_printf_menu(int x, int y, const char *format,...)
Definition: font.cpp:314
int spacing
Definition: font.h:24
unsigned int uint
Definition: pstypes.h:64
#define cfopen(...)
Definition: cfile.h:134
font_kernpair * kern_data
Definition: font.h:48
ubyte * bm_data
Definition: font.h:55
int cf_exists_full(const char *filename, int dir_type)
Definition: cfile.cpp:527
int kern_data_size
Definition: font.h:45
font * Current_font
Definition: font.cpp:36
int * bm_v
Definition: font.h:57
char * filename
#define MAX_FONTS
Definition: font.h:17
void _cdecl gr_printf_no_resize(int x, int y, const char *format,...)
Definition: font.cpp:342
char c2
Definition: font.h:32
void stuff_string(char *outstr, int type, int len, char *terminators)
Definition: parselo.cpp:1189
#define w(p)
Definition: modelsinc.h:68
#define CF_TYPE_TABLES
Definition: cfile.h:50
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
short kerning_entry
Definition: font.h:27
int required_string(const char *pstr)
Definition: parselo.cpp:468
ubyte * pixel_data
Definition: font.h:50
GLdouble s
Definition: Glext.h:5321
int w
Definition: font.h:42
int optional_string(const char *pstr)
Definition: parselo.cpp:539
#define MONITOR(function_name)
Definition: pstypes.h:454
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
Definition: parselo.cpp:1995
int skip_to_start_of_string_either(char *pstr1, char *pstr2, char *end)
Definition: parselo.cpp:433
short user_data
Definition: font.h:28
cfbp fp
Definition: cfile.cpp:1065
int offset
Definition: font.h:26
int id
Definition: font.h:38
void gr_stuff_first_font(char *first_font, size_t first_font_size)
Definition: font.cpp:694
font Fonts[MAX_FONTS]
Definition: font.cpp:35
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
long fix
Definition: pstypes.h:54
GLclampd n
Definition: Glext.h:7286
unsigned char ubyte
Definition: pstypes.h:62
int h
Definition: font.h:43
int bm_create(int bpp, int w, int h, void *data, int flags)
Definition: bmpman.cpp:469
void read_file_text_from_array(const char *array, char *processed_text, char *raw_text)
Definition: parselo.cpp:2022
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
Definition: font.h:23
#define NOX(s)
Definition: pstypes.h:473
int get_centered_x(const char *s, bool scaled)
Definition: font.cpp:114
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
ubyte lcl_get_font_index(int font_num)
Definition: localize.cpp:495
#define vm_malloc(size)
Definition: pstypes.h:547
void reset_parse(char *text)
Definition: parselo.cpp:3305
#define INTEL_INT(x)
Definition: pstypes.h:388
#define _strnicmp(s1, s2, n)
Definition: config.h:273
void stuff_int(int *i)
Definition: parselo.cpp:2372
int bm_h
Definition: font.h:54
char c1
Definition: font.h:32
#define FONT1
Definition: font.h:65
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
char grx_printf_text[2048]
Definition: font.cpp:298
void gr_get_string_size(int *w1, int *h1, const char *text, int len)
Definition: font.cpp:196
int version
Definition: font.h:39
int Num_fonts
Definition: font.cpp:34
int gr_force_fit_string(char *str, int max_str, int max_width)
Definition: font.cpp:48
int clip_width
Definition: 2d.h:378
screen gr_screen
Definition: 2d.cpp:46
int bitmap_id
Definition: font.h:53
#define F_NAME
Definition: parselo.h:34
#define LCL_LANG_NAME_LEN
Definition: localize.h:31
#define LOCATION
Definition: pstypes.h:245
int num_kern_pairs
Definition: font.h:44
const GLfloat * m
Definition: Glext.h:10319
int * bm_u
Definition: font.h:56
GLenum GLsizei len
Definition: Glext.h:6283
int Lcl_special_chars
Definition: localize.cpp:43
int cfclose(CFILE *cfile)
Definition: cfile.cpp:895
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
Definition: Glext.h:7779
void gr_set_font(int fontnum)
Definition: font.cpp:566
#define CF_TYPE_ANY
Definition: cfile.h:42
void _cdecl gr_printf_menu_zoomed(int x, int y, const char *format,...)
Definition: font.cpp:328
#define _cdecl
Definition: config.h:71
int num_chars
Definition: font.h:40
const GLubyte * c
Definition: Glext.h:8376
font_char * char_data
Definition: font.h:49
GLint y
Definition: Gl.h:1505
signed char offset
Definition: font.h:33
#define strcpy_s(...)
Definition: safe_strings.h:67
int current_bitmap
Definition: 2d.h:395
char filename[MAX_FILENAME_LEN]
Definition: font.h:37
#define GR_RESIZE_MENU_ZOOMED
Definition: 2d.h:685
int bm_w
Definition: font.h:54