Public Member Functions | Private Member Functions | Private Attributes | List of all members
nom::BitmapFont Class Reference
Inheritance diagram for nom::BitmapFont:
[legend]
Collaboration diagram for nom::BitmapFont:
[legend]

Public Member Functions

 BitmapFont (void)
 Default constructor.
 
 ~BitmapFont (void)
 Default destructor.
 
IFont::SharedPtr clone (void) const
 Return a std::shared_ptr copy of this instance.
 
const std::string & getText (void) const
 Obtains set text string buffer; defaults to \0.
 
void setText (const std::string &text)
 Set a new text string for drawing; defaults to \0.
 
int32 getFontWidth (void) const
 
int32 getFontHeight (void) const
 
const Color & getColor (void) const
 
const Coords & getPosition (void) const
 
uint32 getSpacing (void) const
 
void setSpacing (uint32 spaces)
 
uint32 getNewline (void) const
 
IFont::TextAlignment getTextJustification (void) const
 
void setNewline (uint32_t newline)
 Set new text character spacing height offsets in pixels.
 
IFont::FontStyle getFontStyle (void) const
 
void setFontStyle (int32 style, uint8 options=150)
 
void setColor (const Color &color)
 Not implemented. More...
 
void setPosition (const Coords &coords)
 
void setTextJustification (IFont::TextAlignment alignment)
 
const Coords findGlyph (const std::string &glyph)
 
bool load (const std::string &filename, const Color &colorkey, bool use_cache=false)
 
void update (void)
 
void draw (RenderTarget target) const
 
bool resize (enum ResizeAlgorithm scaling_algorithm)
 
- Public Member Functions inherited from nom::IFont
virtual void setFontSize (int32 point_size)
 
virtual IFont::RenderStyle getRenderingStyle (void) const
 
virtual void setRenderingStyle (IFont::RenderStyle)
 
- Public Member Functions inherited from nom::IDrawable
 IDrawable (void)
 Do nothing at all default constructor.
 
virtual ~IDrawable (void)
 Do nothing at all destructor.
 

Private Member Functions

bool rebuild (void)
 

Private Attributes

int32 sheet_width
 
int32 sheet_height
 
Texture bitmap_font
 pointer reference holding our bitmap font image sheet
 
Coords chars [256]
 individual chars positioning offsets within bitmap_font
 
Coords coords
 Positioning coordinates.
 
uint32 newline
 height (in pixels) to offset when newline carriage char is encountered
 
uint32 spacing
 
std::string text_buffer
 holds contents of text as a string
 
enum IFont::FontStyle text_style
 Current text effect set.
 
Color color
 Not implemented (yet)
 
enum IFont::TextAlignment text_alignment
 
enum IFont::RenderStyle rendering
 

Additional Inherited Members

- Public Types inherited from nom::IFont
enum  FontStyle {
  Regular = 0, Bold = 1, Italic = 2, Underlined = 3,
  Faded = 4
}
 Text effect styling.
 
enum  TextAlignment {
  TopLeft = 0, TopCenter, TopRight, MiddleLeft,
  MiddleCenter, MiddleRight, BottomLeft, BottomCenter,
  BottomRight
}
 
enum  RenderStyle { NotImplemented = 0, Solid, Shaded, Blended }
 Text rendering qualities.
 
typedef IFont * RawPtr
 
typedef std::unique_ptr< IFont > UniquePtr
 
typedef std::shared_ptr< IFont > SharedPtr
 
- Public Types inherited from nom::IDrawable
typedef std::unique_ptr
< IDrawable > 
UniquePtr
 std::unique_ptr definition type for your convenience, sir!
 
typedef std::shared_ptr
< IDrawable > 
SharedPtr
 std::shared_ptr definition type at your leisure, sir!
 
typedef std::vector
< std::shared_ptr< IDrawable > > 
SharedDrawables
 Vector of std::shared_ptr definition type for the brotherhood, sir!
 
typedef std::vector
< std::unique_ptr< IDrawable > > 
UniqueDrawables
 std::unique_ptr vector container type
 
typedef const Window & RenderTarget
 

Detailed Description

Definition at line 53 of file BitmapFont.hpp.

Member Function Documentation

void nom::BitmapFont::draw ( RenderTarget  target) const
virtual

Draw the set text string to the video surface

Todo:
Test horizontal tabbing ''

Implements nom::IDrawable.

Definition at line 460 of file BitmapFont.cpp.

Here is the call graph for this function:

int32 nom::BitmapFont::getFontHeight ( void  ) const
virtual

Obtain the text height in pixels of the set text string.

This calculation mimics the rendering calculations done and should be exact within one pixel accuracy.

Todo:
Rename me to text_height

Implements nom::IFont.

Definition at line 113 of file BitmapFont.cpp.

int32 nom::BitmapFont::getFontWidth ( void  ) const
virtual

Obtain the text width in pixels of the set text string.

This calculation mimics the rendering calculations done and should be exact within one pixel accuracy.

Todo:

Rename me to text_width

Support multi-line texts

Implements nom::IFont.

Definition at line 72 of file BitmapFont.cpp.

Here is the caller graph for this function:

uint32 nom::BitmapFont::getNewline ( void  ) const
virtual

Obtain text character spacing height offsets in pixels; defaults to variable calculations made within Load method

Implements nom::IFont.

Definition at line 186 of file BitmapFont.cpp.

uint32 nom::BitmapFont::getSpacing ( void  ) const
virtual

Obtain text character spacing width in pixels; this variable is affected by the total image width size.

Implements nom::IFont.

Definition at line 176 of file BitmapFont.cpp.

bool nom::BitmapFont::load ( const std::string &  filename,
const Color &  colorkey,
bool  use_cache = false 
)
virtual

Loads a new bitmap font from a file

Todo:
Add spacing / padding so that we can export with black guidelines

Implements nom::IFont.

Definition at line 415 of file BitmapFont.cpp.

Here is the call graph for this function:

bool nom::BitmapFont::rebuild ( void  )
private

Trigger a rebuild of the font characteristics gleaned from the image file; recalculate the character sizes, coordinate origins, spacing, etc.

Definition at line 246 of file BitmapFont.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool nom::BitmapFont::resize ( enum ResizeAlgorithm  scaling_algorithm)
virtual

Rescale the font with a chosen resizing algorithm

Re-implements IFont::resize

Todo:
SDL2 port

Reimplemented from nom::IFont.

Definition at line 530 of file BitmapFont.cpp.

Here is the call graph for this function:

void nom::BitmapFont::setColor ( const Color &  color)
virtual

Not implemented.

Not implemented

Implements nom::IFont.

Definition at line 161 of file BitmapFont.cpp.

void nom::BitmapFont::setFontStyle ( int32  style,
uint8  options = 150 
)
virtual

Text effect utilizing alpha channels for the appearance of gray text

Implements nom::IFont.

Definition at line 206 of file BitmapFont.cpp.

Here is the call graph for this function:

void nom::BitmapFont::setSpacing ( uint32  spaces)
virtual

Set new text character spacing width (in pixels) – this variable is used during the calculation of the text width (see getFontWidth method) in addition to the rendering process (see draw method) when there is a space character (' ') found in the provided text string.

Implements nom::IFont.

Definition at line 181 of file BitmapFont.cpp.

void nom::BitmapFont::setTextJustification ( IFont::TextAlignment  alignment)
virtual

Set the justification of the text.

This modifies the destination positions used in rendering text.

Implements nom::IFont.

Definition at line 440 of file BitmapFont.cpp.

void nom::BitmapFont::update ( void  )
virtual

Intended to be used internally by the class re-implementing this method; for use in preparing the buffer to be drawn using the draw method call. Whereas both Update & Draw are typically publicly exposed to the end-user, only the Draw method call should be expected of the end-user to be explicitly called.

Todo:
Not all the interfaced (inherited) IDrawable objects in this library conform to the expectations stated above. We need to first figure out if we wish to stay on this course (of expectation), or diverge all together. Undecided. Jeffrey Carpenter jeffr.nosp@m.ey.c.nosp@m.arp@g.nosp@m.mail.nosp@m..com @ 2013-10-03

Implements nom::IDrawable.

Definition at line 455 of file BitmapFont.cpp.

Member Data Documentation

uint32 nom::BitmapFont::spacing
private

Width in pixels to offset when a space carriage char is encountered.

Note that you may need to reset this if you are using bitmap fonts with high resolution graphics. I recently went from 384x224 to 768x448 and this was enough to offset this variable by 18 pixels.

Definition at line 174 of file BitmapFont.hpp.


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