Displaying unicode symbols using pygame

The unicode character is not provided by the “Tahoma” font.

Use the “segoeuisymbol” font if your system supports it:

seguisy80 = pygame.font.SysFont("segoeuisymbol", 80)

Note, the supported fonts can be print by print(pygame.font.get_fonts()).

Alternatively download the font Segoe UI Symbol and create a pygame.font.Font

seguisy80 = pygame.font.Font("seguisym.ttf", 80)

Use the font to render the sign:

queenblack = "♔"
queenblacktext = seguisy80.render(queenblack, True, BLACK)

Minimal example:

import pygame

WHITE = (255, 255, 255)
BLACK = (0, 0, 0)

pygame.init()
window = pygame.display.set_mode((500, 500))

seguisy80 = pygame.font.SysFont("segoeuisymbol", 80)
queenblack = "♔"
queenblacktext = seguisy80.render(queenblack, True, BLACK)

run = True
while run:  
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    window.fill(WHITE)
    window.blit(queenblacktext, (100, 100))
    pygame.display.flip()

Leave a Comment