I'm using the Adafruit_ST7735 (with the Adafruit_GFX) library to display stuff on my 1.8 TFT display. When I set the tft.setTextWrap(false); it does wrap the text but it doesn't care about words. For example, it wraps it like this:
I like to play baske
tball and I really lik
e to play compute
r games
And I need to make it look like this:
I like to play bask-
etball and I really
like to play comp-
uter games
Short words put on the next line but longer words split into two lines connected with a - would allow me to display much more text than putting each word on a new line. My main struggle with this is that the characters are coming one by one in an SD manner like this:
File myFile = SD.open(file_name);
if (myFile) {
while (myFile.available() > myFile.size() - 300) {
tft.write(myFile.read());
}
myFile.close();
} else {
tft.print("Error opening file.");
}
How would I go about writing such a word processor for the incoming characters so short words (i.e containing less or equal to 5 characters) get transferred on the next line and longer words (i.e containing more than 5 characters) get cut with a - and one part is on one line and the other is on the next line (like the last example)?