ssd13x6_font.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _SSD13x6_FONT_H_
  2. #define _SSD13x6_FONT_H_
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. struct SSD13x6_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 SSD13x6_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 SSD13x6_SetFont( struct SSD13x6_Device* Display, const struct SSD13x6_FontDef* Font );
  40. void SSD13x6_FontForceProportional( struct SSD13x6_Device* Display, bool Force );
  41. void SSD13x6_FontForceMonospace( struct SSD13x6_Device* Display, bool Force );
  42. int SSD13x6_FontGetWidth( struct SSD13x6_Device* Display );
  43. int SSD13x6_FontGetHeight( struct SSD13x6_Device* Display );
  44. int SSD13x6_FontGetMaxCharsPerRow( struct SSD13x6_Device* Display );
  45. int SSD13x6_FontGetMaxCharsPerColumn( struct SSD13x6_Device* Display );
  46. int SSD13x6_FontGetCharWidth( struct SSD13x6_Device* Display, char Character );
  47. int SSD13x6_FontGetCharHeight( struct SSD13x6_Device* Display );
  48. int SSD13x6_FontMeasureString( struct SSD13x6_Device* Display, const char* Text );\
  49. void SSD13x6_FontDrawChar( struct SSD13x6_Device* Display, char Character, int x, int y, int Color );
  50. void SSD13x6_FontDrawString( struct SSD13x6_Device* Display, int x, int y, const char* Text, int Color );
  51. void SSD13x6_FontDrawAnchoredString( struct SSD13x6_Device* Display, TextAnchor Anchor, const char* Text, int Color );
  52. void SSD13x6_FontGetAnchoredStringCoords( struct SSD13x6_Device* Display, int* OutX, int* OutY, TextAnchor Anchor, const char* Text );
  53. extern const struct SSD13x6_FontDef Font_droid_sans_fallback_11x13;
  54. extern const struct SSD13x6_FontDef Font_droid_sans_fallback_15x17;
  55. extern const struct SSD13x6_FontDef Font_droid_sans_fallback_24x28;
  56. extern const struct SSD13x6_FontDef Font_droid_sans_mono_7x13;
  57. extern const struct SSD13x6_FontDef Font_droid_sans_mono_13x24;
  58. extern const struct SSD13x6_FontDef Font_droid_sans_mono_16x31;
  59. extern const struct SSD13x6_FontDef Font_liberation_mono_9x15;
  60. extern const struct SSD13x6_FontDef Font_liberation_mono_13x21;
  61. extern const struct SSD13x6_FontDef Font_liberation_mono_17x30;
  62. extern const struct SSD13x6_FontDef Font_Tarable7Seg_16x32;
  63. extern const struct SSD13x6_FontDef Font_Tarable7Seg_32x64;
  64. extern const struct SSD13x6_FontDef Font_line_1;
  65. extern const struct SSD13x6_FontDef Font_line_2;
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69. #endif