1 /** 2 * @file lv_freetype.h 3 * 4 */ 5 #ifndef LV_FREETYPE_H 6 #define LV_FREETYPE_H 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 /********************* 13 * INCLUDES 14 *********************/ 15 #include "../../lv_conf_internal.h" 16 17 #if LV_USE_FREETYPE 18 19 #include "../../misc/lv_types.h" 20 #include "../../misc/lv_event.h" 21 #include LV_STDBOOL_INCLUDE 22 23 /********************* 24 * DEFINES 25 *********************/ 26 27 #define LV_FREETYPE_F26DOT6_TO_INT(x) ((x) >> 6) 28 #define LV_FREETYPE_F26DOT6_TO_FLOAT(x) ((float)(x) / 64) 29 30 #define FT_FONT_STYLE_NORMAL LV_FREETYPE_FONT_STYLE_NORMAL 31 #define FT_FONT_STYLE_ITALIC LV_FREETYPE_FONT_STYLE_ITALIC 32 #define FT_FONT_STYLE_BOLD LV_FREETYPE_FONT_STYLE_BOLD 33 34 /********************** 35 * TYPEDEFS 36 **********************/ 37 38 typedef enum { 39 LV_FREETYPE_FONT_STYLE_NORMAL = 0, 40 LV_FREETYPE_FONT_STYLE_ITALIC = 1 << 0, 41 LV_FREETYPE_FONT_STYLE_BOLD = 1 << 1, 42 } lv_freetype_font_style_t; 43 44 typedef lv_freetype_font_style_t LV_FT_FONT_STYLE; 45 46 typedef enum { 47 LV_FREETYPE_FONT_RENDER_MODE_BITMAP = 0, 48 LV_FREETYPE_FONT_RENDER_MODE_OUTLINE = 1, 49 } lv_freetype_font_render_mode_t; 50 51 typedef void * lv_freetype_outline_t; 52 53 typedef enum { 54 LV_FREETYPE_OUTLINE_END, 55 LV_FREETYPE_OUTLINE_MOVE_TO, 56 LV_FREETYPE_OUTLINE_LINE_TO, 57 LV_FREETYPE_OUTLINE_CUBIC_TO, 58 LV_FREETYPE_OUTLINE_CONIC_TO, 59 } lv_freetype_outline_type_t; 60 61 /********************** 62 * GLOBAL PROTOTYPES 63 **********************/ 64 65 /** 66 * Initialize the freetype library. 67 * @return LV_RESULT_OK on success, otherwise LV_RESULT_INVALID. 68 */ 69 lv_result_t lv_freetype_init(uint32_t max_glyph_cnt); 70 71 /** 72 * Uninitialize the freetype library 73 */ 74 void lv_freetype_uninit(void); 75 76 /** 77 * Create a freetype font. 78 * @param pathname font file path. 79 * @param render_mode font render mode(see @lv_freetype_font_render_mode_t for details). 80 * @param size font size. 81 * @param style font style(see lv_freetype_font_style_t for details). 82 * @return Created font, or NULL on failure. 83 */ 84 lv_font_t * lv_freetype_font_create(const char * pathname, lv_freetype_font_render_mode_t render_mode, uint32_t size, 85 lv_freetype_font_style_t style); 86 87 /** 88 * Delete a freetype font. 89 * @param font freetype font to be deleted. 90 */ 91 void lv_freetype_font_delete(lv_font_t * font); 92 93 /** 94 * Register a callback function to generate outlines for FreeType fonts. 95 * 96 * @param cb The callback function to be registered. 97 * @param user_data User data to be passed to the callback function. 98 * @return The ID of the registered callback function, or a negative value on failure. 99 */ 100 void lv_freetype_outline_add_event(lv_event_cb_t event_cb, lv_event_code_t filter, void * user_data); 101 102 /** 103 * Get the scale of a FreeType font. 104 * 105 * @param font The FreeType font to get the scale of. 106 * @return The scale of the FreeType font. 107 */ 108 uint32_t lv_freetype_outline_get_scale(const lv_font_t * font); 109 110 /** 111 * Check if the font is an outline font. 112 * 113 * @param font The FreeType font. 114 * @return Is outline font on success, otherwise false. 115 */ 116 bool lv_freetype_is_outline_font(const lv_font_t * font); 117 118 /********************** 119 * MACROS 120 **********************/ 121 122 #endif /*LV_USE_FREETYPE*/ 123 124 #ifdef __cplusplus 125 } /* extern "C" */ 126 #endif 127 128 #endif /* LV_FREETYPE_H */ 129