私はPygameのPokémonスタイルのダイアログボックスで作業しています。私はPokemon GBフォントを使用していますが、何らかの理由でテキストが一番上に切り取られています。 pygame.font.Font.size
は、テキストをレンダリングするのに必要なサイズが正しく計算されていないようです(Surface
)。 テキストはPygameの特定のフォントで一番上に切り取られます
This screenshotは、どのように見えるのかを示します。
import pygame
pygame.init()
window = pygame.display.set_mode((640, 192))
window.fill((255, 255, 255))
POKEFONT = pygame.font.Font("Pokemon GB.ttf", 32)
positions = [[32, 64], [36, 128]]
lines = ["Hello there!", "Welcome to the"]
for line, pos in zip(lines, positions):
text = POKEFONT.render(line, True, (0, 0, 0))
rect = text.get_rect()
rect.topleft = pos
window.blit(text, rect)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
pygame.display.update()
PKMN RBYGSCフォントがほとんど同じに見えますが、正しくレンダリングされます。どうしたの?