Changeset 4583015 in mainline


Ignore:
Timestamp:
2022-03-07T16:10:44Z (2 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.

Location:
uspace
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/edit/edit.c

    r5c27e77 r4583015  
    12591259
    12601260        gfx_text_fmt_init(&fmt);
     1261        fmt.font = font;
    12611262        fmt.color = pane->color;
    12621263
     
    13181319                                        return rc;
    13191320
    1320                                 rc = gfx_puttext(font, &tpos, &fmt, cbuf);
     1321                                rc = gfx_puttext(&tpos, &fmt, cbuf);
    13211322                                if (rc != EOK)
    13221323                                        return rc;
  • uspace/app/fontedit/fontedit.c

    r5c27e77 r4583015  
    503503
    504504        gfx_text_fmt_init(&fmt);
     505        fmt.font = fedit->font;
    505506        fmt.color = color;
    506507
     
    508509        pos.y = y;
    509510
    510         return gfx_puttext(fedit->font, &pos, &fmt, str);
     511        return gfx_puttext(&pos, &fmt, str);
    511512}
    512513
  • uspace/app/gfxdemo/gfxdemo.c

    r5c27e77 r4583015  
    238238
    239239                gfx_text_fmt_init(&fmt);
     240                fmt.font = font;
    240241                fmt.color = color;
    241242                fmt.halign = gfx_halign_center;
     
    244245                pos.x = w / 2;
    245246                pos.y = h - 1;
    246                 rc = gfx_puttext(font, &pos, &fmt, text);
     247                rc = gfx_puttext(&pos, &fmt, text);
    247248                if (rc != EOK) {
    248249                        printf("Error rendering text.\n");
     
    689690
    690691        gfx_text_fmt_init(&fmt);
     692        fmt.font = font;
    691693        fmt.color = color;
    692694
    693695        pos.x = rect.p0.x;
    694696        pos.y = rect.p0.y;
    695         rc = gfx_puttext(font, &pos, &fmt, "Top left");
     697        rc = gfx_puttext(&pos, &fmt, "Top left");
    696698        if (rc != EOK) {
    697699                printf("Error rendering text.\n");
     
    702704        pos.y = rect.p0.y;
    703705        fmt.halign = gfx_halign_center;
    704         rc = gfx_puttext(font, &pos, &fmt, "Top center");
     706        rc = gfx_puttext(&pos, &fmt, "Top center");
    705707        if (rc != EOK)
    706708                goto error;
     
    709711        pos.y = rect.p0.y;
    710712        fmt.halign = gfx_halign_right;
    711         rc = gfx_puttext(font, &pos, &fmt, "Top right");
     713        rc = gfx_puttext(&pos, &fmt, "Top right");
    712714        if (rc != EOK)
    713715                goto error;
     
    718720        pos.y = (rect.p0.y + rect.p1.y - 1) / 2;
    719721        fmt.halign = gfx_halign_left;
    720         rc = gfx_puttext(font, &pos, &fmt, "Center left");
     722        rc = gfx_puttext(&pos, &fmt, "Center left");
    721723        if (rc != EOK)
    722724                goto error;
     
    725727        pos.y = (rect.p0.y + rect.p1.y - 1) / 2;
    726728        fmt.halign = gfx_halign_center;
    727         rc = gfx_puttext(font, &pos, &fmt, "Center");
     729        rc = gfx_puttext(&pos, &fmt, "Center");
    728730        if (rc != EOK)
    729731                goto error;
     
    732734        pos.y = (rect.p0.y + rect.p1.y - 1) / 2;
    733735        fmt.halign = gfx_halign_right;
    734         rc = gfx_puttext(font, &pos, &fmt, "Center right");
     736        rc = gfx_puttext(&pos, &fmt, "Center right");
    735737        if (rc != EOK)
    736738                goto error;
     
    741743        pos.y = rect.p1.y - 1;
    742744        fmt.halign = gfx_halign_left;
    743         rc = gfx_puttext(font, &pos, &fmt, "Bottom left");
     745        rc = gfx_puttext(&pos, &fmt, "Bottom left");
    744746        if (rc != EOK)
    745747                goto error;
     
    748750        pos.y = rect.p1.y;
    749751        fmt.halign = gfx_halign_center;
    750         rc = gfx_puttext(font, &pos, &fmt, "Bottom center");
     752        rc = gfx_puttext(&pos, &fmt, "Bottom center");
    751753        if (rc != EOK)
    752754                goto error;
     
    755757        pos.y = rect.p1.y;
    756758        fmt.halign = gfx_halign_right;
    757         rc = gfx_puttext(font, &pos, &fmt, "Bottom right");
     759        rc = gfx_puttext(&pos, &fmt, "Bottom right");
    758760        if (rc != EOK)
    759761                goto error;
     
    762764
    763765        gfx_text_fmt_init(&fmt);
     766        fmt.font = font;
    764767
    765768        for (i = 0; i < 8; i++) {
     
    780783                pos.x = w / 20;
    781784                pos.y = (6 + i) * h / 15;
    782                 rc = gfx_puttext(font, &pos, &fmt, "The quick brown fox jumps over the lazy dog.");
     785                rc = gfx_puttext(&pos, &fmt, "The quick brown fox jumps over the lazy dog.");
    783786                if (rc != EOK)
    784787                        goto error;
  • uspace/app/nav/panel.c

    r5c27e77 r4583015  
    175175
    176176        gfx_text_fmt_init(&fmt);
     177        fmt.font = font;
    177178        rows = panel_page_size(panel);
    178179
     
    219220                return rc;
    220221
    221         rc = gfx_puttext(font, &pos, &fmt, entry->name);
     222        rc = gfx_puttext(&pos, &fmt, entry->name);
    222223        if (rc != EOK) {
    223224                (void) gfx_set_clip_rect(gc, NULL);
     
    236237        gfx_context_t *gc = ui_window_get_gc(panel->window);
    237238        ui_resource_t *res = ui_window_get_res(panel->window);
    238         gfx_text_fmt_t fmt;
    239239        panel_entry_t *entry;
    240240        ui_box_style_t bstyle;
     
    242242        int i, lines;
    243243        errno_t rc;
    244 
    245         gfx_text_fmt_init(&fmt);
    246244
    247245        rc = gfx_set_color(gc, panel->color);
  • uspace/lib/gfxfont/include/gfx/text.h

    r5c27e77 r4583015  
    4545extern void gfx_text_fmt_init(gfx_text_fmt_t *);
    4646extern gfx_coord_t gfx_text_width(gfx_font_t *, const char *);
    47 extern errno_t gfx_puttext(gfx_font_t *, gfx_coord2_t *, gfx_text_fmt_t *,
    48     const char *);
    49 extern void gfx_text_start_pos(gfx_font_t *, gfx_coord2_t *, gfx_text_fmt_t *,
    50     const char *, gfx_coord2_t *);
    51 extern size_t gfx_text_find_pos(gfx_font_t *, gfx_coord2_t *, gfx_text_fmt_t *,
    52     const char *, gfx_coord2_t *);
    53 extern void gfx_text_cont(gfx_font_t *, gfx_coord2_t *, gfx_text_fmt_t *,
    54     const char *, gfx_coord2_t *, gfx_text_fmt_t *);
    55 extern void gfx_text_rect(gfx_font_t *, gfx_coord2_t *, gfx_text_fmt_t *,
    56     const char *, gfx_rect_t *);
     47extern errno_t gfx_puttext(gfx_coord2_t *, gfx_text_fmt_t *, const char *);
     48extern void gfx_text_start_pos(gfx_coord2_t *, gfx_text_fmt_t *, const char *,
     49    gfx_coord2_t *);
     50extern size_t gfx_text_find_pos(gfx_coord2_t *, gfx_text_fmt_t *, const char *,
     51    gfx_coord2_t *);
     52extern void gfx_text_cont(gfx_coord2_t *, gfx_text_fmt_t *, const char *,
     53    gfx_coord2_t *, gfx_text_fmt_t *);
     54extern void gfx_text_rect(gfx_coord2_t *, gfx_text_fmt_t *, const char *,
     55    gfx_rect_t *);
    5756
    5857#endif
  • uspace/lib/gfxfont/include/types/gfx/text.h

    r5c27e77 r4583015  
    6767/** Text formatting */
    6868typedef struct {
     69        /** Text font */
     70        struct gfx_font *font;
    6971        /** Text color */
    7072        gfx_color_t *color;
  • uspace/lib/gfxfont/src/text.c

    r5c27e77 r4583015  
    168168/** Get text starting position.
    169169 *
    170  * @param font Font
    171170 * @param pos Anchor position
    172171 * @param fmt Text formatting
     
    174173 * @param spos Place to store starting position
    175174 */
    176 void gfx_text_start_pos(gfx_font_t *font, gfx_coord2_t *pos,
    177     gfx_text_fmt_t *fmt, const char *str, gfx_coord2_t *spos)
     175void gfx_text_start_pos(gfx_coord2_t *pos, gfx_text_fmt_t *fmt,
     176    const char *str, gfx_coord2_t *spos)
    178177{
    179178        gfx_font_metrics_t fmetrics;
     
    184183        /* Adjust position for horizontal alignment */
    185184        if (fmt->halign != gfx_halign_left) {
    186                 width = gfx_text_width(font, str);
     185                width = gfx_text_width(fmt->font, str);
    187186                switch (fmt->halign) {
    188187                case gfx_halign_center:
     
    198197
    199198        /* Adjust position for vertical alignment */
    200         gfx_font_get_metrics(font, &fmetrics);
     199        gfx_font_get_metrics(fmt->font, &fmetrics);
    201200
    202201        if (fmt->valign != gfx_valign_baseline) {
     
    219218/** Render text.
    220219 *
    221  * @param font Font
    222220 * @param pos Anchor position
    223221 * @param fmt Text formatting
     
    225223 * @return EOK on success or an error code
    226224 */
    227 errno_t gfx_puttext(gfx_font_t *font, gfx_coord2_t *pos,
    228     gfx_text_fmt_t *fmt, const char *str)
     225errno_t gfx_puttext(gfx_coord2_t *pos, gfx_text_fmt_t *fmt, const char *str)
    229226{
    230227        gfx_glyph_metrics_t gmetrics;
     
    238235        errno_t rc;
    239236
    240         gfx_text_start_pos(font, pos, fmt, str, &spos);
     237        gfx_text_start_pos(pos, fmt, str, &spos);
    241238
    242239        /* Text mode */
    243         if ((font->finfo->props.flags & gff_text_mode) != 0)
    244                 return gfx_puttext_textmode(font, &spos, fmt->color, str);
    245 
    246         rc = gfx_set_color(font->typeface->gc, fmt->color);
     240        if ((fmt->font->finfo->props.flags & gff_text_mode) != 0)
     241                return gfx_puttext_textmode(fmt->font, &spos, fmt->color, str);
     242
     243        rc = gfx_set_color(fmt->font->typeface->gc, fmt->color);
    247244        if (rc != EOK)
    248245                return rc;
     
    251248        cp = str;
    252249        while (*cp != '\0') {
    253                 rc = gfx_font_search_glyph(font, cp, &glyph, &stradv);
     250                rc = gfx_font_search_glyph(fmt->font, cp, &glyph, &stradv);
    254251                if (rc != EOK) {
    255252                        ++cp;
     
    269266        /* Text underlining */
    270267        if (fmt->underline) {
    271                 gfx_font_get_metrics(font, &fmetrics);
     268                gfx_font_get_metrics(fmt->font, &fmetrics);
    272269
    273270                rect.p0.x = spos.x;
     
    276273                rect.p1.y = spos.y + fmetrics.underline_y1;
    277274
    278                 rc = gfx_fill_rect(font->typeface->gc, &rect);
     275                rc = gfx_fill_rect(fmt->font->typeface->gc, &rect);
    279276                if (rc != EOK)
    280277                        return rc;
     
    286283/** Find character position in string by X coordinate.
    287284 *
    288  * @param font Font
    289285 * @param pos Anchor position
    290286 * @param fmt Text formatting
     
    298294 *         offset of the following character.
    299295 */
    300 size_t gfx_text_find_pos(gfx_font_t *font, gfx_coord2_t *pos,
    301     gfx_text_fmt_t *fmt, const char *str, gfx_coord2_t *fpos)
     296size_t gfx_text_find_pos(gfx_coord2_t *pos, gfx_text_fmt_t *fmt,
     297    const char *str, gfx_coord2_t *fpos)
    302298{
    303299        gfx_glyph_metrics_t gmetrics;
     
    310306        errno_t rc;
    311307
    312         gfx_text_start_pos(font, pos, fmt, str, &cpos);
     308        gfx_text_start_pos(pos, fmt, str, &cpos);
    313309
    314310        /* Text mode */
    315         if ((font->finfo->props.flags & gff_text_mode) != 0) {
     311        if ((fmt->font->finfo->props.flags & gff_text_mode) != 0) {
    316312                off = 0;
    317313                strsize = str_size(str);
     
    329325        off = 0;
    330326        while (*cp != '\0') {
    331                 rc = gfx_font_search_glyph(font, cp, &glyph, &stradv);
     327                rc = gfx_font_search_glyph(fmt->font, cp, &glyph, &stradv);
    332328                if (rc != EOK) {
    333329                        ++cp;
     
    355351 * to the same objects, respectively.
    356352 *
    357  * @param font Font
    358353 * @param pos Anchor position
    359354 * @param fmt Text formatting
     
    362357 * @param cfmt Place to store format for continuation
    363358 */
    364 void gfx_text_cont(gfx_font_t *font, gfx_coord2_t *pos,
    365     gfx_text_fmt_t *fmt, const char *str, gfx_coord2_t *cpos,
    366     gfx_text_fmt_t *cfmt)
     359void gfx_text_cont(gfx_coord2_t *pos, gfx_text_fmt_t *fmt, const char *str,
     360    gfx_coord2_t *cpos, gfx_text_fmt_t *cfmt)
    367361{
    368362        gfx_coord2_t spos;
     
    370364
    371365        /* Continuation should start where the current string ends */
    372         gfx_text_start_pos(font, pos, fmt, str, &spos);
    373         cpos->x = spos.x + gfx_text_width(font, str);
     366        gfx_text_start_pos(pos, fmt, str, &spos);
     367        cpos->x = spos.x + gfx_text_width(fmt->font, str);
    374368        cpos->y = spos.y;
    375369
     
    387381/** Get text bounding rectangle.
    388382 *
    389  * @param font Font
    390383 * @param pos Anchor position
    391384 * @param fmt Text formatting
     
    393386 * @param rect Place to store bounding rectangle
    394387 */
    395 void gfx_text_rect(gfx_font_t *font, gfx_coord2_t *pos,
    396     gfx_text_fmt_t *fmt, const char *str, gfx_rect_t *rect)
     388void gfx_text_rect(gfx_coord2_t *pos, gfx_text_fmt_t *fmt, const char *str,
     389    gfx_rect_t *rect)
    397390{
    398391        gfx_coord2_t spos;
    399392
    400         gfx_text_start_pos(font, pos, fmt, str, &spos);
     393        gfx_text_start_pos(pos, fmt, str, &spos);
    401394
    402395        rect->p0.x = spos.x;
    403         rect->p0.y = spos.y - font->metrics.ascent;
    404         rect->p1.x = spos.x + gfx_text_width(font, str);
    405         rect->p1.y = spos.y + font->metrics.descent + 1;
     396        rect->p0.y = spos.y - fmt->font->metrics.ascent;
     397        rect->p1.x = spos.x + gfx_text_width(fmt->font, str);
     398        rect->p1.y = spos.y +  fmt->font->metrics.descent + 1;
    406399}
    407400
  • 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);
  • uspace/lib/ui/src/checkbox.c

    r5c27e77 r4583015  
    192192
    193193                gfx_text_fmt_init(&fmt);
     194                fmt.font = checkbox->res->font;
    194195                fmt.color = checkbox->res->entry_fg_color;
    195196                fmt.halign = gfx_halign_center;
    196197                fmt.valign = gfx_valign_center;
    197198
    198                 rc = gfx_puttext(checkbox->res->font, &box_center, &fmt, "X");
     199                rc = gfx_puttext(&box_center, &fmt, "X");
    199200                if (rc != EOK)
    200201                        goto error;
     
    207208
    208209        gfx_text_fmt_init(&fmt);
     210        fmt.font = checkbox->res->font;
    209211        fmt.color = checkbox->res->wnd_text_color;
    210212        fmt.halign = gfx_halign_left;
    211213        fmt.valign = gfx_valign_center;
    212214
    213         rc = gfx_puttext(checkbox->res->font, &pos, &fmt, checkbox->caption);
     215        rc = gfx_puttext(&pos, &fmt, checkbox->caption);
    214216        if (rc != EOK)
    215217                goto error;
     
    244246
    245247        gfx_text_fmt_init(&fmt);
     248        fmt.font = checkbox->res->font;
    246249        fmt.color = depressed ? checkbox->res->entry_act_bg_color :
    247250            checkbox->res->wnd_text_color;
     
    249252        fmt.valign = gfx_valign_top;
    250253
    251         rc = gfx_puttext(checkbox->res->font, &pos, &fmt,
    252             checkbox->checked ? "[X]" : "[ ]");
     254        rc = gfx_puttext(&pos, &fmt, checkbox->checked ? "[X]" : "[ ]");
    253255        if (rc != EOK)
    254256                goto error;
     
    259261        fmt.color = checkbox->res->wnd_text_color;
    260262
    261         rc = gfx_puttext(checkbox->res->font, &pos, &fmt, checkbox->caption);
     263        rc = gfx_puttext(&pos, &fmt, checkbox->caption);
    262264        if (rc != EOK)
    263265                goto error;
  • uspace/lib/ui/src/entry.c

    r5c27e77 r4583015  
    314314
    315315        gfx_text_fmt_init(&fmt);
     316        fmt.font = res->font;
    316317        fmt.color = res->entry_fg_color;
    317318        fmt.halign = gfx_halign_left;
     
    329330        entry->text[off1] = '\0';
    330331
    331         rc = gfx_puttext(res->font, &pos, &fmt, entry->text);
     332        rc = gfx_puttext(&pos, &fmt, entry->text);
    332333        if (rc != EOK) {
    333334                (void) gfx_set_clip_rect(res->gc, NULL);
     
    335336        }
    336337
    337         gfx_text_cont(res->font, &pos, &fmt, entry->text, &cpos, &cfmt);
     338        gfx_text_cont(&pos, &fmt, entry->text, &cpos, &cfmt);
    338339        entry->text[off1] = c;
    339340
     
    345346                cfmt.color = res->entry_sel_text_fg_color;
    346347
    347                 gfx_text_rect(res->font, &cpos, &cfmt, entry->text + off1, &sel);
     348                gfx_text_rect(&cpos, &cfmt, entry->text + off1, &sel);
    348349                sel.p0.x -= ui_entry_sel_hpad;
    349350                sel.p0.y -= ui_entry_sel_vpad;
     
    359360                        goto error;
    360361
    361                 rc = gfx_puttext(res->font, &cpos, &cfmt, entry->text + off1);
     362                rc = gfx_puttext(&cpos, &cfmt, entry->text + off1);
    362363                if (rc != EOK) {
    363364                        (void) gfx_set_clip_rect(res->gc, NULL);
     
    365366                }
    366367
    367                 gfx_text_cont(res->font, &cpos, &cfmt, entry->text + off1,
    368                     &cpos, &cfmt);
     368                gfx_text_cont(&cpos, &cfmt, entry->text + off1, &cpos, &cfmt);
    369369
    370370                entry->text[off2] = c;
     
    374374        cfmt.color = res->entry_fg_color;
    375375
    376         rc = gfx_puttext(res->font, &cpos, &cfmt, entry->text + off2);
     376        rc = gfx_puttext(&cpos, &cfmt, entry->text + off2);
    377377        if (rc != EOK) {
    378378                (void) gfx_set_clip_rect(res->gc, NULL);
     
    421421
    422422        gfx_text_fmt_init(&fmt);
     423        fmt.font = res->font;
    423424        fmt.halign = gfx_halign_left;
    424425        fmt.valign = gfx_valign_top;
    425426
    426         return gfx_text_find_pos(res->font, &geom.text_pos, &fmt,
    427             entry->text, fpos);
     427        return gfx_text_find_pos(&geom.text_pos, &fmt, entry->text, fpos);
    428428}
    429429
     
    11111111                anchor.y = 0;
    11121112                gfx_text_fmt_init(&fmt);
     1113                fmt.font = res->font;
    11131114                fmt.halign = entry->halign;
    1114                 gfx_text_start_pos(res->font, &anchor, &fmt, entry->text,
    1115                     &tpos);
     1115                gfx_text_start_pos(&anchor, &fmt, entry->text, &tpos);
    11161116                entry->scroll_pos = tpos.x - geom.text_rect.p0.x;
    11171117        } else if (geom.text_pos.x + width < geom.text_rect.p1.x &&
  • uspace/lib/ui/src/label.c

    r5c27e77 r4583015  
    215215
    216216        gfx_text_fmt_init(&fmt);
     217        fmt.font = label->res->font;
    217218        fmt.color = label->res->wnd_text_color;
    218219        fmt.halign = label->halign;
    219220        fmt.valign = label->valign;
    220221
    221         rc = gfx_puttext(label->res->font, &pos, &fmt, label->text);
     222        rc = gfx_puttext(&pos, &fmt, label->text);
    222223        if (rc != EOK)
    223224                goto error;
  • uspace/lib/ui/src/menubar.c

    r5c27e77 r4583015  
    185185
    186186        gfx_text_fmt_init(&fmt);
     187        fmt.font = res->font;
    187188        fmt.halign = gfx_halign_left;
    188189        fmt.valign = gfx_valign_top;
     
    215216                        goto error;
    216217
    217                 rc = gfx_puttext(res->font, &tpos, &fmt, caption);
     218                rc = gfx_puttext(&tpos, &fmt, caption);
    218219                if (rc != EOK)
    219220                        goto error;
  • uspace/lib/ui/src/menuentry.c

    r5c27e77 r4583015  
    351351
    352352        gfx_text_fmt_init(&fmt);
     353        fmt.font = res->font;
    353354        fmt.halign = gfx_halign_left;
    354355        fmt.valign = gfx_valign_top;
     
    371372                goto error;
    372373
    373         rc = gfx_puttext(res->font, &geom.caption_pos, &fmt, mentry->caption);
     374        rc = gfx_puttext(&geom.caption_pos, &fmt, mentry->caption);
    374375        if (rc != EOK)
    375376                goto error;
     
    377378        fmt.halign = gfx_halign_right;
    378379
    379         rc = gfx_puttext(res->font, &geom.shortcut_pos, &fmt, mentry->shortcut);
     380        rc = gfx_puttext(&geom.shortcut_pos, &fmt, mentry->shortcut);
    380381        if (rc != EOK)
    381382                goto error;
  • uspace/lib/ui/src/paint.c

    r5c27e77 r4583015  
    402402
    403403        gfx_text_fmt_init(&fmt);
     404        fmt.font = resource->font;
    404405        fmt.color = color;
    405406
     
    427428
    428429        pos = rect->p0;
    429         rc = gfx_puttext(resource->font, &pos, &fmt, str);
     430        rc = gfx_puttext(&pos, &fmt, str);
    430431        if (rc != EOK)
    431432                goto error;
     
    436437
    437438                pos.x = rect->p0.x;
    438                 rc = gfx_puttext(resource->font, &pos, &fmt,
    439                     boxc->c[1][0]);
     439                rc = gfx_puttext(&pos, &fmt, boxc->c[1][0]);
    440440                if (rc != EOK)
    441441                        goto error;
    442442
    443443                pos.x = rect->p1.x - 1;
    444                 rc = gfx_puttext(resource->font, &pos, &fmt,
    445                     boxc->c[1][2]);
     444                rc = gfx_puttext(&pos, &fmt, boxc->c[1][2]);
    446445                if (rc != EOK)
    447446                        goto error;
     
    464463        pos.x = rect->p0.x;
    465464        pos.y = rect->p1.y - 1;
    466         rc = gfx_puttext(resource->font, &pos, &fmt, str);
     465        rc = gfx_puttext(&pos, &fmt, str);
    467466        if (rc != EOK)
    468467                goto error;
     
    519518
    520519        gfx_text_fmt_init(&fmt);
     520        fmt.font = resource->font;
    521521        fmt.color = color;
    522522
     
    542542
    543543        pos = rect->p0;
    544         rc = gfx_puttext(resource->font, &pos, &fmt, str);
     544        rc = gfx_puttext(&pos, &fmt, str);
    545545        if (rc != EOK)
    546546                goto error;
  • uspace/lib/ui/src/pbutton.c

    r5c27e77 r4583015  
    307307
    308308        gfx_text_fmt_init(&fmt);
     309        fmt.font = pbutton->res->font;
    309310        fmt.color = pbutton->res->btn_text_color;
    310311        fmt.halign = gfx_halign_center;
    311312        fmt.valign = gfx_valign_center;
    312313
    313         rc = gfx_puttext(pbutton->res->font, &pos, &fmt, pbutton->caption);
     314        rc = gfx_puttext(&pos, &fmt, pbutton->caption);
    314315        if (rc != EOK)
    315316                goto error;
     
    379380
    380381        gfx_text_fmt_init(&fmt);
     382        fmt.font = pbutton->res->font;
    381383        fmt.color = pbutton->res->btn_text_color;
    382384        fmt.halign = gfx_halign_center;
    383385        fmt.valign = gfx_valign_center;
    384386
    385         rc = gfx_puttext(pbutton->res->font, &pos, &fmt, pbutton->caption);
     387        rc = gfx_puttext(&pos, &fmt, pbutton->caption);
    386388        if (rc != EOK)
    387389                goto error;
  • uspace/lib/ui/src/rbutton.c

    r5c27e77 r4583015  
    278278
    279279        gfx_text_fmt_init(&fmt);
     280        fmt.font = rbutton->group->res->font;
    280281        fmt.color = rbutton->group->res->wnd_text_color;
    281282        fmt.halign = gfx_halign_left;
    282283        fmt.valign = gfx_valign_center;
    283284
    284         rc = gfx_puttext(rbutton->group->res->font, &pos, &fmt,
    285             rbutton->caption);
     285        rc = gfx_puttext(&pos, &fmt, rbutton->caption);
    286286        if (rc != EOK)
    287287                goto error;
     
    316316
    317317        gfx_text_fmt_init(&fmt);
     318        fmt.font = rbutton->group->res->font;
    318319        fmt.color = depressed ? rbutton->group->res->entry_act_bg_color :
    319320            rbutton->group->res->wnd_text_color;
     
    321322        fmt.valign = gfx_valign_top;
    322323
    323         rc = gfx_puttext(rbutton->group->res->font, &pos, &fmt,
    324             rbutton->group->selected == rbutton ? "(\u2022)" : "( )");
     324        rc = gfx_puttext(&pos, &fmt, rbutton->group->selected == rbutton ?
     325            "(\u2022)" : "( )");
    325326        if (rc != EOK)
    326327                goto error;
     
    332333        fmt.color = rbutton->group->res->wnd_text_color;
    333334
    334         rc = gfx_puttext(rbutton->group->res->font, &pos, &fmt,
    335             rbutton->caption);
     335        rc = gfx_puttext(&pos, &fmt, rbutton->caption);
    336336        if (rc != EOK)
    337337                goto error;
  • uspace/lib/ui/src/slider.c

    r5c27e77 r4583015  
    341341
    342342        gfx_text_fmt_init(&fmt);
     343        fmt.font = slider->res->font;
    343344        fmt.color = slider->res->wnd_text_color;
    344345        fmt.halign = gfx_halign_left;
     
    357358        buf[w * gcharsz] = '\0';
    358359
    359         rc = gfx_puttext(slider->res->font, &pos, &fmt, buf);
     360        rc = gfx_puttext(&pos, &fmt, buf);
    360361        free(buf);
    361362        if (rc != EOK)
     
    366367        pos.x += slider->pos;
    367368
    368         rc = gfx_puttext(slider->res->font, &pos, &fmt,
    369             "[O]");
     369        rc = gfx_puttext(&pos, &fmt, "[O]");
    370370        if (rc != EOK)
    371371                goto error;
  • uspace/lib/ui/src/wdecor.c

    r5c27e77 r4583015  
    242242
    243243                gfx_text_fmt_init(&fmt);
     244                fmt.font = wdecor->res->font;
    244245                fmt.color = wdecor->active ?
    245246                    wdecor->res->tbar_act_text_color :
     
    253254                if (wdecor->res->textmode) {
    254255                        /* Make space around caption text */
    255                         gfx_text_rect(wdecor->res->font, &pos, &fmt,
    256                             wdecor->caption, &text_rect);
     256                        gfx_text_rect(&pos, &fmt, wdecor->caption, &text_rect);
    257257
    258258                        /* Only make space if caption is non-empty */
     
    273273                }
    274274
    275                 rc = gfx_puttext(wdecor->res->font, &pos, &fmt, wdecor->caption);
     275                rc = gfx_puttext(&pos, &fmt, wdecor->caption);
    276276                if (rc != EOK)
    277277                        return rc;
Note: See TracChangeset for help on using the changeset viewer.