'Failed to fit char into font texture' Crashes PsychoPy

If this template helps then use it. If not then just delete and start from scratch.

OS: Windows 10
PsychoPy version : v2023.2.2
Standard Standalone? (y/n) If not then what?: yes
What are you trying to achieve?: I am trying to fit a letter and a number onto a screen with a background color of either blue or orange.

What did you try to make it work?: The program works, but sometimes I will get this runtime error and it will crash:

RuntimeError: Failed to fit char into font texture (b'Arial' at size 432.0px)

The letter number combinations are random, so I ordered to to go in order (A1, A2, A3 …, Z10) and whenever it got to X it crashed. Same thing if the number was first (1A, 2A, …, 10Z), it would get to 1X and crash

I have tried changing font sizes, making the font not bold, changing the layout size, height, changing border width, and changing formatting. I get the same error, sometimes with different pixel sizes (e.g. (b’Arial’ at size 368.0px))

Longer version of the error message:

  File "C:\Users\jackpmanning\OneDrive - Texas A&M University\Documents\Projects\vssdt\PsychoPy\Gait\Number_Naming_Task_lastrun.py", line 990, in <module>
    run(
  File "C:\Users\jackpmanning\OneDrive - Texas A&M University\Documents\Projects\vssdt\PsychoPy\Gait\Number_Naming_Task_lastrun.py", line 702, in run
    Number_naming_prompt.setText(Combined)
  File "C:\Users\jackpmanning\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\visual\textbox2\textbox2.py", line 1518, in setText
    setAttribute(self, 'text', text, log)
  File "C:\Users\jackpmanning\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\tools\attributetools.py", line 134, in setAttribute
    setattr(self, attrib, value)
  File "C:\Users\jackpmanning\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\visual\textbox2\textbox2.py", line 783, in text
    self._layout()
  File "C:\Users\jackpmanning\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\visual\textbox2\textbox2.py", line 875, in _layout
    glyph = font[charcode]
  File "C:\Users\jackpmanning\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\visual\textbox2\fontmanager.py", line 389, in __getitem__
    self.fetch('%c' % charcode)
  File "C:\Users\jackpmanning\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\visual\textbox2\fontmanager.py", line 532, in fetch
    raise RuntimeError(msg)
RuntimeError: Failed to fit char into font texture (b'Arial' at size 432.0px)```

Are you doing anything to set the size of any text fonts? What is different about 1X from previous trials?

Hi @wakecarter ,

I am setting the size in Layout as

Size[w,h] $ (2.5, 2.5)

and in formatting I am setting the height and spacing as

Letter height $ 0.3
Line spacing $ 1.0

The thing that makes this weird and hard to fix is that I have three separate experiment files, which are the exact same except the background color changes. For one, the background color alternates randomly between orange and blue, for the other two the background color stays the same the whole time and is either just orange or just blue. The letter number prompt changes every 2 seconds. I noticed today that the experiment where the background stays orange, the prompt stays the same for much longer than 2 seconds, maybe 5-6 seconds for a few prompts, then the program crashes.

Here are some screenshots of the setup. I am also happy to share the .psyexp files on github.



What units are you using? Is it the same for all experiments? 2.5 is bigger than screen size in height and norm and too small in pix

In exp settings I have units set up as height. I am using this in an MRI experiment, so the monitor is mirrored to an MRI compatible tv in the scanner room. What should I be using, and how do I figure out based on my monitors what settings are correct? I do not know how graphics output to monitors works. Thanks!

Hello

You find a description of the various window units here Units for the window and stimuli — PsychoPy v2024.2.0.

Best wishes Jens