-
Notifications
You must be signed in to change notification settings - Fork 17
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
Need some way to center text on screen #18
Comments
Hi @MikeyMoMo , if you check #5 you can use the getTextWidth / height to calculate this and center the text yourself making a function where you send (x, y, text) and then you can calculate it. |
Martin, Thank you. I have used getTextWidth in the past but a lot of time, it has not been available and I forgot to try it this time. Thanks for reminding me. That is working. At least, it is returning an answer and it is trivial to center the text from here. However, I would still like how to make cdrawString work. Any example of a valid call? I cannot figure out how to code that last parameter, the Horizontal or Vertical emum value. It is probably bleedingly simple but I just can't make anything pass muster! Mike |
Hi @MikeyMoMo . For an example of centering, see this example code.
Text alignment (centered or right-aligned) is specified in the enum class Align {
Left,
Center,
Right
}; Currently only horizontal align is supported, vertical align is fixed at the top (just don't have time to implement it). However, it is almost never necessary to actually use the Align enumerator. For left-alignment, use For more information on the functions, see the API documentation. Thank you. |
Here is a much more complete answer that I finally found by just trying stuff till it fit and doing a lot of digging around. This stuff is complex. All praise to the author of this library. It was not easy to create!!
|
More detailed alignment settings are available in I am really sorry for the late update🙇♂️🙇♂️🙇♂️ |
cprintf works. There are still problems with length calculations in many places. |
You don't honor or allow setTextDatum so I am left without any way to center my string on the display. Can you tell what calls to make to enable that? When I am using bit coded text, I choose the centered Datum and it does it for me. I cannot figure out how to make cdrawString work. I can't figure out how to code the Layout item to get past the compiler. I am not even sure that will work for me since there is no specification of the size to center in. Maybe it uses the display width. Surely would like a valid example. Your samples are very basic and leave out a lot.
I am sure I am missing the obvious. Thanks for coding the library. I like having the ability to specify font size by number rather than building a whole new bitcoded font file.
The text was updated successfully, but these errors were encountered: