gds_font.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _GDS_FONT_H_
  2. #define _GDS_FONT_H_
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. struct GDS_Device;
  9. /*
  10. * X-GLCD Font format:
  11. *
  12. * First byte of glyph is it's width in pixels.
  13. * Each data byte represents 8 pixels going down from top to bottom.
  14. *
  15. * Example glyph layout for a 16x16 font
  16. * 'a': [Glyph width][Pixel column 0][Pixel column 1] where the number of pixel columns is the font height divided by 8
  17. * 'b': [Glyph width][Pixel column 0][Pixel column 1]...
  18. * 'c': And so on...
  19. */
  20. struct GDS_FontDef {
  21. const uint8_t* FontData;
  22. int Width;
  23. int Height;
  24. int StartChar;
  25. int EndChar;
  26. bool Monospace;
  27. };
  28. typedef enum {
  29. TextAnchor_East = 0,
  30. TextAnchor_West,
  31. TextAnchor_North,
  32. TextAnchor_South,
  33. TextAnchor_NorthEast,
  34. TextAnchor_NorthWest,
  35. TextAnchor_SouthEast,
  36. TextAnchor_SouthWest,
  37. TextAnchor_Center
  38. } TextAnchor;
  39. bool GDS_SetFont( struct GDS_Device* Display, const struct GDS_FontDef* Font );
  40. void GDS_FontForceProportional( struct GDS_Device* Display, bool Force );
  41. void GDS_FontForceMonospace( struct GDS_Device* Display, bool Force );
  42. int GDS_FontGetWidth( struct GDS_Device* Display );
  43. int GDS_FontGetHeight( struct GDS_Device* Display );
  44. int GDS_FontGetMaxCharsPerRow( struct GDS_Device* Display );
  45. int GDS_FontGetMaxCharsPerColumn( struct GDS_Device* Display );
  46. int GDS_FontGetCharWidth( struct GDS_Device* Display, char Character );
  47. int GDS_FontGetCharHeight( struct GDS_Device* Display );
  48. int GDS_FontMeasureString( struct GDS_Device* Display, const char* Text );\
  49. void GDS_FontDrawChar( struct GDS_Device* Display, char Character, int x, int y, int Color );
  50. void GDS_FontDrawString( struct GDS_Device* Display, int x, int y, const char* Text, int Color );
  51. void GDS_FontDrawAnchoredString( struct GDS_Device* Display, TextAnchor Anchor, const char* Text, int Color );
  52. void GDS_FontGetAnchoredStringCoords( struct GDS_Device* Display, int* OutX, int* OutY, TextAnchor Anchor, const char* Text );
  53. extern const struct GDS_FontDef Font_droid_sans_fallback_11x13;
  54. extern const struct GDS_FontDef Font_droid_sans_fallback_15x17;
  55. extern const struct GDS_FontDef Font_droid_sans_fallback_24x28;
  56. extern const struct GDS_FontDef Font_droid_sans_mono_7x13;
  57. extern const struct GDS_FontDef Font_droid_sans_mono_13x24;
  58. extern const struct GDS_FontDef Font_droid_sans_mono_16x31;
  59. extern const struct GDS_FontDef Font_liberation_mono_9x15;
  60. extern const struct GDS_FontDef Font_liberation_mono_13x21;
  61. extern const struct GDS_FontDef Font_liberation_mono_17x30;
  62. extern const struct GDS_FontDef Font_Tarable7Seg_16x32;
  63. extern const struct GDS_FontDef Font_Tarable7Seg_32x64;
  64. extern const struct GDS_FontDef Font_line_1;
  65. extern const struct GDS_FontDef Font_line_2;
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69. #endif