Ignore:
Timestamp:
Apr 13, 2006, 3:33:31 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Implemented cucul_get_font_width() and cucul_get_font_height().
  • Documented most font functions.
  • Cleaned up cucul_render_canvas() and made it actually usable by external programs. Removed ugly printf() debug calls.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/test/font.c

    r750 r758  
    3434    cucul_t *qq;
    3535    struct cucul_font *f;
     36    unsigned char *buf;
     37    unsigned int x, y, w, h;
    3638
    3739    qq = cucul_create(5, 2);
     40    cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    3841    cucul_putstr(qq, 0, 0, "ABcde");
    3942    cucul_putstr(qq, 0, 1, "&$âøÿ");
    4043
    4144    f = cucul_load_font(font_monospace9, 700000);
    42     cucul_render_canvas(qq, f);
     45
     46    w = cucul_get_width(qq) * cucul_get_font_width(f);
     47    h = cucul_get_height(qq) * cucul_get_font_height(f);
     48    buf = malloc(4 * w * h);
     49
     50    cucul_render_canvas(qq, f, buf, w, h, 4 * w);
     51
     52    for(y = 0; y < h; y++)
     53    {
     54        for(x = 0; x < w; x++)
     55        {
     56            printf("%.02x", buf[4 * (y * w + x) + 3]);
     57        }
     58        printf("\n");
     59    }
     60
     61    free(buf);
    4362    cucul_free_font(f);
    44 
    4563    cucul_free(qq);
    4664
Note: See TracChangeset for help on using the changeset viewer.