microvg  8.0.3
microvg
vg_freetype.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2020-2026 MicroEJ Corp. All rights reserved.
5  * MicroEJ Corp. PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  *
7  * Build: 7E4D1F7C
8  */
9 
17 #if !defined VG_FREETYPE_H
18 #define VG_FREETYPE_H
19 
20 #if defined __cplusplus
21 extern "C" {
22 #endif
23 
24 #include "vg_configuration.h"
25 
26 #if defined VG_FEATURE_FONT && \
27  (defined VG_FEATURE_FONT_FREETYPE_VECTOR || defined VG_FEATURE_FONT_FREETYPE_BITMAP) && \
28  (VG_FEATURE_FONT == VG_FEATURE_FONT_FREETYPE_VECTOR || VG_FEATURE_FONT == VG_FEATURE_FONT_FREETYPE_BITMAP)
29 
30 // -----------------------------------------------------------------------------
31 // Includes
32 // -----------------------------------------------------------------------------
33 
34 #include "vg_path.h"
35 
36 // --------------------------------------------------------------------------------
37 // Typedef
38 // --------------------------------------------------------------------------------
39 
56 typedef jint (* VG_FREETYPE_draw_glyph_t) (
57  /*
58  * @brief The path of the glyph.
59  */
60  VG_PATH_HEADER_t *path,
61 
62  /*
63  * @brief The deformation to apply on the path.
64  */
65  jfloat *matrix,
66 
67  /*
68  * @brief The specific glyph color (example: emoji) or the current destination
69  * color. Useless if the string is drawn with a gradient.
70  */
71  uint32_t color,
72 
73  /*
74  * @brief The glyph outline: true: EVEN_ODD or false: NON_ZERO.
75  */
76  bool fill_rule_even_odd,
77 
78  /*
79  * @brief The custom drawer data (may be null). For instance this structure can
80  * hold the gradient if the GPU's drawing function requires it. In case of
81  * the gradient is set before calling VG_FREETYPE_draw_string(), the
82  * gradient doesn't need to be stored in this structure.
83  */
84  void *user_data);
85 
86 // --------------------------------------------------------------------------------
87 // API
88 // --------------------------------------------------------------------------------
89 
94 
124 bool VG_FREETYPE_string_span(const jchar *text, jint length, jint face_handle, jfloat letter_spacing_font_units,
125  jfloat *left, jfloat *right);
126 
142 jfloat VG_FREETYPE_string_width(jchar *text, jint length, jint face_handle, jfloat size, jfloat letter_spacing);
143 
154 jfloat VG_FREETYPE_get_scale(jint face_handle, jfloat size);
155 
175 jint VG_FREETYPE_draw_string(VG_FREETYPE_draw_glyph_t drawer, const jchar *text, jint length, jint face_handle,
176  jfloat size, const jfloat *matrix, uint32_t color, jfloat letter_spacing, jfloat radius,
177  jint direction, void *user_data);
178 
179 // -----------------------------------------------------------------------------
180 // Implementation
181 // -----------------------------------------------------------------------------
182 
183 /*
184  * @brief Converts an ARGB8888 color to a format compatible with the GPU. The default
185  * implementation does nothing and just returns the original color.
186  */
187 jint VG_FREETYPE_IMPL_convert_color(jint color);
188 
189 // -----------------------------------------------------------------------------
190 // EOF
191 // -----------------------------------------------------------------------------
192 #endif \
193  // defined VG_FEATURE_FONT && \
194  // (defined VG_FEATURE_FONT_FREETYPE_VECTOR || defined VG_FEATURE_FONT_FREETYPE_BITMAP) && \
195  // (VG_FEATURE_FONT == VG_FEATURE_FONT_FREETYPE_VECTOR || VG_FEATURE_FONT == VG_FEATURE_FONT_FREETYPE_BITMAP)
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 #endif // !defined VG_FREETYPE_H
Map a jbyte array that represents a path.
Definition: vg_path.h:54
MicroEJ MicroVG library low level API: enable some features according to the hardware capacities.
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.
void VG_FREETYPE_initialize(void)
Initializes the lowlevel font library.
jfloat VG_FREETYPE_get_scale(jint face_handle, jfloat size)
Computes the scale that converts font units to pixels at the given size.
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.
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....
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.
Definition: vg_freetype.h:56
MicroEJ MicroVG library low level API: implementation of Path.