Skip to content

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