-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getTextBounds missing #6
Comments
The "Free Fonts" can be rendered with background (unlike the stock Adafruit_GFX library) so I did not see a need for a getTextBounds function. See the "TFT_Custom_Fonts" or "Free_Font_Demo" examples. When a "Free Font" is selected the library scans all characters in the set to determine the maximum y coordinate limits, so the background box always has the same height irrespective of what characters are drawn. This makes life easier as you don't need to do the messy box and erase coding yourself. You can also add width padding to the background, so old text gets erased when over-writing. This is particularly useful for numbers that change as the erased box width can be fixed to be larger that the maximum digit count. A getTextBounds function is clearly possible but would need to take into account the feature of the library to set the text coordinate datum (see "Free_Font_Demo" example). |
Hi
I am not a font expert :D, but there could be fonts that don't have this
background ? I mean, the default font that I was using did not.
And, I like such fonts too. When I make custom buttons or any UI element
that is drawn using a BMP and then needs text on top of it, fonts with
background cannot be used. :)
…On 13-Apr-2017 4:24 AM, "Bodmer" ***@***.***> wrote:
The "Free Fonts" can be rendered with background (unlike the stock
Adafruit_GFX library) so I did not see a need for a getTextBounds function.
See the "TFT_Custom_Fonts" or "Free_Font_Demo" examples.
When a "Free Font" is selected the library scans all characters in the set
to determine the maximum y coordinate limits, so the background box always
has the same height irrespective of what characters are drawn. This makes
life easier as you don't need to do the messy box and erase coding yourself.
You can also add width padding to the background, so old text gets erased
when over-writing. This is particularly useful for numbers that change as
the erased box width can be fixed to be larger that the maximum digit count.
A getTextBounds function is clearly possible but would need to take into
account the feature of the library to set the text coordinate datum (see
"Free_Font_Demo" example).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AY1oK2qo7Pf2b47hR3D4iEUlKL7TgMV3ks5rvVYlgaJpZM4M39Da>
.
|
The sketch decides if the font is drawn with background or not, e.g.: tft.setTextColor(TFT_WHITE, TFT_BLACK); // White characters with black background tft.setTextColor(TFT_WHITE); // White characters no (transparent) background The text can then be drawn using the drawString() function If the print() method is used then background is not rendered for the FreeFonts for technical reasons (due to streaming of characters) P.S. For centering text within a button frame use the setTextDatum(MC_DATUM) function and plot text at center coord of button (makes life easy!) |
Ok. :)
…On Apr 14, 2017 6:46 AM, "Bodmer" ***@***.***> wrote:
The sketch decides if he font is drawn with background or not, e.g.:
tft.setTextColor(TFT_WHITE, TFT_BLACK); // White characters with black
background
tft.setTextColor(TFT_WHITE); // White characters no (transparent)
background
The text can then be drawn using the drawString() function
If the print() method is used then background is not rendered for the
FreeFonts for technical reasons (due to streaming of characters)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AY1oK5PU8I6M5utQyPk37Zp1mTswUr0Aks5rvsjSgaJpZM4M39Da>
.
|
@stanzlavos I don't knwo whether this is still in any way relevant to you now but here's my quick and improvised solution (I essentially copied the code from the Adafruit GFX library and changed a few things so that now errors occurred during compilation). Paste this code into your sketch:
|
Hi
First of all, thanks for this fast lib. :)
Any plans to add "getTextBounds" API ? If not, I could try to add something and raise a pull request ?
The text was updated successfully, but these errors were encountered: