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

Re: [pygame] File Copying



"Ian Mallett" <geometrian@xxxxxxxxx> wrote:
> Yes, I know, it just seems a little weird- text with no return function?
> I'm probably just used to notepad and similar programs.

Yeah, but you wouldn't want to compare a string-rendering function with a
text editor.

Think about what the rendering function is doing - it's iterating through
your string and finding those characters in the font, and rendering them
to a surface. When it hits a '\n' character, it looks it up in the font,
and draws a box as an indication of a failure. You can also see this by
sticking other non-printable characters into your string, including '\t'
for the tab character. If you want to support tab stops, you could replace
\t with some number of spaces, or maintain a list of vertical lines that
the cursor advances to when your text display hits a tab character.

It's pretty simple to split your string on carriage returns (and/or line
feeds), create surfaces for each line of text, and blit those surfaces to
the destination surface.


-Dave LeCompte