/tools/fontextract/fontdata.h

http://ftk.googlecode.com/ · C Header · 91 lines · 48 code · 14 blank · 29 comment · 0 complexity · ff92fc292f3d758b57ecae163ea54fac MD5 · raw file

  1. /*
  2. * File: fontdata.h
  3. * Author: Li XianJing <xianjimli@hotmail.com>
  4. * Brief: functions to operate font data.
  5. *
  6. * Copyright (c) 2009 - 2010 Li XianJing <xianjimli@hotmail.com>
  7. *
  8. * Licensed under the Academic Free License version 2.1
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. /*
  25. * History:
  26. * ================================================================
  27. * 2009-09-11 Li XianJing <xianjimli@hotmail.com> created
  28. *
  29. */
  30. #ifdef WITHOUT_FTK
  31. #include "typedef.h"
  32. #define FTK_BEGIN_DECLS
  33. #define FTK_END_DECLS
  34. #else
  35. #include "ftk_typedef.h"
  36. #endif
  37. #ifndef FONT_DATA_H
  38. #define FONT_DATA_H
  39. FTK_BEGIN_DECLS
  40. typedef enum _Encoding
  41. {
  42. ENC_UTF16 = 0,
  43. ENC_ANSI = 1
  44. }Encoding;
  45. typedef struct _Glyph
  46. {
  47. signed char x;
  48. signed char y;
  49. unsigned char w;
  50. unsigned char h;
  51. unsigned short code;
  52. unsigned short unused;
  53. unsigned char* data;
  54. }Glyph;
  55. struct _FontData;
  56. typedef struct _FontData FontData;
  57. FontData* font_data_create(int char_nr, Encoding encoding);
  58. FontData* font_data_load(char* data, size_t length);
  59. FontData* font_data_load_file(const char* file_name);
  60. Ret font_data_add_glyph(FontData* thiz, Glyph* glyph);
  61. Ret font_data_get_glyph(FontData* thiz, unsigned short code, Glyph* glyph);
  62. int font_data_get_version(FontData* thiz);
  63. int font_data_get_width(FontData* thiz);
  64. int font_data_get_height(FontData* thiz);
  65. const char* font_data_get_author(FontData* thiz);
  66. const char* font_data_get_family(FontData* thiz);
  67. const char* font_data_get_style(FontData* thiz);
  68. void font_data_set_size(FontData* thiz, int width, int height);
  69. void font_data_set_author(FontData* thiz, const char* author);
  70. void font_data_set_family(FontData* thiz, const char* family);
  71. void font_data_set_style(FontData* thiz, const char* style);
  72. #ifdef HAS_FONT_DATA_SAVE
  73. Ret font_data_save(FontData* thiz, const char* filename);
  74. #endif
  75. void font_data_destroy(FontData* thiz);
  76. FTK_END_DECLS
  77. #endif/*FONT_DATA_H*/