rotate_glyph.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version 2
  5. * of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. * Author: g0tsu
  12. * Email: g0tsu at dnmx.0rg
  13. */
  14. #include <stdio.h>
  15. #include <assert.h>
  16. #include <libcaptcha.h>
  17. #include <errno.h>
  18. #define STB_IMAGE_WRITE_IMPLEMENTATION
  19. #include "stb_image_write.h"
  20. static int create_bmp_glyph() {
  21. char *fontfile = "../ttf/cmunrm/cmunrm.ttf";
  22. lc_fontBuffer *font = lc_create_font(fontfile);
  23. lc_bmpGlyph *glyph;
  24. if (!font) {
  25. perror("lc_create_font()");
  26. return 1;
  27. }
  28. glyph = lc_create_glyph(font, 'P', 320);
  29. if (!glyph) {
  30. puts("lc_create_glyph()");
  31. return 1;
  32. }
  33. lc_bmpGlyph *rotated = lc_rotate_glyph(glyph, 30);
  34. /* stbi_write_png("/tmp/glyph.png", glyph->w, glyph->h, 1, glyph->buffer, glyph->w);*/
  35. if (!rotated) {
  36. perror("lc_rotate_glyph()");
  37. lc_free(glyph);
  38. lc_free(font);
  39. return 1;
  40. }
  41. /* stbi_write_png("/tmp/glyph.png", rotated->w, rotated->h, 1, rotated->buffer, rotated->w);*/
  42. lc_free(rotated);
  43. lc_free(glyph);
  44. lc_free(font);
  45. return 0;
  46. }
  47. int main() {
  48. assert(!create_bmp_glyph());
  49. return 0;
  50. }