Changeset da15002 in mainline for uspace/app/gfxdemo/gfxdemo.c


Ignore:
Timestamp:
2021-05-10T18:41:29Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
344f8b9, d091007
Parents:
8dbd13d
Message:

No need to load font twice

File:
1 edited

Legend:

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

    r8dbd13d rda15002  
    605605        gfx_color_t *color = NULL;
    606606        gfx_rect_t rect;
    607         gfx_typeface_t *tface = NULL;
    608         gfx_font_info_t *finfo;
    609         gfx_font_t *font = NULL;
    610607        gfx_coord2_t pos;
    611608        gfx_text_fmt_t fmt;
     
    615612        if (quit)
    616613                return EOK;
    617 
    618         /* XXX Crude way of detecting text mode */
    619         if (w < 256) {
    620                 /* Create dummy font for text mode */
    621                 rc = gfx_typeface_create(gc, &tface);
    622                 if (rc != EOK) {
    623                         printf("Error creating typeface\n");
    624                         goto error;
    625                 }
    626 
    627                 rc = gfx_font_create_textmode(tface, &font);
    628                 if (rc != EOK) {
    629                         printf("Error creating font\n");
    630                         goto error;
    631                 }
    632         } else {
    633                 /* Load font */
    634                 rc = gfx_typeface_open(gc, "/data/font/helena.tpf", &tface);
    635                 if (rc != EOK) {
    636                         printf("Error opening typeface\n");
    637                         goto error;
    638                 }
    639 
    640                 finfo = gfx_typeface_first_font(tface);
    641                 if (finfo == NULL) {
    642                         printf("Typeface contains no font.\n");
    643                         rc = ENOENT;
    644                         goto error;
    645                 }
    646 
    647                 rc = gfx_font_open(finfo, &font);
    648                 if (rc != EOK) {
    649                         printf("Error opening font.\n");
    650                         goto error;
    651                 }
    652         }
    653614
    654615        rc = demo_begin(gc, w, h, "Text rendering");
     
    801762        }
    802763
    803         gfx_font_close(font);
    804         gfx_typeface_destroy(tface);
    805764        return EOK;
    806765error:
    807         if (font != NULL)
    808                 gfx_font_close(font);
    809         if (tface != NULL)
    810                 gfx_typeface_destroy(tface);
    811766        return rc;
    812767}
Note: See TracChangeset for help on using the changeset viewer.