NXWidgets  1.19
Public Member Functions | Private Attributes | List of all members
NXWidgets::CNxFont Class Reference

#include <cnxfont.hxx>

Public Member Functions

 CNxFont (enum nx_fontid_e fontid, nxgl_mxpixel_t fontColor, nxgl_mxpixel_t transparentColor)
 
 ~CNxFont ()
 
const bool isCharBlank (const nxwidget_char_t letter) const
 
const nxgl_mxpixel_t getColor () const
 
void setColor (const nxgl_mxpixel_t color)
 
const nxgl_mxpixel_t getTransparentColor () const
 
void setTransparentColor (const nxgl_mxpixel_t color)
 
void drawChar (FAR SBitmap *bitmap, nxwidget_char_t letter)
 
nxgl_coord_t getStringWidth (const CNxString &text) const
 
nxgl_coord_t getStringWidth (const CNxString &text, int startIndex, int length) const
 
void getCharMetrics (nxwidget_char_t letter, FAR struct nx_fontmetric_s *metrics) const
 
nxgl_coord_t getCharWidth (nxwidget_char_t letter) const
 
nxgl_coord_t getCharHeight (nxwidget_char_t letter) const
 
const uint8_t getMaxWidth (void) const
 
const uint8_t getHeight (void) const
 

Private Attributes

enum nx_fontid_e m_fontId
 
NXHANDLE m_fontHandle
 
FAR const struct nx_font_s * m_pFontSet
 
nxgl_mxpixel_t m_fontColor
 
nxgl_mxpixel_t m_transparentColor
 

Detailed Description

Class defining the properties of one font.

Definition at line 70 of file cnxfont.hxx.

Constructor & Destructor Documentation

◆ CNxFont()

CNxFont::CNxFont ( enum nx_fontid_e  fontid,
nxgl_mxpixel_t  fontColor,
nxgl_mxpixel_t  transparentColor 
)

CNxFont Constructor.

Parameters
fontidThe font ID to use.
fontColorThe font color to use.
transparentColorThe color in the font bitmap used as the background color.

Definition at line 75 of file cnxfont.cxx.

◆ ~CNxFont()

NXWidgets::CNxFont::~CNxFont ( )
inline

CNxFont Destructor.

Definition at line 97 of file cnxfont.hxx.

Member Function Documentation

◆ drawChar()

void CNxFont::drawChar ( FAR SBitmap bitmap,
nxwidget_char_t  letter 
)

Draw an individual character of the font to the specified bitmap.

Parameters
bitmapThe bitmap to draw to.
letterThe character to output.

Draw an individual character of the font to the specified bitmap.

Parameters
bitmapThe bitmap to draw use. The caller should use the getFontMetrics method to assure that the buffer will hold the font.
letterThe character to output.
Returns
The width of the string in pixels.

Definition at line 114 of file cnxfont.cxx.

◆ getCharHeight()

nxgl_coord_t NXWidgets::CNxFont::getCharHeight ( nxwidget_char_t  letter) const
inline

Get the height of an individual character.

Parameters
letterThe letter to get the height of.
Returns
The height of the character in pixels.

◆ getCharMetrics()

void CNxFont::getCharMetrics ( nxwidget_char_t  letter,
FAR struct nx_fontmetric_s *  metrics 
) const

Gets font metrics for a particular character

Parameters
letterThe character to get the width of.
metricsThe location to return the font metrics

Definition at line 220 of file cnxfont.cxx.

◆ getCharWidth()

nxgl_coord_t CNxFont::getCharWidth ( nxwidget_char_t  letter) const

Get the width of an individual character.

Parameters
letterThe character to get the width of.
Returns
The width of the character in pixels.

Definition at line 254 of file cnxfont.cxx.

◆ getColor()

const nxgl_mxpixel_t NXWidgets::CNxFont::getColor ( ) const
inline

Gets the color currently being used as the drawing color.

Returns
The current drawing color.

Definition at line 115 of file cnxfont.hxx.

◆ getHeight()

const uint8_t NXWidgets::CNxFont::getHeight ( void  ) const
inline

Gets the height of the font.

Returns
The height of the font.

Definition at line 229 of file cnxfont.hxx.

◆ getMaxWidth()

const uint8_t NXWidgets::CNxFont::getMaxWidth ( void  ) const
inline

Gets the maximum width of the font.

Returns
The height of the font.

Definition at line 218 of file cnxfont.hxx.

◆ getStringWidth() [1/2]

nxgl_coord_t CNxFont::getStringWidth ( const CNxString text) const

Get the width of a string in pixels when drawn with this font.

Parameters
textThe string to check.
Returns
The width of the string in pixels.

Definition at line 142 of file cnxfont.cxx.

◆ getStringWidth() [2/2]

nxgl_coord_t CNxFont::getStringWidth ( const CNxString text,
int  startIndex,
int  length 
) const

Get the width of a portion of a string in pixels when drawn with this font.

Parameters
textThe string to check.
startIndexThe start point of the substring within the string.
lengthThe length of the substring in chars.
Returns
The width of the substring in pixels.

Definition at line 182 of file cnxfont.cxx.

◆ getTransparentColor()

const nxgl_mxpixel_t NXWidgets::CNxFont::getTransparentColor ( ) const
inline

Get the color currently being used as the transparent background color.

Returns
The transparent background color.

Definition at line 137 of file cnxfont.hxx.

◆ isCharBlank()

const bool CNxFont::isCharBlank ( const nxwidget_char_t  letter) const

Checks if supplied character is blank in the current font.

Parameters
letterThe character to check.
Returns
True if the glyph contains any pixels to be drawn. False if the glyph is blank.

Definition at line 93 of file cnxfont.cxx.

◆ setColor()

void NXWidgets::CNxFont::setColor ( const nxgl_mxpixel_t  color)
inline

Sets the color to use as the drawing color. If set, this overrides the colors present in a non-monochrome font.

Parameters
colorThe new drawing color.

Definition at line 126 of file cnxfont.hxx.

◆ setTransparentColor()

void NXWidgets::CNxFont::setTransparentColor ( const nxgl_mxpixel_t  color)
inline

Sets the transparent background color to a new value.

Parameters
colorThe new background color.

Definition at line 147 of file cnxfont.hxx.

Member Data Documentation

◆ m_fontColor

nxgl_mxpixel_t NXWidgets::CNxFont::m_fontColor
private

< The font set metrics Color to draw the font with when rendering.

Definition at line 76 of file cnxfont.hxx.

◆ m_fontHandle

NXHANDLE NXWidgets::CNxFont::m_fontHandle
private

The font handle

Definition at line 74 of file cnxfont.hxx.

◆ m_fontId

enum nx_fontid_e NXWidgets::CNxFont::m_fontId
private

The font ID.

Definition at line 73 of file cnxfont.hxx.

◆ m_pFontSet

FAR const struct nx_font_s* NXWidgets::CNxFont::m_pFontSet
private

Definition at line 75 of file cnxfont.hxx.

◆ m_transparentColor

nxgl_mxpixel_t NXWidgets::CNxFont::m_transparentColor
private

Background color that should not be rendered.

Definition at line 77 of file cnxfont.hxx.


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