8 #ifndef META_OCEAN_CV_FONTS_FREETYPE_FT_FONT_H
9 #define META_OCEAN_CV_FONTS_FREETYPE_FT_FONT_H
38 static constexpr
char firstCharacter_ = 32;
43 static constexpr
char endCharacter_ = 127;
57 bool drawText(
Frame& frame,
const std::string& text,
const int left,
const int top,
const uint8_t* foregroundColor,
const uint8_t* backgroundColor =
nullptr)
const override;
68 bool textExtent(
const std::string& text,
unsigned int& width,
unsigned int& height,
int* left =
nullptr,
int* top =
nullptr)
const override;
94 explicit FTFont(
const FT_Face& ftFace,
const unsigned int size,
const unsigned int dpi);
125 template <
typename T,
unsigned int tTargetChannels>
126 static void renderCharacterFromY8(
const uint8_t* ySourceFrameData, T* targetFrameData,
const unsigned int width,
const unsigned int height,
const T*
const foregroundColor,
const unsigned int ySourceFrameStrideElements,
const unsigned int targetFrameStrideElements);
138 template <
typename T,
unsigned int tChannels>
139 static void renderBackground(T* frameData,
const unsigned int backgroundWidth,
const unsigned int backgroundHeight,
const T*
const backgroundColor,
const unsigned int frameStrideElements);
150 constexpr
static unsigned int extraBorder_ = 1u;
This class implements a font based on FreeType.
Definition: FTFont.h:30
Frame charactersFrame_
The character frame which contains all characters of the font, with pixel format FORMAT_Y8 or FORMAT_...
Definition: FTFont.h:147
SharedCharacters characters_
The information for each individual character in charactersFrame_.
Definition: FTFont.h:144
static bool drawCharacterBitmapToFrame(const FT_Bitmap &bitmap, Frame &frame, const unsigned int framePositionX, const unsigned int framePositionY)
Draws the bitmap of a FreeType character to the frame storing all characters/glyphs.
static void renderCharacterFromY8(const uint8_t *ySourceFrameData, T *targetFrameData, const unsigned int width, const unsigned int height, const T *const foregroundColor, const unsigned int ySourceFrameStrideElements, const unsigned int targetFrameStrideElements)
Renders a font character from the grayscale image storing all characters to a target image.
static void renderBackground(T *frameData, const unsigned int backgroundWidth, const unsigned int backgroundHeight, const T *const backgroundColor, const unsigned int frameStrideElements)
Draws the background color into a rectangular area within the target frame.
bool initialize(const FT_Face &ftFace)
Initializes the font.
bool drawText(Frame &frame, const std::string &text, const int left, const int top, const uint8_t *foregroundColor, const uint8_t *backgroundColor=nullptr) const override
Draws a text into a given frame.
bool characterFrame(Frame &frame, SharedCharacters *characters=nullptr) const override
Returns a frame containing all characters.
bool textExtent(const std::string &text, unsigned int &width, unsigned int &height, int *left=nullptr, int *top=nullptr) const override
Returns the bounding box a given text will occupy in pixel space when using this font.
bool textExtent(const std::string &text, PixelBoundingBoxesI &lineBoundingBoxes) const override
Returns the bounding boxes in which each individual line of a given text will fit.
FTFont(const FT_Face &ftFace, const unsigned int size, const unsigned int dpi)
Creates a new FreeType font object.
This class implements the actual manager for all FreeType fonts.
Definition: FTFontManager.h:34
This class is the base class for all font implementations.
Definition: Font.h:43
std::shared_ptr< Characters > SharedCharacters
Definition of a shared pointers holding characters.
Definition: Font.h:170
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
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15