/*************************************************************** ** ** Broadcom Corp. Confidential ** Copyright 2002 Broadcom Corp. All Rights Reserved. ** ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED ** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM. ** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT ** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. ** ** Description: BGFX bit map font library ** ** Created: 8/22/2002 by Jeffrey P. Fisher ** ** ** ****************************************************************/ #ifndef __bgfx_font_h__ #define __bgfx_font_h__ #include "bgfx_types.h" /* Uncomment to build with freetype support */ /* #define CONFIG_FREETYPE */ #ifdef CONFIG_FREETYPE #include #include #endif /* CONFIG_FREETYPE */ /* * Definitions */ /* * font flags */ #define BGFX_MONO (1 << 0) #define BGFX_CACHE_GLYPHS (1 << 1) #define BGFX_PRELOAD_GLYPHS (1 << 2) #ifdef __cplusplus extern "C" { #endif /**************************************************************** * Initialize global font management structures. * Called by bgfx_init. ****************************************************************/ int bgfx_font_init(void); /**************************************************************** * Cleanup global font management structures. * Called by bgfx_done. ****************************************************************/ void bgfx_font_done(void); /**************************************************************** * Create a new font give an typeface name and size. * The font_p should be a pointer to an allocated * but uninitialized bgfx_font_t structure. The typeface must be * a valid full path name to the font file. Valid flags can be any * combination of BGFX_MONO,BGFX_CACHE_GLYPHS and BGFX_PRELOAD_GLYPHS * REQUIRES FREETYPE SUPPORT ****************************************************************/ int bgfx_new_font( bgfx_font_t *font_p, /* reference to allocated uninitialized bgfx_font_t structure */ const char *typeface_name, /* full path name of the typeface file */ unsigned char height, /* font size in pixels */ unsigned long flags /* font format and handling flags */ ); /**************************************************************** * Free all resources associated with the font * It is important to free fonts when done using them to return memory * resources consumed by the font cache and Freetype. ****************************************************************/ void bgfx_free_font( bgfx_font_t *font_p /* reference to initialized bgfx_font_t structure */ ); /**************************************************************** * Get a glyph from the glyph cache if it exists or by rendering it * with Freetype * The font_p should be a pointer to an initialized bgfx_font_t structure. * Called internally by bgfx. ****************************************************************/ bgfx_glyph_t *bgfx_get_glyph(bgfx_font_t *font_p, /* reference to initialized bgfx_font_t structure */ unsigned long a_char /* 32-bit unicode character */ ); /**************************************************************** * Calculate the width and height of the null terminated string. * Calculate the bounding rectangle for the null terminated string. ****************************************************************/ void bgfx_string_info(bgfx_font_t *font_p, /* initialized font structure */ const unsigned long *str_p, /* array of single 32-bit unicode characters */ int str_len, /* number of 32-bit characters in string */ int *w, /* width in pixels */ int *h /* height in pixels */ ); /**************************************************************** * Load the entire set of font info and glyph cache from a file. * The file must have been produced by the bgfx_save_font function. * This is the only way to draw text when there is no * Freetype support. ****************************************************************/ int bgfx_load_font(bgfx_font_t *font_p, /* reference to initialized bgfx_font_t structure */ void *file_p /* open initialized file pointer to read font from */ ); /**************************************************************** * External function required to load BGFX bitmap font files. ****************************************************************/ extern long bgfx_read(void *buffer, long size, long count, void *fp ); /**************************************************************** * External functions to lock and unlock access to global data structures * Required for freetype support only ****************************************************************/ #ifdef CONFIG_FREETYPE extern void bgfx_lock(void); extern void bgfx_unlock(void); #endif /* CONFIG_FREETYPE */ #ifdef __cplusplus } #endif #endif /* __bgfx_font_h__ */