neuropsychology/Neuropsydia.py

Korean characters are not showing when using instruction, write.py

nuunuu opened this issue · 14 comments

In fact, all functions including text does not show any Korean characters.
I think it is similar issues with the Chinese characters does not show.
I hope you to give options to choose font not only in choice.py but also every functions including text such as instruction, write, questionnaire.

And I also find out choices_style=' font.ttf' does not work in Korean font.

@LeoDutriaux Any idea if that's possible to address?

Hi,
Sorry for the delay, I guess it's too late, but in case of somebody read it. There are different thing that you can do to solve the problem:

  1. change both choices_style and title_style of the choice() function with the name of your font (e.g., font.ttf)
  2. check that your font file is in the same folder as your python script. If not, you can put the path of the font in choices_style and title_style instead.
  3. If none this doesn't work, I have added a new argument in all the function involving text: characters. If characters = 'cjk', then the function will use a font supporting a varieties of non-latin characters.

Hi @LeoDutriaux,

I tried to add the Chinese characters to my instructions, as below:

n.instructions("你好 In this task, you will be presented with different images and your task is to rate how intense your feeling is when you see the images.", non_latin=True)

However, it doesn't seem to work yet
test n instructions()

Hi @Tam-Pham ,
I just tried the exact same command on my computer and it works fine.
Is the problem only with instructions or with write too for instance?

From your screenshot it looks like instructions used 'RobotoBlack.ttf' or 'RobotoBold.ttf' for the font of the text, which is weird as it should use 'RobotoRegular.ttf' by default, I'm not sure where it could come from...

maybe the font has not been properly downloaded? @Tam-Pham could you check if the font has been downloaded and is in the package (python/site-packages/etc)

You're right @DominiqueMakowski , the fonts are not downloading from github. Maybe because they are too heavy (16MB each, and they are 4)? Any other idea why?

hold on, is the format of the font ttf? It seems like all extra-code stuff that has to be imported with the package has to be specified here:

Neuropsydia.py/setup.py

Lines 20 to 23 in 5cad4a3

package_data = {
"neuropsydia.files.font":["*.ttf"],
"neuropsydia.files.binary":["*.png"],
"neuropsydia.files.logo":["*.png"]},

That was indeed the problem, it should work now!

UPDATE: the non_latin argument is now obsolete. Please use characters = 'cjk' instead if you want to use chinese, japanese, or korean characters.This will allow the implementation of other writing systems in the futur.

Can we close the issue?

It works perfectly now!

image

Much thanks, Leo!

Great! How the style of the font looks like to you? Does it look cool? Formal?
The other option would be this one https://www.google.com/get/noto/#serif-hant
What do you think?