Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

57 wiersze
1.3 KiB

  1. /*
  2. * figfont libcaca FIGfont test program
  3. * Copyright (c) 2007-2010 Sam Hocevar <sam@hocevar.net>
  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://sam.zoy.org/wtfpl/COPYING for more details.
  11. */
  12. #include "config.h"
  13. #if !defined(__KERNEL__)
  14. # include <stdio.h>
  15. # include <stdlib.h>
  16. #endif
  17. #include "caca.h"
  18. int main(int argc, char *argv[])
  19. {
  20. caca_canvas_t *cv;
  21. void *buffer;
  22. size_t len;
  23. uint8_t color = 0;
  24. if(argc < 3)
  25. {
  26. fprintf(stderr, "Too few arguments\n");
  27. return -1;
  28. }
  29. cv = caca_create_canvas(0, 0);
  30. if(caca_canvas_set_figfont(cv, argv[1]))
  31. {
  32. fprintf(stderr, "Could not open font\n");
  33. return -1;
  34. }
  35. while(argv[2][0])
  36. {
  37. caca_set_color_ansi(cv, 1 + ((color += 4) % 15), CACA_TRANSPARENT);
  38. caca_put_figchar(cv, argv[2]++[0]);
  39. }
  40. buffer = caca_export_canvas_to_memory(cv, "utf8", &len);
  41. fwrite(buffer, len, 1, stdout);
  42. free(buffer);
  43. caca_free_canvas(cv);
  44. return 0;
  45. }