#include <xrb_asciifont.hpp>
Classes | |
struct | GlyphSpecification |
Public Types | |
enum | { TAB_SIZE = 4, RENDERED_GLYPH_LOWEST = ' ', RENDERED_GLYPH_HIGHEST = '~', RENDERED_GLYPH_COUNT = RENDERED_GLYPH_HIGHEST - RENDERED_GLYPH_LOWEST + 1 } |
Public Member Functions | |
virtual | ~AsciiFont () |
Destructor. Deletes the gl texture. | |
bool | CacheToDisk (Texture *font_texture) const |
Writes the font metadata and bitmap to disk. | |
virtual void | MoveThroughGlyph (FontCoordVector2 *pen_position_26_6, ScreenCoordVector2 const &initial_pen_position, char const *current_glyph, char const *next_glyph, Uint32 *remaining_glyph_count=NULL, FontCoord *major_space_26_6=NULL) const |
virtual void | GenerateWordWrappedString (std::string const &source_string, std::string *dest_string, ScreenCoordVector2 const &text_area) const |
Static Public Member Functions | |
static Uint32 | GlyphIndex (char ascii) |
static char | AsciiValue (Uint32 glyph_index) |
static AsciiFont * | CreateFromCache (std::string const &font_face_path, ScreenCoord pixel_height) |
Returns a pointer to a new instance of AsciiFont, loaded from the cached font metadata and bitmap files corresponding to the given path and pixel height, if said cache exists. | |
static AsciiFont * | Create (std::string const &font_face_path, ScreenCoord pixel_height, bool has_kerning, ScreenCoord baseline_height, GlyphSpecification sorted_glyph_specification[RENDERED_GLYPH_COUNT], FontCoord kern_pair_26_6[RENDERED_GLYPH_COUNT *RENDERED_GLYPH_COUNT], Texture *font_texture) |
Returns a pointer to a new instance of AsciiFont, loaded from the font metadata and bitmap provided. | |
Protected Member Functions | |
AsciiFont (std::string const &font_face_path, ScreenCoord pixel_height) | |
Default constructor. | |
virtual void | DrawGlyphSetup (RenderContext const &render_context) const |
virtual void | DrawGlyphShutdown (RenderContext const &render_context) const |
virtual void | DrawGlyph (RenderContext const &render_context, char const *glyph, FontCoordVector2 const &pen_position_26_6) const |
This class generates pixelized font renderings and stores the resulting data in an OpenGL texture, attempting to use a reasonably small texture to store the set of all rendered glyphs.
Definition at line 34 of file xrb_asciifont.hpp.
Xrb::AsciiFont::AsciiFont | ( | std::string const & | font_face_path, | |
ScreenCoord | pixel_height | |||
) | [inline, protected] |
Default constructor.
Protected so that you must use Xrb::AsciiFont::Create .
Definition at line 157 of file xrb_asciifont.hpp.
Referenced by Create(), and CreateFromCache().
AsciiFont * Xrb::AsciiFont::CreateFromCache | ( | std::string const & | font_face_path, | |
ScreenCoord | pixel_height | |||
) | [static] |
Returns a pointer to a new instance of AsciiFont, loaded from the cached font metadata and bitmap files corresponding to the given path and pixel height, if said cache exists.
This is the means to construct a AsciiFont object from cached data on disk. Using this class by dynamically allocated instances is preferred, so that it can be used in Xrb::Resource .
font_face_path | The path of the font to load. | |
pixel_height | The maximum height, in pixels, of the glyphs to render. |
Definition at line 91 of file xrb_asciifont.cpp.
References AsciiFont(), Create(), Xrb::Delete(), Xrb::DeleteAndNullify(), Hash(), m_baseline_height, m_gl_texture, m_glyph_specification, m_has_kerning, m_kern_pair_26_6, and Xrb::Singleton::Pal().
AsciiFont * Xrb::AsciiFont::Create | ( | std::string const & | font_face_path, | |
ScreenCoord | pixel_height, | |||
bool | has_kerning, | |||
ScreenCoord | baseline_height, | |||
GlyphSpecification | sorted_glyph_specification[RENDERED_GLYPH_COUNT], | |||
FontCoord | kern_pair_26_6[RENDERED_GLYPH_COUNT *RENDERED_GLYPH_COUNT], | |||
Texture * | font_texture | |||
) | [static] |
Returns a pointer to a new instance of AsciiFont, loaded from the font metadata and bitmap provided.
This is the means to construct a AsciiFont object using the font data provided. Using this class by dynamically allocated instances is preferred, so that it can be used in Xrb::Resource . See SDLPal::LoadFont for example usage.
font_face_path | The path of the font loaded. | |
pixel_height | The maximum height, in pixels, of the glyphs to render. | |
has_kerning | True iff the font has kerning enabled. | |
baseline_height | Pixel offset to the baseline of the font. | |
sorted_glyph_specification | Data per-glyph | |
kern_pair_26_6 | Kerning data in 26.6 fixed point format. | |
font_texture | A Texture object holding the font bitmap. This method does not delete the font texture. |
Definition at line 164 of file xrb_asciifont.cpp.
References AsciiFont(), m_baseline_height, m_gl_texture, m_glyph_specification, m_has_kerning, and m_kern_pair_26_6.
Referenced by CreateFromCache().
bool Xrb::AsciiFont::CacheToDisk | ( | Texture * | font_texture | ) | const |
Writes the font metadata and bitmap to disk.
Analogous to CreateFromCache.
Definition at line 187 of file xrb_asciifont.cpp.
References Xrb::Singleton::Pal().