Changeset c78a03d in mainline for uspace/lib/gfxfont/src/font.c
- Timestamp:
- 2020-07-21T22:48:59Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5592c56
- Parents:
- 703c743
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/src/font.c
r703c743 rc78a03d 34 34 */ 35 35 36 #include <adt/list.h> 36 37 #include <assert.h> 37 38 #include <errno.h> 38 39 #include <gfx/font.h> 40 #include <gfx/glyph.h> 39 41 #include <mem.h> 40 42 #include <stdlib.h> 41 43 #include "../private/font.h" 44 #include "../private/glyph.h" 42 45 43 46 /** Initialize font metrics structure. … … 83 86 84 87 font->metrics = *metrics; 88 list_initialize(&font->glyphs); 85 89 *rfont = font; 86 90 return EOK; … … 93 97 void gfx_font_destroy(gfx_font_t *font) 94 98 { 99 gfx_glyph_t *glyph; 100 101 glyph = gfx_font_first_glyph(font); 102 while (glyph != NULL) { 103 gfx_glyph_destroy(glyph); 104 glyph = gfx_font_first_glyph(font); 105 } 106 95 107 free(font); 96 108 } … … 125 137 gfx_glyph_t *gfx_font_first_glyph(gfx_font_t *font) 126 138 { 127 return NULL; 139 link_t *link; 140 141 link = list_first(&font->glyphs); 142 if (link == NULL) 143 return NULL; 144 145 return list_get_instance(link, gfx_glyph_t, lglyphs); 128 146 } 129 147 … … 135 153 gfx_glyph_t *gfx_font_next_glyph(gfx_glyph_t *cur) 136 154 { 137 return NULL; 155 link_t *link; 156 157 link = list_next(&cur->lglyphs, &cur->font->glyphs); 158 if (link == NULL) 159 return NULL; 160 161 return list_get_instance(link, gfx_glyph_t, lglyphs); 138 162 } 139 163 … … 149 173 gfx_glyph_t **rglyph, size_t *rsize) 150 174 { 151 return EOK; 175 gfx_glyph_t *glyph; 176 size_t msize; 177 178 glyph = gfx_font_first_glyph(font); 179 while (glyph != NULL) { 180 if (gfx_glyph_matches(glyph, str, &msize)) { 181 *rglyph = glyph; 182 *rsize = msize; 183 return EOK; 184 } 185 186 glyph = gfx_font_next_glyph(glyph); 187 } 188 189 return ENOENT; 152 190 } 153 191
Note:
See TracChangeset
for help on using the changeset viewer.