-
Notifications
You must be signed in to change notification settings - Fork 83
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
Text incorrectly wraps with custom font... #130
Comments
Thanks, this is a good find! As you say it's not actually taking into account the font geometry. @tvoverbeek do you know if there is a way to allow it to be aware of the size of the font? |
This is pretty much the last thing standing in the way of my app working perfectly. |
Look at the PIL ImageFont documentation.
I believe the function you need is ImageFont.ImageFont.getsize(text) which
returns (width, height).
…On 2 July 2017 at 13:29, eat-sleep-code ***@***.***> wrote:
This is pretty much the last thing standing in the way of my app working
perfectly.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#130 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABJE7kOSayutkKrA-Gr9v-nNNneqYctkks5sJw6fgaJpZM4N8uD1>
.
|
@tvoverbeak So that would get me height and width of my text? But what would I do with the height and width? |
Look at the code in textpos.py (https://github.com/PiSupply/PaPiRus/blob/master/papirus/textpos.py). |
I will let you tackle it when you get back. My Python skills are elementary, so would prefer if a pro did it. Have a good holiday. |
@tvoverbeek Had any chance to review this yet? |
@eat-sleep-code Back home now. Plan to start on it next week.
…On Thu, Jul 20, 2017 at 9:49 PM, eat-sleep-code ***@***.***> wrote:
@tvoverbeek <https://github.com/tvoverbeek> Had any chance to review this
yet?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#130 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABJE7hyGH3F8rOjEQeSkpzHpBdJg7vEoks5sP69IgaJpZM4N8uD1>
.
|
See my PR #142. Should solve your problem. |
@tvoverbeek see my comment on the PR about an extraneous preceding space. |
Also might be nice to have option to limit text to X lines (and truncate any remaining data). |
See reply on the PR.
Regarding limiting the text, the code already limits the text to what fits
on the screen.
Any text going (vertically) off screen is discarded.
…On Tue, Jul 25, 2017 at 6:32 AM, eat-sleep-code ***@***.***> wrote:
Also might be nice to have option to limit text to *X* lines (and
truncate any remain data).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#130 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABJE7iCjCKa_oQiOaSfvUkgF78NMJrj5ks5sRW_cgaJpZM4N8uD1>
.
|
See pull request for text limiting. In the case of my MLB app, sometimes a play description provided by MLB was too long and was colliding with the ball and base display below it. By adding a maxLines feature, I can limit it to 3 lines and prevent the collision. I also resolved the preceding space issue that was causing subsequent lines to be slightly updated. |
PR #144 has been merged. Closing issue. |
display.AddText(text = 'Awaiting player roster', x = 5, y = 5, size = 14, Id = 'Status')
results in text wrapping because there is not quite enough room to fit the text with the default font.display.AddText(text = 'Awaiting player roster', x = 5, y = 5, size = 14, Id = 'Status', font_path = '/font/benton-sans-regular.ttf')
results in text wrapping, even though the font face should provide plenty of room for the text.It appears that font geometry is not being properly accounted for.
The text was updated successfully, but these errors were encountered: