largeText = pygame.font.Font('digifaw.ttf',450)
字体大小为450,适合在分辨率为1366x768
的全屏显示中显示文本。如何更改字体大小以使其与其他显示分辨率兼容?我在pydocs中查找font,但没有找到任何与自动缩放相关的内容。在
更新:下面是一段代码
def text_objects(text, font):
textSurface = font.render(text, True, black)
return textSurface, textSurface.get_rect()
def message_display(text):
largeText = pygame.font.Font('digifaw.ttf',450)
TextSurf, TextRect = text_objects(text, largeText)
TextRect.center = ((display_width/2),(display_height/2))
gameDisplay.blit(TextSurf, TextRect)
pygame.display.update()
time.sleep(1)
你必须手动调整字体。如果字体适合高度为768的窗口,则必须按
current_height/768
缩放字体。e、 g.:注意,您可以使用^{} 模块:
^{pr2}$以及方法^{} ,将字体直接呈现到一个表面:
如果要缩放字体呈现的^{} 的宽度和高度,则必须使用^{} :
相关问题 更多 >
编程相关推荐