简体   繁体   中英

I cannot use more than one font in pygame

This sounds like a stupid question, but I can't get it to work.

from pygame import *
from random import *
from math import *
import os
from datetime import datetime
#importing all needed modules
mixer.init() #initializing mixer for sound use
init() #initializing pygame
font.init() #Just to prove that it still doesn't work
SCREEN = (1000,700)
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d, %d" %(350, 25)
screen = display.set_mode(SCREEN)

font = font.SysFont("Times New Roman", 52)
font2 = font.SysFont("Times New Roman", 12)

the first one works but the second one throws an error: builtins.AttributeError: 'pygame.font.Font' object has no attribute 'SysFont'

been having this problem and need to use fonts because I need to blit a variable that changes.

您在第一行中将font声明为变量,则需要将其更改为font1或类似的传真

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM