6 #ifndef TC_UNICODE_FONTHELPER_H
7 #define TC_UNICODE_FONTHELPER_H
14 #define TCUNICODE_API_VERSION 2
16 #if !defined(pgm_read_dword) && (defined(__MBED__) || defined(BUILD_FOR_PICO_CMAKE))
17 #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
18 #define pgm_read_word(addr) (*(const unsigned short *)(addr))
19 #define pgm_read_dword(addr) (*(const unsigned long *)(addr))
20 #define pgm_read_float(addr) (*(const float *)(addr))
21 #define pgm_read_ptr(addr) (*(addr))
22 #define memcpy_P memcpy
30 #if __has_include ("zio_local_definitions.h")
31 # include "zio_local_definitions.h"
34 #ifndef TC_COORD_DEFINED
35 #define TC_COORD_DEFINED
57 Coord& operator = (
const Coord& other) =
default;
66 using namespace tcgfx;
83 virtual void drawPixel(uint16_t x, uint16_t y, uint32_t color) = 0;
99 #define TC_UNICODE_CHAR_ERROR 0xffffffff
107 const uint8_t *bitmapData =
nullptr;
124 void setBitmapData(
const uint8_t *bm) {
125 GlyphWithBitmap::bitmapData = bm;
129 GlyphWithBitmap::glyph = g;
133 void handleUtf8Drawing(
void *userData, uint32_t ch);
135 #if __has_include (<Print.h>) || defined(ARDUINO_SAM_DUE)
137 class UnicodeFontHandler :
public Print {
138 #elif __has_include(<PrintCompat.h>)
139 #include <PrintCompat.h>
140 class UnicodeFontHandler :
public Print {
142 class UnicodeFontHandler {
147 HANDLER_SIZING_TEXT, HANDLER_DRAWING_TEXT
156 bool fontAdafruit =
false;
157 HandlerMode handlerMode = HANDLER_DRAWING_TEXT;
158 uint16_t xExtentCurrent = 0;
159 int16_t calculatedBaseline = -1;
160 uint32_t drawColor = 0;
174 unicodeFont(nullptr) {}
175 virtual ~UnicodeFontHandler() =
default;
188 void setTextPlotPipeline(
TextPlotPipeline *newPipeline) { plotter = newPipeline; }
196 fontAdafruit =
false;
197 calculatedBaseline = -1;
204 void setFont(
const GFXfont *font) {
207 calculatedBaseline = -1;
216 void setCursor(int16_t x, int16_t y) { plotter->
setCursor(
Coord(x, y)); }
229 void setDrawColor(uint32_t color) { this->drawColor = color; }
235 void writeUnicode(uint32_t unicodeText);
245 Coord textExtents(
const char *text,
int *baseline,
bool progMem =
false);
253 Coord textExtents_P(
const char *text,
int *baseline) {
return textExtents(text, baseline,
true); }
255 #if !defined(__MBED__) && !defined(BUILD_FOR_PICO_CMAKE)
263 Coord textExtents(
const __FlashStringHelper *fh,
int *baseline) {
264 return textExtents((
const char *) fh, baseline,
true);
274 Coord textExtent(uint32_t theChar);
281 size_t print_P(
const char *textPgm);
296 size_t write(uint8_t data)
override;
310 int getYAdvance()
const {
311 if(adaFont ==
nullptr)
return 0;
312 return pgm_read_byte((fontAdafruit ? &adaFont->yAdvance : &unicodeFont->yAdvance));
319 void internalHandleUnicodeFont(uint32_t ch);
322 using namespace tccore;
contains font rendering structures both for AdafruitGFX fonts and TcUnicode fonts
Definition: UnicodeFontDefs.h:54
Definition: UnicodeFontDefs.h:120
Definition: UnicodeFontDefs.h:82
contains a strict asynchronous UTF-8 decoder that uses very little memory.
UnicodeEncodingMode
Definition: Utf8TextProcessor.h:25
Definition: tcUnicodeHelper.h:105
const uint8_t * getBitmapData() const
Definition: tcUnicodeHelper.h:113
const UnicodeFontGlyph * getGlyph() const
Definition: tcUnicodeHelper.h:120
Definition: tcUnicodeHelper.h:74
virtual Coord getDimensions()=0
virtual void setCursor(const Coord &where)=0
virtual Coord getCursor()=0
virtual void drawPixel(uint16_t x, uint16_t y, uint32_t color)=0
Definition: Utf8TextProcessor.h:37
Definition: tcUnicodeHelper.h:40
Coord()
Definition: tcUnicodeHelper.h:42
Coord(int x, int y)
Definition: tcUnicodeHelper.h:51