Changeset 6a87f28 in mainline for uspace/app/gfxdemo/gfxdemo.c


Ignore:
Timestamp:
2021-02-25T16:48:13Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bac8acab
Parents:
26853ebc
Message:

First attempt at printing text in text-mode via GFX

File:
1 edited

Legend:

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

    r26853ebc r6a87f28  
    185185                for (j = 0; j < h; j++) {
    186186                        pixelmap_put_pixel(&pixelmap, i, j,
    187                             PIXEL(255, (i % 30) < 3 ? 255 : 0,
     187                            PIXEL(0, (i % 30) < 3 ? 255 : 0,
    188188                            (j % 30) < 3 ? 255 : 0, i / 2));
    189189                }
     
    221221                        k = i * i + j * j;
    222222                        pixelmap_put_pixel(&pixelmap, i, j,
    223                             PIXEL(255, k, k, k));
     223                            PIXEL(0, k, k, k));
    224224                }
    225225        }
     
    256256                        k = i * i + j * j;
    257257                        pixelmap_put_pixel(&pixelmap, i, j,
    258                             k < w * w / 2 ? PIXEL(255, 0, 255, 0) :
     258                            k < w * w / 2 ? PIXEL(0, 0, 255, 0) :
    259259                            PIXEL(0, 255, 0, 255));
    260260                }
     
    469469                return EOK;
    470470
    471         rc = gfx_typeface_open(gc, "/data/font/helena.tpf", &tface);
    472         if (rc != EOK) {
    473                 printf("Error opening typeface\n");
    474                 goto error;
    475         }
    476 
    477         finfo = gfx_typeface_first_font(tface);
    478         if (finfo == NULL) {
    479                 printf("Typeface contains no font.\n");
    480                 rc = ENOENT;
    481                 goto error;
    482         }
    483 
    484         rc = gfx_font_open(finfo, &font);
    485         if (rc != EOK) {
    486                 printf("Error opening font.\n");
    487                 goto error;
     471        /* XXX Crude way of detecting text mode */
     472        if (w < 256) {
     473                /* Create dummy font for text mode */
     474                rc = gfx_typeface_create(gc, &tface);
     475                if (rc != EOK) {
     476                        printf("Error creating typeface\n");
     477                        goto error;
     478                }
     479
     480                rc = gfx_font_create_textmode(tface, &font);
     481                if (rc != EOK) {
     482                        printf("Error creating font\n");
     483                        goto error;
     484                }
     485        } else {
     486                /* Load font */
     487                rc = gfx_typeface_open(gc, "/data/font/helena.tpf", &tface);
     488                if (rc != EOK) {
     489                        printf("Error opening typeface\n");
     490                        goto error;
     491                }
     492
     493                finfo = gfx_typeface_first_font(tface);
     494                if (finfo == NULL) {
     495                        printf("Typeface contains no font.\n");
     496                        rc = ENOENT;
     497                        goto error;
     498                }
     499
     500                rc = gfx_font_open(finfo, &font);
     501                if (rc != EOK) {
     502                        printf("Error opening font.\n");
     503                        goto error;
     504                }
    488505        }
    489506
Note: See TracChangeset for help on using the changeset viewer.