Skip to content

Proof of concept: Hyphenate Braille using pyphen#19916

Draft
LeonarddeR wants to merge 11 commits intonvaccess:masterfrom
LeonarddeR:pyphen
Draft

Proof of concept: Hyphenate Braille using pyphen#19916
LeonarddeR wants to merge 11 commits intonvaccess:masterfrom
LeonarddeR:pyphen

Conversation

@LeonarddeR
Copy link
Copy Markdown
Collaborator

Link to issue number:

Closes #17010 

Summary of the issue:

Word wrap is sometimes pretty aggressive, especially on shorter braille displays.

Description of user facing changes:

This pull request introduces significant enhancements to braille text wrapping and language management in the braille buffer, along with related configuration and compatibility improvements. The main changes include the addition of a more flexible text wrapping configuration for braille output, support for hyphenation based on language and improved handling of language changes within braille regions.

There are mainly two additional options to choose from:

  • Text wrap with continuation mark. When a word wraps to the next line, use the last cell to show a continuation mark so that it is clear that a word continues on the next line. Basically you may call this dumb hyphenation.
  • The hyphenate option is the smarter part and uses real hyphenation rules from pyphen based on the current language.

Description of developer facing changes:

None

Description of development approach:

Braille text wrapping and hyphenation:

  • Introduced a new BrailleTextWrap enum with options for off, continuation mark only, word boundaries, and hyphenation, replacing the previous boolean wordWrap setting. Updated the configuration spec and UI strings accordingly.
  • Enhanced the braille buffer to support hyphenation at line breaks, using the pyphen library and language-aware hyphenation logic. This allows words to be split across lines with proper hyphenation based on the detected language.

Language management in braille regions:

  • Implemented tracking of language changes within braille regions, allowing for accurate language detection at any position in the buffer. This supports correct hyphenation and text processing for multilingual content.

Configuration and backward compatibility:

  • Updated configuration logic to map the deprecated wordWrap setting to the new textWrap enum, ensuring backward compatibility and providing deprecation warnings when the old setting is used.

Testing strategy:

T.b.d.

Known issues with pull request:

Since this is a proof of concept, there are several major open issues:

  1. Distribution and launcher builds don't yet work with pyphen because the dictionaries aren't build correctly. I think this requires a py2exe hook in setup.py to patch pyphen.
  2. The options need better naming really, but I find it hard to come up with clear options here.
  3. Unknown languages are not yet handled correctly.
  4. Unit tests should be added.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Apr 10, 2026
@seanbudd seanbudd requested a review from SaschaCowley April 10, 2026 00:50
@cary-rowen
Copy link
Copy Markdown
Contributor

Once the Chinese word segmentation PR is merged, will it be possible to use its rules to handle Chinese line breaks within this new text wrap framework

@LeonarddeR
Copy link
Copy Markdown
Collaborator Author

I have no idea honestly. That is something we'd need to find out after that is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add hyphenation support to braille using Pyphen

4 participants