You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In rare cases, Text#text_box (https://www.rubydoc.info/gems/prawn/Prawn/Text#text_box-instance_method) with the overflow: :shrink_to_fit option causes part of the text to be cropped out. This is unexpected because if the text doesn't fix the box, it should be shrunk until it does, not cropped.
This occurs specifically when the width of the box is just big enough to fit the text and two float precisions errors occur. Say, for example, we want to put "Two words" in a text box of width 50.0. First, when shrink_to_fit runs to determine the font size, the width of "Two words" is computed as 49.999999.shrink_to_fit says, cool, this will fit, no need to reduce the font size or wrap the line. Then the line is actually printed and this time the width is computed as 50.00000001. This causes the line to be split and "words" is put on the second line, but if there isn't enough height, it will be cropped.
I have a commit with a spec that manually introduces these precision errors and has a failing spec here: unterkoefler@aca0044
Happy to put up a pr to fix :)
The text was updated successfully, but these errors were encountered:
In rare cases,
Text#text_box
(https://www.rubydoc.info/gems/prawn/Prawn/Text#text_box-instance_method) with theoverflow: :shrink_to_fit
option causes part of the text to be cropped out. This is unexpected because if the text doesn't fix the box, it should be shrunk until it does, not cropped.This occurs specifically when the width of the box is just big enough to fit the text and two float precisions errors occur. Say, for example, we want to put
"Two words"
in a text box of width 50.0. First, whenshrink_to_fit
runs to determine the font size, the width of "Two words" is computed as 49.999999.shrink_to_fit
says, cool, this will fit, no need to reduce the font size or wrap the line. Then the line is actually printed and this time the width is computed as 50.00000001. This causes the line to be split and "words" is put on the second line, but if there isn't enough height, it will be cropped.I have a commit with a spec that manually introduces these precision errors and has a failing spec here: unterkoefler@aca0044
Happy to put up a pr to fix :)
The text was updated successfully, but these errors were encountered: