class words(Sprite):
def __init__(self,content,pm,x=50,y=85,size=20,kind='fangsong'):
super(words,self).__init__()
self.size=size
self.font=pygame.font.SysFont(kind,size)
self.pm=pm
self.kind=kind
self.content=content
self.update(content,x,y)
def update(self,content,x=None,y=None):
self.content=str(content)
self.image=self.font.render(str(self.content),True,(60,60,60))
if x==None or y==None:
x,y=self.rect.center
self.rect=self.image.get_rect()
if x=='no' or y=='no':
self.rect.right=1000
self.rect.top=0
else:
self.rect.centerx=x
self.rect.centery=y
一些特殊符号的数据集难找怎么办?
这篇博客介绍了如何利用pygame库中的font模块,创建包含特殊字符的图像,并保存为不同字体的图片文件。通过遍历pygame支持的字体,生成了包含除号字符的图像并进行保存。
摘要由CSDN通过智能技术生成