Howdy, Stranger!

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

Supported by

rendering unicode symbols in sketchpad

edited August 2017 in OpenSesame

Hi all,

I need to render these 4 unicode symbols (or similar ones) in a sketchpad: a black circle, a star, a square, and a different start.

for example, in python I can use:
print(u'\u25CF')
for the black circle

However, when I try to represent a Unicode symbol (both loaded from a variable or a csv file) in a sketchpad it is not rendered correctly and I get always an empty square (something like []) indicating a problem in the encoding. I’ve tried to set the font to: mono, serif, arial, …

For example, if I put this line in the preparation phase of a inline script before the sketchpad (that has [mytext] as a pointer for the variable):

exp.set("mytext", u'\u25CF')

I get the empty square rendered in the sketchpad.

The only case that is working, is when I add the special characters in openoffice (openOffice>Insert>Special Character> Wingdings) as wingdings and then I set the sketchpad font to wingdings. Unfortunately, this generates a very "unstable" csv file: sometimes the changes stay, sometimes they disappear… a big mess!

Any solution? Of course, I could generate 4 images with these symbols, but I’m surprised that opensesame cannot render it correctly.

Thanks a lot for your help!

Best,

Diego

Comments

  • Hi Diego,

    Unicode is a standard that describes which visual characters correspond to which character codes. So it refers to something very specific, and not just to anything that is not a regular ASCII character.

    WingDings is not a Unicode font, which means that a character that is (say) a star with WingDings is something completely different with another font (or perhaps even undefined, in which case you get an empty square, a question mark, or some other placeholder character). Does that make sense?

    To be honest, I'm not entirely sure what happens if you try to use WingDings in OpenSesame. But I wouldn't go there, and just use bitmaps.

    Cheers,
    Sebastiaan

  • Hi Sebastiaan,

    the problem is that even using Unicode fonts (like u'\u25CF') gives me the same problem. I was using Wingdings as a possible solution to that.

    Cheers,

    Diego

  • edited August 2017

    Hi Diego,

    Right, 0x25CF is indeed a valid Unicode character (a filled circle). If you enter this into a sketchpad, for example by entering it as Python expression, and select a font that actually contains this character, then you will see it.

    If you don't see it, this means that the selected font simply doesn't contain the character. Most modern programs deal with this by falling back to another font that does contain the character, so you don't notice this. But the current font renderer used by OpenSesame doesn't do this. Does that make sense?

    So you need to specify a valid Unicode character and select a font that actually contains this character—that's all. In the case of the black circle, it is defined for example in Arial.

    Cheers,
    Sebastiaan

  • That's cool!

    Last question: if I want to pass the unicode value using a variable created in a previous inline script like:

    exp.set("mysymbol", u'\u25CF' ")

    if in the sketchpad I use the variable pointer [mysymbol], it will print on the screen just the code u'\u25CF' (without interpreting it). What am I doing wrong?

    Cheers,

    Diego

  • Your example is not syntactically valid Python, but if you fix the quotes it should work just fine. By the way, are you running an up-to-date version of OpenSesame? I'm asking because the exp.set() method of setting variables has been deprecated for a while now. (If not, I would update.)

    This should do the trick:

    var.mysymbol = u'\u25CF'
    
  • Awesome, thanks a lot!

    Yes, I'm using an old version because I know it works just fine. :)

    Thanks a lot for your help

    Diego

Sign In or Register to comment.