calculate character spacing
This commit is contained in:
parent
ee5ea34ad2
commit
f68c66f356
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue