font(), text()

font() creates a font from a TrueType file which can then be used by text() to draw text to the screen. Creating the font is computationally much more intensive than the actual drawing of the text to the screen and should preferably not be done in a looping event handler like onDraw(). For more advanced typography the following two classes are suggested over these methods: TagText, SpriteText

font(size, typeface_key)
font(size, typeface_file)
  • size ... font size in pixels
  • typeface_file ... file path to a TrueType file
  • typeface_key ... specifies a font that comes with Slut. Valid keys are:
    • "bitstream_sans"
    • "arial"
    • "times"
    • "courier"
    • "euromode", "euromode_b", "euromode_i", "euromode_bi"
    • "oblivious"
    • "impact"
    • "silkscreen", "silkscreen_b", "silkscreen_i", "silkscreen_bi"

text(string, font, x, y)
  • string ... text to draw to the screen
  • font ... object that was created with font()
  • x, y ... location on the screen of lower left corner of the text

Relevant examples: text.py , spritetext.py , tagtext.py , ALL

In Context

def onSetup(self):
    self.font = font(16, 'arial')

def onDrawOrtho(self):
    text("dispalythis", self.font, 95, 150)
Initiated by Stephan Hechenberger
Thanks to CADRE's 103