nomlib
Loading...
Searching...
No Matches
nom::BMFont Class Reference

Bitmap font interface implementing most of the BMFont text/ascii file spec. More...

#include <BMFont.hpp>

Inheritance diagram for nom::BMFont:
[legend]

Public Types

typedef BMFont self_type
Public Types inherited from nom::IFont
enum  FontType { NotDefined = 0 , BitmapFont , TrueTypeFont , BMFont }
typedef IFont self_type
typedef self_type * raw_ptr
typedef std::shared_ptr< self_type > shared_ptr
typedef std::unique_ptr< self_type > unique_ptr

Public Member Functions

 BMFont ()
 Default constructor.
virtual ~BMFont ()
 Destructor.
IFont * clone () const override
bool valid () const override
IFont::FontType type () const override
const Imageimage (uint32 character_size) const override
const Glyphglyph (uint32 codepoint, uint32 character_size) const override
int spacing (uint32 character_size) const override
int kerning (uint32 first_char, uint32 second_char, uint32 character_size) const override
 Obtain the kerning pair offsets between two glyphs.
int hinting () const override
uint32 font_style () const override
const Size2i & page_size (uint32 page) const
int newline (uint32 character_size) const override
const FontMetricsmetrics () const override
int point_size () const
bool use_kerning () const
bool set_point_size (int) override
bool set_hinting (int) override
bool set_outline (int) override
void set_font_style (uint32) override
void set_font_kerning (bool state) override
 Set the use of kerning for the font.
bool load (const std::string &filename) override
bool parse_ascii_file (std::istream &fp)
 Read an input source that conforms to the BMFont file spec.

Private Member Functions

bool build (uint32 character_size)
 Create the texture atlas from the parsed font metrics.
void parse_string (const std::string &key, std::string &value)

Private Attributes

Size2i page_size_
 The total dimensions – width and height in integer pixels – of the texture atlas used to hold the glyphs.
FontMetrics metrics_
 The glyph characteristics for the font in use.
GlyphPage pages_
int point_size_
 The point size of the font.
BMFontPage page_
std::vector< BMFontKerningPairkernings_
 Kerning pairs.
bool use_kerning_
 Usage state of kerning pair offsets.

Detailed Description

Bitmap font interface implementing most of the BMFont text/ascii file spec.

The following fields are not implemented from the info tag: 'bold', 'italic', 'charset', 'unicode', 'stretchH', 'smooth', 'aa', 'padding', 'spacing', 'outline'.

The following fields are not implemented from the common tag: 'packed', 'alphaChnl', 'redChnl', 'greenChnl', 'blueChnl'.

The following fields are not implemented from the char tag: 'page', 'chnl'.

Only one glyph page is supported. String sequences with spaces are not supported.

Software this interface has been tested with includes:

BMGlyph v2.0.4 BMFont v1.14b

Definition at line 80 of file BMFont.hpp.

Member Typedef Documentation

◆ self_type

typedef BMFont nom::BMFont::self_type

Definition at line 83 of file BMFont.hpp.

Member Function Documentation

◆ build()

bool nom::BMFont::build ( uint32 character_size)
private

Create the texture atlas from the parsed font metrics.

Parameters
character_sizeNot implemented.

◆ clone()

IFont * nom::BMFont::clone ( ) const
overridevirtual

Implements nom::IFont.

◆ font_style()

uint32 nom::BMFont::font_style ( ) const
overridevirtual
Remarks
Not implemented.

Implements nom::IFont.

◆ glyph()

const Glyph & nom::BMFont::glyph ( uint32 codepoint,
uint32 character_size ) const
overridevirtual
Parameters
codepointThe char identifier (an ASCII value) to lookup.
character_sizeNot implemented.

Implements nom::IFont.

◆ hinting()

int nom::BMFont::hinting ( ) const
overridevirtual
Remarks
Not implemented.

Implements nom::IFont.

◆ image()

const Image * nom::BMFont::image ( uint32 character_size) const
overridevirtual
Parameters
character_sizeNot implemented.

Implements nom::IFont.

◆ kerning()

int nom::BMFont::kerning ( uint32 first_char,
uint32 second_char,
uint32 character_size ) const
overridevirtual

Obtain the kerning pair offsets between two glyphs.

Parameters
character_sizeNot implemented.
Returns
A kerning pair offset value on success, or nom::NOM_INT_MIN on failure, such as if the font in use is invalid. If font kerning is disabled, a value of zero (0) is always returned.

Implements nom::IFont.

◆ load()

bool nom::BMFont::load ( const std::string & filename)
overridevirtual
Todo
Rename to load_file.

Implements nom::IFont.

◆ metrics()

const FontMetrics & nom::BMFont::metrics ( ) const
overridevirtual

Implements nom::IFont.

◆ newline()

int nom::BMFont::newline ( uint32 character_size) const
overridevirtual
Parameters
character_sizeNot implemented.

Implements nom::IFont.

◆ page_size()

const Size2i & nom::BMFont::page_size ( uint32 page) const
Parameters
character_sizeNot implemented.

◆ parse_ascii_file()

bool nom::BMFont::parse_ascii_file ( std::istream & fp)

Read an input source that conforms to the BMFont file spec.

Note
The file parser derives from the implementation provided by Promit of GameDev.net Forums. Thanks!

◆ parse_string()

void nom::BMFont::parse_string ( const std::string & key,
std::string & value )
private
Todo
Parsing string sequences with spaces

◆ set_font_kerning()

void nom::BMFont::set_font_kerning ( bool state)
overridevirtual

Set the use of kerning for the font.

Remarks
Not implemented.

Implements nom::IFont.

◆ set_font_style()

void nom::BMFont::set_font_style ( uint32 )
overridevirtual
Remarks
Not implemented.

Implements nom::IFont.

◆ set_hinting()

bool nom::BMFont::set_hinting ( int )
overridevirtual
Remarks
Not implemented.

Implements nom::IFont.

◆ set_outline()

bool nom::BMFont::set_outline ( int )
overridevirtual
Remarks
Not implemented.

Implements nom::IFont.

◆ set_point_size()

bool nom::BMFont::set_point_size ( int )
overridevirtual
Remarks
Not implemented.

Implements nom::IFont.

◆ spacing()

int nom::BMFont::spacing ( uint32 character_size) const
overridevirtual
Parameters
character_sizeNot implemented.

Implements nom::IFont.

◆ type()

IFont::FontType nom::BMFont::type ( ) const
overridevirtual

Implements nom::IFont.

◆ valid()

bool nom::BMFont::valid ( ) const
overridevirtual

Implements nom::IFont.

Member Data Documentation

◆ kernings_

std::vector<BMFontKerningPair> nom::BMFont::kernings_
private

Kerning pairs.

Definition at line 198 of file BMFont.hpp.

◆ metrics_

FontMetrics nom::BMFont::metrics_
private

The glyph characteristics for the font in use.

Remarks
This structure maps the FontMetrics::lineHeight field to the common tag's 'lineHeight' field and the FontMetrics::base field to the common tag's 'base' field.

Definition at line 181 of file BMFont.hpp.

◆ page_

BMFontPage nom::BMFont::page_
private

Definition at line 195 of file BMFont.hpp.

◆ page_size_

Size2i nom::BMFont::page_size_
private

The total dimensions – width and height in integer pixels – of the texture atlas used to hold the glyphs.

Remarks
This is mapped to the common tag's 'scaleW' and 'scaleH' fields.

Definition at line 174 of file BMFont.hpp.

◆ pages_

GlyphPage nom::BMFont::pages_
mutableprivate
Remarks
This structure maps the GlyphAtlas::GlyphPage::bounds fields to the char tag's 'x', 'y', 'width' and 'height' fields, the GlyphAtlas::GlyphPage::advance field to the char tag's 'advance' field and GlyphAtlas::GlyphPage::offset fields to the char tag's 'xoffset' and 'xoffset' fields.

Definition at line 188 of file BMFont.hpp.

◆ point_size_

int nom::BMFont::point_size_
private

The point size of the font.

Remarks
This is mapped to the info tag's 'size' field.

Definition at line 193 of file BMFont.hpp.

◆ use_kerning_

bool nom::BMFont::use_kerning_
private

Usage state of kerning pair offsets.

Definition at line 201 of file BMFont.hpp.


The documentation for this class was generated from the following file: