Changeset 760 for libcaca/trunk/test
- Timestamp:
- Apr 13, 2006, 4:24:31 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/test/font.c
r758 r760 28 28 #include "cucul.h" 29 29 30 extern uint8_t font_monospace9[];31 32 30 int main(int argc, char *argv[]) 33 31 { … … 37 35 unsigned int x, y, w, h; 38 36 39 qq = cucul_create(5, 2); 37 /* Create a canvas */ 38 qq = cucul_create(8, 2); 39 40 /* Draw stuff on our canvas */ 40 41 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, "&$âøÿ░▒█"); 43 44 44 f = cucul_load_font(font_monospace9, 700000); 45 /* Load a libcucul internal font */ 46 f = cucul_load_font("Monospace 9", 0); 45 47 48 /* Create our bitmap buffer (32-bit ARGB) */ 46 49 w = cucul_get_width(qq) * cucul_get_font_width(f); 47 50 h = cucul_get_height(qq) * cucul_get_font_height(f); 48 51 buf = malloc(4 * w * h); 49 52 53 /* Render the canvas onto our image buffer */ 50 54 cucul_render_canvas(qq, f, buf, w, h, 4 * w); 51 55 56 /* Just for fun, output the image on the terminal using ASCII art */ 52 57 for(y = 0; y < h; y++) 53 58 { 54 59 for(x = 0; x < w; x++) 55 60 { 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]); 57 66 } 58 67 printf("\n"); 59 68 } 60 69 70 /* Free everything */ 61 71 free(buf); 62 72 cucul_free_font(f);
Note: See TracChangeset
for help on using the changeset viewer.