font_fnt.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * File : font_fnt.h
  3. * This file is part of RT-Thread GUI Engine
  4. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2010-04-10 Bernard first version
  23. */
  24. #ifndef __FONT_FNT_H__
  25. #define __FONT_FNT_H__
  26. #include <rtgui/font.h>
  27. #include <rtgui/dc.h>
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* fnt font header */
  32. struct fnt_header
  33. {
  34. rt_uint8_t version[4];
  35. rt_uint16_t max_width;
  36. rt_uint16_t height;
  37. rt_uint16_t ascent;
  38. rt_uint16_t depth;
  39. rt_uint32_t first_char;
  40. rt_uint32_t default_char;
  41. rt_uint32_t size;
  42. rt_uint32_t nbits;
  43. rt_uint32_t noffset;
  44. rt_uint32_t nwidth;
  45. };
  46. typedef rt_uint8_t MWIMAGEBITS;
  47. struct fnt_font
  48. {
  49. struct fnt_header header;
  50. const MWIMAGEBITS *bits; /* nbits */
  51. const rt_uint16_t *offset; /* noffset */
  52. const rt_uint8_t *width; /* nwidth */
  53. };
  54. extern const struct rtgui_font_engine fnt_font_engine;
  55. struct rtgui_font *fnt_font_create(const char* filename, const char* font_family);
  56. struct rtgui_fnt_header
  57. {
  58. rt_uint32_t p;
  59. rt_uint32_t len1;
  60. rt_uint32_t len2;
  61. rt_uint32_t asc_offset;
  62. rt_uint32_t asc_length;
  63. rt_uint8_t w;
  64. rt_uint8_t h;
  65. rt_uint16_t crc16;
  66. };
  67. struct rtgui_font *rtgui_fnt_font_create(const char* filename, const char* font_family);
  68. struct rtgui_font *rtgui_hz_fnt_font_create(const char* filename, const char* font_family, rt_uint8_t font_size);
  69. struct rtgui_font *rtgui_asc_fnt_font_create(const char* filename, const char* font_family, rt_uint8_t font_size);
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #endif