Skip to content

Not an issue but you don't have a Discussion tab. How to outline text with OFR. Google comes up empty. #53

@MikeyMoMo

Description

@MikeyMoMo

I am using a TTGO T-Display S3 and the following code adds 200ms to write the 8 times it takes to get the border fully filled in. Then the original printf to put in the different color actual text inside the outline. Looks good. Change the 2s to 3s or 1s for more or less border. A little expensive in time but only 25ms per printf. I have a full second to do this task (it's a clock) and the whole update including the loading a jpg into a sprite and then adding the text fields is costing me 366ms. Still plenty of time left for the 1 second update. I originally had orthogonal movement but it turns out to not be needed. Just doing the diagonals is enough. That saved about 100ms.

// Add a bright red border. The black will become invisible and the
// background will show through the characters.
// This has to be done 4 ways to get full outline coverage.

int x = 2, y = 2;  // 2 to leave room for the outline
 ofr.setFontColor(RGB565(255, 50, 25), TFT_BLACK);

 ofr.setCursor(x - 2, y - 2);
 ofr.printf(chBuffer);
 ofr.setCursor(x + 2, y + 2);
 ofr.printf(chBuffer);
 ofr.setCursor(x + 2, y - 2);
 ofr.printf(chBuffer);
 ofr.setCursor(x + 2, y + 2);
 ofr.printf(chBuffer);

 ofr.setFontColor(pInfo[BGPic].tColor, TFT_BLACK);
 ofr.setCursor(x, y);
 ofr.printf(chBuffer);  // Finally the real text.

 // Add to background picture with the invisible color of black.
 spriteTime.pushToSprite(&spriteBG, 20, 38, TFT_BLACK);

You can close this and then, please add it to the Readme. I think others might want to know about this little trick. It does not seem to be well known. Outlining line this does not come up in Google as far as I can see.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions