Text size and text font changed when the ptb program packaged into exe files

I wrote a program using PTB and I want to package it into a executable file so I can use it easier. However, the packaged exe file doesn’t have the same appearance as the m file directly run in the Matlab. The text size and font look different and weird in the executable file.
Why? Did I miss some files or libs when packaging the m file into the executable file?
Thanks. Best wishes.

Why i don’t know. But have you tried setting the screen font etc in your code at the start of your script? is it still different then?

A reason may well be by the way that the high quality text drawing plugin fails to load when packaged. It has a bunch of dependencies that need to be installed on the system you run it on.

Thank U.
Pity. It doesn’t work. I’ tried as you said, put the font setting sentence

Screen('TextFont', winPtr, 'Arial');
Screen('TextSize', winPtr, round(keyHeight/2));

in the top part of my script which is the initialization period.
And the dependent files which are packaged together in the Matlab are as follows.


I think your opinion is right, dependencies are so complex. Maybe I should ask in the Matlab forum as well.
Thank U!

This isn’t a matlab dependency, but a PTB text drawing plugin dependency. See help DrawTextPlugin.
I think it comes down to needing to have the exact right version of GStreamer installed on the machine you deploy on (so not fully self-contained anymore). At least i hope that may do the trick

You don’t mention OS type and version, Matlab version etc., so i can only guess this is about Windows?

Yes, that list of dependencies misses the drawtext plugin for your operating system itself, which would need to be in the library search path, or in the right folder Psychtoolbox/PsychBasic/PsychPlugins/ inside your package. Also libfontconfig and libfreetype are needed in the library search path. Normally these come with GStreamer, or with GNU/Octave, or maybe some bit even with some Matlab releases.

In any case, we don’t officially support building such .exe’s from Psychtoolbox, so there’s nothing in PTB that would guarantee that this stuff works trouble-free.

On Windows, if the drawtext plugin fails to load / is missing, it would fall back to the old (and officially unsupported in case of trouble!) GDI text renderer, which may or may not be good enough for you. One way out, apart from bundling all needed components for the high quality renderer, would be to use Screen(‘Preference’,‘TextRenderer’, 0) to always use the old GDI renderer, then tweak your Matlab code into shape to display text as you want with that setup, so it looks the same during .exe deployment as during development/testing. As i said, no help or support in case of trouble.

Lastly, if you’d choose a TextFont that isn’t installed on the target machine, the renderer would probably choose a font that is similar, but not identical in appearance.

Thanks. This method works. At least, it looks same in both Matlab and the exe now.
It runs in Windows10 and the Matlab version is r2015b.