-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathpygame_minimal_text_bold.py
39 lines (32 loc) · 1.13 KB
/
pygame_minimal_text_bold.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# pygame.font module
# https://www.pygame.org/docs/ref/font.html
#
# Make a Single Word Within a String Bold
# https://stackoverflow.com/questions/72409725/make-a-single-word-within-a-string-bold/72409816#72409816
#
# GitHub - PyGameExamplesAndAnswers - Text and font - Bold
# https://github.com/Rabbid76/PyGameExamplesAndAnswers/blob/master/documentation/pygame/pygame_text_and_font.md
#
# https://replit.com/@Rabbid76/PyGame-Text
import pygame
pygame.init()
window = pygame.display.set_mode((400, 200))
clock = pygame.time.Clock()
courer_regular = pygame.font.match_font("Courier", bold = False)
courer_bold = pygame.font.match_font("Courier", bold = True)
font = pygame.font.Font(courer_regular, 50)
font_b = pygame.font.Font(courer_bold, 50)
text1 = font.render("Some ", True, (255, 255, 255))
text2 = font_b.render("Text", True, (255, 255, 255))
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
window.fill('black')
window.blit(text1, (50, 75))
window.blit(text2, (50 + text1.get_width(), 75))
pygame.display.flip()
clock.tick(60)
pygame.quit()
exit()