Howdy, Stranger!

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

Supported by

[open] Farsi fonts display

edited April 2013 in OpenSesame

I am using the latest version of OpenSesame. I need to have both the instructions and the word stimuli in Farsi. The Farsi font is selected in the relevant combo box but the outcome is squares instead of letters. In addition, after trying different Arabic fonts, The letters are showed detached but not continues and from the left to right.
Any advice is much appreciated.


  • edited 9:28AM

    Regarding the showing of squares instead of characters, Lotje's explanation from this discussion should work in principle. Could you be more specific as to what happens exactly? Do you see boxes in the GUI as well, or just during the experiment? What back-end are you using? And are you sure the selected font contains Farsi characters?

    Regarding the direction of writing, OpenSesame does indeed not take into account the correct direction. Please see this discussion for a script-based workaround:


  • edited 9:28AM

    Thanks !The inline script works well. The direction is corrected now but the fonts are displayed in capital letters. As you may know, in Farsi, like Arabic, the letters are continues and small. Do you think if this could be fixed too?

  • edited April 2013

    Hi Masoud,

    I'm afraid that I cannot offer much help here, as my understanding of non-western alphabets is essentially zero. I can blindly manipulate text strings (such as reversing them), but I have no idea whether the outcome makes sense.

    Edit: This suggests that rendering Arabic fonts with PyGame is inherently problematic. However, they also provide a link to another library, which may be worth checking out.

    Perhaps you could experiment a bit with the PyGame font rendering (which is what is used for the legacy and xpyriment back-ends), to see whether you can get things to display properly this way? If you succeed, you can share your findings here, and I can hopefully use this to improve this aspect of OpenSesame. For example, the script below (assuming the legacy back-end) shows a simple string of text using the PyGame functions directly:

    import pygame
    fontSize = 24
    fontColor = 255, 255, 255 # White
    fontAntiAlias = True # Fuzzy edges
    # Get the full path to the font
    fontPath = pygame.font.match_font('Times New Roman')
    # Create a font object
    font = pygame.font.Font(fontPath, fontSize)
    # Render some text onto a surface
    surf = font.render('Some text', fontAntiAlias, fontColor)
    # Paste the surface onto the window (i.e. the screen)
    win.blit(surf, (0,0))
    # Update the screen!

    See also


Sign In or Register to comment.