Files
fs2open.github.com/code/graphics/font.h
T
wmcoolmon fb94960327 WMC codebase commit. See pre-commit build thread for details on changes.
git-svn-id: svn://svn.icculus.org/fs2open/trunk/fs2_open@3821 387891d4-d844-0410-90c0-e4c51a9137d3
2015-04-29 18:42:42 +10:00

185 lines
5.1 KiB
C

/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
/*
* $Logfile: /Freespace2/code/Graphics/Font.h $
* $Revision: 2.6 $
* $Date: 2006-12-28 00:59:26 $
* $Author: wmcoolmon $
*
* header file for font stuff
*
* $Log: not supported by cvs2svn $
* Revision 2.5 2006/09/11 06:36:38 taylor
* clean up the grstub mess (for work on standalone server, and just for sanity sake)
* move color and shader functions to 2d.cpp since they are exactly the same everywhere
* don't bother with the function pointer for gr_set_font(), it's the same everywhere anyway
*
* Revision 2.4 2005/07/13 02:50:47 Goober5000
* remove PreProcDefine #includes in FS2
* --Goober5000
*
* Revision 2.3 2004/08/11 05:06:24 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.2 2002/08/01 01:41:05 penguin
* The big include file move
*
* Revision 2.1 2002/07/07 19:55:59 penguin
* Back-port to MSVC
*
* Revision 2.0 2002/06/03 04:02:22 penguin
* Warpcore CVS sync
*
* Revision 1.2 2002/05/03 22:07:08 mharris
* got some stuff to compile
*
* Revision 1.1 2002/05/02 18:03:07 mharris
* Initial checkin - converted filenames and includes to lower case
*
*
* 4 7/09/99 10:32p Dave
* Command brief and red alert screens.
*
* 3 10/13/98 9:28a Dave
* Started neatening up freespace.h. Many variables renamed and
* reorganized. Added AlphaColors.[h,cpp]
*
* 2 10/07/98 10:52a Dave
* Initial checkin.
*
* 1 10/07/98 10:49a Dave
*
* 14 5/25/98 10:32a John
* Took out redundant code for font bitmap offsets that converted to a
* float, then later on converted back to an integer. Quite unnecessary.
*
* 13 3/25/98 8:07p John
* Restructured software rendering into two modules; One for windowed
* debug mode and one for DirectX fullscreen.
*
* 12 3/10/98 4:18p John
* Cleaned up graphics lib. Took out most unused gr functions. Made D3D
* & Glide have popups and print screen. Took out all >8bpp software
* support. Made Fred zbuffer. Made zbuffer allocate dynamically to
* support Fred. Made zbuffering key off of functions rather than one
* global variable.
*
* 11 3/09/98 6:06p John
* Restructured font stuff to avoid duplicate code in Direct3D and Glide.
* Restructured Glide to avoid redundent state setting.
*
* 10 2/19/98 9:04a John
* Fixed fonts with glide
*
* 9 2/17/98 7:27p John
* Got fonts and texturing working in Direct3D
*
* 8 11/30/97 12:18p John
* added more 24 & 32-bpp primitives
*
* 7 11/06/97 5:42p Hoffoss
* Added support for fixed size timstamp rendering.
*
* 6 11/03/97 10:59a John
* added support for more than one font.
*
* 5 10/24/97 12:13p Hoffoss
* Added gr_force_fit_string().
*
* 4 10/09/97 5:23p John
* Added support for more 16-bpp functions
*
* 3 6/05/97 4:53p John
* First rev of new antialiased font stuff.
*
* 2 4/22/97 10:33a John
* fixed the 2d resource leaks that Alan found.
*
* 1 3/31/97 9:42a Allender
*
* $NoKeywords: $
*/
#ifndef _FONT_H
#define _FONT_H
#include "globalincs/pstypes.h"
#define MAX_FONTS 3
#define FONT_VERSION 0
#define WIDEST_DIGIT "4" // the widest number character
#define WIDEST_CHAR "W" // the widest character
typedef struct font_char {
int spacing;
int byte_width;
int offset;
short kerning_entry;
short user_data;
} font_char;
typedef struct font_kernpair {
char c1,c2;
signed char offset;
} font_kernpair;
typedef struct font {
char filename[MAX_FILENAME_LEN];
int id; // Should be 'VFNT'
int version; // font version
int num_chars;
int first_ascii;
int w;
int h;
int num_kern_pairs;
int kern_data_size;
int char_data_size;
int pixel_data_size;
font_kernpair *kern_data;
font_char *char_data;
ubyte *pixel_data;
// Data for 3d cards
int bitmap_id; // A bitmap representing the font data
int bm_w, bm_h; // Bitmap width and height
ubyte *bm_data; // The actual font data
int *bm_u; // U offset of each character
int *bm_v; // V offset of each character
} font;
extern int Num_fonts;
extern font Fonts[MAX_FONTS];
extern font *Current_font;
#define FONT_INDEX(font) (font - &Fonts[0])
#define FONT1 0 // font01.vf
#define FONT2 1 // font02.vf
#define FONT3 2 // font03.vf
// extern definitions for basic font functions
extern int gr_get_fontnum(char *filename);
extern void gr_set_font(int fontnum);
extern void gr8_string(int x,int y,char * text);
void gr_print_timestamp(int x, int y, int timestamp);
char *gr_force_fit_string(char *str, int max_str, int max_width);
void gr_font_init();
void gr_font_close();
extern font * Current_font;
extern int get_char_width(ubyte c1,ubyte c2,int *width,int *spacing);
extern int get_centered_x(char *s);
#endif