Changeset 06b8383 in mainline for uspace/lib/gfxfont/test/glyph.c


Ignore:
Timestamp:
2020-08-18T11:32:59Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
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)
Message:

Introduce typeface

In other words a font family.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfxfont/test/glyph.c

    rd2100e2 r06b8383  
    3232#include <gfx/glyph.h>
    3333#include <gfx/glyph_bmp.h>
     34#include <gfx/typeface.h>
    3435#include <io/pixelmap.h>
    3536#include <pcut/pcut.h>
     
    7576PCUT_TEST(create_destroy)
    7677{
    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);
    99107        rc = gfx_context_delete(gc);
    100108        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    104112PCUT_TEST(get_metrics)
    105113{
    106         gfx_font_metrics_t fmetrics;
     114        gfx_font_props_t fprops;
     115        gfx_font_metrics_t fmetrics;
     116        gfx_typeface_t *tface;
    107117        gfx_font_t *font;
    108118        gfx_glyph_metrics_t gmetrics;
     
    116126        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    117127
    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
    120136        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    121137
     
    131147        gfx_glyph_destroy(glyph);
    132148
    133         gfx_font_destroy(font);
     149        gfx_font_close(font);
     150        gfx_typeface_destroy(tface);
    134151        rc = gfx_context_delete(gc);
    135152        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    139156PCUT_TEST(set_metrics)
    140157{
    141         gfx_font_metrics_t fmetrics;
     158        gfx_font_props_t fprops;
     159        gfx_font_metrics_t fmetrics;
     160        gfx_typeface_t *tface;
    142161        gfx_font_t *font;
    143162        gfx_glyph_metrics_t gmetrics1;
     
    152171        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    153172
    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);
    156179        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    157180
     
    172195        gfx_glyph_destroy(glyph);
    173196
    174         gfx_font_destroy(font);
     197        gfx_font_close(font);
     198        gfx_typeface_destroy(tface);
    175199        rc = gfx_context_delete(gc);
    176200        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    180204PCUT_TEST(set_pattern)
    181205{
    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);
    195225        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    196226
     
    215245        gfx_glyph_destroy(glyph);
    216246
    217         gfx_font_destroy(font);
     247        gfx_font_close(font);
     248        gfx_typeface_destroy(tface);
    218249        rc = gfx_context_delete(gc);
    219250        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    223254PCUT_TEST(clear_pattern)
    224255{
    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);
    238275        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    239276
     
    261298        gfx_glyph_destroy(glyph);
    262299
    263         gfx_font_destroy(font);
     300        gfx_font_close(font);
     301        gfx_typeface_destroy(tface);
    264302        rc = gfx_context_delete(gc);
    265303        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    269307PCUT_TEST(matches)
    270308{
    271         gfx_font_metrics_t fmetrics;
     309        gfx_font_props_t fprops;
     310        gfx_font_metrics_t fmetrics;
     311        gfx_typeface_t *tface;
    272312        gfx_font_t *font;
    273313        gfx_glyph_metrics_t gmetrics;
     
    282322        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    283323
    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);
    286330        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    287331
     
    315359        gfx_glyph_destroy(glyph);
    316360
    317         gfx_font_destroy(font);
     361        gfx_font_close(font);
     362        gfx_typeface_destroy(tface);
    318363        rc = gfx_context_delete(gc);
    319364        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    323368PCUT_TEST(first_next_pattern)
    324369{
    325         gfx_font_metrics_t fmetrics;
     370        gfx_font_props_t fprops;
     371        gfx_font_metrics_t fmetrics;
     372        gfx_typeface_t *tface;
    326373        gfx_font_t *font;
    327374        gfx_glyph_metrics_t gmetrics;
     
    335382        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    336383
    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);
    339390        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    340391
     
    360411        gfx_glyph_destroy(glyph);
    361412
    362         gfx_font_destroy(font);
     413        gfx_font_close(font);
     414        gfx_typeface_destroy(tface);
    363415        rc = gfx_context_delete(gc);
    364416        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    368420PCUT_TEST(pattern_str)
    369421{
    370         gfx_font_metrics_t fmetrics;
     422        gfx_font_props_t fprops;
     423        gfx_font_metrics_t fmetrics;
     424        gfx_typeface_t *tface;
    371425        gfx_font_t *font;
    372426        gfx_glyph_metrics_t gmetrics;
     
    381435        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    382436
    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);
    385443        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    386444
     
    406464        gfx_glyph_destroy(glyph);
    407465
    408         gfx_font_destroy(font);
     466        gfx_font_close(font);
     467        gfx_typeface_destroy(tface);
    409468        rc = gfx_context_delete(gc);
    410469        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    414473PCUT_TEST(transfer)
    415474{
    416         gfx_font_metrics_t fmetrics;
     475        gfx_font_props_t fprops;
     476        gfx_font_metrics_t fmetrics;
     477        gfx_typeface_t *tface;
    417478        gfx_font_t *font;
    418479        gfx_glyph_metrics_t gmetrics;
     
    431492        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    432493
    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);
    435500        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    436501
     
    498563        gfx_glyph_destroy(glyph);
    499564
    500         gfx_font_destroy(font);
     565        gfx_font_close(font);
     566        gfx_typeface_destroy(tface);
    501567        rc = gfx_context_delete(gc);
    502568        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
Note: See TracChangeset for help on using the changeset viewer.