Version 4 (modified by boyan, 15 years ago) (diff) |
---|
Analysis
Overview
Sophie needs support for justified text. This task has to provide both the UI and the needed algorithms for test justification.
Task requirements
- TextParagraphHud should provide a button for justified alignment. After pressing it, the text should be aligned justified, meaning:
- Text is aligned along both the left and right frame border;
- Spacing between words is equally distributed;
- TODO How do we handle spacing between letters? What about single words on a line (if they are long, adding spaces seems sensible, if they are short, it will look ugly)?
- The algorithm for justification should be easily changeable with an alternative implementation.
- If the suggested algorithm requirements tend to produce bad layout (whitespace rivers, loose lines, etc.) or downgrade the performance by more than 20% (measured by the text performance tests run on left-aligned and justified text), they might be changed.
- The algorithm should not significantly slow down text performance.
Task result
Source code
Implementation idea
At this revision we want something simple - we take the width of the segment/line, take out the width of the text, and distribute the space equally between words. Another approach is to distribute 80% of the space between words and the rest between letters (theoretically this should tend to produce better results).
Related
None
How to demo
Insert a text frame in Sophie, type some text and align it justified.
Design
Describe your design here.
Implementation
Describe and link the implementation results here (from the wiki or the repository).
Testing
Place the testing results here.
Comments
Write comments for this or later revisions here.