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 :: resize image array python 
Python :: python import all words 
Python :: django proper capitalization case jinja 
Python :: trigonometry in python 
Python :: tkinter window to start maximized 
Python :: python list ascii 
Python :: py for line in file 
Python :: how to change button background color while clicked tkinter python 
Python :: Extract categorical data features 
Python :: PySpark null or missing values 
Python :: built in function in python 
Python :: how to get data from json web api in python 
Python :: python ceiling 
Python :: how to start ftpd server with python 
Python :: how to do label encoding in multiple column at once 
Python :: random .randint renpy 
Python :: open tiff image pyt 
Python :: python merge strings in columns 
Python :: filter dataframe by index 
Python :: python timeit commandline example 
Python :: python loop every month datetime 
Python :: add rows to dataframe pandas 
Python :: matplotlib grid thickness 
Python :: check if user log in flask 
Python :: getting dummies for a column in pandas dataframe 
Python :: number of database queries django 
Python :: dump data in json file and keep structure tabulation 
Python :: how to say someting in python 
Python :: requirements.txt flask 
Python :: how to create a tkinter window 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =