# How to display stimuli in Thai?

**URL:** <https://discourse.psychopy.org/t/how-to-display-stimuli-in-thai/24074>\
**Category:** Builder\
**Tags:** textbox\
**Created:** [July 16, 2021, 9:31am UTC](https://discourse.psychopy.org/t/how-to-display-stimuli-in-thai/24074 "2021-07-16T09:31:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 16, 2021, 9:31am UTC](https://discourse.psychopy.org/t/how-to-display-stimuli-in-thai/24074/1 "2021-07-16T09:31:07Z")

</div>

PsychoPy version 2021. 1.4)

What are you trying to achieve?:

I have constructed a fairly simple experiment involving the presentation of text stimuli (single words) with a rating task. The experiment has X number of trials per block for a total of 3 blocks. Everything is now working but I recently changed the text stimuli from English words to Thai words (in the Excel file) and then came across a coding problem. The experiment starts ok but stops just before the first trial. Everything works perfectly fine when I use English words instead.

I saw others have encountered presentation problems with other languages. Does anyone know a simple solution (I’m still quite a beginner).

**What did you try to make it work?:**  
It works with English words but not with Thai words. With Thai words it stops the experiment.

I tried using the Textbox component as an alternative and it displays square symbols or squares and question makrs when using Thai words. Seems like it could be a font or encoding issue, but not sure how to fix this.

**What specifically went wrong when you tried that?:**

This is the message I get (partial message) when the experiment stops working (using the text box component to display the stimuli):

File “C:\Program Files\PsychoPy3\lib\site-packages\pyglet\font\base.py”, line 394, in get\_glyphs  
self.glyphs[c] = glyph\_renderer.render(c)  
File “C:\Program Files\PsychoPy3\lib\site-packages\pyglet\font\win32.py”, line 432, in render  
ord(text), ord(text), byref(abc)):  
TypeError: ord() expected a character, but string of length 2 found

##### Experiment ended.

Hopefully there’s a simple solution.

Ben

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [July 16, 2021, 12:11pm UTC](https://discourse.psychopy.org/t/how-to-display-stimuli-in-thai/24074/2 "2021-07-16T12:11:11Z")

</div>

Could you post the Thai phrases you’re trying to display? What is the font set to for the text box?

We have tests that we run which make sure a set of phrases work in corresponding fonts - I’ll add this to the test and can then see what’s causing this error 🙂

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 16, 2021, 12:53pm UTC](https://discourse.psychopy.org/t/how-to-display-stimuli-in-thai/24074/3 "2021-07-16T12:53:06Z")

</div>

Thanks a lot. I’m using Arial but tried a few other fonts without success.

This is a list of 10 single word items from one of the blocks:

ธนบัตร  
วิทยุ  
อัลมอลต์  
เสาอากาศ  
แอปเปิ้ล  
ที่เขี่ยบุหรี่  
หน่อไม้ฝรั่ง  
อะโวคาโด  
ขวาน  
ขวดนม

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [July 19, 2021, 11:46am UTC](https://discourse.psychopy.org/t/how-to-display-stimuli-in-thai/24074/4 "2021-07-19T11:46:44Z")

</div>

When I try this, I don’t get any error, but the characters don’t display in Arial - they’re squares instead, as should happen when a font doesn’t have glyphs for a particular character. What happens when you try one of these fonts:

> **[Google Fonts](https://fonts.google.com/?subset=thai)**
>
> Making the web more beautiful, fast, and open through great typography

(you can download and install the fonts, or just refer to them by name and PsychoPy will get them from online)

If my theory is right, these shouldn’t cause an error as they’ll have those characters in their glyph set.

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 20, 2021, 3:33am UTC](https://discourse.psychopy.org/t/how-to-display-stimuli-in-thai/24074/5 "2021-07-20T03:33:49Z")

</div>

Brilliant! It works. I can also confirm that it works both ways as well: download and install the font or just type in the name of a preferred font from the google directory.

The next step is to get the experiment online.

For future reference, it only works with the textbox component (not with text).
