Search code examples
pythonfontspygame

custom font not working in pygame, custom font not showing up


I tried to use a custom font downloaded on internet but it doesn't work. everything works but the font isn't changing. i installed the font and the path is correct

def mainmenutext_function():
    global mainmenutext
    global mainmenutext_width
    global mainmenutext_height
    global ROOTwidth
    global ROOTheight

    mainfont = pygame.font.SysFont("fonts/main_font.ttf", int(ROOTwidth/7))
    mainmenutext = mainfont.render('text', False, (0, 0, 0))
    mainmenutext_width = mainmenutext.get_width()
    mainmenutext_height = mainmenutext.get_height()

Solution

  • I found a solution: in mainfont = pygame.font.SysFont("fonts/main_font.ttf", int(ROOTwidth/7))

    I replaced pygame.font.SysFont with pygame.font.Font