Ocean
Ocean::CV::Canvas::Font Class Reference

This class implements a standard font similar to a code-block like font. More...

Inheritance diagram for Ocean::CV::Canvas::Font:

Data Structures

class  Character
 This class implements one character of a font for which each pixel has as size of at most 16x16. More...
 

Public Types

typedef std::vector< CharacterCharacters
 Definition of a vector holding characters. More...
 

Public Member Functions

bool drawText (Frame &frame, const std::string &text, const int left, const int top, const uint8_t *foregroundColor, const uint8_t *backgroundColor=nullptr) const
 Paints a given text into a given frame using this font. More...
 
bool textExtent (const std::string &text, unsigned int &width, unsigned int &height) const
 Returns the bounding box a given text will occupy in pixel space when using this font. More...
 

Protected Member Functions

 Font ()
 The protected constructor creating a new font. More...
 
- Protected Member Functions inherited from Ocean::Singleton< Font >
 Singleton ()=default
 Default constructor. More...
 

Protected Attributes

Characters characters_
 The characters of this font. More...
 

Friends

class Singleton< Font >
 

Additional Inherited Members

- Static Public Member Functions inherited from Ocean::Singleton< Font >
static Font & get ()
 Returns a reference to the unique object. More...
 

Detailed Description

This class implements a standard font similar to a code-block like font.

Member Typedef Documentation

◆ Characters

Definition of a vector holding characters.

Constructor & Destructor Documentation

◆ Font()

Ocean::CV::Canvas::Font::Font ( )
protected

The protected constructor creating a new font.

Member Function Documentation

◆ drawText()

bool Ocean::CV::Canvas::Font::drawText ( Frame frame,
const std::string &  text,
const int  left,
const int  top,
const uint8_t *  foregroundColor,
const uint8_t *  backgroundColor = nullptr 
) const

Paints a given text into a given frame using this font.

The given location can be partially outside of the frame.

Parameters
frameThe frame in which the text will be painted, must have a generic pixel format like e.g., FORMAT_Y8 or FORMAT_RGB24, must be valid
textThe text to be painted, the text can contain end-of-line characters to paint the remaining the following characters in the next line, can be empty
leftThe horizontal start position of the text within the frame, in pixel, with range (-infinity, infinity)
topThe vertical start position of the text within the frame, in pixel, with range (-infinity, infinity)
foregroundColorThe foreground color to be used when painting the character, must be valid
backgroundColorThe optional background color to be used when paining the character, nullptr to paint the foreground pixels only
Returns
True, if succeeded

◆ textExtent()

bool Ocean::CV::Canvas::Font::textExtent ( const std::string &  text,
unsigned int &  width,
unsigned int &  height 
) const

Returns the bounding box a given text will occupy in pixel space when using this font.

Parameters
textThe text for which the extent will be determined, can be empty
widthThe width of the bounding box, in pixel, with range [0, infinity)
heightThe height of the bounding box, in pixel, with range [0, infinity)
Returns
True, if succeeded

Friends And Related Function Documentation

◆ Singleton< Font >

friend class Singleton< Font >
friend

Field Documentation

◆ characters_

Characters Ocean::CV::Canvas::Font::characters_
protected

The characters of this font.


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