Howdy, Stranger!

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

Supported by

[solved] Hebrew Text

edited January 2012 in OpenSesame

Hi to all,

Long time ago I've asked Sebastiaan about writing hebrew, he offered using pics instead of text, that was a helpful idea and I've used it alot.
Since then, the ability of hebrew fonts was added , I tried to use it recently and the letters came out alright but in mirror writing, is there a way to fix that? perhaps an inline code that tells the computer to flip any text?

Thanks in advance.

Ezer

Comments

  • edited January 2013

    Haha, right, that should be more or less fixable using a bit of inline code.

    I'm a bit busy: just arrived in Marseille for a six month visit and in the process of finding a house etc., but I'll check it out and get back to you.

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited April 2013

    If you add the following to the prepare phase of an inline script at the start of your experiment, it should do the trick:

    for item in self.experiment.items.values():
        if item.item_type in ['sketchpad', 'feedback']:
            for element in item.items:
                if 'text' in element:
                    element['text'] = element['text'][::-1]
        elif item.item_type in ['text_input']:
            item._question = item._question[::-1]
        elif item.item_type in ['text_display']:
            item.content = item.content[::-1]
    

    Btw, this trick works only for sketchpad, feedback, text_display, and text_input (question only) items. Because each plug-in is free to store text however it likes, there's no generic method that always works for everything.

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 2:53AM

    This is realy not that important, so enjoying the new city would probably be a better choice, but just to let you know the code you sent makes hebrew text appear as unicode (u+ etc).

    Ezer

  • edited April 2013

    Ow, right! It also reversed the unicode notiation (U+1000 -> 0001+U), which messes things up. This is a slightly more elaborate script, which should preserve Unicode characters:

    from PyQt4.QtCore import QString
    for item in self.experiment.items.values():
        if item.item_type in ['sketchpad', 'feedback']:
            for element in item.items:
                if 'text' in element:
                    s = element['text']
                    s = self.usanitize(QString(self.unsanitize(s)[::-1]))
                    element['text'] = s
        elif item.item_type in ['text_input']:
            s = item._question
            s = self.usanitize(QString(self.unsanitize(s)[::-1]))
            item._question = s
        elif item.item_type in ['text_display']:
            s = item.content
            s = self.usanitize(QString(self.unsanitize(s)[::-1]))
            item.content = s
    

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 2:53AM

    Works like a charm

    Thanks

Sign In or Register to comment.