Closed wEPac closed 5 years ago
I think I know what you mean, you suggest scanning chars from the end. Maybe you could make a fix and a pull request? If not I can ask the original author of this example to improve it.
I will try the "pull request"... something new to learn for me lol
@bartoszbielawski please delete this example, it is highly inefficient. Replace with my other one.
Okay, guys, then I close this bug report, I will remove the code in the future and replace it with a better version.
Hello, I think there is a little bug in this example when detecting a char width, line 320 :
320 int c_Width = 0;
321 for(int c = 0; c < CHAR_WIDTH; c++)
322 {
323 if (font[asc][c] != 0) c_Width++;
324
325 }
Starting from the least-significant bit, we are checking each byte from a char to count those they are not empty. For a char like double quote ", this will make an error. The right way would be to start from the highest bit and to check for the 1st byte it is not empty. It should be also faster ;), we won't check every byte. Something alike that, or else:byte c_Width = CHAR_WIDTH;
while (c_Width--)
{
if (font[asc][c_Width]) break;
}
c_Width++;
So we will get the exact width and for empty char we keep width == 0