3
我有一個名爲「pixelfont」的字體,我想加載到我的遊戲中。我怎樣才能加載這個字體到pygame中?我已經嘗試了以下方法:從pygame的系統中加載字體
import pygame
font_1_path = pygame.font.match_font("pixelfont", 0, 0)
font_1 = pygame.font.Font(font_1_path, 128)
text = font.render("Hello world!", True, (0, 0, 0))
display.blit(text, [0, 0])
爲什麼不打印出「Hello world!」在pixelfont?
如果您的字體,「pixelfont」,是一個TTF文件,你可以簡單地用'pygame.font加載進去。字體(「pixelfont.ttf」,128)'(假設pixelfont.ttf在當前工作目錄中。) –