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

Re: [pygame] freetype + unusual font format: What am I doing wrong?



Okay, setting the resolution to 45 corrects the sizes:

pygame.freetype.init(resolution=45)

Python 2.7.3
pygame 1.9.2a0
pygame.freetype 2.4.10
radon.bdf 12
radon.bdf 13
radon-wide.bdf 12
radon-wide.bdf 13
c64.bdf 8
c64d.bdf 16

I don't know why this is the case. Explicit bitmap font support is not built into the freetype module, so is untested. It is something I intended, but have not got around too. Sorry.

Lenard Lindstrom.

On 13-10-05 03:07 PM, Lenard Lindstrom wrote:
Hi,

I don't know what exactly you are looking for. The BDF fonts are bitmap fonts, so do not scale. Each font supports only a few specifc sizes.

Freetype works in point size, which is not pixel size. Point size is supposed to represent the size as viewed. By default it assumes there are 72 points to an inch. So a point size of 10 should give around 7 characters per inch. However, the pitch value of 72 points per inch is a builtin constant; it is not calculated from the actual screen resolution. So actual font size will vary with the monitor used.

The freetype version of pygame.font.init() is just pygame.freetype.init(). It takes a 'resolution' keyword argument that sets the default pitch used in rendering. I suppose setting the pitch to the screen resolution, in pixels per inch, makes the point size equal pixel size. The pygame.freetype.Font type allows pitch to be set individually for each Font instance. It is this pitch twiddling which allows pygame.freetype.Font to mimic how pygame.font.Font handles the default Pygame font, which is scaled differently from other fonts.

Lenard Lindstom

On 13-10-05 01:48 PM, Jason Marshall wrote:
Maybe my understanding of size is wrong...
http://www.freetype.org/freetype2/docs/ft2faq.html#other-size

------------------------------------------------------------------------
*From:* Jason Marshall <jmm0@xxxxxxxxx>
*To:* "pygame-users@xxxxxxxx" <pygame-users@xxxxxxxx>
*Sent:* Saturday, October 5, 2013 2:41 PM
*Subject:* Re: [pygame] freetype + unusual font format: What am I doing wrong?

Lenard,

Sorry, updating to pygame-1.9.2a0-12de2da43ecb.win32-py3.3.msi didn't help.

By passing a different (wrong) size, I was able to get freetype to render some fonts but not others. I made a webpage with the only documentation that I have found, some demo code that can render from some BDF fonts, and a screenshot:
http://www.marshallworkshop.com/pygame/freetype-bug/

I suspect that there's a mistake in the documentation for instantiating the pygame.freetype.Font class. If I follow the documentation and pass it the font name, style and size, I get an error. If I just pass only the font name and a certain (wrong) size, it sometimes renders.

Jason


------------------------------------------------------------------------
*From:* Lenard Lindstrom <len-l@xxxxxxxxx>
*To:* pygame-users@xxxxxxxx
*Sent:* Friday, October 4, 2013 1:21 PM
*Subject:* Re: [pygame] freetype + unusual font format: What am I doing wrong?

Hi Jason,

This sounds like issue #144, unable to render text.
<https://bitbucket.org/pygame/pygame/issue/144/unable-to-render-text>
The issue #144 fix is included in an updated 32bit Windows installer
added to the downloads page
<https://bitbucket.org/pygame/pygame/issue/144/unable-to-render-text>
earlier this week: pygame-1.9.2a0-12de2da43ecb.win32-py3.3.msi
<https://bitbucket.org/pygame/pygame/downloads/pygame-1.9.2a0-12de2da43ecb.win32-py3.3.msi>.
I have taken to adding a changeset identifier to the file name so
tracking installer versions will be easer.

Lenard Lindstrom

On 13-10-04 05:50 AM, Jason Marshall wrote:
> I would like to use the freetype module to render text from a BDF font
> file, but I am getting a vague error. I am using the 8x8 font from
> this site:
> http://beej.us/c64bdf/c64bdf/c64.bdf
>
> >>>import os
> >>>os.environ["PYGAME_FREETYPE"] = "1"
> >>>import pygame
> >>> pygame.font
> <module 'pygame.ftfont' from
> 'C:\\Python33\\lib\\site-packages\\pygame\\ftfont.py'>
> >>> import pygame.freetype
> >>> pygame.freetype.init()
> >>> c64 = pygame.freetype.Font(r'C:\Users\marshalls\Downloads\c64.bdf', 8) > >>> s = c64.render('TEST', pygame.Color('white'), pygame.Color('blue'))
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> SystemError: error return without exception set
> >>>
>
> Can somebody spot what I am doing wrong?
>
> I am using a recent build of pygame 1.9.2pre and Python 3.3 (32-bit)
> on Windows.
>
> Thanks,
> Jason