Skip to content

fix: avoid orphaning a final wrapped character - #239

Merged
tannewt merged 1 commit into
adafruit:mainfrom
giri256:fix/avoid-orphaned-final-character
Jul 27, 2026
Merged

fix: avoid orphaning a final wrapped character#239
tannewt merged 1 commit into
adafruit:mainfrom
giri256:fix/avoid-orphaned-final-character

Conversation

@giri256

@giri256 giri256 commented Jul 27, 2026

Copy link
Copy Markdown

Fixes #226

When splitting an overlong word, wrap_text_to_pixels() always reserved space for a continuation hyphen before testing the next character. On the final character, that could force a character that otherwise fit onto a new line and leave the previous line ending in an unnecessary hyphen.

This reserves hyphen width only when characters remain after the one being tested. True continuations still keep their hyphen, while the final character can use the available line width.

Regression example at width 4:

  • before: ['abc-', 'def-', 'g']
  • after: ['abc-', 'defg']

Verification:

  • boundary regression matrix covering exact fit, normal continuation, and the orphaned-final-character case
  • python -m compileall -q adafruit_display_text
  • ruff format --check adafruit_display_text/__init__.py
  • ruff check adafruit_display_text/__init__.py
  • clean sdist and wheel build

Signed-off-by: p1 <giridharpavan593@gmail.com>

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@tannewt
tannewt merged commit 6761a7f into adafruit:main Jul 27, 2026
1 check passed
adafruit-adabot pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 29, 2026
Updating https://github.com/adafruit/Adafruit_CircuitPython_GPS to 3.11.9 from 3.11.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_GPS#127 from grgrant/Fix123
  > Merge pull request adafruit/Adafruit_CircuitPython_GPS#126 from grgrant/issue124

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 5.0.5 from 5.0.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#239 from giri256/fix/avoid-orphaned-final-character

Updating https://github.com/adafruit/Adafruit_CircuitPython_Motor to 3.5.0 from 3.4.20:
  > Merge pull request adafruit/Adafruit_CircuitPython_Motor#79 from giri256/fix/continuous-servo-disable

Updating https://github.com/adafruit/Adafruit_CircuitPython_Register to 1.12.1 from 1.12.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Register#61 from giri256/docs/alarm-date-limits
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.

TextBox text length hyphen issue

2 participants