acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
Smooth_font.h (2192B)
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 4 public: 5 6 // These are for the new anti-aliased fonts 7 void loadFont(const uint8_t array[]); 8 #ifdef FONT_FS_AVAILABLE 9 void loadFont(String fontName, fs::FS &ffs); 10 #endif 11 void loadFont(String fontName, bool flash = true); 12 void unloadFont( void ); 13 bool getUnicodeIndex(uint16_t unicode, uint16_t *index); 14 15 virtual void drawGlyph(uint16_t code); 16 17 void showFont(uint32_t td); 18 19 // This is for the whole font 20 typedef struct 21 { 22 const uint8_t* gArray; //array start pointer 23 uint16_t gCount; // Total number of characters 24 uint16_t yAdvance; // Line advance 25 uint16_t spaceWidth; // Width of a space character 26 int16_t ascent; // Height of top of 'd' above baseline, other characters may be taller 27 int16_t descent; // Offset to bottom of 'p', other characters may have a larger descent 28 uint16_t maxAscent; // Maximum ascent found in font 29 uint16_t maxDescent; // Maximum descent found in font 30 } fontMetrics; 31 32 fontMetrics gFont = { nullptr, 0, 0, 0, 0, 0, 0, 0 }; 33 34 // These are for the metrics for each individual glyph (so we don't need to seek this in file and waste time) 35 uint16_t* gUnicode = NULL; //UTF-16 code, the codes are searched so do not need to be sequential 36 uint8_t* gHeight = NULL; //cheight 37 uint8_t* gWidth = NULL; //cwidth 38 uint8_t* gxAdvance = NULL; //setWidth 39 int16_t* gdY = NULL; //topExtent 40 int8_t* gdX = NULL; //leftExtent 41 uint32_t* gBitmap = NULL; //file pointer to greyscale bitmap 42 43 bool fontLoaded = false; // Flags when a anti-aliased font is loaded 44 45 #ifdef FONT_FS_AVAILABLE 46 fs::File fontFile; 47 fs::FS &fontFS = SPIFFS; 48 bool spiffs = true; 49 bool fs_font = false; // For ESP32/8266 use smooth font file or FLASH (PROGMEM) array 50 51 #else 52 bool fontFile = true; 53 #endif 54 55 private: 56 57 void loadMetrics(void); 58 uint32_t readInt32(void); 59 60 uint8_t* fontPtr = nullptr; 61