Version 20 (modified by vlado, 16 years ago) (diff) |
---|
Analysis
Overview
- The ability of text to wrap around objects.
- The objects could wrap the text as follows:
- none - text is not wrapped
- before - text wraps only on the left side
- after - text wraps only on the right side
- parallel - text wraps from both sides
- Default value should be parallel.
- Modification of wrapping options will be available from a separate hud added to the HotText halo menu. It will contain a group of radio buttons to switch between No Wrapping, Before, After and Parallel.
- Text can be flowed/wrapped only around overlapping objects (frames, etc.), that is - objects that have a higher z-order than the current Frame.
- The way of wrapping will depend on the available space for flowing of the text around the overlapping objects.
- The following strategy will be considered
- A kind of priority (weight) will be present to estimate the different options for text layout in various cases of overlapping.
- The objects could wrap the text as follows:
- Text layout inside a Frame.
- Text is divided into the following parts which define scopes for the text elements:
- Text - the whole flowing text.
- Text Part - part of the whole text, that is displayed as content of a Frame.
- Line - one line of visible text inside a Frame. It is composed of one or more line segments, depending on overlapping with other objects (frames, etc.)
- Segment (Line Part) - part of a line wrapped around two objects, object and border or two borders of the container Frame.
- Text is divided into the following parts which define scopes for the text elements:
Task requirements
- Refine the existing text layout algorithm.
- Provide layout functionality for accurate calculation of Text Parts depending on the present Frames (needed for TEXT_CHAINING_BEHAVIOUR_R0 and TEXT_AUTO_CHAIN_BEHAVIOUR_R0).
- Fixing a known bug with layout algorithm specified at http://www.sophie2.org/trac/wiki/TEXT_INPLACE_EDITOR_R0#Implementation.
- If there is time a simple line by line text flowing will be added.
Task result
The result should be source code.
Implementation idea
- Hill climbing algorithm is used for laying out text (a general implementation is already present).
- Check Hill Climbing Algorithm at Wikipedia for more information.
- The roles in the algorithm for the purpose of HotTextLayout:
- Vertex - a collection of vertex fields, such as text range (a specific Segment) and its supported properties (scope, area, position properties, etc.)
- Edge - represents a placement (positioning) operation for the next Segment depending on the previous Segment (it is the concrete kind of transition from a Vertex to one of its neighboring Vertex-s)
- Path - represents a layout of some text (group of Segments, Line or Text Part) with a calculated weight, or "badness" (it is a collection of edges defining the path from one Vertex to another).
- The goal is to layout the text according to the Path with lowest weight ("badness").
- The algorithm can be extended with:
- a better separation of Segments in relation to the needs of wrapping functionality.
- a better Segment handling and calculations.
- a better estimation of the weight ("badness") in different use cases.
Related
How to demo
- A simple line by line text flowing demo (if implemented)
- Start the application
- Create new book
- Inside the book create new text frame and type some text (you could use lorem ipsum generator for better result - http://www.lipsum.com/)
- Place another frame on top of the text frame. The text should be flowed around the second frame.
Design
Implementation
(Describe and link the implementation results here (from the wiki or the repository).)
Testing
Comments
(Write comments for this or later revisions here.)