Changeset 4583015 in mainline for uspace/lib/gfxfont/test/text.c


Ignore:
Timestamp:
2022-03-07T16:10:44Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ca2680d
Parents:
5c27e77
Message:

Add font to gfx_text_fmt_t

This is quite logical and saves us one argument that we need to pass to
all text formatting functions.

File:
1 edited

Legend:

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

    r5c27e77 r4583015  
    135135
    136136        gfx_text_fmt_init(&fmt);
     137        fmt.font = font;
    137138        fmt.color = color;
    138139        pos.x = 0;
    139140        pos.y = 0;
    140141
    141         rc = gfx_puttext(font, &pos, &fmt, "Hello world!");
     142        rc = gfx_puttext(&pos, &fmt, "Hello world!");
    142143        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    143144
     
    181182
    182183        gfx_text_fmt_init(&fmt);
     184        fmt.font = font;
    183185        fmt.color = color;
    184186        pos.x = 0;
    185187        pos.y = 0;
    186188
    187         rc = gfx_puttext(font, &pos, &fmt, "Hello world!");
     189        rc = gfx_puttext(&pos, &fmt, "Hello world!");
    188190        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    189191
     
    245247
    246248        gfx_text_fmt_init(&fmt);
     249        fmt.font = font;
    247250        anchor.x = 10;
    248251        anchor.y = 0;
     
    250253        fpos.x = 9;
    251254        fpos.y = 0;
    252         off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos);
     255        off = gfx_text_find_pos(&anchor, &fmt, "Aii", &fpos);
    253256        PCUT_ASSERT_INT_EQUALS(0, off);
    254257
    255258        fpos.x = 10;
    256259        fpos.y = 0;
    257         off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos);
     260        off = gfx_text_find_pos(&anchor, &fmt, "Aii", &fpos);
    258261        PCUT_ASSERT_INT_EQUALS(0, off);
    259262
    260263        fpos.x = 11;
    261264        fpos.y = 0;
    262         off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos);
     265        off = gfx_text_find_pos(&anchor, &fmt, "Aii", &fpos);
    263266        PCUT_ASSERT_INT_EQUALS(0, off);
    264267
    265268        fpos.x = 19;
    266269        fpos.y = 0;
    267         off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos);
     270        off = gfx_text_find_pos(&anchor, &fmt, "Aii", &fpos);
    268271        PCUT_ASSERT_INT_EQUALS(1, off);
    269272
    270273        fpos.x = 20;
    271274        fpos.y = 0;
    272         off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos);
     275        off = gfx_text_find_pos(&anchor, &fmt, "Aii", &fpos);
    273276        PCUT_ASSERT_INT_EQUALS(2, off);
    274277
    275278        fpos.x = 21;
    276279        fpos.y = 0;
    277         off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos);
     280        off = gfx_text_find_pos(&anchor, &fmt, "Aii", &fpos);
    278281        PCUT_ASSERT_INT_EQUALS(3, off);
    279282
    280283        fpos.x = 22;
    281284        fpos.y = 0;
    282         off = gfx_text_find_pos(font, &anchor, &fmt, "Aii", &fpos);
     285        off = gfx_text_find_pos(&anchor, &fmt, "Aii", &fpos);
    283286        PCUT_ASSERT_INT_EQUALS(3, off);
    284287
     
    318321        anchor.y = 0;
    319322        gfx_text_fmt_init(&fmt);
     323        fmt.font = font;
    320324
    321325        fpos.x = 9;
    322326        fpos.y = 0;
    323         off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos);
     327        off = gfx_text_find_pos(&anchor, &fmt, "Abc", &fpos);
    324328        PCUT_ASSERT_INT_EQUALS(0, off);
    325329
    326330        fpos.x = 10;
    327331        fpos.y = 0;
    328         off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos);
     332        off = gfx_text_find_pos(&anchor, &fmt, "Abc", &fpos);
    329333        PCUT_ASSERT_INT_EQUALS(0, off);
    330334
    331335        fpos.x = 11;
    332336        fpos.y = 0;
    333         off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos);
     337        off = gfx_text_find_pos(&anchor, &fmt, "Abc", &fpos);
    334338        PCUT_ASSERT_INT_EQUALS(1, off);
    335339
    336340        fpos.x = 12;
    337341        fpos.y = 0;
    338         off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos);
     342        off = gfx_text_find_pos(&anchor, &fmt, "Abc", &fpos);
    339343        PCUT_ASSERT_INT_EQUALS(2, off);
    340344
    341345        fpos.x = 13;
    342346        fpos.y = 0;
    343         off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos);
     347        off = gfx_text_find_pos(&anchor, &fmt, "Abc", &fpos);
    344348        PCUT_ASSERT_INT_EQUALS(3, off);
    345349
    346350        fpos.x = 14;
    347351        fpos.y = 0;
    348         off = gfx_text_find_pos(font, &anchor, &fmt, "Abc", &fpos);
     352        off = gfx_text_find_pos(&anchor, &fmt, "Abc", &fpos);
    349353        PCUT_ASSERT_INT_EQUALS(3, off);
    350354
     
    385389        anchor.y = 20;
    386390        gfx_text_fmt_init(&fmt);
     391        fmt.font = font;
    387392        fmt.color = color;
    388393
    389         gfx_text_cont(font, &anchor, &fmt, "Abc", &cpos, &cfmt);
     394        gfx_text_cont(&anchor, &fmt, "Abc", &cpos, &cfmt);
    390395
    391396        PCUT_ASSERT_INT_EQUALS(13, cpos.x);
     
    431436        anchor.y = 20;
    432437        gfx_text_fmt_init(&fmt);
     438        fmt.font = font;
    433439        fmt.color = color;
    434440
    435         gfx_text_rect(font, &anchor, &fmt, "Abc", &rect);
     441        gfx_text_rect(&anchor, &fmt, "Abc", &rect);
    436442
    437443        PCUT_ASSERT_INT_EQUALS(10, rect.p0.x);
Note: See TracChangeset for help on using the changeset viewer.