Giter Club home page Giter Club logo

Comments (7)

MichaelWoodc avatar MichaelWoodc commented on June 2, 2024

Is this correct? If not, could you share a rendered example?

image

If this is correct, I think the issue in your case is with pyglet:
Psychopy_video_experiment.venv\lib\site-packages\pyglet\font\win32.py", line 432, in render
ord(text), ord(text), byref(abc)):

The relevant portion:

image
it seems to want only one characters worth of data, in UTF-8, that's, what, one byte? (utf-8 i think 8 stands for the bits, so 1 byte) but it's a multi byte character, I think.

If you have a virtual environment, set it up and go to line 430 in your win32.py file and make it like this:
image
with this one small change everything seems to work fine. (Did that display correctly?) Just add three lines of code and indent the existing. I'm surprised to see this issue in this way. Pyglet can render the text but evidently relies on built in functions which are not setup to handle those characters.

I'm thinking:

  1. The issue is with pyglet's reliance on what eventually leads to a built in function that can't handle that character
  2. changing this one thing in pyglet fixed this issue. I'd change pyglett

from psychopy.

niket-agrawal avatar niket-agrawal commented on June 2, 2024

Hi @MichaelWoodc, amazing. Thanks a lot for your help. Yes I can confirm that it is indeed correct rendering.

word_to_display = "समर्पण" #displays incorrectly, स + म + र + ् + प + ण
word_to_display = "क्षत्रिय" #displays incorrectly, क + ् + ष + त + ् + र + ि + य

However, some more complex Hindi alphabets are still showing up as separate characters instead of coming up as a single glyph.
Some examples are:

  • र + ् + प = र्प
  • क + ् + ष = क्ष

Rendering Hindi can be challenging due to its complex script, where multiple units combine to form a single glyph. The good news is that the program can now render individual characters, a task it was unable to do previously.

from psychopy.

MichaelWoodc avatar MichaelWoodc commented on June 2, 2024

from psychopy.

niket-agrawal avatar niket-agrawal commented on June 2, 2024

Thanks a lot. I tried to play with changing backends,
The experiment does not load with pygame
and the issue is same with your pyglet hack as with glfw

For now we are using images as text stimuli but for eye-tracker and getting character level data, makes those images useless. Interestingly, OpenSesame library worked for us to render stimuli.

Thanks a lot again for your help @MichaelWoodc

from psychopy.

peircej avatar peircej commented on June 2, 2024

Actually, I'm most interested in whether we could solve this with TextBox2 rather than TextStim. TextBox2 is written in-house which means we have complete control over how layout works, so we should be able to apply a fix like this ourselves rather than requesting the fix in pyglet. TextBox2 is also much faster to update text than TextStim.

from psychopy.

niket-agrawal avatar niket-agrawal commented on June 2, 2024

Oh, I wasn't aware of that. I'll try with some stimuli using TextBox2 and provide an update here.

from psychopy.

peircej avatar peircej commented on June 2, 2024

Just to be clear, I'm not thinking that TextBox2 already solves the issue - it needs each character manually laying out by us and i don't think we've handled this issues yet - but on the plus side the code to lay out the printable characters is only 20 lines long and is within our control meaning that a solution like @MichaelWoodc found could be very easy to implement here

from psychopy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.