FS2_Open
Open source remastering of the Freespace 2 engine
font.cpp File Reference
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#include "bmpman/bmpman.h"
#include "cfile/cfile.h"
#include "globalincs/def_files.h"
#include "globalincs/systemvars.h"
#include "graphics/2d.h"
#include "graphics/font.h"
#include "io/key.h"
#include "localization/localize.h"
#include "palman/palman.h"
#include "parse/parselo.h"

Go to the source code of this file.

Functions

int gr_force_fit_string (char *str, int max_str, int max_width)
 
int get_char_width (ubyte c1, ubyte c2, int *width, int *spacing)
 
int get_centered_x (const char *s, bool scaled)
 
void gr_char_centered (int x, int y, char chr, ubyte sc1, int resize_mode)
 
void gr_print_timestamp (int x, int y, fix timestamp, int resize_mode)
 
int gr_get_font_height ()
 
void gr_get_string_size (int *w1, int *h1, const char *text, int len)
 
void _cdecl gr_printf (int x, int y, const char *format,...)
 
void _cdecl gr_printf_menu (int x, int y, const char *format,...)
 
void _cdecl gr_printf_menu_zoomed (int x, int y, const char *format,...)
 
void _cdecl gr_printf_no_resize (int x, int y, const char *format,...)
 
void gr_font_close ()
 
int gr_create_font (char *typeface)
 
int gr_get_current_fontnum ()
 
int gr_get_fontnum (const char *filename)
 
void gr_set_font (int fontnum)
 
void parse_fonts_tbl (char *only_parse_first_font, size_t only_parse_first_font_size)
 
void gr_stuff_first_font (char *first_font, size_t first_font_size)
 
void gr_font_init ()
 

Variables

int Num_fonts = 0
 
font Fonts [MAX_FONTS]
 
fontCurrent_font = NULL
 
char grx_printf_text [2048]
 

Function Documentation

int get_centered_x ( const char *  s,
bool  scaled 
)

Definition at line 114 of file font.cpp.

int get_char_width ( ubyte  c1,
ubyte  c2,
int width,
int spacing 
)

Takes the character BEFORE being offset into current font

Returns
the letter code

Definition at line 75 of file font.cpp.

void gr_char_centered ( int  x,
int  y,
char  chr,
ubyte  sc1,
int  resize_mode 
)

Draws a character centered on x

Definition at line 129 of file font.cpp.

int gr_create_font ( char *  typeface)
Returns
-1 if couldn't init font, otherwise returns the font id number.

Definition at line 401 of file font.cpp.

void gr_font_close ( )

Definition at line 356 of file font.cpp.

void gr_font_init ( )

Definition at line 699 of file font.cpp.

int gr_force_fit_string ( char *  str,
int  max_str,
int  max_width 
)

Crops a string if required to force it to not exceed max_width pixels when printed. Does this by dropping characters at the end of the string and adding '...' to the end.

Parameters
strstring to crop. Modifies this string directly
max_strmax characters allowed in str
max_widthnumber of pixels to limit string to (less than or equal to).
Returns
Returns the width of the string as given by gr_get_string_size().

Definition at line 48 of file font.cpp.

int gr_get_current_fontnum ( )

Definition at line 545 of file font.cpp.

int gr_get_font_height ( )

Definition at line 187 of file font.cpp.

int gr_get_fontnum ( const char *  filename)

Definition at line 554 of file font.cpp.

void gr_get_string_size ( int w1,
int h1,
const char *  text,
int  len 
)

Definition at line 196 of file font.cpp.

void gr_print_timestamp ( int  x,
int  y,
fix  timestamp,
int  resize_mode 
)

Definition at line 143 of file font.cpp.

void _cdecl gr_printf ( int  x,
int  y,
const char *  format,
  ... 
)

Definition at line 300 of file font.cpp.

void _cdecl gr_printf_menu ( int  x,
int  y,
const char *  format,
  ... 
)

Definition at line 314 of file font.cpp.

void _cdecl gr_printf_menu_zoomed ( int  x,
int  y,
const char *  format,
  ... 
)

Definition at line 328 of file font.cpp.

void _cdecl gr_printf_no_resize ( int  x,
int  y,
const char *  format,
  ... 
)

Definition at line 342 of file font.cpp.

void gr_set_font ( int  fontnum)

Definition at line 566 of file font.cpp.

void gr_stuff_first_font ( char *  first_font,
size_t  first_font_size 
)

Definition at line 694 of file font.cpp.

void parse_fonts_tbl ( char *  only_parse_first_font,
size_t  only_parse_first_font_size 
)

Definition at line 580 of file font.cpp.

Variable Documentation

font * Current_font = NULL

Definition at line 36 of file font.cpp.

font Fonts[MAX_FONTS]

Definition at line 35 of file font.cpp.

char grx_printf_text[2048]

Definition at line 298 of file font.cpp.

int Num_fonts = 0

Definition at line 34 of file font.cpp.