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

Limit <line> to the text box width #363

Merged
merged 2 commits into from
Feb 6, 2022

Conversation

bszonye
Copy link
Contributor

@bszonye bszonye commented Jan 26, 2022

The <line> substitution expands to a string of 22 en dash characters, which is 11 ems wide. Any text box narrower than that will cause the <line> to break and overflow onto a second line. The BodyText font is 10 points, so the overflow happens with any text box narrower than 110 points (about 3.88 cm). Accounting for margins, that means that <line> breaks on cards narrower than about 5 cm wide.

This PR adds an emWidth parameter to the add_inline_text function to indicate the available horizontal space in ems. The function then limits the replacement to the number of em dashes that will fit. (The function previously measured in en dashes, which are exactly half the width of an em dash. Changing to em dashes eliminates an extra conversion step.)

Fixes #360.

@sumpfork sumpfork self-assigned this Jan 26, 2022
@sumpfork sumpfork self-requested a review January 26, 2022 20:01
@sumpfork sumpfork removed their assignment Jan 26, 2022
Copy link
Owner

@sumpfork sumpfork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work as advertised, thanks!

@sumpfork sumpfork merged commit 9e0a174 into sumpfork:master Feb 6, 2022
@bszonye bszonye deleted the bradd/line-limit branch February 6, 2022 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<line> overflows narrow card widths
2 participants