Re: [pygame] Good code for text wrapping?
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] wrote: Yeah pygame.font needs support for \n. :P On Wed, Sep 17, 2008 at 2:31 PM, Charlie Nolan [EMAIL PROTECTED]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 [EMAIL PROTECTED] 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/)
Re: [pygame] Good code for text wrapping?
LaTeX support ;-) On Sun, Sep 21, 2008 at 9:18 PM, René Dudfield [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] wrote: Yeah pygame.font needs support for \n. :P On Wed, Sep 17, 2008 at 2:31 PM, Charlie Nolan [EMAIL PROTECTED]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 [EMAIL PROTECTED] 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/)
Re: [pygame] Good code for text wrapping?
oops, I also forgot... - CSS3 and CSS4 support. - a pony. On Mon, Sep 22, 2008 at 2:32 PM, Hugo Arts [EMAIL PROTECTED] wrote: LaTeX support ;-) On Sun, Sep 21, 2008 at 9:18 PM, René Dudfield [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] wrote: Yeah pygame.font needs support for \n. :P On Wed, Sep 17, 2008 at 2:31 PM, Charlie Nolan [EMAIL PROTECTED]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 [EMAIL PROTECTED] 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/)
Re: [pygame] Good code for text wrapping?
On Mon, Sep 22, 2008 at 02:41:28PM +1000, René Dudfield wrote: oops, I also forgot... - CSS3 and CSS4 support. - a pony. I'm sure the last one could be implemented easily, if you had SVG support and Javascript. Marius Gedminas -- In short, at least give the penguin a fair viewing. If you still don't like it, that's ok: that's why I'm boss. I simply know better than you do. -- Linus what, me arrogant? Torvalds, on c.o.l.advocacy signature.asc Description: Digital signature
Re: [pygame] Good code for text wrapping?
On Mon, Sep 22, 2008 at 3:06 PM, Marius Gedminas [EMAIL PROTECTED] wrote: On Mon, Sep 22, 2008 at 02:41:28PM +1000, René Dudfield wrote: oops, I also forgot... - CSS3 and CSS4 support. - a pony. I'm sure the last one could be implemented easily, if you had SVG support and Javascript. Cool. I'll add x86 emulator onto the list. So we can get SVG+javascript by installing linux + firefox.
Re: [pygame] Good code for text wrapping?
René Dudfield [EMAIL PROTECTED] writes: Shall we start by making an ultimate list of features, or use cases... snip Anything else? Eventually, you'll want: - text flow other than left-right (right-left, mixed, top-down) - support for non-letter fonts (e.g. button glyphs for help text) -- although I suppose you could handle it by something you described, flowing text around images, if the images could be floated as well - support for non-breaking spaces and hyphens - proper handling of line-breaking in different languages (e.g., French inserts a space or two between the last letter of a sentence and a final exclamation point, don't want to break there, some languages consider certain combinations of letters to really be only one, can't break in between them, etc.) - proper support for full Unicode fonts But this is a bit pie-in-the-sky, it can wait until the basics are in, I just have text processing on the brain a bit lately :) =wl -- The whole fist fight is over who gets locked up and thrown rudely to the ground and tied into little greasy knots. -- Chas Clements