# Adding a font type

**URL:** <https://discourse.psychopy.org/t/adding-a-font-type/2441>\
**Category:** Other\
**Created:** [May 14, 2017, 8:19am UTC](https://discourse.psychopy.org/t/adding-a-font-type/2441 "2017-05-14T08:19:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ofirshan](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@ofirshan](https://discourse.psychopy.org/u/ofirshan)\
**Post date:** [May 14, 2017, 8:19am UTC](https://discourse.psychopy.org/t/adding-a-font-type/2441/1 "2017-05-14T08:19:34Z")

</div>

Hello,  
I am running an experiment on version 1.84.2 of PsychoPy.  
I wish to display text in the Aharoni font. However, this works only on one computer but not on others (yet, I am able to display other fonts, such as Arial, in those computers). In all computers I am using win 10, and in those in which displaying this font does not work, the font does seem to exist in other programs such as Power Point or Word.  
How can I add a font?  
Thanks,  
Ofir

---

<div class="post-metadata">

**Author:** ![lindeloev](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lindeloev/32/15_2.png) [@lindeloev](https://discourse.psychopy.org/u/lindeloev)\
**Post date:** [May 24, 2017, 7:29am UTC](https://discourse.psychopy.org/t/adding-a-font-type/2441/2 "2017-05-24T07:29:44Z")

</div>

My guess is that the font is installed on one computer but not the others. There’s two solutions:

1. Install the font on all systems. Google how to do it for your operating system.

2. You can add the font file (probably “aharoni.ttf”) to your experiment folder and then specify that as the font in your `TextStim`.

---

<div class="post-metadata">

**Author:** ![rongmu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/rongmu/32/983_2.png) [@rongmu](https://discourse.psychopy.org/u/rongmu)\
**Post date:** [June 8, 2022, 4:50pm UTC](https://discourse.psychopy.org/t/adding-a-font-type/2441/3 "2022-06-08T16:50:47Z")

</div>

Hi,

I found a solution after doing some research. It seems that non-system font files must be registered for _once_ before you can specify them in a text’s Font field (Builder) or `.font` property.

You can use a temporary TextStim object at the beginning of the experiment just for registering font files:

```python
font_files = ['NotoSansSC-Regular.otf', 'NotoSerifSC-Regular.otf']
font_main = 'Noto Sans SC'

_ = visual.TextStim(win=win, font=font_main, fontFiles=font_files)
del _

```

After this, you can set the font of your texts to ‘Noto Sans SC’ or ‘Noto Serif SC’ (the names of the two Simplified Chinese fonts). PsychoPy will recognize the font name and you don’t need to pass the `fontFiles` argument again.

```python
new_text = visual.TextStim(win=win, text='Hello, font', font=font_main)

```

Alternatively, you can directly register the font files with `pyglet` instead of creating a temporary TextStim. This is what the `.fontFiles` setter does under the hood (see the [source code](https://psychopy.org/_modules/psychopy/visual/text.html#:~:text=def%20fontFiles(self%2C%20fontFiles)%3A)).

```python
import pyglet

font_files = ['NotoSansSC-Regular.otf', 'NotoSerifSC-Regular.otf']

for font in font_files:
    pyglet.font.add_file(font)

new_text = visual.TextStim(win=win, text='Hello, font', font='Noto Sans SC')

```

(tested with PsychoPy 2022.1.4)
