Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Typedefs | Functions
unifont.cpp File Reference
#include "precompiled.h"
#include "unifont.h"
#include <stdio.h>
#include <string>
#include <sstream>
#include <map>
#include "ogl_tex.h"
#include "lib/res/h_mgr.h"

Go to the source code of this file.

Classes

struct  UniFont
 

Typedefs

typedef std::map< u16,
UnifontGlyphData
glyphmap
 

Functions

 H_TYPE_DEFINE (UniFont)
 
static void UniFont_init (UniFont *f, va_list args)
 
static void UniFont_dtor (UniFont *f)
 
static Status UniFont_reload (UniFont *f, const PIVFS &vfs, const VfsPath &basename, Handle h)
 
static Status UniFont_validate (const UniFont *f)
 
static Status UniFont_to_string (const UniFont *f, wchar_t *buf)
 
Handle unifont_load (const PIVFS &vfs, const VfsPath &pathname, size_t flags)
 Load a font. More...
 
Status unifont_unload (Handle &h)
 Release a handle to a previously loaded font (subject to reference counting). More...
 
int unifont_linespacing (const Handle h)
 
int unifont_height (const Handle h)
 
bool unifont_has_rgb (const Handle h)
 
int unifont_character_width (const Handle h, wchar_t c)
 
Status unifont_stringsize (const Handle h, const wchar_t *text, int &width, int &height)
 Determine pixel extents of a string. More...
 
const glyphmapunifont_get_glyphs (const Handle h)
 
Handle unifont_get_texture (const Handle h)
 

Typedef Documentation

typedef std::map<u16, UnifontGlyphData> glyphmap

Definition at line 38 of file unifont.cpp.

Function Documentation

H_TYPE_DEFINE ( UniFont  )
int unifont_character_width ( const Handle  h,
wchar_t  c 
)
Returns
width [pixels] of a certain character.

Definition at line 237 of file unifont.cpp.

static void UniFont_dtor ( UniFont f)
static

Definition at line 58 of file unifont.cpp.

const glyphmap& unifont_get_glyphs ( const Handle  h)
Returns
glyph data for all glyphs in this font.

Definition at line 276 of file unifont.cpp.

Handle unifont_get_texture ( const Handle  h)
Returns
texture handle for this font.

Definition at line 289 of file unifont.cpp.

bool unifont_has_rgb ( const Handle  h)
Returns
whether the font is an RGBA texture, not an ALPHA texture.

Definition at line 228 of file unifont.cpp.

int unifont_height ( const Handle  h)
Returns
height [pixels] of the font.

Definition at line 221 of file unifont.cpp.

static void UniFont_init ( UniFont f,
va_list  args 
)
static

Definition at line 54 of file unifont.cpp.

int unifont_linespacing ( const Handle  h)
Returns
spacing in pixels from one line of text to the next.

Definition at line 214 of file unifont.cpp.

Handle unifont_load ( const PIVFS vfs,
const VfsPath pathname,
size_t  flags = 0 
)

Load a font.

Parameters
vfs
pathnamepath and basename of the font definition file (.fnt) and its texture (.png)
flags

Definition at line 201 of file unifont.cpp.

static Status UniFont_reload ( UniFont f,
const PIVFS vfs,
const VfsPath basename,
Handle  h 
)
static

Definition at line 68 of file unifont.cpp.

Status unifont_stringsize ( const Handle  h,
const wchar_t text,
int &  width,
int &  height 
)

Determine pixel extents of a string.

Parameters
h
textstring in question.
width
heightis roughly the pixel height of a capital letter, for use when aligning text in an aesthetically pleasing way.

note: This is intended for the GUI (hence Unicode).

Definition at line 248 of file unifont.cpp.

static Status UniFont_to_string ( const UniFont f,
wchar_t buf 
)
static

Definition at line 188 of file unifont.cpp.

Status unifont_unload ( Handle h)

Release a handle to a previously loaded font (subject to reference counting).

Definition at line 207 of file unifont.cpp.

static Status UniFont_validate ( const UniFont f)
static

Definition at line 175 of file unifont.cpp.