calculate character spacing

This commit is contained in:
interfisch 2023-11-25 14:58:31 +01:00
parent ee5ea34ad2
commit f68c66f356
1 changed files with 10 additions and 2 deletions

View File

@ -53,17 +53,25 @@ void Image::addBuffer_text(String text,uint8_t xoffset, uint8_t yoffset)
char currentchar=text.charAt(textpos); char currentchar=text.charAt(textpos);
Serial.print("Current Char "); Serial.print((uint8_t)currentchar); Serial.print(":"); Serial.println(currentchar); Serial.print("Current Char "); Serial.print((uint8_t)currentchar); Serial.print(":"); Serial.println(currentchar);
for (uint8_t x=0;x<6;x++) { uint8_t emptycolumncounter=0; //count how many empty trailing columns for a character
for (uint8_t x=0;x<font_width;x++) {
uint16_t addBuffer; uint16_t addBuffer;
if (currentchar==' ') { //space if (currentchar==' ') { //space
addBuffer=0; //empty addBuffer=0; //empty
}else{ }else{
addBuffer=( (uint16_t)( font_minecraftia[(uint8_t)currentchar-font_offset][x] ) << yoffset); addBuffer=( (uint16_t)( font_minecraftia[(uint8_t)currentchar-font_offset][x] ) << yoffset);
if (addBuffer==0) {
emptycolumncounter++;
}else{
emptycolumncounter=0; //reset
}
} }
backBuffer[bufferxpos]|= addBuffer; backBuffer[bufferxpos]|= addBuffer;
Serial.print("Buffer at "); Serial.print(bufferxpos); Serial.print(" add ");Serial.print(addBuffer,2); Serial.print(" result="); Serial.println(backBuffer[bufferxpos],2); Serial.print("Buffer at "); Serial.print(bufferxpos); Serial.print(" add ");Serial.print(addBuffer,2); Serial.print(" result="); Serial.println(backBuffer[bufferxpos],2);
bufferxpos++; //TODO: do not increment when font column is empty
bufferxpos++;
} }
bufferxpos-= emptycolumncounter-font_spacing; //remove trailing empty columns except one
} }
Serial.println("Finished Text"); Serial.println("Finished Text");
} }