You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1.3 KiB

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