2

So I've been making a game using Pygame, and I want to send it over to a friend. I've been trying to use Pyinstaller to turn it into an exe file and sending it over to him. When I make the exe file I'll test it and it'll work fine on my computer, but when I send it over to him he says that all it does is open a black screen and then close automatically. After a lot of tests and checks, I've finally figured out the issue is with the fonts, and this is the line that keeps on breaking:

font = pygame.font.SysFont("arjulianopentype", 40)

I've tried to have sysfont.py added as a hidden import, but that didn't work, and the only other thread I've seen remotely close to the problem I have is this one, but it doesn't have a real answer that helps. So can someone please tell me what I'm missing and/ or doing wrong? I would really appreciate the help, thank you!

  • 1
    The linked question suggest that it didn't work with their font. Does the other use have the font _"arjulianopentype"?_ I'm guessing it's a font you've downloaded and not a system font. Have you tried if it works with `font = pygame.font.SysFont("arial", 40)`? – Ted Klein Bergman Aug 20 '20 at 20:36
  • I concur with @TedKleinBergman. Maybe you could use a freely-licensed font, and bundle that in with your executable. But make sure you take care when loading external files, ref: https://stackoverflow.com/a/63182146/1730895 – Kingsley Aug 20 '20 at 22:57
  • @TedKleinBergman It's not a font that I downloaded, not independently of Pygame or Python, knowingly anyway. While I didn't check "arial", I did find out that "twcen" works. Where would I find the file for the font, or what type of file would I be looking for exactly? – ElectroTerra Aug 21 '20 at 02:56
  • 1
    Font locations are typically platform specific, e.g. in Windows, it's in `C:\Windows\Fonts`. You could also try using the default font, e.g. `font = pygame.font.SysFont(pygame.font.get_default_font(), 40)`. – import random Aug 24 '20 at 03:40

0 Answers0