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

Re: [pygame] Time to load font with pygame.font.SysFont on Mac



Hi,

There probably should be an open issue for this. The initial query is quite slow unfortunately, and I can’t find a quicker query. What can be done is to use a known set of fonts for different or some subset of OS versions... Apple did/does publish these lists somewhere, so a fix would be to first look at these lists and then only query if the font can not be found.

For many/most fonts that people use with SysFont (like Arial) this would hit the fast path and avoid this slow query.

cheers,

On Sunday, April 4, 2021, Greg Ewing <greg.ewing@xxxxxxxxxxxxxxxx> wrote:
On 5/04/21 9:29 am, Irv Kalb wrote:
If I load a font like the system font using None with a call to pygame.font.font, it happens almost immediately.

But if I load a font by name using pygame.font.SysFont, it's taking over 7 seconds on my Mac to load.  It doesn't seem to matter which font I try to use.

Is it slow every time you run it, or are subsequent runs faster?

I don't have an OSX 11 system handy to try it on, but I tried
it on 10.12.6 and got this:

First run:
Loading System font took 0.015527009963989258
Loading Arial font took 4.879987001419067

Second run:
Loading System font took 0.00061798095703125
Loading Arial font took 0.05048775672912598

Third run:
Loading System font took 0.0006070137023925781
Loading Arial font took 0.0516507625579834

So for me it took about 4.9 seconds the first time, but was
a lot faster once it was warmed up.

--
Greg