GlyType 0.1
a ultra lightweight font renderer and font
|
Macros | |
#define | GLY_TYPE_INT unsigned char |
#define | GLY_TYPE_SAFE |
Functions | |
void | gly_type_render (GLY_TYPE_INT x, GLY_TYPE_INT y, GLY_TYPE_INT s, const char *t, signed int len, const void *const f) |
a ultra lightweight font renderer and font
The 8 bit/segment it is a special line, its size varies, from bottom to top it stops when it hits the first fixed segment G
or A
There are special characters, which would be x , v and z to differentiate them from all other characters, they have their own internal rendering function, are flagged as segment H
without segment G
or A
#define GLY_TYPE_INT unsigned char |
The GLY_TYPE_INT
defines the integer type used for coordinates and sizes in gly_type_render.
int
but size varies by compiler/architecture. Common in rendering libraries. uint8_t
suitable for small screens or limited coordinate ranges. uint16_t
often ideal for most cases, balancing range and memory efficiency.#define GLY_TYPE_SAFE |
The GLY_TYPE_SAFE
macro enables a length parameter to ensure safe string handling in the gly_type_render function. When defined, it activates an additional check to limit the number of processed characters, preventing access beyond the string's end.
void gly_type_render | ( | GLY_TYPE_INT | x, |
GLY_TYPE_INT | y, | ||
GLY_TYPE_INT | s, | ||
const char * | t, | ||
signed int | len, | ||
const void *const | f ) |
gly_type_render
The gly_type_render
function is used to render text at specified coordinates using a line-drawing function. It employs segments to display characters and allows control over the position and size of the rendered characters.
len
parameter is used, GLY_TYPE_SAFE must be defined with #define GLY_TYPE_SAFE
prior to including this function.[in] | x | Horizontal coordinate (in pixels). |
[in] | y | Vertical coordinate (in pixels). |
[in] | size | Character size in pixels. |
[in] | text | Text string to be rendered, terminated with a null character (\0 ). |
[in] | fptr | Pointer to a line-drawing function, with the interface: function(x1, y1, x2, y2) draws a line from (x1, y1) to (x2, y2) . |
Optional Parameter:
[in] | len | Maximum length of characters to process, applicable only if GLY_TYPE_SAFE is defined. If len is -1, all characters in the string are processed until the null terminator. |
Total Size:
length(text) * (size + 1)
min(count(text, 0x0A), 1) * (size + 1)
Example Usage:
This function will render the text "hello world" at the coordinates (x, y)
, with the specified character size, using draw_line_func
to draw the lines.