有没有办法使用pygame渲染刻度线?我尝试像这样直接使用unicode:
def write(screen, text, color, position, size):
font = pygame.font.Font(pygame.font.get_default_font(), size)# Defining a font with font and size
text_surface = font.render(text, True, color)# Defining the text color which will be rendered
screen.blit(text_surface, (position[0], position[1])) # Rendering the font
write(window, u'\u2713', self.color, position, size)
但这只是绘制了一个矩形。
正在写入的这个“矩形”实际上是✓
使用pygame.font.get_default_font()
. 为了显示✓
标志,您需要确保该标志包含在您使用的字体中。我提出以下解决方案:
font = pygame.font.Font("seguisym.ttf", size)
write(window, u'\u2713', self.color, position, size)
方法或直接使用写入函数write(screen, "✓", self.color, position, size)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句