[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Good code for text wrapping?



LaTeX support ;-)

On Sun, Sep 21, 2008 at 9:18 PM, René Dudfield <renesd@xxxxxxxxx> wrote:
awesome :)


yeah, maybe some text layout code would be a useful addition to
pygame.font ?  Or even as a separate download.



Shall we start by making an ultimate list of features, or use cases...

- aligning text, left, right, center etc.
- vertical alignment... top, bottom, center.
- justify text.
- breaking words (word-break), so it can add a long word like
"complexifcation" as "complexif-\ncation"
- splitting text up into 'pages',
   - different sized pages or Rects could be useful too.
- scrolling text.
- selecting text.  Based on mouse click, which letter and word does it
collide with?
- each part of text having a separate font/attributes.  So you can
then do words with bold, italics etc.
- letter spacing
- line spacing
- word spacing
- flowing around areas...
   - eg( place an image, and the text flows around it)
   - example here:  http://www.csstextwrap.com/example_for_demo.php
- indenting
- padding around text.
- text color
- text render method.



Anything else?




On Fri, Sep 19, 2008 at 6:16 PM, Charlie Nolan <funnyman3595@xxxxxxxxx> wrote:
> I'll happily chip in my word-wrap code, if you want it as a starting
> point for pygame.  It's not beautiful, but it does have a very nice
> property:
>
> orig_string[x] -> "".join(wrapped_string)[x]
>
> They're not always equal, because it converts some spaces to a
> zero-width character for alignment purposes.  (The char was originally
> \x00, hence strip_to_null, but that caused issues elsewhere,
> presumably with C strings.)
>
> http://code.google.com/p/endgame-singularity/source/browse/trunk/code/graphics/text.py?r=892
>
> -FM
>
> On 9/17/08, pymike <pymike93@xxxxxxxxx> wrote:
>> Yeah pygame.font needs support for \n. :P
>>
>> On Wed, Sep 17, 2008 at 2:31 PM, Charlie Nolan
>> <funnyman3595@xxxxxxxxx>wrote:
>>
>>> Hmm, I've written this too.  Given that it seems pretty common,
>>> wouldn't this be a good candidate for adding to pygame.font.Font?
>>>
>>> -FM
>>>
>>> On 9/16/08, Marius Gedminas <mgedmin@xxxxxxxx> wrote:
>>> > On Tue, Sep 16, 2008 at 12:11:45PM +1000, René Dudfield wrote:
>>> >> The cookbook has this entry, but it doesn't work with new lines.
>>> >> http://www.pygame.org/wiki/TextWrapping
>>> >>
>>> >> Anyone have any code like this that supports new lines?
>>> >
>>> > http://mg.pov.lt/pyspacewar/trac/browser/trunk/src/pyspacewar/ui.py#L466
>>> >
>>> > Output example: http://mg.pov.lt/pyspacewar/pyspacewar-help-screen.png
>>> >
>>> > It's GPL-ed, feel free to use or ask me for a licence change if that's
>>> > not suitable.
>>> >
>>> > Marius Gedminas
>>> > --
>>> > If you are smart enough to know that you're not smart enough to be an
>>> > Engineer, then you're in Business.
>>> >
>>>
>>
>>
>>
>> --
>> - pymike (http://pymike.4rensics.org/)
>>
>