Changeset 06b8383 in mainline for uspace/lib/gfxfont/test


Ignore:
Timestamp:
2020-08-18T11:32:59Z (6 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.

Location:
uspace/lib/gfxfont/test
Files:
1 added
4 edited

Legend:

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

    rd2100e2 r06b8383  
    3030#include <gfx/font.h>
    3131#include <gfx/glyph.h>
     32#include <gfx/typeface.h>
    3233#include <pcut/pcut.h>
    3334#include "../private/font.h"
     35#include "../private/typeface.h"
    3436
    3537PCUT_INIT;
     
    7072PCUT_TEST(create_destroy)
    7173{
     74        gfx_font_props_t props;
    7275        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
    8696        rc = gfx_context_delete(gc);
    8797        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    91101PCUT_TEST(get_metrics)
    92102{
     103        gfx_font_props_t props;
    93104        gfx_font_metrics_t metrics;
    94105        gfx_font_metrics_t gmetrics;
     106        gfx_typeface_t *tface;
    95107        gfx_font_t *font;
    96108        gfx_context_t *gc;
     
    106118        metrics.leading = 3;
    107119
    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);
    109126        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    110127
     
    114131        PCUT_ASSERT_INT_EQUALS(metrics.leading, gmetrics.leading);
    115132
    116         gfx_font_destroy(font);
     133        gfx_font_close(font);
     134        gfx_typeface_destroy(tface);
    117135        rc = gfx_context_delete(gc);
    118136        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    122140PCUT_TEST(set_metrics)
    123141{
     142        gfx_font_props_t props;
    124143        gfx_font_metrics_t metrics1;
    125144        gfx_font_metrics_t metrics2;
    126145        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);
    134159
    135160        gfx_font_metrics_init(&metrics1);
     
    138163        metrics1.leading = 3;
    139164
    140         rc = gfx_font_create(gc, &metrics1, &font);
     165        rc = gfx_font_create(tface, &props, &metrics1, &font);
    141166        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    142167
     
    154179        PCUT_ASSERT_INT_EQUALS(metrics2.leading, gmetrics.leading);
    155180
    156         gfx_font_destroy(font);
     181        gfx_font_close(font);
     182        gfx_typeface_destroy(tface);
    157183        rc = gfx_context_delete(gc);
    158184        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    162188PCUT_TEST(first_glyph)
    163189{
     190        gfx_font_props_t props;
    164191        gfx_font_metrics_t metrics;
    165192        gfx_glyph_metrics_t gmetrics;
     193        gfx_typeface_t *tface;
    166194        gfx_font_t *font;
    167195        gfx_context_t *gc;
     
    176204        gfx_font_metrics_init(&metrics);
    177205
    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);
    179212        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    180213
     
    193226
    194227        gfx_glyph_destroy(glyph);
    195         gfx_font_destroy(font);
     228        gfx_font_close(font);
     229        gfx_typeface_destroy(tface);
    196230        rc = gfx_context_delete(gc);
    197231        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    201235PCUT_TEST(next_glyph)
    202236{
     237        gfx_font_props_t props;
    203238        gfx_font_metrics_t metrics;
    204239        gfx_glyph_metrics_t gmetrics;
     240        gfx_typeface_t *tface;
    205241        gfx_font_t *font;
    206242        gfx_context_t *gc;
     
    217253        gfx_font_metrics_init(&metrics);
    218254
    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);
    220261        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    221262
     
    240281        gfx_glyph_destroy(glyph1);
    241282        gfx_glyph_destroy(glyph2);
    242         gfx_font_destroy(font);
     283        gfx_font_close(font);
     284        gfx_typeface_destroy(tface);
    243285        rc = gfx_context_delete(gc);
    244286        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    248290PCUT_TEST(search_glyph)
    249291{
     292        gfx_font_props_t props;
    250293        gfx_font_metrics_t metrics;
     294        gfx_typeface_t *tface;
    251295        gfx_font_t *font;
    252296        gfx_context_t *gc;
     
    261305        gfx_font_metrics_init(&metrics);
    262306
    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);
    264313        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    265314
     
    267316        PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
    268317
    269         gfx_font_destroy(font);
     318        gfx_font_close(font);
     319        gfx_typeface_destroy(tface);
    270320        rc = gfx_context_delete(gc);
    271321        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    275325PCUT_TEST(splice_at_glyph)
    276326{
     327        gfx_font_props_t props;
    277328        gfx_font_metrics_t fmetrics;
     329        gfx_typeface_t *tface;
    278330        gfx_font_t *font;
    279331        gfx_glyph_metrics_t gmetrics;
     
    286338        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    287339
     340        rc = gfx_typeface_create(gc, &tface);
     341        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     342
     343        gfx_font_props_init(&props);
    288344        gfx_font_metrics_init(&fmetrics);
    289         rc = gfx_font_create(gc, &fmetrics, &font);
     345        rc = gfx_font_create(tface, &props, &fmetrics, &font);
    290346        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    291347
     
    299355        gfx_glyph_destroy(glyph);
    300356
    301         gfx_font_destroy(font);
     357        gfx_font_close(font);
     358        gfx_typeface_destroy(tface);
    302359        rc = gfx_context_delete(gc);
    303360        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
  • 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);
  • uspace/lib/gfxfont/test/glyph_bmp.c

    rd2100e2 r06b8383  
    3131#include <gfx/glyph.h>
    3232#include <gfx/glyph_bmp.h>
     33#include <gfx/typeface.h>
    3334#include <pcut/pcut.h>
    3435
     
    7071PCUT_TEST(open_close)
    7172{
     73        gfx_font_props_t fprops;
    7274        gfx_font_metrics_t fmetrics;
     75        gfx_typeface_t *tface;
    7376        gfx_font_t *font;
    7477        gfx_glyph_metrics_t gmetrics;
     
    8285        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    8386
     87        rc = gfx_typeface_create(gc, &tface);
     88        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     89
     90        gfx_font_props_init(&fprops);
    8491        gfx_font_metrics_init(&fmetrics);
    85         rc = gfx_font_create(gc, &fmetrics, &font);
     92        rc = gfx_font_create(tface, &fprops, &fmetrics, &font);
    8693        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    8794
     
    102109        gfx_glyph_destroy(glyph);
    103110
    104         gfx_font_destroy(font);
     111        gfx_font_close(font);
     112        gfx_typeface_destroy(tface);
    105113        rc = gfx_context_delete(gc);
    106114        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    110118PCUT_TEST(save)
    111119{
     120        gfx_font_props_t fprops;
    112121        gfx_font_metrics_t fmetrics;
     122        gfx_typeface_t *tface;
    113123        gfx_font_t *font;
    114124        gfx_glyph_metrics_t gmetrics;
     
    123133        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    124134
     135        rc = gfx_typeface_create(gc, &tface);
     136        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     137
     138        gfx_font_props_init(&fprops);
    125139        gfx_font_metrics_init(&fmetrics);
    126         rc = gfx_font_create(gc, &fmetrics, &font);
     140        rc = gfx_font_create(tface, &fprops, &fmetrics, &font);
    127141        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    128142
     
    174188        gfx_glyph_destroy(glyph);
    175189
    176         gfx_font_destroy(font);
     190        gfx_font_close(font);
     191        gfx_typeface_destroy(tface);
    177192        rc = gfx_context_delete(gc);
    178193        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    182197PCUT_TEST(getpix)
    183198{
     199        gfx_font_props_t fprops;
    184200        gfx_font_metrics_t fmetrics;
     201        gfx_typeface_t *tface;
    185202        gfx_font_t *font;
    186203        gfx_glyph_metrics_t gmetrics;
     
    195212        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    196213
     214        rc = gfx_typeface_create(gc, &tface);
     215        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     216
     217        gfx_font_props_init(&fprops);
    197218        gfx_font_metrics_init(&fmetrics);
    198         rc = gfx_font_create(gc, &fmetrics, &font);
     219        rc = gfx_font_create(tface, &fprops, &fmetrics, &font);
    199220        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    200221
     
    218239        gfx_glyph_destroy(glyph);
    219240
    220         gfx_font_destroy(font);
     241        gfx_font_close(font);
     242        gfx_typeface_destroy(tface);
    221243        rc = gfx_context_delete(gc);
    222244        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    226248PCUT_TEST(setpix_flip)
    227249{
     250        gfx_font_props_t fprops;
    228251        gfx_font_metrics_t fmetrics;
     252        gfx_typeface_t *tface;
    229253        gfx_font_t *font;
    230254        gfx_glyph_metrics_t gmetrics;
     
    239263        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    240264
     265        rc = gfx_typeface_create(gc, &tface);
     266        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     267
     268        gfx_font_props_init(&fprops);
    241269        gfx_font_metrics_init(&fmetrics);
    242         rc = gfx_font_create(gc, &fmetrics, &font);
     270        rc = gfx_font_create(tface, &fprops, &fmetrics, &font);
    243271        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    244272
     
    274302        gfx_glyph_destroy(glyph);
    275303
    276         gfx_font_destroy(font);
     304        gfx_font_close(font);
     305        gfx_typeface_destroy(tface);
    277306        rc = gfx_context_delete(gc);
    278307        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    282311PCUT_TEST(setpix_externd)
    283312{
     313        gfx_font_props_t fprops;
    284314        gfx_font_metrics_t fmetrics;
     315        gfx_typeface_t *tface;
    285316        gfx_font_t *font;
    286317        gfx_glyph_metrics_t gmetrics;
     
    296327        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    297328
     329        rc = gfx_typeface_create(gc, &tface);
     330        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     331
     332        gfx_font_props_init(&fprops);
    298333        gfx_font_metrics_init(&fmetrics);
    299         rc = gfx_font_create(gc, &fmetrics, &font);
     334        rc = gfx_font_create(tface, &fprops, &fmetrics, &font);
    300335        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    301336
     
    343378        gfx_glyph_destroy(glyph);
    344379
    345         gfx_font_destroy(font);
     380        gfx_font_close(font);
     381        gfx_typeface_destroy(tface);
    346382        rc = gfx_context_delete(gc);
    347383        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
  • uspace/lib/gfxfont/test/main.c

    rd2100e2 r06b8383  
    3434PCUT_IMPORT(glyph);
    3535PCUT_IMPORT(glyph_bmp);
     36PCUT_IMPORT(typeface);
    3637
    3738PCUT_MAIN();
Note: See TracChangeset for help on using the changeset viewer.