gds_font.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. const struct GDS_FontDef* 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. int GDS_FontMeasureStringLine( struct GDS_Device* Display, int Line, const char* Text );
  50. void GDS_FontDrawChar( struct GDS_Device* Display, char Character, int x, int y, int Color );
  51. void GDS_FontDrawString( struct GDS_Device* Display, int x, int y, const char* Text, int Color );
  52. void GDS_FontDrawAnchoredString( struct GDS_Device* Display, TextAnchor Anchor, const char* Text, int Color );
  53. void GDS_FontGetAnchoredStringCoords( struct GDS_Device* Display, int* OutX, int* OutY, TextAnchor Anchor, const char* Text );
  54. extern const struct GDS_FontDef Font_droid_sans_fallback_11x13;
  55. extern const struct GDS_FontDef Font_droid_sans_fallback_15x17;
  56. extern const struct GDS_FontDef Font_droid_sans_fallback_24x28;
  57. extern const struct GDS_FontDef Font_droid_sans_mono_7x13;
  58. extern const struct GDS_FontDef Font_droid_sans_mono_13x24;
  59. extern const struct GDS_FontDef Font_droid_sans_mono_16x31;
  60. extern const struct GDS_FontDef Font_liberation_mono_9x15;
  61. extern const struct GDS_FontDef Font_liberation_mono_13x21;
  62. extern const struct GDS_FontDef Font_liberation_mono_17x30;
  63. extern const struct GDS_FontDef Font_Tarable7Seg_16x32;
  64. extern const struct GDS_FontDef Font_Tarable7Seg_32x64;
  65. extern const struct GDS_FontDef Font_line_1;
  66. extern const struct GDS_FontDef Font_line_2;
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif