Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub

The Font class provides text drawing. More...

#include <SimdFont.hpp>

Public Types

typedef std::string String
 
typedef Simd::Point< ptrdiff_t > Point
 
typedef Simd::View< Simd::AllocatorView
 

Public Member Functions

 Font (size_t height=16)
 
bool Resize (size_t height)
 
size_t Height () const
 
Point Measure (const String &text) const
 
template<class Color >
bool Draw (View &canvas, const String &text, const Point &position, const Color &color) const
 
template<class Color >
bool Draw (View &canvas, const String &text, const View::Position &position, const Color &color) const
 
template<class Color >
bool Draw (View &canvas, const String &text, const View::Position &position, const Color &color, const Color &background) const
 

Detailed Description

The Font class provides text drawing.

Using example:

#include "Simd/SimdFont.hpp"
int main()
{
typedef Simd::Pixel::Bgra32 Color;
Simd::Font font(32);
View image(320, 240, View::Bgra32);
Simd::FillPixel(image, Color(128, 128, 0));
font.Draw(image, "Hello, Simd!", View::MiddleCenter, Color(0, 0, 255));
image.Save("HelloSimd.ppm");
return 0;
}
The Font class provides text drawing.
Definition: SimdFont.hpp:64
Simd::View< Simd::Allocator > View
Definition: SimdFont.hpp:68
SIMD_INLINE void FillPixel(View< A > &dst, const Pixel &pixel)
Fills image by value of given pixel.
Definition: SimdLib.hpp:1849
32-bit BGRA pixel.
Definition: SimdPixel.hpp:136
@ Bgra32
Definition: SimdView.hpp:89
@ MiddleCenter
Definition: SimdView.hpp:133

Member Typedef Documentation

◆ String

typedef std::string String

String type definition.

◆ Point

typedef Simd::Point<ptrdiff_t> Point

Point type definition.

◆ View

Image time definition.

Constructor & Destructor Documentation

◆ Font()

Font ( size_t  height = 16)

Creates a new Font class with given height.

Note
The font supports ASCII characters only. It was generated on the base of the generic monospace font from Gdiplus.
Parameters
[in]height- initial height value. By default it is equal to 16.

Member Function Documentation

◆ Resize()

bool Resize ( size_t  height)

Sets a new height value to font.

Parameters
[in]height- a new height value.
Returns
a result of the operation.

◆ Height()

size_t Height ( ) const

Gets height of the font.

Returns
current height of the font.

◆ Measure()

Point Measure ( const String text) const

Measures a size of region is need to draw given text.

Parameters
[in]text- a text to draw.
Returns
measured size.

◆ Draw() [1/3]

bool Draw ( View canvas,
const String text,
const Point position,
const Color &  color 
) const

Draws a text at the image.

Parameters
[out]canvas- a canvas (image where we draw text).
[in]text- a text to draw.
[in]position- a start position to draw text.
[in]color- a color of the text.
Returns
a result of the operation.

◆ Draw() [2/3]

bool Draw ( View canvas,
const String text,
const View::Position position,
const Color &  color 
) const

Draws a text at the image.

Parameters
[out]canvas- a canvas (image where we draw text).
[in]text- a text to draw.
[in]position- a position to draw text (see Simd::View::Position).
[in]color- a color of the text.
Returns
a result of the operation.

◆ Draw() [3/3]

bool Draw ( View canvas,
const String text,
const View::Position position,
const Color &  color,
const Color &  background 
) const

Draws a text at the image. Fills the text background by given color.

Parameters
[out]canvas- a canvas (image where we draw text).
[in]text- a text to draw.
[in]position- a position to draw text (see Simd::View::Position).
[in]color- a color of the text.
[in]background- background color.
Returns
a result of the operation.