[tuhopuu-devel] Tech readme on the sourcecode for MultiLanguage Blender.

Rob Haarsma tuhopuu-devel@blender.org
Fri, 04 Apr 2003 00:38:13 +0200


Hey All,

I have committed all nescessary changes for a multilanguage Blender
(for windows!) to the Tuhopuu tree. It works really well and altough
there are some issues, I think it can be added to bf real soon. This
readme is meant for everyone interested in the new font and language
features, but mostly it's written for the volunteers that'll try to
build the stuff on other platforms. (warning: looooong text)

Shizu's patch added ttf Fonts and Language options to Blender, but to
create the right environment he used external files as .blocale and
boot*.bat to make it work. Which means that if you wanted to change
the font and/or language, you had to quit Blender, edit these files
and restart.

I've put a lot of effort in rewriting Shizu's patch, and now the user
is able to switch Font and Language settings on-the-fly. This wasn't
easy because the gettext and iconv translation libraries depend on
the system environment variable LANG (LANG=en), which isn't common for
every platform. (at least, it was missing on my winbox)
For details and adapting the LANG setting for other platforms, check
the file FTF_TTFont.cpp in source/blender/ftfont/intern. I have also
comitted Shizu's original files to Tuhopuu, so you can investigate
the diff for both techniques.

The current implementation replaces the four standard bitmap fonts with
one freetype font. This means all texts in the interface have the same
size. However the new settings (including the fontsize) can be changed
through the newly enhanced userpreference window:
http://www.tncci.com/transopts.jpg

All modifications committed to Tuhopuu are hidden behind the compileflag
INTERNATIONAL. Adding the new FTF_DrawString routine implied not only to
check if the freetype rendering is available, but also if a translation
is requested. To give you an idea, the original BMF_Drawstring function
is currently replaced by:
#ifdef INTERNATIONAL
if(G.ui_international == TRUE)
	if(U.transopts & TR_BUTTONS)	// TRANSLATE BUTTON TEXTS
		FTF_DrawString(but->drawstr+but->ofs, FTF_USE_GETTEXT | FTF_INPUT_UTF8);
	else
		FTF_DrawString(but->drawstr+but->ofs, FTF_NO_TRANSCONV | FTF_INPUT_UTF8);
else
	BMF_DrawString(but->font, but->drawstr+but->ofs);
#else
BMF_DrawString(but->font, but->drawstr+but->ofs);
#endif

I had rather integrated the FTF calls into the original BM api, but
on the other hand, spamming the sourcecode with this construction was
much easier and faster (for me) and also allows 'per item' translation.

There are some loose ends at the moment. The code works and even allows
the user to SAVE the USER SETTINGS, but this has to be tweaked when a
version change will occur and requires a correct path to the font files
in the userpreferences. Another issue is the Encoding popup in the
userpreference window. This button allows different text encodings but
a) this option doesn't change anything on my computer, and b) I really
have no clue on what it's supposed to do. Any expert on this subject is
welcome to figure it out.

Another issue is the incorrect font rendering:
http://www.tncci.com/drawerror.jpg
Although Ton was a great help and almost everything looks fine now,
there are a few locations in the interface where the font is still
rendered with errors. I have contacted the author of the FTGL library,
and hopefully a solution for this prob will come up in the near future.

Okay then ! Now its time for the volunteers to get it to work on other
platforms. The sourcecode for the libraries (yes, 4 new dependancies !)
can be found here:

GNU gettext and iconv: http://www.gnu.org

Freetype2: http://www.freetype.org

FTGL: http://www.tncci.com/FTGL
(Shizu patched FTGL to work correctly with japanese characters, the
original files can be found at

For windows I have added the precompiled libraries to bf-blender, and
to Tuhopuu i added the appropriate projectfiles. This means that win
users have to checkout the lib/windows directory from bf to get the
libraries required for the Tuhopuu build. Or they can delete the
'INTERNATIONAL' flag in the BL_src, blendercreator and FTF_ftfont
project settings.

That's all.
Let me end with saying that none of my commits are sacred, and that
anyone with more insight is invited to make any adjustment to the code.

Seeya' !


Rob.