microvg  2.1.0
microvg
freetype_bitmap_helper.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2021-2022 MicroEJ Corp. All rights reserved.
5  * Use of this source code is governed by a BSD-style license that can be found with this software.
6  */
7 
15 #ifndef FREETYPE_BITMAP_HELPER_H_
16 #define FREETYPE_BITMAP_HELPER_H_
17 
18 #ifdef __cplusplus
19  extern "C" {
20 #endif
21 
22 /* Includes ------------------------------------------------------------------*/
23 
24 #include <stdint.h>
25 
26 #include <ft2build.h>
27 #include FT_FREETYPE_H
28 #include <freetype/internal/ftobjs.h>
29 
30 #include <LLVG_FONT_PAINTER_impl.h>
31 #include <LLVG_FONT_impl.h>
32 
33 /* Macros ------------------------------------------------------------------*/
34 
38 #define METRICS_DIVISOR 6
39 
40 #define FT_HELPER_X_MIN 0
41 #define FT_HELPER_Y_MIN 0
43 #define FREETYPE_OK 0
44 #define FREETYPE_INTERNAL_ERROR -1
45 #define FREETYPE_NOT_IMPLEMENTED -2
47 #define TRANSFORM_MATRIX_POS_X 2
48 #define TRANSFORM_MATRIX_POS_Y 5
50 /* Shift for the pixel red component for argb format. */
51 #define FT_RED_SHIFT 16
52 /* Shift for the pixel green component for argb format. */
53 #define FT_GREEN_SHIFT 8
54 /* Shift for the pixel blue component for argb format. */
55 #define FT_BLUE_SHIFT 0
56 
57 
58 /* Private Type Definitions ---------------------------------------------- */
59 
64 typedef struct{
65  FT_Library library;
66  FT_Face face;
67  FT_Error error;
68  FT_GlyphSlot slot;
69  FT_UInt glyph_index;
70  FT_Renderer renderer;
71  FT_Vector pen;
73 
74 typedef struct transform_matrix {
75  float m[3][3];
77 
78 
79 /* Public Function Prototypes ------------------------------------------------ */
80 
81 /*
82  * @brief Returns the highest value between two integers.
83  *
84  * @param[in] X first integer to compare.
85  * @param[in] Y second integer to compare.
86  *
87  * @return X if it has the highest value, Y is returned otherwise.
88  */
89 #define max(X, Y) (((X) > (Y)) ? (X) : (Y))
90 
91 /*
92  * @brief Returns the lowest value between two integers.
93  *
94  * @param[in] X the first integer to compare.
95  * @param[in] Y the second integer to compare.
96  *
97  * @return X if it has the lowest value, Y is returned otherwise.
98  */
99 #define min(X, Y) (((X) < (Y)) ? (X) : (Y))
100 
118 int ft_helper_print_jstring_clipped(MICROUI_GraphicsContext* gc, Freetype_context_type *freetype_context, jchar* string, jint s_size, jint x, jint y, jint color, jint alpha, jfloat size, jint blend, jfloat letterSpacing);
119 
130 static void ft_helper_write_to_framebuffer_clipped(MICROUI_GraphicsContext* gc, Freetype_context_type *freetype_context, jint x, jint y, jint color, jint alpha);
131 
132 
138 void ft_helper_free(Freetype_context_type *freetype_context);
139 
140 // -----------------------------------------------------------------------------
141 // EOF
142 // -----------------------------------------------------------------------------
143 
144 #ifdef __cplusplus
145  }
146 #endif
147 
148 #endif // FREETYPE_BITMAP_HELPER_H_
void ft_helper_free(Freetype_context_type *freetype_context)
Frees all Freetype data context.
Data structure for pack all the variables required by freetype handler.
int ft_helper_print_jstring_clipped(MICROUI_GraphicsContext *gc, Freetype_context_type *freetype_context, jchar *string, jint s_size, jint x, jint y, jint color, jint alpha, jfloat size, jint blend, jfloat letterSpacing)
Prints a string in a buffer respecting the clipping area of the MicroUI Graphics Context.