node-escpos / driver

🖨️ ESC/POS Printer driver for Node.js.
Other
309 stars 30 forks source link

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

Open jacksonstone-fs opened 2 weeks ago

jacksonstone-fs commented 2 weeks ago

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.

changeset-bot[bot] commented 2 weeks ago

🦋 Changeset detected

Latest commit: 9a3e957ff9bffc22797eec75d6ad97a9cc61b435

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