Changeset 06b8383 in mainline
- Timestamp:
- 2020-08-18T11:32:59Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 20d0098
- Parents:
- d2100e2
- git-author:
- Jiri Svoboda <jiri@…> (2020-08-17 18:32:40)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-08-18 11:32:59)
- Location:
- uspace
- Files:
-
- 5 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fontedit/fontedit.c
rd2100e2 r06b8383 38 38 #include <guigfx/canvas.h> 39 39 #include <gfx/color.h> 40 #include <gfx/font.h> 40 41 #include <gfx/render.h> 42 #include <gfx/typeface.h> 41 43 #include <stdbool.h> 42 44 #include <stdio.h> … … 117 119 canvas_t *canvas = NULL; 118 120 font_edit_t *fedit = NULL; 121 gfx_typeface_t *tface = NULL; 119 122 gfx_font_t *font = NULL; 123 gfx_font_props_t props; 120 124 gfx_font_metrics_t metrics; 121 125 gfx_coord_t vw, vh; … … 178 182 179 183 gc = canvas_gc_get_ctx(cgc); 184 185 rc = gfx_typeface_create(gc, &tface); 186 if (rc != EOK) { 187 printf("Error creating typeface.\n"); 188 goto error; 189 } 190 191 gfx_font_props_init(&props); 180 192 gfx_font_metrics_init(&metrics); 181 193 182 rc = gfx_font_create( gc, &metrics, &font);194 rc = gfx_font_create(tface, &props, &metrics, &font); 183 195 if (rc != EOK) { 184 196 printf("Error creating font.\n"); … … 190 202 fedit->width = vw; 191 203 fedit->height = vh; 192 fedit-> font = font;204 fedit->typeface = tface; 193 205 194 206 *rfedit = fedit; -
uspace/app/fontedit/fontedit.h
rd2100e2 r06b8383 37 37 #define FONTEDIT_H 38 38 39 #include <gfx/ font.h>39 #include <gfx/typeface.h> 40 40 #include <guigfx/canvas.h> 41 41 … … 50 50 /** Window height */ 51 51 int height; 52 /** Font*/53 gfx_ font_t *font;52 /** Typeface */ 53 gfx_typeface_t *typeface; 54 54 } font_edit_t; 55 55 -
uspace/lib/gfxfont/include/gfx/font.h
rd2100e2 r06b8383 42 42 #include <types/gfx/font.h> 43 43 #include <types/gfx/glyph.h> 44 #include <types/gfx/typeface.h> 44 45 45 46 extern void gfx_font_metrics_init(gfx_font_metrics_t *); 46 extern errno_t gfx_font_create(gfx_context_t *, gfx_font_metrics_t *, 47 gfx_font_t **); 48 extern void gfx_font_destroy(gfx_font_t *); 47 extern void gfx_font_props_init(gfx_font_props_t *); 48 extern void gfx_font_get_props(gfx_font_info_t *, gfx_font_props_t *); 49 extern errno_t gfx_font_create(gfx_typeface_t *, gfx_font_props_t *, 50 gfx_font_metrics_t *, gfx_font_t **); 51 extern errno_t gfx_font_open(gfx_font_info_t *, gfx_font_t **); 52 extern void gfx_font_close(gfx_font_t *); 49 53 extern void gfx_font_get_metrics(gfx_font_t *, gfx_font_metrics_t *); 50 extern errno_t gfx_font_set_metrics(gfx_font_t *, gfx_font_metrics_t *); 54 extern errno_t gfx_font_set_metrics(gfx_font_t *, 55 gfx_font_metrics_t *); 51 56 extern gfx_glyph_t *gfx_font_first_glyph(gfx_font_t *); 52 57 extern gfx_glyph_t *gfx_font_next_glyph(gfx_glyph_t *); -
uspace/lib/gfxfont/include/types/gfx/font.h
rd2100e2 r06b8383 42 42 typedef struct gfx_font gfx_font_t; 43 43 44 /** Font metrics */ 44 struct gfx_font_info; 45 typedef struct gfx_font_info gfx_font_info_t; 46 47 /** Font flags */ 48 typedef enum { 49 /** Bold */ 50 gff_bold = 0x1, 51 /** Italic */ 52 gff_italic = 0x2, 53 /** Bold, italic */ 54 gff_bold_italic = gff_bold | gff_italic 55 } gfx_font_flags_t; 56 57 /** Font properties */ 45 58 typedef struct { 46 /** Ascent */ 47 gfx_coord_t ascent; 48 /** Descent */ 49 gfx_coord_t descent; 50 /** Leading */ 51 gfx_coord_t leading; 52 } gfx_font_metrics_t; 53 54 /** Text metrics */ 55 typedef struct { 56 /** Bounding rectangle (not including oversize elements) */ 57 gfx_rect_t bounds; 58 } gfx_text_metrics_t; 59 /** Size */ 60 gfx_coord_t size; 61 /** Flags */ 62 gfx_font_flags_t flags; 63 } gfx_font_props_t; 59 64 60 65 #endif -
uspace/lib/gfxfont/meson.build
rd2100e2 r06b8383 32 32 'src/glyph.c', 33 33 'src/glyph_bmp.c', 34 'src/typeface.c', 34 35 ) 35 36 … … 39 40 'test/glyph_bmp.c', 40 41 'test/main.c', 42 'test/typeface.c', 41 43 ) -
uspace/lib/gfxfont/private/font.h
rd2100e2 r06b8383 43 43 #include <types/gfx/context.h> 44 44 #include <types/gfx/font.h> 45 #include <types/gfx/typeface.h> 45 46 46 47 /** Font … … 55 56 */ 56 57 struct gfx_font { 57 /** Graphics context of the font*/58 gfx_context_t *gc;58 /** Containing typeface */ 59 struct gfx_typeface *typeface; 59 60 /** Font metrics */ 60 61 gfx_font_metrics_t metrics; … … 67 68 }; 68 69 70 /** Font info 71 * 72 * This is an entry in the list of fonts in typeface 73 */ 74 struct gfx_font_info { 75 /** Containing typeface */ 76 struct gfx_typeface *typeface; 77 /** Link to @c typeface->fonts */ 78 link_t lfonts; 79 /** Font properties */ 80 gfx_font_props_t props; 81 /** Font or @c NULL if font is not present in memory */ 82 struct gfx_font *font; 83 }; 84 69 85 extern errno_t gfx_font_splice_at_glyph(gfx_font_t *, gfx_glyph_t *, 70 86 gfx_coord_t, gfx_coord_t); -
uspace/lib/gfxfont/src/font.c
rd2100e2 r06b8383 44 44 #include "../private/font.h" 45 45 #include "../private/glyph.h" 46 #include "../private/typeface.h" 46 47 47 48 /** Initialize font metrics structure. … … 57 58 } 58 59 59 /** Create font in graphics context. 60 * 61 * @param gc Graphic context 60 /** Initialize font properties structure. 61 * 62 * Font properties structure must always be initialized using this function 63 * first. 64 * 65 * @param props Font properties structure 66 */ 67 void gfx_font_props_init(gfx_font_props_t *props) 68 { 69 memset(props, 0, sizeof(gfx_font_props_t)); 70 } 71 72 /** Get font properties. 73 * 74 * @param finfo Font info 75 * @param props Place to store font properties 76 */ 77 void gfx_font_get_props(gfx_font_info_t *finfo, gfx_font_props_t *props) 78 { 79 *props = finfo->props; 80 } 81 82 /** Create font. 83 * 84 * @param tface Typeface 62 85 * @param metrics Font metrics 63 86 * @param rfont Place to store pointer to new font … … 67 90 * was lost 68 91 */ 69 errno_t gfx_font_create(gfx_context_t *gc, gfx_font_metrics_t *metrics, 70 gfx_font_t **rfont) 71 { 72 gfx_font_t *font; 92 errno_t gfx_font_create(gfx_typeface_t *tface, gfx_font_props_t *props, 93 gfx_font_metrics_t *metrics, gfx_font_t **rfont) 94 { 95 gfx_font_info_t *finfo = NULL; 96 gfx_font_t *font = NULL; 73 97 gfx_bitmap_params_t params; 74 98 errno_t rc; 75 99 100 finfo = calloc(1, sizeof(gfx_font_info_t)); 101 if (finfo == NULL) { 102 rc = ENOMEM; 103 goto error; 104 } 105 76 106 font = calloc(1, sizeof(gfx_font_t)); 77 if (font == NULL) 78 return ENOMEM; 79 80 font->gc = gc; 107 if (font == NULL) { 108 rc = ENOMEM; 109 goto error; 110 } 111 112 finfo->typeface = tface; 113 finfo->props = *props; 114 finfo->font = font; 115 font->typeface = tface; 81 116 82 117 rc = gfx_font_set_metrics(font, metrics); 83 118 if (rc != EOK) { 84 119 assert(rc == EINVAL); 85 free(font); 86 return rc; 120 goto error; 87 121 } 88 122 … … 91 125 params.rect = font->rect; 92 126 93 rc = gfx_bitmap_create(font->gc, ¶ms, NULL, &font->bitmap); 94 if (rc != EOK) { 95 free(font); 96 return rc; 97 } 127 rc = gfx_bitmap_create(tface->gc, ¶ms, NULL, &font->bitmap); 128 if (rc != EOK) 129 goto error; 98 130 99 131 font->metrics = *metrics; 100 132 list_initialize(&font->glyphs); 133 list_append(&finfo->lfonts, &tface->fonts); 101 134 *rfont = font; 102 135 return EOK; 103 } 104 105 /** Destroy font. 106 * 107 * @param font Font 108 */ 109 void gfx_font_destroy(gfx_font_t *font) 136 error: 137 if (finfo != NULL) 138 free(finfo); 139 if (font != NULL) 140 free(font); 141 return rc; 142 } 143 144 /** Open font. 145 * 146 * @param finfo Font info 147 * @param rfont Place to store pointer to open font 148 * @return EOK on success or an error code 149 */ 150 errno_t gfx_font_open(gfx_font_info_t *finfo, gfx_font_t **rfont) 151 { 152 if (finfo->font == NULL) { 153 /* 154 * We cannot load an absent font yet. 155 * This should not happen. 156 */ 157 assert(false); 158 return ENOTSUP; 159 } 160 161 *rfont = finfo->font; 162 return EOK; 163 } 164 165 /** Close font. 166 * 167 * @param font Font 168 */ 169 void gfx_font_close(gfx_font_t *font) 110 170 { 111 171 gfx_glyph_t *glyph; … … 232 292 params.rect.p1.y = height; 233 293 234 rc = gfx_bitmap_create(font-> gc, ¶ms, NULL, &nbitmap);294 rc = gfx_bitmap_create(font->typeface->gc, ¶ms, NULL, &nbitmap); 235 295 if (rc != EOK) 236 296 goto error; -
uspace/lib/gfxfont/src/glyph_bmp.c
rd2100e2 r06b8383 37 37 #include <gfx/bitmap.h> 38 38 #include <gfx/coord.h> 39 #include <gfx/font.h>40 39 #include <gfx/glyph_bmp.h> 41 40 #include <io/pixelmap.h> -
uspace/lib/gfxfont/test/font.c
rd2100e2 r06b8383 30 30 #include <gfx/font.h> 31 31 #include <gfx/glyph.h> 32 #include <gfx/typeface.h> 32 33 #include <pcut/pcut.h> 33 34 #include "../private/font.h" 35 #include "../private/typeface.h" 34 36 35 37 PCUT_INIT; … … 70 72 PCUT_TEST(create_destroy) 71 73 { 74 gfx_font_props_t props; 72 75 gfx_font_metrics_t metrics; 73 gfx_font_t *font; 74 gfx_context_t *gc; 75 test_gc_t tgc; 76 errno_t rc; 77 78 rc = gfx_context_new(&test_ops, (void *)&tgc, &gc); 79 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 80 81 gfx_font_metrics_init(&metrics); 82 rc = gfx_font_create(gc, &metrics, &font); 83 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 84 85 gfx_font_destroy(font); 76 gfx_typeface_t *tface; 77 gfx_font_t *font; 78 gfx_context_t *gc; 79 test_gc_t tgc; 80 errno_t rc; 81 82 rc = gfx_context_new(&test_ops, (void *)&tgc, &gc); 83 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 84 85 rc = gfx_typeface_create(gc, &tface); 86 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 87 88 gfx_font_props_init(&props); 89 gfx_font_metrics_init(&metrics); 90 rc = gfx_font_create(tface, &props, &metrics, &font); 91 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 92 93 gfx_font_close(font); 94 gfx_typeface_destroy(tface); 95 86 96 rc = gfx_context_delete(gc); 87 97 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 91 101 PCUT_TEST(get_metrics) 92 102 { 103 gfx_font_props_t props; 93 104 gfx_font_metrics_t metrics; 94 105 gfx_font_metrics_t gmetrics; 106 gfx_typeface_t *tface; 95 107 gfx_font_t *font; 96 108 gfx_context_t *gc; … … 106 118 metrics.leading = 3; 107 119 108 rc = gfx_font_create(gc, &metrics, &font); 120 rc = gfx_typeface_create(gc, &tface); 121 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 122 123 gfx_font_props_init(&props); 124 gfx_font_metrics_init(&metrics); 125 rc = gfx_font_create(tface, &props, &metrics, &font); 109 126 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 110 127 … … 114 131 PCUT_ASSERT_INT_EQUALS(metrics.leading, gmetrics.leading); 115 132 116 gfx_font_destroy(font); 133 gfx_font_close(font); 134 gfx_typeface_destroy(tface); 117 135 rc = gfx_context_delete(gc); 118 136 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 122 140 PCUT_TEST(set_metrics) 123 141 { 142 gfx_font_props_t props; 124 143 gfx_font_metrics_t metrics1; 125 144 gfx_font_metrics_t metrics2; 126 145 gfx_font_metrics_t gmetrics; 127 gfx_font_t *font; 128 gfx_context_t *gc; 129 test_gc_t tgc; 130 errno_t rc; 131 132 rc = gfx_context_new(&test_ops, (void *)&tgc, &gc); 133 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 146 gfx_typeface_t *tface; 147 gfx_font_t *font; 148 gfx_context_t *gc; 149 test_gc_t tgc; 150 errno_t rc; 151 152 rc = gfx_context_new(&test_ops, (void *)&tgc, &gc); 153 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 154 155 rc = gfx_typeface_create(gc, &tface); 156 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 157 158 gfx_font_props_init(&props); 134 159 135 160 gfx_font_metrics_init(&metrics1); … … 138 163 metrics1.leading = 3; 139 164 140 rc = gfx_font_create( gc, &metrics1, &font);165 rc = gfx_font_create(tface, &props, &metrics1, &font); 141 166 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 142 167 … … 154 179 PCUT_ASSERT_INT_EQUALS(metrics2.leading, gmetrics.leading); 155 180 156 gfx_font_destroy(font); 181 gfx_font_close(font); 182 gfx_typeface_destroy(tface); 157 183 rc = gfx_context_delete(gc); 158 184 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 162 188 PCUT_TEST(first_glyph) 163 189 { 190 gfx_font_props_t props; 164 191 gfx_font_metrics_t metrics; 165 192 gfx_glyph_metrics_t gmetrics; 193 gfx_typeface_t *tface; 166 194 gfx_font_t *font; 167 195 gfx_context_t *gc; … … 176 204 gfx_font_metrics_init(&metrics); 177 205 178 rc = gfx_font_create(gc, &metrics, &font); 206 rc = gfx_typeface_create(gc, &tface); 207 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 208 209 gfx_font_props_init(&props); 210 gfx_font_metrics_init(&metrics); 211 rc = gfx_font_create(tface, &props, &metrics, &font); 179 212 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 180 213 … … 193 226 194 227 gfx_glyph_destroy(glyph); 195 gfx_font_destroy(font); 228 gfx_font_close(font); 229 gfx_typeface_destroy(tface); 196 230 rc = gfx_context_delete(gc); 197 231 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 201 235 PCUT_TEST(next_glyph) 202 236 { 237 gfx_font_props_t props; 203 238 gfx_font_metrics_t metrics; 204 239 gfx_glyph_metrics_t gmetrics; 240 gfx_typeface_t *tface; 205 241 gfx_font_t *font; 206 242 gfx_context_t *gc; … … 217 253 gfx_font_metrics_init(&metrics); 218 254 219 rc = gfx_font_create(gc, &metrics, &font); 255 rc = gfx_typeface_create(gc, &tface); 256 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 257 258 gfx_font_props_init(&props); 259 gfx_font_metrics_init(&metrics); 260 rc = gfx_font_create(tface, &props, &metrics, &font); 220 261 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 221 262 … … 240 281 gfx_glyph_destroy(glyph1); 241 282 gfx_glyph_destroy(glyph2); 242 gfx_font_destroy(font); 283 gfx_font_close(font); 284 gfx_typeface_destroy(tface); 243 285 rc = gfx_context_delete(gc); 244 286 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 248 290 PCUT_TEST(search_glyph) 249 291 { 292 gfx_font_props_t props; 250 293 gfx_font_metrics_t metrics; 294 gfx_typeface_t *tface; 251 295 gfx_font_t *font; 252 296 gfx_context_t *gc; … … 261 305 gfx_font_metrics_init(&metrics); 262 306 263 rc = gfx_font_create(gc, &metrics, &font); 307 rc = gfx_typeface_create(gc, &tface); 308 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 309 310 gfx_font_props_init(&props); 311 gfx_font_metrics_init(&metrics); 312 rc = gfx_font_create(tface, &props, &metrics, &font); 264 313 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 265 314 … … 267 316 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 268 317 269 gfx_font_destroy(font); 318 gfx_font_close(font); 319 gfx_typeface_destroy(tface); 270 320 rc = gfx_context_delete(gc); 271 321 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 275 325 PCUT_TEST(splice_at_glyph) 276 326 { 327 gfx_font_props_t props; 277 328 gfx_font_metrics_t fmetrics; 329 gfx_typeface_t *tface; 278 330 gfx_font_t *font; 279 331 gfx_glyph_metrics_t gmetrics; … … 286 338 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 287 339 340 rc = gfx_typeface_create(gc, &tface); 341 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 342 343 gfx_font_props_init(&props); 288 344 gfx_font_metrics_init(&fmetrics); 289 rc = gfx_font_create( gc, &fmetrics, &font);345 rc = gfx_font_create(tface, &props, &fmetrics, &font); 290 346 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 291 347 … … 299 355 gfx_glyph_destroy(glyph); 300 356 301 gfx_font_destroy(font); 357 gfx_font_close(font); 358 gfx_typeface_destroy(tface); 302 359 rc = gfx_context_delete(gc); 303 360 PCUT_ASSERT_ERRNO_VAL(EOK, rc); -
uspace/lib/gfxfont/test/glyph.c
rd2100e2 r06b8383 32 32 #include <gfx/glyph.h> 33 33 #include <gfx/glyph_bmp.h> 34 #include <gfx/typeface.h> 34 35 #include <io/pixelmap.h> 35 36 #include <pcut/pcut.h> … … 75 76 PCUT_TEST(create_destroy) 76 77 { 77 gfx_font_metrics_t fmetrics; 78 gfx_font_t *font; 79 gfx_glyph_metrics_t gmetrics; 80 gfx_glyph_t *glyph; 81 gfx_context_t *gc; 82 test_gc_t tgc; 83 errno_t rc; 84 85 rc = gfx_context_new(&test_ops, (void *) &tgc, &gc); 86 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 87 88 gfx_font_metrics_init(&fmetrics); 89 rc = gfx_font_create(gc, &fmetrics, &font); 90 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 91 92 gfx_glyph_metrics_init(&gmetrics); 93 rc = gfx_glyph_create(font, &gmetrics, &glyph); 94 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 95 96 gfx_glyph_destroy(glyph); 97 98 gfx_font_destroy(font); 78 gfx_font_props_t fprops; 79 gfx_font_metrics_t fmetrics; 80 gfx_typeface_t *tface; 81 gfx_font_t *font; 82 gfx_glyph_metrics_t gmetrics; 83 gfx_glyph_t *glyph; 84 gfx_context_t *gc; 85 test_gc_t tgc; 86 errno_t rc; 87 88 rc = gfx_context_new(&test_ops, (void *) &tgc, &gc); 89 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 90 91 rc = gfx_typeface_create(gc, &tface); 92 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 93 94 gfx_font_props_init(&fprops); 95 gfx_font_metrics_init(&fmetrics); 96 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 97 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 98 99 gfx_glyph_metrics_init(&gmetrics); 100 rc = gfx_glyph_create(font, &gmetrics, &glyph); 101 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 102 103 gfx_glyph_destroy(glyph); 104 105 gfx_font_close(font); 106 gfx_typeface_destroy(tface); 99 107 rc = gfx_context_delete(gc); 100 108 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 104 112 PCUT_TEST(get_metrics) 105 113 { 106 gfx_font_metrics_t fmetrics; 114 gfx_font_props_t fprops; 115 gfx_font_metrics_t fmetrics; 116 gfx_typeface_t *tface; 107 117 gfx_font_t *font; 108 118 gfx_glyph_metrics_t gmetrics; … … 116 126 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 117 127 118 gfx_font_metrics_init(&fmetrics); 119 rc = gfx_font_create(gc, &fmetrics, &font); 128 rc = gfx_typeface_create(gc, &tface); 129 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 130 131 gfx_font_props_init(&fprops); 132 gfx_font_metrics_init(&fmetrics); 133 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 134 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 135 120 136 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 121 137 … … 131 147 gfx_glyph_destroy(glyph); 132 148 133 gfx_font_destroy(font); 149 gfx_font_close(font); 150 gfx_typeface_destroy(tface); 134 151 rc = gfx_context_delete(gc); 135 152 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 139 156 PCUT_TEST(set_metrics) 140 157 { 141 gfx_font_metrics_t fmetrics; 158 gfx_font_props_t fprops; 159 gfx_font_metrics_t fmetrics; 160 gfx_typeface_t *tface; 142 161 gfx_font_t *font; 143 162 gfx_glyph_metrics_t gmetrics1; … … 152 171 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 153 172 154 gfx_font_metrics_init(&fmetrics); 155 rc = gfx_font_create(gc, &fmetrics, &font); 173 rc = gfx_typeface_create(gc, &tface); 174 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 175 176 gfx_font_props_init(&fprops); 177 gfx_font_metrics_init(&fmetrics); 178 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 156 179 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 157 180 … … 172 195 gfx_glyph_destroy(glyph); 173 196 174 gfx_font_destroy(font); 197 gfx_font_close(font); 198 gfx_typeface_destroy(tface); 175 199 rc = gfx_context_delete(gc); 176 200 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 180 204 PCUT_TEST(set_pattern) 181 205 { 182 gfx_font_metrics_t fmetrics; 183 gfx_font_t *font; 184 gfx_glyph_metrics_t gmetrics; 185 gfx_glyph_t *glyph; 186 gfx_context_t *gc; 187 test_gc_t tgc; 188 errno_t rc; 189 190 rc = gfx_context_new(&test_ops, (void *) &tgc, &gc); 191 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 192 193 gfx_font_metrics_init(&fmetrics); 194 rc = gfx_font_create(gc, &fmetrics, &font); 206 gfx_font_props_t fprops; 207 gfx_font_metrics_t fmetrics; 208 gfx_typeface_t *tface; 209 gfx_font_t *font; 210 gfx_glyph_metrics_t gmetrics; 211 gfx_glyph_t *glyph; 212 gfx_context_t *gc; 213 test_gc_t tgc; 214 errno_t rc; 215 216 rc = gfx_context_new(&test_ops, (void *) &tgc, &gc); 217 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 218 219 rc = gfx_typeface_create(gc, &tface); 220 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 221 222 gfx_font_props_init(&fprops); 223 gfx_font_metrics_init(&fmetrics); 224 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 195 225 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 196 226 … … 215 245 gfx_glyph_destroy(glyph); 216 246 217 gfx_font_destroy(font); 247 gfx_font_close(font); 248 gfx_typeface_destroy(tface); 218 249 rc = gfx_context_delete(gc); 219 250 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 223 254 PCUT_TEST(clear_pattern) 224 255 { 225 gfx_font_metrics_t fmetrics; 226 gfx_font_t *font; 227 gfx_glyph_metrics_t gmetrics; 228 gfx_glyph_t *glyph; 229 gfx_context_t *gc; 230 test_gc_t tgc; 231 errno_t rc; 232 233 rc = gfx_context_new(&test_ops, (void *) &tgc, &gc); 234 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 235 236 gfx_font_metrics_init(&fmetrics); 237 rc = gfx_font_create(gc, &fmetrics, &font); 256 gfx_font_props_t fprops; 257 gfx_font_metrics_t fmetrics; 258 gfx_typeface_t *tface; 259 gfx_font_t *font; 260 gfx_glyph_metrics_t gmetrics; 261 gfx_glyph_t *glyph; 262 gfx_context_t *gc; 263 test_gc_t tgc; 264 errno_t rc; 265 266 rc = gfx_context_new(&test_ops, (void *) &tgc, &gc); 267 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 268 269 rc = gfx_typeface_create(gc, &tface); 270 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 271 272 gfx_font_props_init(&fprops); 273 gfx_font_metrics_init(&fmetrics); 274 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 238 275 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 239 276 … … 261 298 gfx_glyph_destroy(glyph); 262 299 263 gfx_font_destroy(font); 300 gfx_font_close(font); 301 gfx_typeface_destroy(tface); 264 302 rc = gfx_context_delete(gc); 265 303 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 269 307 PCUT_TEST(matches) 270 308 { 271 gfx_font_metrics_t fmetrics; 309 gfx_font_props_t fprops; 310 gfx_font_metrics_t fmetrics; 311 gfx_typeface_t *tface; 272 312 gfx_font_t *font; 273 313 gfx_glyph_metrics_t gmetrics; … … 282 322 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 283 323 284 gfx_font_metrics_init(&fmetrics); 285 rc = gfx_font_create(gc, &fmetrics, &font); 324 rc = gfx_typeface_create(gc, &tface); 325 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 326 327 gfx_font_props_init(&fprops); 328 gfx_font_metrics_init(&fmetrics); 329 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 286 330 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 287 331 … … 315 359 gfx_glyph_destroy(glyph); 316 360 317 gfx_font_destroy(font); 361 gfx_font_close(font); 362 gfx_typeface_destroy(tface); 318 363 rc = gfx_context_delete(gc); 319 364 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 323 368 PCUT_TEST(first_next_pattern) 324 369 { 325 gfx_font_metrics_t fmetrics; 370 gfx_font_props_t fprops; 371 gfx_font_metrics_t fmetrics; 372 gfx_typeface_t *tface; 326 373 gfx_font_t *font; 327 374 gfx_glyph_metrics_t gmetrics; … … 335 382 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 336 383 337 gfx_font_metrics_init(&fmetrics); 338 rc = gfx_font_create(gc, &fmetrics, &font); 384 rc = gfx_typeface_create(gc, &tface); 385 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 386 387 gfx_font_props_init(&fprops); 388 gfx_font_metrics_init(&fmetrics); 389 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 339 390 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 340 391 … … 360 411 gfx_glyph_destroy(glyph); 361 412 362 gfx_font_destroy(font); 413 gfx_font_close(font); 414 gfx_typeface_destroy(tface); 363 415 rc = gfx_context_delete(gc); 364 416 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 368 420 PCUT_TEST(pattern_str) 369 421 { 370 gfx_font_metrics_t fmetrics; 422 gfx_font_props_t fprops; 423 gfx_font_metrics_t fmetrics; 424 gfx_typeface_t *tface; 371 425 gfx_font_t *font; 372 426 gfx_glyph_metrics_t gmetrics; … … 381 435 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 382 436 383 gfx_font_metrics_init(&fmetrics); 384 rc = gfx_font_create(gc, &fmetrics, &font); 437 rc = gfx_typeface_create(gc, &tface); 438 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 439 440 gfx_font_props_init(&fprops); 441 gfx_font_metrics_init(&fmetrics); 442 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 385 443 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 386 444 … … 406 464 gfx_glyph_destroy(glyph); 407 465 408 gfx_font_destroy(font); 466 gfx_font_close(font); 467 gfx_typeface_destroy(tface); 409 468 rc = gfx_context_delete(gc); 410 469 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 414 473 PCUT_TEST(transfer) 415 474 { 416 gfx_font_metrics_t fmetrics; 475 gfx_font_props_t fprops; 476 gfx_font_metrics_t fmetrics; 477 gfx_typeface_t *tface; 417 478 gfx_font_t *font; 418 479 gfx_glyph_metrics_t gmetrics; … … 431 492 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 432 493 433 gfx_font_metrics_init(&fmetrics); 434 rc = gfx_font_create(gc, &fmetrics, &font); 494 rc = gfx_typeface_create(gc, &tface); 495 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 496 497 gfx_font_props_init(&fprops); 498 gfx_font_metrics_init(&fmetrics); 499 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 435 500 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 436 501 … … 498 563 gfx_glyph_destroy(glyph); 499 564 500 gfx_font_destroy(font); 565 gfx_font_close(font); 566 gfx_typeface_destroy(tface); 501 567 rc = gfx_context_delete(gc); 502 568 PCUT_ASSERT_ERRNO_VAL(EOK, rc); -
uspace/lib/gfxfont/test/glyph_bmp.c
rd2100e2 r06b8383 31 31 #include <gfx/glyph.h> 32 32 #include <gfx/glyph_bmp.h> 33 #include <gfx/typeface.h> 33 34 #include <pcut/pcut.h> 34 35 … … 70 71 PCUT_TEST(open_close) 71 72 { 73 gfx_font_props_t fprops; 72 74 gfx_font_metrics_t fmetrics; 75 gfx_typeface_t *tface; 73 76 gfx_font_t *font; 74 77 gfx_glyph_metrics_t gmetrics; … … 82 85 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 83 86 87 rc = gfx_typeface_create(gc, &tface); 88 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 89 90 gfx_font_props_init(&fprops); 84 91 gfx_font_metrics_init(&fmetrics); 85 rc = gfx_font_create( gc, &fmetrics, &font);92 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 86 93 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 87 94 … … 102 109 gfx_glyph_destroy(glyph); 103 110 104 gfx_font_destroy(font); 111 gfx_font_close(font); 112 gfx_typeface_destroy(tface); 105 113 rc = gfx_context_delete(gc); 106 114 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 110 118 PCUT_TEST(save) 111 119 { 120 gfx_font_props_t fprops; 112 121 gfx_font_metrics_t fmetrics; 122 gfx_typeface_t *tface; 113 123 gfx_font_t *font; 114 124 gfx_glyph_metrics_t gmetrics; … … 123 133 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 124 134 135 rc = gfx_typeface_create(gc, &tface); 136 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 137 138 gfx_font_props_init(&fprops); 125 139 gfx_font_metrics_init(&fmetrics); 126 rc = gfx_font_create( gc, &fmetrics, &font);140 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 127 141 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 128 142 … … 174 188 gfx_glyph_destroy(glyph); 175 189 176 gfx_font_destroy(font); 190 gfx_font_close(font); 191 gfx_typeface_destroy(tface); 177 192 rc = gfx_context_delete(gc); 178 193 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 182 197 PCUT_TEST(getpix) 183 198 { 199 gfx_font_props_t fprops; 184 200 gfx_font_metrics_t fmetrics; 201 gfx_typeface_t *tface; 185 202 gfx_font_t *font; 186 203 gfx_glyph_metrics_t gmetrics; … … 195 212 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 196 213 214 rc = gfx_typeface_create(gc, &tface); 215 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 216 217 gfx_font_props_init(&fprops); 197 218 gfx_font_metrics_init(&fmetrics); 198 rc = gfx_font_create( gc, &fmetrics, &font);219 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 199 220 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 200 221 … … 218 239 gfx_glyph_destroy(glyph); 219 240 220 gfx_font_destroy(font); 241 gfx_font_close(font); 242 gfx_typeface_destroy(tface); 221 243 rc = gfx_context_delete(gc); 222 244 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 226 248 PCUT_TEST(setpix_flip) 227 249 { 250 gfx_font_props_t fprops; 228 251 gfx_font_metrics_t fmetrics; 252 gfx_typeface_t *tface; 229 253 gfx_font_t *font; 230 254 gfx_glyph_metrics_t gmetrics; … … 239 263 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 240 264 265 rc = gfx_typeface_create(gc, &tface); 266 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 267 268 gfx_font_props_init(&fprops); 241 269 gfx_font_metrics_init(&fmetrics); 242 rc = gfx_font_create( gc, &fmetrics, &font);270 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 243 271 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 244 272 … … 274 302 gfx_glyph_destroy(glyph); 275 303 276 gfx_font_destroy(font); 304 gfx_font_close(font); 305 gfx_typeface_destroy(tface); 277 306 rc = gfx_context_delete(gc); 278 307 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 282 311 PCUT_TEST(setpix_externd) 283 312 { 313 gfx_font_props_t fprops; 284 314 gfx_font_metrics_t fmetrics; 315 gfx_typeface_t *tface; 285 316 gfx_font_t *font; 286 317 gfx_glyph_metrics_t gmetrics; … … 296 327 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 297 328 329 rc = gfx_typeface_create(gc, &tface); 330 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 331 332 gfx_font_props_init(&fprops); 298 333 gfx_font_metrics_init(&fmetrics); 299 rc = gfx_font_create( gc, &fmetrics, &font);334 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 300 335 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 301 336 … … 343 378 gfx_glyph_destroy(glyph); 344 379 345 gfx_font_destroy(font); 380 gfx_font_close(font); 381 gfx_typeface_destroy(tface); 346 382 rc = gfx_context_delete(gc); 347 383 PCUT_ASSERT_ERRNO_VAL(EOK, rc); -
uspace/lib/gfxfont/test/main.c
rd2100e2 r06b8383 34 34 PCUT_IMPORT(glyph); 35 35 PCUT_IMPORT(glyph_bmp); 36 PCUT_IMPORT(typeface); 36 37 37 38 PCUT_MAIN();
Note:
See TracChangeset
for help on using the changeset viewer.