25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
2.1 KiB

  1. // Coded by Bodmer 10/2/18, see license in root directory.
  2. // This is part of the TFT_eSPI class and is associated with anti-aliased font functions
  3. public:
  4. // These are for the new antialiased fonts
  5. void loadFont(const uint8_t array[]);
  6. #ifdef FONT_FS_AVAILABLE
  7. void loadFont(String fontName, fs::FS &ffs);
  8. #endif
  9. void loadFont(String fontName, bool flash = true);
  10. void unloadFont( void );
  11. bool getUnicodeIndex(uint16_t unicode, uint16_t *index);
  12. virtual void drawGlyph(uint16_t code);
  13. void showFont(uint32_t td);
  14. // This is for the whole font
  15. typedef struct
  16. {
  17. const uint8_t* gArray; //array start pointer
  18. uint16_t gCount; // Total number of characters
  19. uint16_t yAdvance; // Line advance
  20. uint16_t spaceWidth; // Width of a space character
  21. int16_t ascent; // Height of top of 'd' above baseline, other characters may be taller
  22. int16_t descent; // Offset to bottom of 'p', other characters may have a larger descent
  23. uint16_t maxAscent; // Maximum ascent found in font
  24. uint16_t maxDescent; // Maximum descent found in font
  25. } fontMetrics;
  26. fontMetrics gFont = { nullptr, 0, 0, 0, 0, 0, 0, 0 };
  27. // These are for the metrics for each individual glyph (so we don't need to seek this in file and waste time)
  28. uint16_t* gUnicode = NULL; //UTF-16 code, the codes are searched so do not need to be sequential
  29. uint8_t* gHeight = NULL; //cheight
  30. uint8_t* gWidth = NULL; //cwidth
  31. uint8_t* gxAdvance = NULL; //setWidth
  32. int16_t* gdY = NULL; //topExtent
  33. int8_t* gdX = NULL; //leftExtent
  34. uint32_t* gBitmap = NULL; //file pointer to greyscale bitmap
  35. bool fontLoaded = false; // Flags when a anti-aliased font is loaded
  36. #ifdef FONT_FS_AVAILABLE
  37. fs::File fontFile;
  38. fs::FS &fontFS = SPIFFS;
  39. bool spiffs = true;
  40. bool fs_font = false; // For ESP32/8266 use smooth font file or FLASH (PROGMEM) array
  41. #else
  42. bool fontFile = true;
  43. #endif
  44. private:
  45. void loadMetrics(void);
  46. uint32_t readInt32(void);
  47. uint8_t* fontPtr = nullptr;