psychopy.org | Reference | Downloads | Github

Using a non-system font for Builder text components

OS: macOS
PsychoPy version: 2020.1.1
Standard Standalone? (y/n): y

It turns out using non-system fonts (as specified in a .ttf file) in Builder text components is not straightforward. After getting some advice from @jon, I came up with the attached hack. The main idea is to use the following code in the Begin Routine tab of a code component to update the font used by the text component:

if text.fontFiles != ['myFont.ttf']:
    text.fontFiles = ['myFont.ttf']  # this needs to be a list
    text.setFont('myFont')

Jan

use_non-system_font.psyexp (8.2 KB)