You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

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