1 /**************************************************************************** 2 * 3 * The MIT License (MIT) 4 * 5 * Copyright 2020 NXP 6 * All Rights Reserved. 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining 9 * a copy of this software and associated documentation files (the 10 * 'Software'), to deal in the Software without restriction, including 11 * without limitation the rights to use, copy, modify, merge, publish, 12 * distribute, sub license, and/or sell copies of the Software, and to 13 * permit persons to whom the Software is furnished to do so, subject 14 * to the following conditions: 15 * 16 * The above copyright notice and this permission notice (including the 17 * next paragraph) shall be included in all copies or substantial 18 * portions of the Software. 19 * 20 * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 23 * IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS BE LIABLE FOR ANY 24 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 * 28 *****************************************************************************/ 29 30 #ifndef _VFT_DRAW_H 31 #define _VFT_DRAW_H 32 33 #include <stdint.h> 34 35 typedef enum eFontBlkType { 36 eUnkBlock, 37 eFontFaceDesc, 38 eGlyphTableDesc, 39 eKernTableDesc, 40 eGlyphData, 41 eMaxBlock 42 }eFontBlock_t; 43 44 static const int32_t BLK_HDR_SIZE = 4; 45 46 typedef struct path_descriptor { 47 float bounds[4]; 48 uint32_t num_draw_cmds; 49 uint32_t draw_cmds_offset; 50 float* draw_cmds; /* NOTE: this will be used while loading table, DONT REMOVE */ 51 }path_desc_t; 52 53 typedef struct kern_desc { 54 uint16_t unicode; 55 uint16_t kern; 56 }kern_desc_t; 57 58 typedef struct glyph_descriptor { 59 uint16_t unicode; /* unicode name */ 60 uint16_t horiz_adv_x; /* Short to align to 32-bit boundry */ 61 uint32_t kern_num_entries; 62 uint32_t kern_table_offset; 63 kern_desc_t* kern_table; /* NOTE: this will be used while loading table, DONT REMOVE */ 64 path_desc_t path; 65 }glyph_desc_t; 66 67 typedef struct font_face_info { 68 int8_t font_family_name[64]; 69 uint16_t units_per_em; 70 uint16_t ascent; 71 uint16_t descent; 72 uint16_t vg_font; 73 uint32_t num_glyphs; 74 glyph_desc_t* glyphs; /* NOTE: this will be used while loading table, DONT REMOVE */ 75 }font_face_desc_t; 76 77 //NOTE: No glyph caching at this time 78 79 /* Load vector font ROM table from file */ 80 font_face_desc_t* vft_load(char* vcft_file_path); 81 82 /* Find glyph of given character from glyph table */ 83 glyph_desc_t* vft_find_glyph(font_face_desc_t* font_face, uint16_t ug2); 84 85 /* Find distance between 2 glyph symbols */ 86 int vft_glyph_distance(glyph_desc_t* g1, glyph_desc_t* g2); 87 88 /* 89 * Get internal vector path of given glyph 90 * This is internal function 91 */ 92 path_desc_t* vft_get_glyph_path(glyph_desc_t* g2); 93 94 /* Draw vector font based glyph on given x,y co-ordinate */ 95 void vft_draw_glyph(int x, int y, glyph_desc_t* g2); 96 97 /* Compute horizotal pixels coverted by this path */ 98 int vft_compute_dx(glyph_desc_t* g2); 99 100 /* Unload font face descriptor and all glyphs */ 101 void vft_unload(font_face_desc_t*); 102 103 /* Draw string with vector font s*/ 104 int vg_lite_vtf_draw_text(vg_lite_buffer_t *rt, int x, int y, 105 vg_lite_blend_t blend, 106 vg_lite_font_t font, 107 vg_lite_matrix_t *matrix, 108 vg_lite_font_attributes_t * attributes, 109 char *text); 110 111 /* Internal memory allocator API */ 112 void *_mem_allocate(int size); 113 void _mem_free(void *buf); 114 115 vg_lite_error_t vg_lite_load_font_data(vg_lite_font_t font, int font_height); 116 font_face_desc_t* vft_load_from_buffer(char* buf_base, int file_size); 117 void vg_lite_unload_font_data(void); 118 119 #endif //!_VFT_DRAW_H 120