您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

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