1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

hebrew text

Posted by Guy on Apr 3, 2007

I'm trying to use the text() method to output some hebrew text using the following code, but altough my selected font has proper hebrew characters, the result includes non-hebrew charecters.

I used a textfile to import the text instead of typing it. (they both have the same problem)



Posted by Tom De Smedt on Apr 4, 2007

You need to inform NodeBox that your text includes Unicode characters. To do this, add a "u" in front of the string, like this:

# Sorry I have no idea what this text reads:
str = u"""תמיכת סוריה בטרור"""
align(RIGHT)
text(str, 100, 100, width= 200)


If you're reading text from a file, make sure it is saved in Unicode format. For example, in TextEdit, convert the text to Plain Text in the Format menu, and then when you save it, select Unicode (UTF-8) in the Plain Text Encoding menu.

Then, when you import the file, have NodeBox decode the contents:

str = open("hebrew2.txt").read()
str = str.decode("utf-8")
text(str, 100, 200)


Let me know if that worked for you!