Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

68 řádky
1.5 KiB

  1. /*
  2. * font libcucul font test program
  3. * Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the Do What The Fuck You Want To
  10. * Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. #include "config.h"
  14. #if defined(HAVE_INTTYPES_H)
  15. # include <inttypes.h>
  16. #else
  17. typedef unsigned char uint8_t;
  18. typedef unsigned short uint16_t;
  19. typedef unsigned int uint32_t;
  20. #endif
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include "cucul.h"
  25. extern uint8_t font_monospace9[];
  26. int main(int argc, char *argv[])
  27. {
  28. cucul_t *qq;
  29. struct cucul_font *f;
  30. unsigned char *buf;
  31. unsigned int x, y, w, h;
  32. qq = cucul_create(5, 2);
  33. cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
  34. cucul_putstr(qq, 0, 0, "ABcde");
  35. cucul_putstr(qq, 0, 1, "&$âøÿ");
  36. f = cucul_load_font(font_monospace9, 700000);
  37. w = cucul_get_width(qq) * cucul_get_font_width(f);
  38. h = cucul_get_height(qq) * cucul_get_font_height(f);
  39. buf = malloc(4 * w * h);
  40. cucul_render_canvas(qq, f, buf, w, h, 4 * w);
  41. for(y = 0; y < h; y++)
  42. {
  43. for(x = 0; x < w; x++)
  44. {
  45. printf("%.02x", buf[4 * (y * w + x) + 3]);
  46. }
  47. printf("\n");
  48. }
  49. free(buf);
  50. cucul_free_font(f);
  51. cucul_free(qq);
  52. return 0;
  53. }