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

fix: spacing for right and center aligned text in tableCustom #99

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jacksonstone-fs
Copy link

@jacksonstone-fs jacksonstone-fs commented Oct 9, 2024

fix #62

This PR aims to fix misalignment in certain circumstances when using center and right aligned text. Because the floor of the number of spaces the column had available wasn't taken for right and center as it was for left, these columns had a tendency to overflow and cause extra newlines.

This is fixed by taking the floor of cellWidth - textLength for right aligned text, and handling fractional components by taking the ceiling for the left side and floor for the right side for center aligned text. This keeps the previous convention of preferring extra space on the left instead of right for center aligned text.

An example of bad parameters that would cause issues before this PR for testing purposes is cellWidth = 4.2 and textLength = 2.

Copy link

changeset-bot bot commented Oct 9, 2024

🦋 Changeset detected

Latest commit: 9a3e957

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@node-escpos/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table items are not aligned
1 participant