Changeset 2821 for libcaca/trunk/examples/font.c
- Timestamp:
- Sep 27, 2008, 3:12:46 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/examples/font.c
r2300 r2821 1 1 /* 2 * font libc uculfont test program2 * font libcaca font test program 3 3 * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 25 25 #endif 26 26 27 #include "cucul.h"28 27 #include "caca.h" 29 28 30 29 int main(int argc, char *argv[]) 31 30 { 32 c ucul_canvas_t *cv;31 caca_canvas_t *cv; 33 32 caca_display_t *dp; 34 c ucul_font_t *f;35 c ucul_dither_t *d;33 caca_font_t *f; 34 caca_dither_t *d; 36 35 uint8_t *buf; 37 36 unsigned int w, h; … … 39 38 40 39 /* Create a canvas */ 41 cv = c ucul_create_canvas(8, 2);40 cv = caca_create_canvas(8, 2); 42 41 if(cv == NULL) 43 42 { … … 48 47 49 48 /* Draw stuff on our canvas */ 50 c ucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);51 c ucul_put_str(cv, 0, 0, "ABcde");52 c ucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_BLACK);53 c ucul_put_str(cv, 5, 0, "\\o/");54 c ucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);55 c ucul_put_str(cv, 0, 1, "&$âøÿØ?!");49 caca_set_color_ansi(cv, CACA_WHITE, CACA_BLACK); 50 caca_put_str(cv, 0, 0, "ABcde"); 51 caca_set_color_ansi(cv, CACA_LIGHTRED, CACA_BLACK); 52 caca_put_str(cv, 5, 0, "\\o/"); 53 caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE); 54 caca_put_str(cv, 0, 1, "&$âøÿØ?!"); 56 55 57 /* Load a libc uculinternal font */58 fonts = c ucul_get_font_list();56 /* Load a libcaca internal font */ 57 fonts = caca_get_font_list(); 59 58 if(fonts[0] == NULL) 60 59 { 61 fprintf(stderr, "error: libc uculwas compiled without any fonts\n");60 fprintf(stderr, "error: libcaca was compiled without any fonts\n"); 62 61 return -1; 63 62 } 64 f = c ucul_load_font(fonts[0], 0);63 f = caca_load_font(fonts[0], 0); 65 64 if(f == NULL) 66 65 { … … 70 69 71 70 /* Create our bitmap buffer (32-bit ARGB) */ 72 w = c ucul_get_canvas_width(cv) * cucul_get_font_width(f);73 h = c ucul_get_canvas_height(cv) * cucul_get_font_height(f);71 w = caca_get_canvas_width(cv) * caca_get_font_width(f); 72 h = caca_get_canvas_height(cv) * caca_get_font_height(f); 74 73 buf = malloc(4 * w * h); 75 74 76 75 /* Render the canvas onto our image buffer */ 77 c ucul_render_canvas(cv, f, buf, w, h, 4 * w);76 caca_render_canvas(cv, f, buf, w, h, 4 * w); 78 77 79 78 /* Just for fun, render the image using libcaca */ 80 c ucul_set_canvas_size(cv, 80, 32);79 caca_set_canvas_size(cv, 80, 32); 81 80 dp = caca_create_display(cv); 82 81 … … 89 88 if(*(uint8_t const *)&tmp == 0x12) 90 89 #endif 91 d = c ucul_create_dither(32, w, h, 4 * w,90 d = caca_create_dither(32, w, h, 4 * w, 92 91 0xff0000, 0xff00, 0xff, 0xff000000); 93 92 else 94 d = c ucul_create_dither(32, w, h, 4 * w,93 d = caca_create_dither(32, w, h, 4 * w, 95 94 0xff00, 0xff0000, 0xff000000, 0xff); 96 95 } 97 96 98 c ucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv),99 c ucul_get_canvas_height(cv), d, buf);97 caca_dither_bitmap(cv, 0, 0, caca_get_canvas_width(cv), 98 caca_get_canvas_height(cv), d, buf); 100 99 caca_refresh_display(dp); 101 100 … … 105 104 caca_free_display(dp); 106 105 free(buf); 107 c ucul_free_dither(d);108 c ucul_free_font(f);109 c ucul_free_canvas(cv);106 caca_free_dither(d); 107 caca_free_font(f); 108 caca_free_canvas(cv); 110 109 111 110 return 0;
Note: See TracChangeset
for help on using the changeset viewer.