Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Font size is smaller when experiment is run

edited January 2015 in OpenSesame

I use a sketchpad to display a background image and some textual descriptions on top of it. It all looks nice in the development window, but once I actually run the experiment, all the text is smaller. The text fields appear at the correct location, but do not extend to same place to the right and to the bottom as they should. Is there a way to fix this issue?

I'm on Ubuntu 14.10, using the DejaVu Sans font (I need special characters from it) with the Expyriment back-end since I definitely care about millisecond precision. I tried changing the back-ends just to see if this issue will go away, but I couldn't run any of the other back-ends. The PsychoPy back-end showed an error associated with audio and Legacy could not find the DejaVu Sans.ttf file. In any case, I'd like to resolve the issue and stick to Expyriment.

Any hints are much appreciated.

Comments

  • edited 10:33PM

    Hi,

    This is indeed a small bug: In the GUI the font size is specified in points, but during the experiment it is specified in pixels, as it should be.

    This is just a visual glitch, so you can safely ignore the fact that the GUI shows the font to be slightly larger (on most systems) than it should be.

    Legacy could not find the DejaVu Sans.ttf file

    Could you provide some more info? What exactly did you do, and where did you place the font file?

    Cheers,
    Sebastiaan

  • edited 10:33PM

    Hi Sebastiaan

    Thanks for looking into this.

    Do you know if you'll be releasing a fix for this bug with the next maintenance release and if so when might that be? In my particular case, I need to carefully position some text and visual elements with respect to each other. It's quite hard to do so as I have to run the experiment over and over again just to see if things are at the right place, so I would really appreciate the ability to this in the GUI.

    I haven't really done anything special for the fonts. The font file is in the default location in Ubuntu (/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf). I just selected "DejaVu Sans" in the general properties of my experiment, and it worked without a hitch with Expyriment. If I change the back-end to legacy in the general properties tab, I get this error message:

    Unexpected error
    line: 423
    exception message: The resource 'DejaVu Sans.ttf' could not be found in libopensesame.experiment.resource()
    exception type: Exception
    
    Traceback (also in debug window):
      File "/usr/lib/pymodules/python2.7/libqtopensesame/misc/process.py", line 139, in run
        exp.run()
      File "/usr/lib/pymodules/python2.7/libopensesame/experiment.py", line 335, in run
        self.init_display()
      File "/usr/lib/pymodules/python2.7/libopensesame/experiment.py", line 690, in init_display
        canvas.init_display(self)
      File "/usr/lib/pymodules/python2.7/openexp/canvas.py", line 66, in init_display
        mod.init_display(experiment)
      File "/usr/lib/pymodules/python2.7/openexp/_canvas/legacy.py", line 317, in init_display
        u"%s.ttf" % experiment.font_family), experiment.font_size)
      File "/usr/lib/pymodules/python2.7/libopensesame/experiment.py", line 423, in resource
        % name)
    Exception: The resource 'DejaVu Sans.ttf' could not be found in libopensesame.experiment.resource()
    

    It seems like OpenSesame is trying to use the wrong file name (has an extra space). Is there something special that needs to be done before that font works with Legacy? In any case, as I mentioned I don't really want to use Legacy, but I'm willing to help diagnose this problem if you wish.

    Cheers,
    Mitko

  • edited 10:33PM

    Thanks for the error message. That does indeed look like another font-related bug.

    I will include these fixes in 2.9.3, which I'll probably release somewhere in the next few weeks. These are actually the first new bugs that have been reported, and I generally wait until there's a bit more before building a new release. If you want to fix the size issue before then, you consider grabbing the latest snapshot from GitHub (the heisenberg branch). Even just replacing your libqtopensesame/misc/sketchpad_canvas.pyc with the updated file should do the trick:

    Cheers!
    Sebastiaan

  • edited 10:33PM

    Hi Sebastiaan,

    Thank you very much for the suggested fix. I replaced the python files and now the disparity between the GUI and the running experiment is greatly reduced. The current state is sufficient for my needs. :)

    In case you want to dig deeper into this to achieve a perfect match between the sketchpad GUI and the rendering during a run, have a look at this image to see the differences that I am currently seeing:

    The part on the top is the GUI and the one on the bottom is the running experiment in a window (running in a full screen has the same issue).

    The little red lines are sketchpad arrows and as you can see, they are identically positioned in both cases. Relative to them, the text position/size does not quite match. I hope this helps.

    Thanks for your support.

    Cheers,
    Mitko

  • edited 10:33PM

    Hi Mitko,

    The GUI uses a different font engine than the back-ends, each of which in turn renders text slightly differently. I just tried it with a few different fonts, and, indeed, for some reason Deja Vu Sans is rendered much narrower during the experiment than in the GUI. Much more so than other fonts, which is weird. But as far as I can tell, it's a genuine difference between the font engines.

    Cheers,
    Sebastiaan

Sign In or Register to comment.