Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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))
Comment

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()
Comment

PREVIOUS NEXT
Code Example
Python :: python - save file 
Python :: python nCr n choose r function 
Python :: how to check if an element is visible on the web page in selenium python 
Python :: oddlyspecific09123890183019283 
Python :: get file extension python 
Python :: bs4 from url 
Python :: print key of dictionary python 
Python :: get max pixel value python 
Python :: change py version in colab 
Python :: how to read a json resposnse from a link in python 
Python :: how to print whole year calendar in python 
Python :: django import models 
Python :: easy sending email python 
Python :: matplotlib plot data 
Python :: stringf replcae in python 
Python :: pandas column string first n characters 
Python :: pandas columns add prefix 
Python :: how to get pygame window height size 
Python :: Make tkinter window look less blury 
Python :: find index of max value in 2d array python 
Python :: make a message appear after specified Time python 
Python :: python folium add minimap to map 
Python :: matplotlib plot 
Python :: matplotlib transparency 
Python :: no such table: django_session 
Python :: x= [10] def List_ex(): x.append(20) def add_list(): x=[30,40] x.append(50) print (x) List_ex() print (x) add_list() print (x) 
Python :: python index where true 
Python :: numpy identity matrix 
Python :: np array to wav file 
Python :: how to redefine a legend in pandas 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =