Display differently styled bulletpoints with pygame

Viewed 59

Is there any posibility to render differently styled bullet points in Python3 with pygame? I can use the following character ' - ', but I'd rather have round bulletpoints for example, like the ones stackoverflow uses:

  • This type of bulletpoint

As a horribly ugly workaround I am currently thinking of drawing a circle where the bulletpoint would be, but before I put the effort in, I wanted to ask if it is inherently impossible with pygame or if I am missing something.

Minimal working code if you want to test your solutions:

import pygame
pygame.init()
screen = pygame.display.set_mode((600, 900))
pygame.display.get_surface().fill((200, 200, 200))
# Fonts
pygame.font.init()
my_font = pygame.font.SysFont('Arial', 30)
text_surface = my_font.render('Some Text', False, (0, 0, 0))
text_surface2 = my_font.render('- A bulletpoint text', False, (0, 0, 0))
# Loop
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            exit()
    screen.blit(text_surface, (10, 0))
    screen.blit(text_surface2, (10, 50))
    pygame.display.flip()
1 Answers

You have an option to download font that has different types of bulletpoints and use it. An easier but limiting alternative is to directly use the unicode for bulletpoint, which is u'\u2022', but this would limit the types of bulletpoints you can use.

import pygame
pygame.init()
screen = pygame.display.set_mode((600, 900))
pygame.display.get_surface().fill((200, 200, 200))
# Fonts
pygame.font.init()
my_font = pygame.font.SysFont('Arial', 30)
text_surface = my_font.render('Some Text', False, (0, 0, 0))
text_surface2 = my_font.render(u'\u2022 BulletPoint' , False, (0, 0, 0))
# Loop
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            exit()
    screen.blit(text_surface, (10, 0))
    screen.blit(text_surface2, (10, 50))
    pygame.display.flip()

Also, note that you have to set anti-aliasing to True, otherwise it doesn't make a circle.

 my_font.render(u'\u2022 BulletPoint' , True, (0, 0, 0))
Related