| Reference | Downloads | Github

Freetype/Textbox issue with 64bit portable python 3.6.5

Hi, I am getting the following error if I try to create a TextBox using a portable python 3.6.5. This seems to only be a problem in 64bit. I am using Windows 10.

I am getting the following Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\marku\Downloads\Test_Python_365_64\Portable Python 3.6.5 x64 R2\App\Python\lib\site-packages\psychopy\contrib\", line 120, in __call__
    return obj(*args, **kwargs)
  File "C:\Users\marku\Downloads\Test_Python_365_64\Portable Python 3.6.5 x64 R2\App\Python\lib\site-packages\psychopy\visual\textbox\", line 384, in __init__
    self._font_name, self._font_size, self._bold, self._italic, self._dpi)
  File "C:\Users\marku\Downloads\Test_Python_365_64\Portable Python 3.6.5 x64 R2\App\Python\lib\site-packages\psychopy\visual\textbox\", line 220, in getGLFont
  File "C:\Users\marku\Downloads\Test_Python_365_64\Portable Python 3.6.5 x64 R2\App\Python\lib\site-packages\psychopy\visual\textbox\", line 390, in createFontAtlas
    face.load_char(uchar, FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT)
  File "C:\Users\marku\Downloads\Test_Python_365_64\Portable Python 3.6.5 x64 R2\App\Python\lib\site-packages\freetype\", line 1455, in load_char
    if error: raise FT_Exception( error )
freetype.ft_errors.FT_Exception: FT_Exception:  (unknown error)

Steps to reproduce:
I am using portable python ( Download Portable Python from
Portable Python 3.6.5 Basic R2 → This will work
Portable Python 3.6.5 Basic (x64) R2 → Will not work

After downloading and unpacking python, I am running the following commands to configure my python environment
python -m pip install --upgrade pip
python -m pip install wheel
python -m pip install psychopy

… In the 32bit version there seems to be an odd pip problem where the freetype dll is not in the site-packages folder, if that happens I add it manually.

I will get this error on 64, but not the 32bit version running this script:

import psychopy.visual as psypy
textstimlike=psypy.TextBox(window=win, text='This textbox looks most like a textstim.', font_size=18, font_color=[-1,-1,1], color_space='rgb', size=(1.8,.1), pos=(0.0,.5), units='norm')
input("Press Enter to continue...")

This exception appears to be occurring from within the freetype package. Are you sure that the 64bit Python env is using a 64 bit version of the freetype.dll?

A couple weeks ago I noticed a similar issue for a specific font file & glyph combo. A patch was added to the textbox source so that it skips over any chars that raise this expection within the freetype package.

You may want to try getting the latest psychopy release source, install that, and try running it again.

Perhaps the reason for the difference between environments is from a different font file is being used in the 32 bit env. vs the 64 bit env. To see what font name is being used for the textbox, try adding this line after you create the textbox stim:

print("font name:",textstimlike._font_name)

Thank you.

Installing the latest version on GitHub solves the problem.