| 1 |
/* |
| 2 |
* figfont libcaca FIGfont test program |
| 3 |
* Copyright (c) 2007-2012 Sam Hocevar <[email protected]> |
| 4 |
* All Rights Reserved |
| 5 |
* |
| 6 |
* This program is free software. It comes without any warranty, to |
| 7 |
* the extent permitted by applicable law. You can redistribute it |
| 8 |
* and/or modify it under the terms of the Do What the Fuck You Want |
| 9 |
* to Public License, Version 2, as published by Sam Hocevar. See |
| 10 |
* http://www.wtfpl.net/ for more details. |
| 11 |
*/ |
| 12 |
|
| 13 |
#include "config.h" |
| 14 |
|
| 15 |
#if !defined(__KERNEL__) |
| 16 |
# include <stdio.h> |
| 17 |
# include <stdlib.h> |
| 18 |
#endif |
| 19 |
|
| 20 |
#include "caca.h" |
| 21 |
|
| 22 |
int main(int argc, char *argv[]) |
| 23 |
{ |
| 24 |
caca_canvas_t *cv; |
| 25 |
void *buffer; |
| 26 |
size_t len; |
| 27 |
uint8_t color = 0; |
| 28 |
|
| 29 |
if(argc < 3) |
| 30 |
{ |
| 31 |
fprintf(stderr, "Too few arguments\n"); |
| 32 |
return -1; |
| 33 |
} |
| 34 |
|
| 35 |
cv = caca_create_canvas(0, 0); |
| 36 |
if(caca_canvas_set_figfont(cv, argv[1])) |
| 37 |
{ |
| 38 |
fprintf(stderr, "Could not open font\n"); |
| 39 |
return -1; |
| 40 |
} |
| 41 |
|
| 42 |
while(argv[2][0]) |
| 43 |
{ |
| 44 |
caca_set_color_ansi(cv, 1 + ((color += 4) % 15), CACA_TRANSPARENT); |
| 45 |
caca_put_figchar(cv, argv[2]++[0]); |
| 46 |
} |
| 47 |
|
| 48 |
buffer = caca_export_canvas_to_memory(cv, "utf8", &len); |
| 49 |
fwrite(buffer, len, 1, stdout); |
| 50 |
free(buffer); |
| 51 |
|
| 52 |
caca_free_canvas(cv); |
| 53 |
|
| 54 |
return 0; |
| 55 |
} |
| 56 |
|