Copy/paste accent problem in array

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PEIGNAULT Laurent

Hello everybody,

I have a story made with other software (test with excel, textedit, twine…), I’m on Mac.

I copy/paste my story in a array into Godot.
Problems are accents !

When I correct in editor something strange happened :

video here

I don’t know what to do.
I tried to format the story in plein text and past it but doesn’t work either !
I have to manually correct all accents…

If someone have a better solution
Thanks in advance.

Can you show some code what the paste looks like?

wyattb | 2021-06-21 01:49

Sur,

Initial text formatted in excel :
[“D’ailleurs où êtes vous ?”,6,“La porte au fond du couloir”,7,“La porte en bois clair”,4,“La porte sombre”,3,],
[and so on…]

Pasted in Godot:
var story = [“D’ailleurs où êtes vous ?”,6,“La porte au fond du couloir”,7,“La porte en bois clair”,4,“La porte sombre”,3,],

Output in game :
D’ailleurs ou’ e ^tes vous ?

Thanks.

PEIGNAULT Laurent | 2021-06-21 05:22

Does the font used in the project (not the editor) have the required characters? The default project font doesn’t support much outside the plain ASCII range.

Calinou | 2021-06-21 13:03

:bust_in_silhouette: Reply From: Andrew Wilkes

Your problem will be related to the character codes. The basic set is ASCII and uses 1 byte per character as used by the Label Node, but for extended text characters we need multi-byte text which is usually encoded with UTF-8 and used with the Rich Text Label.

And you probably want to install a Font to support the extended characters that you want to display.

I don’t see the problem when I copy/paste your code:

var story = ["D'ailleurs où êtes vous ?",6,"La porte au fond du couloir",7,"La porte en bois clair",4,"La porte sombre",3,]

func _ready() -> void:
	for s in story:
		print(s)

here is the output

--- Debugging process started ---
Godot Engine v3.3.2.stable.official - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce GT 650M OpenGL Engine
OpenGL ES Batching: ON
 
D'ailleurs où êtes vous ?
6
La porte au fond du couloir
7
La porte en bois clair
4
La porte sombre
3

wyattb | 2021-06-21 11:50

Thanks a lot.
It’s already a Rich Text Label.
Here a screen of code / console / game :

PEIGNAULT Laurent | 2021-06-21 13:03

The RichTextLabel has some CustomFonts properties. In the Inspector, you need to set up Dynamic Fonts for at least the Normal Font. This entails creating a Dynamic Font Resource and specifying a .ttf (True Type) Font that you have in your project. You will have to find one on your computer or download one to match the character set that you want. Also, be aware of license conditions for using the fonts in your published work.

Andrew Wilkes | 2021-06-25 10:13

Thanks for replying me, I’m going to try.
I’ll tell you the results.
Have a nice day.

PEIGNAULT Laurent | 2021-06-25 11:05

Hello,
My font is already set dynamically :

$text.add_font_override("normal_font", dynamic_font)

As you said, I try changing the font, and it’s ok, no more spaces or stranges accents.
But…
When I switched to the previous not working font, no more pb too, everything go back to normal… really strange.

Changing the font resolve the pb.
Thanks for your help.

Have a nice day !!

PEIGNAULT Laurent | 2021-07-01 08:07