Vizard 7 » Reference » 3D models » Text nodes » Unicode text
7.6

Unicode text

Vizard has support for displaying all Unicode characters using UTF-8 encoding. In order to display Unicode text you must first set the encoding of your script to UTF-8 ( File > Encoding > UTF-8 ). You will now be able to type Unicode characters into your script.

 

Vizard uses the Arial font by default. Some languages are not supported by this font and will show up as invalid characters. In this case you can tell Vizard to use a different font by modifying the viz.text.font option. When a new text object is created Vizard will use this option to set the font. If you want to display Japanese text, for example, add the following line to the top of your script:

#Use a font that supports Japanese characters
viz.setOption('viz.text.font','mingliu.ttc')

This will tell Vizard to use MingLiU as the default font for all text objects.

Manually setting text encoding

All text objects will use the default global text encoding. The global text encoding is specified by the viz.text.encoding option in your cfg file. The default behavior of this option is to automatically determine the encoding by checking for a UTF-8 BOM in the main script file. However, a text object can override the global default by using the <text>.setEncoding command:

text = viz.addText('some unicode text')
text.setEncoding(viz.ENCODING_UTF8)

This code will force the text object to use UTF-8 encoding, regardless of the global encoding value.

Right-to-Left languages

Vizard also supports displaying right-to-left languages, like hebrew or arabic. In order to support these languages you need to enable the viz.text.bidirectional option in your cfg file or in your script by using the following code:

viz.setOption('viz.text.bidirectional',1)

When this option is enabled Vizard will automatically perform the Unicode Bidirectional algorithm on the input characters when displaying UTF-8 encoded text.

See also

In this section:

3D text command table

Other sections:

3D model command tables

User interface basics

3D Model basics

Displaying HTML pages

Example scripts:

3D text