Do you want to put the Japanese text in blender? (with Tkinter)

Hi,
This script is a input helper script for Text object(It uses Tk widget, “Tkinter”)
It can input unicode text,Japanese Kanji,Katakana,Hiragana,
also French , German , Chinese , Korean ,Cyrillic…


http://www.vimeo.com/1568245

Blender 2.40 (or higher version) supports unicode text (text object), but there is no relation to input method like M$-IME.
Before,a way to input Japanese,it uses saved textfile(utf-8 encoded) and “insert text” button. Just like this;
http://blenderartists.org/forum/showthread.php?t=80247&highlight=Japanese

I want to edit a text more directly, so I written it.
pyhon supports unicode text too (2.4x) and ready to use Tk widget set(also Tk supports Unicode input/edit).so I decide to use python.

Ver 0.09 python script;
http://www.rock.sannet.ne.jp/lab1092/data/bl2unitxt3d.py
PDF doc( for 0.001)
http://www.rock.sannet.ne.jp/lab1092/data/bl2unitxt3d.pdf

It supports
Blender 2.40-2.46
Python 2.5,Tkinter(You must install full-set-install)
Linux with SCIM and GTK (or KDE?)
Windows 2000(SP4)/XP/Vista SP1 (If you not apply SP1 yet,this script may not be able to handle M$-IME from this)

this script still have some problem:
1.Tkinter seems that it supports RTL( Right-To-Left: like arabic , old Japanese), But Blender does not Support this.
2.Blender stopped when grub text3d objects ,create it. This happens more often at handling many words.
3.Some Language can’t output on my console (cmd.exe:CP932)…
and(I need a help)…
a.Can this script run on OS X?
b.I don’t know how to input Other language on Other OS.
c.I want to decolate 3Dtext with materials, What Blender API can I use?
d.You need ‘International’ font,but these fonts are huge size.
e.Blender’s text editor doesn’t support Japanese and other Language.

Thanks

Have you got any experience in C? it would be good to allow Python/Blender to draw international fonts rather then just the bitmap ones.

hi ideasman42,
thanks for your comments.

Have you got any experience in C?

in C? it means add this function into Blender?

Its alredy in blender as far as I know, but python cant print unicode text - using Blender.Draw.Text()

Hi,
There are some update.

1.Edit area changed. Entry -> Text ( 1line -> Muitiline ):slight_smile:
2.Logging
3.Document update

@ideasman42

but python cant print unicode text - using Blender.Draw.Text()

I tried follow code, it coudn’t display Japanese text correctly. Where is wrong?


# coding:utf-8
import Blender
from Blender.BGL import *
from Blender import Draw

title = "Japanese string display test(can't display)"
japanese_text = u"ABC 日本語 あいう UTF-8"
brownfox ="The quick brown fox jumps over the lazy dog."
quitting = " Press ESC or q to quit."
len1 = Draw.GetStringWidth(title)
len2 = Draw.GetStringWidth(instructions + quitting)
#
def show_win():
  glClearColor(.01,.01,.01,1)
  glClear(GL_COLOR_BUFFER_BIT)
  glColor3f(1,1,1)
  glRasterPos2i(10,100)
  Draw.Text(title)
  glRasterPos2i(10,80)
  Draw.Text(brownfox)
  glRasterPos2i(10,60)
  Draw.Text(japanese_text)
  glRasterPos2i(10,40)
  Draw.Text(quitting)
  glEnd()
#
def ev(evt, val):
  if evt == Draw.ESCKEY or evt == Draw.QKEY:
    Draw.Exit()
  elif not val: return
  Draw.Redraw(1) 
#
Draw.Register(show_win, ev, None)

Thanks.

update :smiley:
Ver 0.09 python script;
http://www.rock.sannet.ne.jp/lab1092/data/bl2unitxt3d.py

Hi ,

here is a sample .blend file.
http://www.rock.sannet.ne.jp/lab1092/bl2unitxt3d.html

I think this script can input other Language too,because this uses string as “unicode”.

thanks.

It’s bad news for Windows vista user(it might be very little problem for this community).

I could’t input Kanji character to textbox using this script from keyboard when M$-IME was active on Vista,It cant handle IME.
but input from tablet(pen-writing) is ok,and I could input Kanji to IDLE textbox using Keyboard, too.

I can’t quite understand these defference.:no:
please help…

I think that It relate to Vista (and tkinter), not blender.
but a few person who use this script must be “blenderhead”:cool:

Thanks

Hi,

Update(Sorry it is only some info, I did not change/improve this script for a while.)

It can handle M$-IME on Vista SP1.
I checked if it can run at Blender 2.46. - it’s working!!
It support French,German,Japanese,Chinese,Koeran,Cyrillic…
I made a video
http://www.vimeo.com/1568245

Ver 0.09 python script;
http://www.rock.sannet.ne.jp/lab1092/data/bl2unitxt3d.py

It supports
Blender 2.40-2.46
Python 2.5,Tkinter(You must install full-set-install)
Linux with SCIM and GTK (or KDE?)
Windows 2000(SP4)/XP/Vista SP1 (If you not apply SP1 yet,this script may not be able to handle M$-IME from this)

this script still have some problem:
1.Tkinter seems that it supports RTL( Right-To-Left: like arabic , old Japanese), But Blender does not Support this.
2.Blender stopped when grub text3d objects ,create it. This happens more often at handling many words.
3.Some Language can’t output on my console (cmd.exe:CP932)…
and(I need a help)…
a.Can this script run on OS X?
b.I don’t know how to input Other language on Other OS.
c.I want to decolate 3Dtext with materials, What Blender API can I use?
d.You need ‘International’ font,but these fonts are huge size.
e.Blender’s text editor doesn’t support Japanese and other Language.

Thanks

hello manda,
i also tryed to write a chinese text inside the blender text…cant seme to make it work on my windows…did you manage to find out how to do this?

Hi Manda

I see the text above the 3D text in that screenshot (the lines that reads “text”, “text”, “ooiee”, up to “Python 2.5.1” and the other blue texts) and I was wondering if you could help me in http://blenderartists.org/forum/showthread.php?t=140855 if it is what I think it is, a bitmap text.

Anyway, nice contribution. It’s a shame that I’m using Blender 2.48a though. Thanks.

I wrote some lines to use unicode object on my script for non ascii text,instead to string object.
because blender treat text as unicode.

I did change default encode( in python scripting) , and use some tricks:)

  1. Change default encoding to “utf-8”,because blender can’t handle other encodings , like “shift-jis” and “euc-jp”.I wrote two lines in “sitecustomize.py”
import sys
sys.setdefaultencoding("utf-8")

  1. add a header in my script , python can recognize encoding in script.
#!BPY
# coding: utf-8

I hope this helps you:)

Hello Manda ^^

I read your all message.
I think your script is not working in Mac OS X.
I am using PowerMac Dual 2.0G and Blender 2.48a.
Could you tell me website where I can download script for Mac OS X?