Skip to content

Conversation

@belono
Copy link
Contributor

@belono belono commented Aug 4, 2025

Description

  • Add justify to text alignment and expose to software_columns() .
  • Extend software_columns() to also support single-column text.
  • Include tests.

Fixes #689

Tested with

If applicable, please describe with which device you have tested.

@codecov
Copy link

codecov bot commented Aug 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.50%. Comparing base (b85d5b9) to head (e453f36).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #690      +/-   ##
==========================================
+ Coverage   81.29%   81.50%   +0.20%     
==========================================
  Files          21       21              
  Lines        1679     1692      +13     
  Branches      262      266       +4     
==========================================
+ Hits         1365     1379      +14     
  Misses        234      234              
+ Partials       80       79       -1     
Flag Coverage Δ
unittests 81.32% <100.00%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/escpos/escpos.py 75.40% <100.00%> (+0.86%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@belono
Copy link
Contributor Author

belono commented Aug 7, 2025

My initial idea was to expose the _justify() function to at least the software_columns() and block_text() methods, but after a second look at those methods, I think it's better to keep block_text() as-is to avoid breaking the API.
Instead, I'm going to extend software_columns() to also support single-column text (single-item list), since it currently doesn't.

This way, users will have two possible ways to print a block of text:

  • Backwards compatible block_text("Text string", font="A", width=None), which will align the text as usual, according to the printer defaults or by the set(align="") method that do not support justify.
  • software_columns(["Single item"], width=[column_width], align="center|left|right|justify") which will align the text according to the align parameter (supports justify) and can also benefit from truncation and placeholders for words that are too long.

@belono belono changed the title Add justify to text alignment Fixes #689 Add justify to text alignment of software_columns() Fixes #689 Aug 7, 2025
@belono belono marked this pull request as ready for review August 7, 2025 22:20
@belono
Copy link
Contributor Author

belono commented Aug 7, 2025

CI pipeline is green.

I think this is ready for review @patkan.

@belono belono requested a review from patkan August 7, 2025 22:24
@patkan patkan merged commit ebd6f88 into python-escpos:master Aug 10, 2025
13 checks passed
@belono belono deleted the belono/issue689 branch August 11, 2025 15: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.

Add a justify method for text justification

2 participants