Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

90 строки
2.4 KiB

  1. /*
  2. * font2tga 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. #include "common.h"
  15. #if defined(HAVE_INTTYPES_H)
  16. # include <inttypes.h>
  17. #endif
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include "cucul.h"
  21. #define WIDTH 64
  22. /* Copied from makefont.c */
  23. static unsigned int const blocklist[] =
  24. {
  25. 0x0000, 0x0080, /* Basic latin: A, B, C, a, b, c */
  26. 0x0080, 0x0100, /* Latin-1 Supplement: Ä, Ç, å, ß */
  27. 0x0100, 0x0180, /* Latin Extended-A: Ā č Ō œ */
  28. 0x0180, 0x0250, /* Latin Extended-B: Ǝ Ƹ */
  29. 0x0250, 0x02b0, /* IPA Extensions: ɐ ɔ ɘ ʌ ʍ */
  30. 0x0370, 0x0400, /* Greek and Coptic: Λ α β */
  31. 0x0400, 0x0500, /* Cyrillic: И Я */
  32. 0x0530, 0x0590, /* Armenian: Ո */
  33. 0x1d00, 0x1d80, /* Phonetic Extensions: ᴉ ᵷ */
  34. 0x2000, 0x2070, /* General Punctuation: ‘’ “” */
  35. 0x2100, 0x2150, /* Letterlike Symbols: Ⅎ */
  36. 0x2200, 0x2300, /* Mathematical Operators: √ ∞ ∙ */
  37. 0x2300, 0x2400, /* Miscellaneous Technical: ⌐ ⌂ ⌠ ⌡ */
  38. 0x2500, 0x2580, /* Box Drawing: ═ ║ ╗ ╔ ╩ */
  39. 0x2580, 0x25a0, /* Block Elements: ▛ ▞ ░ ▒ ▓ */
  40. 0, 0
  41. };
  42. int main(int argc, char *argv[])
  43. {
  44. cucul_canvas_t *cv;
  45. cucul_buffer_t *buffer;
  46. unsigned int i, j, x, y, glyphs;
  47. for(i = 0, glyphs = 0; blocklist[i + 1]; i += 2)
  48. glyphs += blocklist[i + 1] - blocklist[i];
  49. /* Create a canvas */
  50. cv = cucul_create_canvas(WIDTH, (glyphs + WIDTH - 1) / WIDTH);
  51. cucul_set_color(cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_WHITE);
  52. /* Put all glyphs on the canvas */
  53. x = y = 0;
  54. for(i = 0; blocklist[i + 1]; i += 2)
  55. {
  56. for(j = blocklist[i]; j < blocklist[i + 1]; j++)
  57. {
  58. cucul_putchar(cv, x, y, j);
  59. if(++x == WIDTH)
  60. {
  61. x = 0;
  62. y++;
  63. }
  64. }
  65. }
  66. buffer = cucul_export_canvas(cv, "tga");
  67. fwrite(cucul_get_buffer_data(buffer),
  68. cucul_get_buffer_size(buffer), 1, stdout);
  69. cucul_free_buffer(buffer);
  70. /* Free everything */
  71. cucul_free_canvas(cv);
  72. return 0;
  73. }