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

Re: [pygame] How the get a font size




On Jan 12, 2009, at 8:46 PM, James Paige wrote:

On Mon, Jan 12, 2009 at 04:54:38PM -0800, Lenard Lindstrom wrote:
Hi,

James Paige wrote:
The only bad thing I can say about it is that it simply doesn't work :(


f = pygame.font.Font(None, 12)
f.size = 12

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'pygame.font.Font' object attribute 'size' is read- only

And that is not just because Font already has a method named .size()


f.pointsize = 12

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'pygame.font.Font' object has no attribute 'pointsize'

I'm guessing that since pygame.font.Font is impelmented in C, it doesn't
allow new members to be added as it would if it was implemented in
python (Correct me if I am wrong)


You're right. Font instances lack attribute dictionaries. It was a
design decision, or omission, and not a restriction of Font being
implemented in C.


Ah, interesting. I stand corrected.

Why was the attribute dictionary left out? What is the advantage? Is it
a performance thing?

You clearly don't understand how C classes work. Please consult the Python documentation.

--Noah