用 pygame 渲染 freetype 字体

问题描述

我是 pygame 的新手,所以我试图使用 pygame 打印出一个简单的标题页。

我的原始代码如下:

import pygame
import pygame.freetype

pygame.init()

pygame.display.set_caption('hello world')

screen = pygame.display.set_mode((800,600),32)

title_font = pygame.font.Font(".../Montserrat-BlackItalic.ttf",24)
title = title_font.render('sup',False,(250,250,250))

running = True

while running: 
    for event in pygame.event.get():
        if event.type == pygame.quit:
            running = False
            
        
    screen.fill((25,25,25))
    screen.blit(title,(0,0))
    pygame.display.update()

pygame.quit()

它有效。但是,字体超级模糊。我读到使用 freetype 字体将有助于减少模糊,但是当我尝试时,我收到了这个错误


  File ".../untitled1.py",line 22,in <module>
    screen.blit(title,0))

TypeError: argument 1 must be pygame.Surface,not tuple

我只更改了代码以查找字体类型,使其看起来像这样:

title_font = pygame.freetype.Font(".../Montserrat-BlackItalic.ttf",24)

我现在如何减少模糊的字体?

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)