Ignore:
Timestamp:
Apr 13, 2006, 4:24:31 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Internal font support through cucul_load_font(). Documented that.
  • Removed ugly hooks from test/font.c.
File:
1 edited

Legend:

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

    r758 r760  
    2828#include "cucul.h"
    2929
    30 extern uint8_t font_monospace9[];
    31 
    3230int main(int argc, char *argv[])
    3331{
     
    3735    unsigned int x, y, w, h;
    3836
    39     qq = cucul_create(5, 2);
     37    /* Create a canvas */
     38    qq = cucul_create(8, 2);
     39
     40    /* Draw stuff on our canvas */
    4041    cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    41     cucul_putstr(qq, 0, 0, "ABcde");
    42     cucul_putstr(qq, 0, 1, "&$âøÿ");
     42    cucul_putstr(qq, 0, 0, "ABcde\\o/");
     43    cucul_putstr(qq, 0, 1, "&$âøÿ░▒█");
    4344
    44     f = cucul_load_font(font_monospace9, 700000);
     45    /* Load a libcucul internal font */
     46    f = cucul_load_font("Monospace 9", 0);
    4547
     48    /* Create our bitmap buffer (32-bit ARGB) */
    4649    w = cucul_get_width(qq) * cucul_get_font_width(f);
    4750    h = cucul_get_height(qq) * cucul_get_font_height(f);
    4851    buf = malloc(4 * w * h);
    4952
     53    /* Render the canvas onto our image buffer */
    5054    cucul_render_canvas(qq, f, buf, w, h, 4 * w);
    5155
     56    /* Just for fun, output the image on the terminal using ASCII art */
    5257    for(y = 0; y < h; y++)
    5358    {
    5459        for(x = 0; x < w; x++)
    5560        {
    56             printf("%.02x", buf[4 * (y * w + x) + 3]);
     61            static const char list[] = {
     62                ' ', '.', ':', 't', 'S', 'R', '#', '@'
     63            };
     64
     65            printf("%c", list[buf[4 * (y * w + x) + 3] / 0x20]);
    5766        }
    5867        printf("\n");
    5968    }
    6069
     70    /* Free everything */
    6171    free(buf);
    6272    cucul_free_font(f);
Note: See TracChangeset for help on using the changeset viewer.