Skip to content
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

Improve min_width calculation using longest word #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ashtonthomas
Copy link

@ashtonthomas ashtonthomas commented Dec 20, 2017

I am having the same issue as #67

This pull request is an alternative to #68 (just go ahead and use min width of longest word as @ericfreese suggests)

Instead of using the styled length of 'M', use the styled width of the longest word in order to calculate the min_width of a Cell's Text.

This will prevent words from being split in the middle.

There may be an issue with this if the total of the min_widths add up to more than the available width. We should look into the tests around that to see if something will error or if this is being accounted for already.

Instead of using the styled length of 'M', use the styled width of the longest word in order to calculate the min_width of a Cell's Text.

This will prevent words from being split in the middle.

There may be an issue with this if the total of the min_widths add up to more than the available width. We should look into the tests around that to see if something will error or if this is being accounted for already.
@ashtonthomas
Copy link
Author

A CannotFit exception will be thrown if the sum of all min_width is more width than the table has.

Prawn::Errors::CannotFit: Table's width was set too small to contain its contents

We might want to go with @ericfreese's suggestion of using a :word_wrap option can be set. If this option is set (to something like :normal vs :break_word - CSS Reference) then perhaps we can let the CannotFit error be raised. Otherwise if the :word_wrap is not set, we use the original styled_width_of_single_character method.

Just a thought..

@akostadinov akostadinov mentioned this pull request Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant