54 if ((
int) strlen(str) > max_str - 3) {
59 strcpy(str + strlen(str) - 1,
"...");
61 while (w > max_width) {
63 strcpy(str + strlen(str) - 4,
"...");
79 Assert ( Current_font != NULL );
82 if (letter<0 || letter>=Current_font->
num_chars) {
84 *spacing = Current_font->
w;
93 if (!(c2==0 || c2==
'\n')) {
98 if ((letter2>=0) && (letter2<Current_font->num_chars) ) {
100 while( (k->
c1 == (
char)letter) && (k->
c2<(
char)letter2) && (i<Current_font->num_kern_pairs-1) ) {
104 if ( k->
c2 == (
char)letter2 ) {
118 for (w=0;*s!=0 && *s!=
'\n';s++) {
140 gr_string(x - w / 2, y, str, resize_mode);
145 char h[2],
m[3],
s[3];
149 int time = (
int)
f2fl(timestamp);
152 sprintf(h,
"%.1d", (time / 3600));
153 sprintf(m,
"%.2d", (time / 60) % 60);
160 gr_string(x + w * 3 + c, y,
":", resize_mode);
163 if (font_num == -1) {
190 return Current_font->
h;
217 h += Current_font->
h;
218 while (*text && (len>0) ) {
221 while ((*text ==
'\n') && (len>0) ) {
225 h += Current_font->
h;
236 if (w > longest_width)
255 HFONT MyhFont = NULL;
271 ptr = strchr(text,
'\n');
279 SelectObject( hDibDC, MyhFont );
282 GetTextExtentPoint32( hDibDC, text, strlen(text), &size);
288 GetTextExtentPoint32(hDibDC, text, ptr - text, &size);
290 if (w && (size.cx > *w) )
296 #endif // ifdef _WIN32
304 if ( !Current_font )
return;
306 va_start(args, format);
307 vsnprintf(grx_printf_text,
sizeof(grx_printf_text)-1, format, args);
318 if ( !Current_font )
return;
320 va_start(args, format);
321 vsnprintf(grx_printf_text,
sizeof(grx_printf_text)-1, format, args);
332 if ( !Current_font )
return;
334 va_start(args, format);
335 vsnprintf(grx_printf_text,
sizeof(grx_printf_text)-1, format, args);
346 if ( !Current_font )
return;
348 va_start(args, format);
349 vsnprintf(grx_printf_text,
sizeof(grx_printf_text)-1, format, args);
409 for (fontnum=0; fontnum<
Num_fonts; fontnum++ ) {
423 Warning(
LOCATION,
"Too many fonts!\nSee John, or change MAX_FONTS in Graphics\\Font.h\n" );
427 if ( fontnum == Num_fonts ) {
431 bool localize =
true;
434 if ( fp == NULL )
return -1;
441 cfread( &fnt->
w,
sizeof(
int), 1, fp );
442 cfread( &fnt->
h,
sizeof(
int), 1, fp );
523 if ( y+fnt->
h > fnt->
bm_h ) {
530 for( y1=0; y1<fnt->
h; y1++ ) {
533 if ( c > 14 ) c = 14;
534 fnt->
bm_data[(x+x1)+(y+y1)*fnt->
bm_w] = (
unsigned char)(c);
547 if (Current_font == NULL) {
550 return (Current_font - &Fonts[0]);
559 if(!
strextcmp(Fonts[i].filename, filename))
574 if ( fontnum >= 0 && fontnum <
Num_fonts) {
575 Current_font = &Fonts[fontnum];
589 filename =
"fonts.tbl";
596 if (filename != NULL) {
617 if (only_parse_first_font != NULL) {
618 strcpy_s(only_parse_first_font, only_parse_first_font_size, font_filename);
625 Warning(
LOCATION,
"Could not create font from typeface '%s'!", font_filename);
630 static const int MAX_SPECIAL_CHAR_IDX = UCHAR_MAX - 6;
633 int default_special_char_index = 0;
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);
648 int special_char_index, lang_idx = -1;
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);
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);
684 Error(
LOCATION,
"There must be at least three fonts in %s!", (filename) ? filename :
NOX(
"<default fonts.tbl>"));
689 mprintf((
"TABLES: Unable to parse '%s'! Error message = %s.\n", (filename) ? filename :
NOX(
"<default fonts.tbl>"), e.what()));
GLenum GLsizei GLenum format
void parse_fonts_tbl(char *only_parse_first_font, size_t only_parse_first_font_size)
int gr_get_fontnum(const char *filename)
int timestamp(int delta_ms)
int gr_get_current_fontnum()
void _cdecl gr_printf(int x, int y, const char *format,...)
GLfloat GLfloat GLfloat GLfloat h
void gr_char_centered(int x, int y, char chr, ubyte sc1, int resize_mode)
void gr_string_win(int x, int y, const char *s)
int cfread(void *buf, int elsize, int nelem, CFILE *fp)
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
int get_char_width(ubyte c1, ubyte c2, int *width, int *spacing)
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
SCP_vector< lang_info > Lcl_languages
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
const char * defaults_get_file(const char *filename)
void gr_print_timestamp(int x, int y, fix timestamp, int resize_mode)
int gr_create_font(char *typeface)
int required_string_either(char *str1, char *str2)
Checks for one of two required strings.
#define BMP_AABITMAP
antialiased bitmap
void gr_get_string_size_win(int *w, int *h, const char *text)
int strextcmp(const char *s1, const char *s2)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
void _cdecl gr_printf_menu(int x, int y, const char *format,...)
font_kernpair * kern_data
int cf_exists_full(const char *filename, int dir_type)
void _cdecl gr_printf_no_resize(int x, int y, const char *format,...)
void stuff_string(char *outstr, int type, int len, char *terminators)
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
int required_string(const char *pstr)
int optional_string(const char *pstr)
#define MONITOR(function_name)
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
int skip_to_start_of_string_either(char *pstr1, char *pstr2, char *end)
void gr_stuff_first_font(char *first_font, size_t first_font_size)
GLint GLint GLint GLint GLint x
int bm_create(int bpp, int w, int h, void *data, int flags)
void read_file_text_from_array(const char *array, char *processed_text, char *raw_text)
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
int get_centered_x(const char *s, bool scaled)
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)
void reset_parse(char *text)
#define _strnicmp(s1, s2, n)
GLubyte GLubyte GLubyte GLubyte w
char grx_printf_text[2048]
void gr_get_string_size(int *w1, int *h1, const char *text, int len)
int gr_force_fit_string(char *str, int max_str, int max_width)
#define LCL_LANG_NAME_LEN
int cfclose(CFILE *cfile)
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
void gr_set_font(int fontnum)
void _cdecl gr_printf_menu_zoomed(int x, int y, const char *format,...)
char filename[MAX_FILENAME_LEN]
#define GR_RESIZE_MENU_ZOOMED