Horje
display text in pygame Code Example
display text in pygame
def writeText(string, coordx, coordy, fontSize):
  	#set the font to write with
    font = pygame.font.Font('freesansbold.ttf', fontSize) 
    #(0, 0, 0) is black, to make black text
    text = font.render(string, True, (0, 0, 0))
    #get the rect of the text
    textRect = text.get_rect()
    #set the position of the text
    textRect.center = (coordx, coordy)
    #add text to window
	window.blit(text, textRect)
    #update window
	pygame.display.update()
pygame render text
"""system font"""
font = pygame.font.SysFont("Segoe UI", 35)

"""font from .ttf file"""
font = pygame.font.Font("path/to/font.ttf", 35)

textsurface = font.render("text", False, color)  # "text", antialias, color
surface.blit(textsurface, (x, y))
how to write a font in pygame
font = pygame.font.SysFont(None, 24)
img = font.render('hello', True, BLUE)
screen.blit(img, (20, 20))




Python

Related
python float to fraction Code Example python float to fraction Code Example
python calculate computation time Code Example python calculate computation time Code Example
python get file date creation Code Example python get file date creation Code Example
find duplicated rows with respect to multiple columns pandas Code Example find duplicated rows with respect to multiple columns pandas Code Example
get file creation date py Code Example get file creation date py Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7