1 #ifndef _EVAS_TEXT_UTILS_H 2 # define _EVAS_TEXT_UTILS_H 3 4 typedef struct _Evas_Text_Props Evas_Text_Props; 5 // special case props 6 typedef struct _Evas_Text_Props_One Evas_Text_Props_One; 7 8 typedef struct _Evas_Text_Props_Info Evas_Text_Props_Info; 9 typedef struct _Evas_Font_Array_Data Evas_Font_Array_Data; 10 typedef struct _Evas_Font_Array Evas_Font_Array; 11 typedef struct _Evas_Font_Glyph_Info Evas_Font_Glyph_Info; 12 13 typedef enum 14 { 15 EVAS_TEXT_PROPS_MODE_NONE = 0, 16 EVAS_TEXT_PROPS_MODE_SHAPE 17 } Evas_Text_Props_Mode; 18 19 # include "evas_font_ot.h" 20 # include "language/evas_language_utils.h" 21 22 /* Used for showing "malformed" or missing chars */ 23 #define REPLACEMENT_CHAR 0xFFFD 24 25 typedef struct _Evas_Glyph Evas_Glyph; 26 typedef struct _Evas_Glyph_Array Evas_Glyph_Array; 27 28 struct _Evas_Glyph_Array 29 { 30 Eina_Inarray *array; 31 void *fi; 32 unsigned int refcount; 33 }; 34 35 struct _Evas_Text_Props 36 { 37 Evas_Text_Props_Info *info; // 8/4 38 Evas_Glyph_Array *glyphs; // 8/4 39 void *font_instance; // 8/4 40 /* Start and len represent the start offset and the length in the 41 * glyphs_info and ot_data fields, they are both internal */ 42 // i only wonder if generation needs 32bits... :) 43 int generation; // 4 44 // Evas_BiDi_Props bidi; // 4 // bidi.dir == enum 45 // Evas_Script_Type script; // 4 // enum 46 // Eina_Bool changed : 1; // 1 47 // Eina_Bool prepare : 1; 48 // // +3 pad 49 // ** the below saves 8 bytes (72 -> 64 on 64bit) 50 Evas_BiDi_Direction bidi_dir : 2; // 2 (enough for values) 51 Evas_Script_Type script : 7; // cont (enough for values) 52 Eina_Bool changed : 1; // cont (bool) 53 Eina_Bool prepare : 1; // cont (bool) 54 // we have space here for at LEAST 5 bits (round up to 2 bytes) but due 55 // to common padding we actually can add 5 + 16 (21) more bits for free 56 Eina_Bool szlen_mode : 5; // use 5 of he 21 bits 57 // this can go here as the above is nicely aligned.... 58 // this is really big... 32 bytes. MOSt of the time the following... 59 // start == text_offset == 0 AND len == text_len == smallish value (8 or 60 // 16 bit is enough to store it most of the time). 61 size_t start; // 8/4 62 size_t len; // 8/4 63 size_t text_offset; // 8/4 /* The text offset from the start of the info */ 64 size_t text_len; // 8/4 /* The length of the original text */ 65 }; 66 67 #define EVAS_TP_SZLEN_FULL 0 68 #define EVAS_TP_SZLEN_ONE 1 69 70 // special case textprop for ONE char! should use this for textgrid but 71 // we have to modify every bit of code that usea a textprop to go through a 72 // getter or setter etc. etc. 73 struct _Evas_Text_Props_One 74 { 75 Evas_Text_Props_Info *info; // 8/4 76 Evas_Glyph_Array *glyphs; // 8/4 77 void *font_instance; // 8/4 78 /* Start and len represent the start offset and the length in the 79 * glyphs_info and ot_data fields, they are both internal */ 80 // i only wonder if generation needs 32bits... :) 81 int generation; // 4 82 // Evas_BiDi_Props bidi; // 4 // bidi.dir == enum 83 // Evas_Script_Type script; // 4 // enum 84 // Eina_Bool changed : 1; // 1 85 // Eina_Bool prepare : 1; 86 // // +3 pad 87 // ** the below saves 8 bytes (72 -> 64 on 64bit) 88 Evas_BiDi_Direction bidi_dir : 2; // 2 (enough for values) 89 Evas_Script_Type script : 7; // cont (enough for values) 90 Eina_Bool changed : 1; // cont (bool) 91 Eina_Bool prepare : 1; // cont (bool) 92 // we have space here for at LEAST 5 bits (round up to 2 bytes) but due 93 // to common padding we actually can add 5 + 16 (21) more bits for free 94 Eina_Bool szlen_mode : 5; // use 5 of he 21 bits 95 }; 96 97 struct _Evas_Text_Props_Info 98 { 99 Evas_Font_Glyph_Info *glyph; // 8/4 100 Evas_Font_OT_Info *ot; // 8/4 101 unsigned int refcount; // 4 102 }; 103 104 struct _Evas_Font_Array_Data 105 { 106 struct { 107 unsigned char r, g, b, a; 108 } color; 109 int x; 110 Evas_Glyph_Array *glyphs; 111 }; 112 113 struct _Evas_Font_Array 114 { 115 Eina_Inarray *array; 116 unsigned int refcount; 117 }; 118 119 /* Sorted in visual order when created */ 120 struct _Evas_Font_Glyph_Info 121 { 122 unsigned int index; // 4 /* Should conform to FT */ 123 #if 1 124 // done with shorts to save space... if we need 32k or bigger glyphs and 125 // relative layout info... worry then. 126 Evas_Coord pen_after; // 4 127 short x_bear, y_bear, width; // 6 128 #else 129 Evas_Coord x_bear; // 4 130 /* This one is rarely used, only in draw, in which we already get the glyph 131 * so it doesn't really save time. Leaving it here just so no one will 132 * add it thinking it was accidentally skipped */ 133 Evas_Coord y_bear; // 4 134 Evas_Coord width; // 4 135 Evas_Coord pen_after; // 4 136 #endif 137 }; 138 139 void 140 evas_common_font_glyphs_ref(Evas_Glyph_Array *array); 141 void 142 evas_common_font_glyphs_unref(Evas_Glyph_Array *array); 143 144 void 145 evas_common_font_fonts_ref(Evas_Font_Array *array); 146 void 147 evas_common_font_fonts_unref(Evas_Font_Array *array); 148 149 void 150 evas_common_text_props_bidi_set(Evas_Text_Props *props, 151 Evas_BiDi_Paragraph_Props *bidi_par_props, size_t start); 152 153 void 154 evas_common_text_props_script_set(Evas_Text_Props *props, Evas_Script_Type scr); 155 156 EAPI Eina_Bool 157 evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, 158 Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, 159 size_t par_pos, int len, Evas_Text_Props_Mode mode, const char *lang); 160 161 void 162 evas_common_text_props_content_copy_and_ref(Evas_Text_Props *dst, 163 const Evas_Text_Props *src); 164 165 void 166 evas_common_text_props_content_ref(Evas_Text_Props *props); 167 168 void 169 evas_common_text_props_content_nofree_unref(Evas_Text_Props *props); 170 171 void 172 evas_common_text_props_content_unref(Evas_Text_Props *props); 173 174 EAPI int 175 evas_common_text_props_cluster_next(const Evas_Text_Props *props, int pos); 176 177 EAPI int 178 evas_common_text_props_cluster_prev(const Evas_Text_Props *props, int pos); 179 180 EAPI int 181 evas_common_text_props_index_find(const Evas_Text_Props *props, int _cutoff); 182 183 EAPI Eina_Bool 184 evas_common_text_props_split(Evas_Text_Props *base, Evas_Text_Props *ext, 185 int cutoff); 186 EAPI void 187 evas_common_text_props_merge(Evas_Text_Props *item1, const Evas_Text_Props *item2); 188 189 /* Common to Textblock and Filters */ 190 Eina_Bool evas_common_format_color_parse(const char *str, int slen, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a); 191 192 #endif 193