Skip to content

Spaces are deleted when word-wrapping #162

Closed
@kmatch98

Description

@kmatch98

I noticed that some spaces are being deleted when word-wrapping text using the wrap_text_to_pixels function in the adafruit_display_text library. Library is pulled from bundle adafruit-circuitpython-bundle-7.x-mpy-20220131.

I use a long string with long words and a narrow pixel width, and it causes some spaces to be deleted , such as in:

  • simplifyexp - "simplify experimenting"
  • low-costmic - "low-cost microcontroller boards"

Here's the output I'm getting:

code.py output:
width: 75
text_lines: ['CircuitPyth-', 'on is a', 'programming', 'language', 'designed to', 'simplifyexp-', 'erimenting', 
'and learning', 'to code on', 'low-costmic-', 'rocontrolle-', 'r boards.', '', 'WithCircuit-', 'Python,', 'there are no', 
'upfront', 'desktop', 'downloads', 'needed. Once', 'you get your', 'board set', 'up, open any', 'text editor,', 
'and start', 'editing', "code. It's", 'that simple.']

Here's my code:

import terminalio
from adafruit_display_text import bitmap_label, wrap_text_to_pixels

text_string = "CircuitPython is a programming language designed to simplify experimenting and learning to code on low-cost microcontroller boards."
text_string=text_string+("\n\nWith CircuitPython, there are no upfront desktop downloads needed. Once you get your board set up, open any text editor, and start editing code. It's that simple.")

width=75
text_lines = wrap_text_to_pixels(text_string, width, terminalio.FONT)
print("width: {}".format(width))
print('text_lines: {}'.format(text_lines))

while True:
    pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions