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

Re: [pygame] How the get a font size



On Mon, Jan 12, 2009 at 12:02 AM, Luca <lucafbb@xxxxxxxxx> wrote:
Thanks all, but in this way is impossible to get the size on an unknow
font? I'm making a library for developer that need to know what is the
font size that the developer can have choosen...

The problem is that SDL does not currently expose the size property in a reliable way, so getting the "size" argument that was used to create the font object is not really practical.

However, pygame.font does expose a number of metrics (ascent, descent, max height, line spacing and sizing info and advance for individual characters) about the rendered font that can be used to figure out how to work with a font in a large number of cases, regardless of the point size argument used in the font's constructor. In fact, the point size of the font may not actually relate to anything about the font's rendered pixel size (that's really up to the font designed, who's allowed to design "outside the box" in a number of ways), so the point size itself can be misleading in determining positioning choices depending on the individual ttf used.

So Luca, what are you trying to do with the font object passed in, in your library? In what way do you expect the font point size passed into the constructor to the Font object to help you with that task?