Pango should implement the other tab alignments
Submitted by Itai Bar-Haim
Link to original bug (#325547)
Description
I took some time to read the pango code that does the line-layouting and handles the tabs. I didn't try to implement anything yet, this is just a thought of how to implement the other alignments:
The static method shape_tab (pango-layout.c), if I get it right, is modifying the given glyphs string to include a tab character, that is - an empty glyph which width is the difference between the end of the current line (where the tab was inserted) to the next possible tab position. This is good for left-aligned tabs; However, in order to handle the rest of the tab alignments, the returned width must vary. In the current implementation, it is somewhat hard to know what comes next, so instead I suggest a different approach:
- shape_tab will remain the same.
- The tab returned by shape_tab will be stored in a last_tab_glyph variable.
- When a new glyph is added, a value is subtructed from last_tab_glyph's width:
- For PANGO_TAB_LEFT, the value is 0.
- For PANGO_TAB_RIGHT, the value is the width of the new glyph.
- For PANGO_TAB_CENTER, the value is half the width of the new glyph.
- For PANGO_TAB_NUMERIC, well, that's a bit tricky... :-)
- If last_tab_glyph's width is nullified or becoming negative, it is removed.
That is my proposal. I don't know if I will have time to try to implement it, hope to recieve some feedback about it (and maybe some successful attempts :-) )
Itai.
Version: 1.11.x