kmonsoor / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

tabs looking bad, especially in monospace fonts #727

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
(comes from issue #702)

Tabs looking bad, especially in monospace fonts

This is OS independent, and can be stated as
"Text with tabs does not look good in a monospace font"

This is really a mismatch between programmer expectations and current pyglet 
behavior.

A tab in pyglet text is interpreted as 'move to the next tab stop'
Tab stops are specified in pixels, not in some font unit; by default theres a 
tab stop each 50 pixels.

So, when displaying the text "hello people,\n\twhat are you doing ?" the 
character boxes in the second line will not vertically align with the ones in 
the first lines.

Also, the tabs will be seen too wide for small fonts and too small for large 
fonts. Notice that this will also happen in non monospaced fonts.

Two ways to fix this defect in a concrete case:
    - untabify the text before sending to a label or other text renderer in pyglet
    - set the tab stops to i * spaces_per_tab * pixel_width(' ')

Should pyglet do something about this ?
I suggest to
    - add a simple paragraph in text and fonts suggesting how to handle tabs
    - bonus points: provide a simple recipe or function to get pixel_width(' ')

Anything more will be code bloat and / or restricting the options for the 
pyglet user (programmer)

Original issue reported on code.google.com by ccanepacc@gmail.com on 4 Apr 2014 at 4:01

GoogleCodeExporter commented 9 years ago

Original comment by useboxnet on 17 Apr 2014 at 6:24

GoogleCodeExporter commented 9 years ago
Attached tabs_rendering.diff, a patch to clarify tab behavior in the docs.

Fell free to modify at will, my English is not too good.

I think that should close the issue.

Original comment by ccanepacc@gmail.com on 9 May 2014 at 4:27

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by useboxnet on 9 May 2014 at 5:41

GoogleCodeExporter commented 9 years ago
Thanks Claudio, your English is good :)

I put your comments as sub-section of "paragraphs styles" as is there where the 
tab_stops is defined.

Original comment by useboxnet on 19 May 2014 at 4:29

GoogleCodeExporter commented 9 years ago
This issue was closed by revision b85df72ae77a.

Original comment by useboxnet on 19 May 2014 at 4:30