![]() |
microvg
8.0.3
microvg
|
MicroEJ MicroVG library low level API: implementation over FreeType. More...
Go to the source code of this file.
Typedefs | |
| typedef jint(* | VG_FREETYPE_draw_glyph_t) (VG_PATH_HEADER_t *path, jfloat *matrix, uint32_t color, bool fill_rule_even_odd, void *user_data) |
| Function to draw a character element: a glyph. A glyph is a vectorial path. More... | |
Functions | |
| void | VG_FREETYPE_initialize (void) |
| Initializes the lowlevel font library. | |
| bool | VG_FREETYPE_string_span (const jchar *text, jint length, jint face_handle, jfloat letter_spacing_font_units, jfloat *left, jfloat *right) |
| Folds the ink of a string and returns its two extreme edges. More... | |
| jfloat | VG_FREETYPE_string_width (jchar *text, jint length, jint face_handle, jfloat size, jfloat letter_spacing) |
| Measures the width of a text for the specified font and size. More... | |
| jfloat | VG_FREETYPE_get_scale (jint face_handle, jfloat size) |
| Computes the scale that converts font units to pixels at the given size. More... | |
| jint | VG_FREETYPE_draw_string (VG_FREETYPE_draw_glyph_t drawer, const jchar *text, jint length, jint face_handle, jfloat size, const jfloat *matrix, uint32_t color, jfloat letter_spacing, jfloat radius, jint direction, void *user_data) |
| Draws a string using the Freetype engine along a line or a circle, with a color or a linear gradient. The implementation does not draw, it calls the drawer function for each glyph: VG_FREETYPE_draw_glyph_t. More... | |
| jint | VG_FREETYPE_IMPL_convert_color (jint color) |
MicroEJ MicroVG library low level API: implementation over FreeType.
Definition in file vg_freetype.h.
| typedef jint(* VG_FREETYPE_draw_glyph_t) ( VG_PATH_HEADER_t *path, jfloat *matrix, uint32_t color, bool fill_rule_even_odd, void *user_data) |
Function to draw a character element: a glyph. A glyph is a vectorial path.
This function is called by VG_FREETYPE_draw_string(). Two implementations are required: one that draws the path with a color and one that draws the path with a gradient.
The list of the drawing parameters is reduced to the elements that the Freetype engine changes for each glyph: the glyph's path, the transformation to apply on the glyph, the glyph color (useful for colored glyphs like emoji), the glyph's outine.
All others elements required by the drawer (if any) have to be listed in the dedicated structure user_data.
Definition at line 56 of file vg_freetype.h.
| jint VG_FREETYPE_draw_string | ( | VG_FREETYPE_draw_glyph_t | drawer, |
| const jchar * | text, | ||
| jint | length, | ||
| jint | face_handle, | ||
| jfloat | size, | ||
| const jfloat * | matrix, | ||
| uint32_t | color, | ||
| jfloat | letter_spacing, | ||
| jfloat | radius, | ||
| jint | direction, | ||
| void * | user_data | ||
| ) |
Draws a string using the Freetype engine along a line or a circle, with a color or a linear gradient. The implementation does not draw, it calls the drawer function for each glyph: VG_FREETYPE_draw_glyph_t.
| [in] | drawer | the function to draw a glyph. |
| [in] | text | the array of characters to draw. |
| [in] | length | the length of the array |
| [in] | face_handle | the font reference handle. |
| [in] | size | the height of the font in pixels. |
| [in] | matrix | the transformation to apply. |
| [in] | color | the 32-bit color to apply (useless when drawing with a gradient). |
| [in] | letter_spacing | the extra letter spacing to use. |
| [in] | radius | the radius of the circle (0 to draw along a line). |
| [in] | direction | the direction of the text along the circle (0 to draw along a line). |
| [in] | user_data | the data used by the drawer; may be null. |
| jfloat VG_FREETYPE_get_scale | ( | jint | face_handle, |
| jfloat | size | ||
| ) |
Computes the scale that converts font units to pixels at the given size.
LLVG_FONT_IMPL_load_font() refuses a face whose EM size is 0, so the division is always defined.
| [in] | face_handle | the font reference handle. |
| [in] | size | the height of the font in pixels. |
| bool VG_FREETYPE_string_span | ( | const jchar * | text, |
| jint | length, | ||
| jint | face_handle, | ||
| jfloat | letter_spacing_font_units, | ||
| jfloat * | left, | ||
| jfloat * | right | ||
| ) |
Folds the ink of a string and returns its two extreme edges.
Every glyph is placed at its own pen position, and a glyph that draws nothing contributes no edge at either end. The pen carries the letter spacing, so a string that draws no glyph has no span whatever the spacing is.
Returns the two extreme edges of the ink; the caller decides what to do with them.
A caller that passes NULL for the right edge asks for the left one alone. The fold then stops as soon as no remaining glyph can reach further left, so it reads a few glyphs instead of the whole string. It returns the same left edge as a full fold as long as no glyph is placed more than one EM to the left of its own pen position, which is the margin the stop keeps; a letter spacing below zero and an advance seen to be negative each disable the stop instead of narrowing that margin.
The function leaves no iteration open, so a caller that iterates afterwards must call VG_HELPER_layout_configure() again.
| [in] | text | the array of characters to fold. |
| [in] | length | the length of the array. |
| [in] | face_handle | the font reference handle. |
| [in] | letter_spacing_font_units | the extra letter spacing, in font units. |
| [out] | left | the left edge of the ink, in font units; untouched when no glyph draws. |
| [out] | right | the right edge of the ink, in font units; untouched when no glyph draws. NULL asks for the left edge alone, which lets the fold stop before the end of the string. |
| jfloat VG_FREETYPE_string_width | ( | jchar * | text, |
| jint | length, | ||
| jint | face_handle, | ||
| jfloat | size, | ||
| jfloat | letter_spacing | ||
| ) |
Measures the width of a text for the specified font and size.
The width is the union of the ink of every glyph, each at its own pen position: the leftmost pixel any glyph draws to the rightmost, whichever glyphs those are. A character that draws nothing contributes nothing, at either end.
| [in] | text | the array of characters to draw. |
| [in] | length | the length of the array |
| [in] | face_handle | the font reference handle |
| [in] | size | the height of the font in pixels. |
| [in] | letter_spacing | the extra letter spacing to use |
1.9.1