Ocean
Ocean::CV::Fonts::Font Class Referenceabstract

This class is the base class for all font implementations. More...

Inheritance diagram for Ocean::CV::Fonts::Font:

Data Structures

class  Character
 This class stores font-specific layout information about each individual character. More...
 

Public Types

typedef std::vector< CharacterCharacters
 Definition of a vector holding information about characters. More...
 
typedef std::shared_ptr< CharactersSharedCharacters
 Definition of a shared pointers holding characters. More...
 

Public Member Functions

virtual ~Font ()=default
 Destructs the font object. More...
 
virtual bool drawText (Frame &frame, const std::string &text, const int left, const int top, const uint8_t *foregroundColor, const uint8_t *backgroundColor=nullptr) const =0
 Draws a text into a given frame. More...
 
virtual bool textExtent (const std::string &text, unsigned int &width, unsigned int &height, int *left=nullptr, int *top=nullptr) const =0
 Returns the bounding box in which a given text will fit. More...
 
virtual bool textExtent (const std::string &text, PixelBoundingBoxesI &lineBoundingBoxes) const =0
 Returns the bounding boxes in which each individual line of a given text will fit. More...
 
virtual bool characterFrame (Frame &frame, SharedCharacters *characters=nullptr) const =0
 Returns a frame containing all characters. More...
 
unsigned int size () const
 Returns the size of the font in dots. More...
 
unsigned int height () const
 Returns the height of the font in pixels. More...
 
unsigned int dpi () const
 Returns the dpi of the font. More...
 
bool isValid () const
 Returns whether the font is valid and whether it can be used. More...
 

Protected Member Functions

 Font ()
 Creates a new font. More...
 

Protected Attributes

unsigned int size_
 The font's size in dots, with range [0, infinity). More...
 
unsigned int height_
 The font's height in pixel, with range [0, infinity). More...
 
unsigned int dpi_
 The font's dots per inch, with range [0, infinity). More...
 
bool isValid_
 True, if the font is valid. More...
 

Detailed Description

This class is the base class for all font implementations.

Each font object must be acquired via the FontManager singleton.

See also
FontManager.

Member Typedef Documentation

◆ Characters

Definition of a vector holding information about characters.

◆ SharedCharacters

Definition of a shared pointers holding characters.

Constructor & Destructor Documentation

◆ ~Font()

virtual Ocean::CV::Fonts::Font::~Font ( )
virtualdefault

Destructs the font object.

◆ Font()

Ocean::CV::Fonts::Font::Font ( )
inlineprotected

Creates a new font.

Member Function Documentation

◆ characterFrame()

virtual bool Ocean::CV::Fonts::Font::characterFrame ( Frame frame,
SharedCharacters characters = nullptr 
) const
pure virtual

Returns a frame containing all characters.

Parameters
frameThe resulting frame containing all characters, the frame will own the memory
charactersOptional resulting layout information for each individual character
Returns
True, if succeeded

Implemented in Ocean::CV::Fonts::FTFont.

◆ dpi()

unsigned int Ocean::CV::Fonts::Font::dpi ( ) const
inline

Returns the dpi of the font.

Returns
The font's dots per inch, with range [0, infinity)

◆ drawText()

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

Draws a text into a given frame.

Parameters
frameThe frame in which the text will be drawn, must have dataType() == DT_UNSIGNED_INTEGER_8, must be valid
textThe text to be drawn, can be empty
leftThe horizontal start position of the text, with range (-infinity, infinity)
topThe vertical start positoin of the text, with range (-infinity, infinity)
foregroundColorThe foreground color to be used, must match with the pixel format of the given frame
backgroundColorOptional explicit background color of the text, nullptr to draw the text without background color
Returns
True, if succeeded

Implemented in Ocean::CV::Fonts::FTFont.

◆ height()

unsigned int Ocean::CV::Fonts::Font::height ( ) const
inline

Returns the height of the font in pixels.

Returns
The font's height in pixel, with range [0, infinity)

◆ isValid()

bool Ocean::CV::Fonts::Font::isValid ( ) const
inline

Returns whether the font is valid and whether it can be used.

Returns
True, if so

◆ size()

unsigned int Ocean::CV::Fonts::Font::size ( ) const
inline

Returns the size of the font in dots.

Returns
The font's size in dots, with range [0, infinity)

◆ textExtent() [1/2]

virtual bool Ocean::CV::Fonts::Font::textExtent ( const std::string &  text,
PixelBoundingBoxesI lineBoundingBoxes 
) const
pure virtual

Returns the bounding boxes in which each individual line of a given text will fit.

Parameters
textThe text for which the individual line extents will be determined, can be empty
lineBoundingBoxesThe resulting bounding boxes, one for each text line
Returns
True, if succeeded

Implemented in Ocean::CV::Fonts::FTFont.

◆ textExtent() [2/2]

virtual bool Ocean::CV::Fonts::Font::textExtent ( const std::string &  text,
unsigned int &  width,
unsigned int &  height,
int *  left = nullptr,
int *  top = nullptr 
) const
pure virtual

Returns the bounding box in which a given text will fit.

In case the text contains multiple lines, the maximal bounding box is determined.

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)
leftOptional resulting explicit horizontal start location of the bounding box (e.g., if parts of a character are drawn to the left of character's origin), nullptr otherwise
topOptional resulting explicit vertical start location of the bounding box, nullptr otherwise
Returns
True, if succeeded

Implemented in Ocean::CV::Fonts::FTFont.

Field Documentation

◆ dpi_

unsigned int Ocean::CV::Fonts::Font::dpi_
protected

The font's dots per inch, with range [0, infinity).

◆ height_

unsigned int Ocean::CV::Fonts::Font::height_
protected

The font's height in pixel, with range [0, infinity).

◆ isValid_

bool Ocean::CV::Fonts::Font::isValid_
protected

True, if the font is valid.

◆ size_

unsigned int Ocean::CV::Fonts::Font::size_
protected

The font's size in dots, with range [0, infinity).


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