8 #ifndef META_OCEAN_CV_FONTS_FONT_H
9 #define META_OCEAN_CV_FONTS_FONT_H
42 class OCEAN_CV_FONTS_EXPORT
Font
72 inline Character(
const unsigned int characterIndex,
const unsigned int framePositionX,
const unsigned int framePositionY,
const unsigned int linePositionY,
const unsigned int width,
const unsigned int height,
const int bearingX,
const int bearingY,
const unsigned int advanceX);
78 inline unsigned int characterIndex()
const;
84 inline unsigned int framePositionX()
const;
90 inline unsigned int framePositionY()
const;
97 inline unsigned int linePositionY()
const;
103 inline unsigned int width()
const;
109 inline unsigned int height()
const;
115 inline int bearingX()
const;
121 inline int bearingY()
const;
127 inline unsigned int advanceX()
const;
134 inline void setPositionY(
const unsigned int framePositionY,
const unsigned int linePositionY);
189 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;
201 virtual bool textExtent(
const std::string& text,
unsigned int& width,
unsigned int& height,
int* left =
nullptr,
int* top =
nullptr)
const = 0;
223 inline unsigned int size()
const;
229 inline unsigned int height()
const;
235 inline unsigned int dpi()
const;
241 inline bool isValid()
const;
266 characterIndex_((unsigned int)(-1)),
279 inline Font::Character::Character(
const unsigned int characterIndex,
const unsigned int framePositionX,
const unsigned int framePositionY,
const unsigned int linePositionY,
const unsigned int width,
const unsigned int height,
const int bearingX,
const int bearingY,
const unsigned int advanceX) :
280 characterIndex_(characterIndex),
281 framePositionX_(framePositionX),
282 framePositionY_(framePositionY),
283 linePositionY_(linePositionY),
295 ocean_assert(characterIndex_ != (
unsigned int)(-1));
296 return characterIndex_;
301 return framePositionX_;
306 return framePositionY_;
311 return linePositionY_;
341 ocean_assert(linePositionY <= framePositionY);
343 framePositionY_ = framePositionY;
344 linePositionY_ = linePositionY;
This class stores font-specific layout information about each individual character.
Definition: Font.h:52
unsigned int framePositionX_
The character's left pixel in 'charactersFrame', in pixels, with range [0, charactersFrame_....
Definition: Font.h:142
unsigned int framePositionY_
The character's top pixel in 'charactersFrame', in pixels, with range [0, charactersFrame_....
Definition: Font.h:145
void setPositionY(const unsigned int framePositionY, const unsigned int linePositionY)
Sets the vertical start pixel of the character inside 'charactersFrame'.
Definition: Font.h:339
unsigned int height_
The character's hieght, in pixels, with rang [0, charactersFrame_.height()].
Definition: Font.h:154
Character()
Creates a new invalid character object.
Definition: Font.h:265
unsigned int advanceX() const
Returns the horizontal distance between this character and the next character (between the origins of...
Definition: Font.h:334
unsigned int width_
The character's width, in pixels, with rang [0, charactersFrame_.width()].
Definition: Font.h:151
int bearingX() const
Returns the horizontal offset of the character in relation to the origin.
Definition: Font.h:324
unsigned int advanceX_
The horizontal distance between this character and the next character (between the origins of both ch...
Definition: Font.h:163
unsigned int height() const
The height of the character.
Definition: Font.h:319
unsigned int width() const
The width of the character.
Definition: Font.h:314
int bearingX_
The character's horizontal offset, in pixels, with range (-infinity, infinity).
Definition: Font.h:157
unsigned int characterIndex_
The character's index, with range [0, infinity).
Definition: Font.h:139
unsigned int framePositionX() const
Returns the horizontal start pixel of the character inside 'charactersFrame'.
Definition: Font.h:299
unsigned int framePositionY() const
Returns the vertical start pixel of the character inside 'charactersFrame'.
Definition: Font.h:304
int bearingY() const
Returns the vertical offset of the character in relation to the origin.
Definition: Font.h:329
unsigned int linePositionY() const
Returns the vertical start pixel of the character inside the target text line.
Definition: Font.h:309
int bearingY_
Definition: Font.h:160
unsigned int linePositionY_
The character's top pixel in the target text line, in pixel, with range [0, font.height() - 1].
Definition: Font.h:148
unsigned int characterIndex() const
Returns the index of this character.
Definition: Font.h:293
This class is the base class for all font implementations.
Definition: Font.h:43
unsigned int dpi_
The font's dots per inch, with range [0, infinity).
Definition: Font.h:259
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.
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.
unsigned int size() const
Returns the size of the font in dots.
Definition: Font.h:356
virtual bool characterFrame(Frame &frame, SharedCharacters *characters=nullptr) const =0
Returns a frame containing all characters.
std::shared_ptr< Characters > SharedCharacters
Definition of a shared pointers holding characters.
Definition: Font.h:170
bool isValid_
True, if the font is valid.
Definition: Font.h:262
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.
bool isValid() const
Returns whether the font is valid and whether it can be used.
Definition: Font.h:377
virtual ~Font()=default
Destructs the font object.
unsigned int height() const
Returns the height of the font in pixels.
Definition: Font.h:363
Font()
Creates a new font.
Definition: Font.h:347
std::vector< Character > Characters
Definition of a vector holding information about characters.
Definition: Font.h:167
unsigned int size_
The font's size in dots, with range [0, infinity).
Definition: Font.h:253
unsigned int height_
The font's height in pixel, with range [0, infinity).
Definition: Font.h:256
unsigned int dpi() const
Returns the dpi of the font.
Definition: Font.h:370
This class implements Ocean's image class.
Definition: Frame.h:1792
std::vector< PixelBoundingBoxI > PixelBoundingBoxesI
Definition of a vector holding bounding box objects with positive and negative coordinate values.
Definition: PixelBoundingBox.h:49
std::shared_ptr< Font > SharedFont
Definition of a shared font pointer.
Definition: Font.h:27
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15