Open Font Render 1.2
|
Macros | |
#define | setDrawPixel(F) set_drawPixel([&](int32_t x, int32_t y, uint16_t c) { return F(x, y, c); }) |
Set function to draw pixel to screen. | |
#define | setDrawFastHLine(F) set_drawFastHLine([&](int32_t x, int32_t y, int32_t w, uint16_t c) { return F(x, y, w, c); }) |
Set function to fast draw horizontal line to screen. (Optional) | |
#define | setStartWrite(F) set_startWrite([&](void) { return F(); }) |
It is called only once at the beginning of a sequence of drawings. (Optional) | |
#define | setEndWrite(F) set_endWrite([&](void) { return F(); }) |
It is called only once at the beginning of a sequence of drawings. (Optional) | |
#define | setPrintFunc(F) set_printFunc([&](const char *s) { return F(s); }) |
Specifies the standard output destination for the system. (Optional) | |
Functions | |
template<typename T > | |
void | OpenFontRender::setDrawer (T &drawer) |
Collectively set up screen control functions. | |
void | OpenFontRender::setCacheSize (unsigned int max_faces, unsigned int max_sizes, unsigned long max_bytes) |
Set FreeType cache size. | |
FT_Error | OpenFontRender::loadFont (const unsigned char *data, size_t size, uint8_t target_face_index=0) |
Load font from memory. | |
FT_Error | OpenFontRender::loadFont (const char *fpath, uint8_t target_face_index=0) |
Load font from external memory. | |
void | OpenFontRender::unloadFont () |
Unload font data. | |
uint16_t | OpenFontRender::drawHString (const char *str, int32_t x, int32_t y, uint16_t fg, uint16_t bg, Align align, Drawing drawing, FT_BBox &abbox, FT_Error &error) |
Renders text horizontally. | |
FT_Error | OpenFontRender::drawChar (char character, int32_t x=0, int32_t y=0, uint16_t fg=0xFFFF, uint16_t bg=0x0000, Align align=Align::Left) |
Render single character. | |
uint16_t | OpenFontRender::drawString (const char *str, int32_t x=0, int32_t y=0, uint16_t fg=0xFFFF, uint16_t bg=0x0000, Layout layout=Layout::Horizontal) |
Renders text. | |
uint16_t | OpenFontRender::cdrawString (const char *str, int32_t x=0, int32_t y=0, uint16_t fg=0xFFFF, uint16_t bg=0x0000, Layout layout=Layout::Horizontal) |
Renders text as Top-Center. | |
uint16_t | OpenFontRender::rdrawString (const char *str, int32_t x=0, int32_t y=0, uint16_t fg=0xFFFF, uint16_t bg=0x0000, Layout layout=Layout::Horizontal) |
Renders text as Top-Right. | |
uint16_t | OpenFontRender::printf (const char *fmt,...) |
Renders text with format specifier. | |
uint16_t | OpenFontRender::cprintf (const char *fmt,...) |
Renders text as Top-Center with format specifier. | |
uint16_t | OpenFontRender::rprintf (const char *fmt,...) |
Renders text as Top-Right with format specifier. | |
FT_BBox | OpenFontRender::calculateBoundingBoxFmt (int32_t x, int32_t y, unsigned int font_size, Align align, Layout layout, const char *fmt,...) |
Calculate text bounding box with format specifier. | |
FT_BBox | OpenFontRender::calculateBoundingBox (int32_t x, int32_t y, unsigned int font_size, Align align, Layout layout, const char *str) |
Calculate text bounding box. | |
uint32_t | OpenFontRender::getTextWidth (const char *fmt,...) |
Calculate text width. | |
uint32_t | OpenFontRender::getTextHeight (const char *fmt,...) |
Calculate text height. | |
unsigned int | OpenFontRender::calculateFitFontSizeFmt (uint32_t limit_width, uint32_t limit_height, Layout layout, const char *fmt,...) |
Calculates the maximum font size that will fit the specified format string and the specified rectangle. | |
unsigned int | OpenFontRender::calculateFitFontSize (uint32_t limit_width, uint32_t limit_height, Layout layout, const char *str) |
Calculates the maximum font size that will fit the specified string and the specified rectangle. | |
This is a group of methods related to text rendering.
#define setDrawFastHLine | ( | F | ) | set_drawFastHLine([&](int32_t x, int32_t y, int32_t w, uint16_t c) { return F(x, y, w, c); }) |
Set function to fast draw horizontal line to screen. (Optional)
[in] | (user_func) | User function for fast draw horizontal line to screen. |
Type | Name | Description |
---|---|---|
int32_t | x | Draw position X |
int32_t | y | Draw position Y |
int32_t | w | Draw Length |
int32_t | c | Draw color (16 bit color) |
#define setDrawPixel | ( | F | ) | set_drawPixel([&](int32_t x, int32_t y, uint16_t c) { return F(x, y, c); }) |
Set function to draw pixel to screen.
[in] | (user_func) | User function for draw pixel to screen. |
Type | Name | Description |
---|---|---|
int32_t | x | Draw position X |
int32_t | y | Draw position Y |
int32_t | c | Draw color (16 bit color) |
#define setEndWrite | ( | F | ) | set_endWrite([&](void) { return F(); }) |
It is called only once at the beginning of a sequence of drawings. (Optional)
Certain libraries can occupy the bus during continuous drawing to increase the drawing speed.
[in] | (user_func) | User function that call after draw to screen. |
#define setPrintFunc | ( | F | ) | set_printFunc([&](const char *s) { return F(s); }) |
Specifies the standard output destination for the system. (Optional)
[in] | (user_func) | User function for output message. |
#define setStartWrite | ( | F | ) | set_startWrite([&](void) { return F(); }) |
It is called only once at the beginning of a sequence of drawings. (Optional)
Certain libraries can occupy the bus during continuous drawing to increase the drawing speed.
[in] | (user_func) | User function that call before draw to screen. |
FT_BBox OpenFontRender::calculateBoundingBox | ( | int32_t | x, |
int32_t | y, | ||
unsigned int | font_size, | ||
Align | align, | ||
Layout | layout, | ||
const char * | str | ||
) |
Calculate text bounding box.
[in] | (x) | Drawing start position (x-coordinate). |
[in] | (y) | Drawing start position (y-coordinate). |
[in] | (font_size) | Font size. |
[in] | (align) | Text alignment. |
[in] | (layout) | Direction of writing. |
[in] | (*str) | Target string. |
FT_BBox OpenFontRender::calculateBoundingBoxFmt | ( | int32_t | x, |
int32_t | y, | ||
unsigned int | font_size, | ||
Align | align, | ||
Layout | layout, | ||
const char * | fmt, | ||
... | |||
) |
Calculate text bounding box with format specifier.
[in] | (x) | Drawing start position (x-coordinate). |
[in] | (y) | Drawing start position (y-coordinate). |
[in] | (font_size) | Font size. |
[in] | (align) | Text alignment. |
[in] | (layout) | Direction of writing. |
[in] | (*fmt) | Format specifier. |
[in] | (...) | Arguments for format specifier. |
unsigned int OpenFontRender::calculateFitFontSize | ( | uint32_t | limit_width, |
uint32_t | limit_height, | ||
Layout | layout, | ||
const char * | str | ||
) |
Calculates the maximum font size that will fit the specified string and the specified rectangle.
[in] | (limit_width) | Limit width size. |
[in] | (limit_height) | Limit height size. |
[in] | (layout) | Direction of text writing. |
[in] | (*str) | Target string. |
unsigned int OpenFontRender::calculateFitFontSizeFmt | ( | uint32_t | limit_width, |
uint32_t | limit_height, | ||
Layout | layout, | ||
const char * | fmt, | ||
... | |||
) |
Calculates the maximum font size that will fit the specified format string and the specified rectangle.
[in] | (limit_width) | Limit width size. |
[in] | (limit_height) | Limit height size. |
[in] | (layout) | Direction of text writing. |
[in] | (*fmt) | Format specifier. |
[in] | (...) | Arguments for format specifier. |
uint16_t OpenFontRender::cdrawString | ( | const char * | str, |
int32_t | x = 0 , |
||
int32_t | y = 0 , |
||
uint16_t | fg = 0xFFFF , |
||
uint16_t | bg = 0x0000 , |
||
Layout | layout = Layout::Horizontal |
||
) |
Renders text as Top-Center.
[in] | (*str) | String to draw. |
[in] | (x) | Drawing start position (x-coordinate). |
[in] | (y) | Drawing start position (y-coordinate). |
[in] | (fg) | 16 bit rgb color for text. |
[in] | (bg) | 16 bit rgb color for background. |
[in] | (layout) | Direction of writing. |
Vertical
is not yet supported (will be implemented in the future). It is recommended to use the printf
or drawString
functions in combination with optional methods such as setAlignment
function.
It will be removed in the future.
uint16_t OpenFontRender::cprintf | ( | const char * | fmt, |
... | |||
) |
Renders text as Top-Center with format specifier.
[in] | (*fmt) | Format specifier. |
[in] | (...) | Arguments for format specifier. |
It is recommended to use the printf
or drawString
functions in combination with optional methods such as setAlignment
function.
It will be removed in the future.
FT_Error OpenFontRender::drawChar | ( | char | character, |
int32_t | x = 0 , |
||
int32_t | y = 0 , |
||
uint16_t | fg = 0xFFFF , |
||
uint16_t | bg = 0x0000 , |
||
Align | align = Align::Left |
||
) |
Render single character.
[in] | (character) | Character to draw. |
[in] | (x) | Drawing start position (x-coordinate). |
[in] | (y) | Drawing start position (y-coordinate). |
[in] | (fg) | 16 bit rgb color for text. |
[in] | (bg) | 16 bit rgb color for background. |
[in] | (align) | Text alignment. |
uint16_t OpenFontRender::drawHString | ( | const char * | str, |
int32_t | x, | ||
int32_t | y, | ||
uint16_t | fg, | ||
uint16_t | bg, | ||
Align | align, | ||
Drawing | drawing, | ||
FT_BBox & | abbox, | ||
FT_Error & | error | ||
) |
Renders text horizontally.
[in] | (*str) | String to draw. |
[in] | (x) | Drawing start position (x-coordinate). |
[in] | (y) | Drawing start position (y-coordinate). |
[in] | (fg) | 16 bit rgb color for text. |
[in] | (bg) | 16 bit rgb color for background. |
[in] | (align) | Text alignment. |
[in] | (drawing) | Mode of draw to screen |
[out] | (&abbox) | Bounding box around drawn text. |
[out] | (&error) | Rendering error. |
printf
and drawString
functions in combination with optional methods such as setFontColor
and setAlignment
function. uint16_t OpenFontRender::drawString | ( | const char * | str, |
int32_t | x = 0 , |
||
int32_t | y = 0 , |
||
uint16_t | fg = 0xFFFF , |
||
uint16_t | bg = 0x0000 , |
||
Layout | layout = Layout::Horizontal |
||
) |
Renders text.
[in] | (*str) | String to draw. |
[in] | (x) | Drawing start position (x-coordinate). |
[in] | (y) | Drawing start position (y-coordinate). |
[in] | (fg) | 16 bit rgb color for text. |
[in] | (bg) | 16 bit rgb color for background. |
[in] | (layout) | Direction of writing. |
Vertical
is not yet supported (will be implemented in the future). uint32_t OpenFontRender::getTextHeight | ( | const char * | fmt, |
... | |||
) |
Calculate text height.
[in] | (*fmt) | Format specifier. |
[in] | (...) | Arguments for format specifier. |
uint32_t OpenFontRender::getTextWidth | ( | const char * | fmt, |
... | |||
) |
Calculate text width.
[in] | (*fmt) | Format specifier. |
[in] | (...) | Arguments for format specifier. |
FT_Error OpenFontRender::loadFont | ( | const char * | fpath, |
uint8_t | target_face_index = 0 |
||
) |
Load font from external memory.
[in] | (*fpath) | Font file path. |
[in] | (target_face_index) | Load font index. Default is 0. |
FT_Error OpenFontRender::loadFont | ( | const unsigned char * | data, |
size_t | size, | ||
uint8_t | target_face_index = 0 |
||
) |
Load font from memory.
[in] | (*data) | Font data array. |
[in] | (size) | Font data array size. |
[in] | (target_face_index) | Load font index. Default is 0. |
uint16_t OpenFontRender::printf | ( | const char * | fmt, |
... | |||
) |
Renders text with format specifier.
[in] | (*fmt) | Format specifier. |
[in] | (...) | Arguments for format specifier. |
uint16_t OpenFontRender::rdrawString | ( | const char * | str, |
int32_t | x = 0 , |
||
int32_t | y = 0 , |
||
uint16_t | fg = 0xFFFF , |
||
uint16_t | bg = 0x0000 , |
||
Layout | layout = Layout::Horizontal |
||
) |
Renders text as Top-Right.
[in] | (*str) | String to draw. |
[in] | (x) | Drawing start position (x-coordinate). |
[in] | (y) | Drawing start position (y-coordinate). |
[in] | (fg) | 16 bit rgb color for text. |
[in] | (bg) | 16 bit rgb color for background. |
[in] | (layout) | Direction of writing. |
Vertical
is not yet supported (will be implemented in the future). It is recommended to use the printf
or drawString
functions in combination with optional methods such as setAlignment
function.
It will be removed in the future.
uint16_t OpenFontRender::rprintf | ( | const char * | fmt, |
... | |||
) |
Renders text as Top-Right with format specifier.
[in] | (*fmt) | Format specifier. |
[in] | (...) | Arguments for format specifier. |
It is recommended to use the printf
or drawString
functions in combination with optional methods such as setAlignment
function.
It will be removed in the future.
void OpenFontRender::setCacheSize | ( | unsigned int | max_faces, |
unsigned int | max_sizes, | ||
unsigned long | max_bytes | ||
) |
Set FreeType cache size.
[in] | (max_faces) | Maximum number of opened FT_Face objects. |
[in] | (max_sizes) | Maximum number of opened FT_Size objects. |
[in] | (max_bytes) | Maximum number of bytes to use for cached data. |
CACHE_SIZE_MINIMUM
.
|
inline |
Collectively set up screen control functions.
(T) | Screen control class. |
[in] | (&drawer) | Instance for screen control. |
drawPixel(x, y, c)
, drawFastHLine(x, y, w, c)
, startWrite()
, endWrite()
void OpenFontRender::unloadFont | ( | ) |
Unload font data.