TrueType font Support by FreeType Library
I don't think so. I have used a few fonts with 12pt (see here: http://www.michaelzeilfelder.de/Pics/fonts.png) and they are fine. But for good results I had to enable antialias and disable the transparency flag. Otherwise they didn't look nice.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 135
- Joined: Thu Oct 30, 2008 11:56 am
- Location: UK
- Contact:
hi guys
I have used your TT library code successfully on win32 in VS2008 and am impressed with how easy that went compared to earlier implementations.
However
when I compile the project on linux (ubuntu intrepid) I am getting some weird errors on make, originally I was getting fails on "sprintf_s is not declared in the current scope", I have fixed this by using a C++ function to print the string. Now I am getting the following and am not sure if the above fix has really sorted out the underlying problem.
anyone else got a similar issue??
I have used your TT library code successfully on win32 in VS2008 and am impressed with how easy that went compared to earlier implementations.
However
when I compile the project on linux (ubuntu intrepid) I am getting some weird errors on make, originally I was getting fails on "sprintf_s is not declared in the current scope", I have fixed this by using a C++ function to print the string. Now I am getting the following and am not sure if the above fix has really sorted out the underlying problem.
Code: Select all
Makefile:29: Building...
g++ -I./include -I/usr/X11R6/include -L/usr/lib/mqsql -lmysqlclient -O2 -ffast-math main.cpp murmuurFX.cpp murmuurGUI.cpp murmuurSQL.cpp murmuurBASE.cpp CGUITTFont.cpp cMirror.cpp -o ./bin/Linux/murmuur -L/usr/X11R6/lib -L./lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11
main.cpp: In function ‘int main()’:
main.cpp:509: warning: deprecated conversion from string constant to ‘char*’
main.cpp:510: warning: deprecated conversion from string constant to ‘char*’
main.cpp:591: warning: deprecated conversion from string constant to ‘char*’
main.cpp:632: warning: deprecated conversion from string constant to ‘char*’
CGUITTFont.cpp: In member function ‘void irr::gui::CGUITTGlyph::cache(irr::u32, FT_FaceRec_*, irr::video::IVideoDriver*)’:
CGUITTFont.cpp:129: error: incompatible types in assignment of ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >’ to ‘irr::c8 [128]’
CGUITTFont.cpp:208: error: incompatible types in assignment of ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >’ to ‘irr::c8 [128]’
make: *** [all_linux] Error 1
Not sure, but I updated now the version on my homepage. It contains a few bugfixes and compiles on a current debian system. Maybe it helps if you compare to that (or just use that version).
http://www.michaelzeilfelder.de/irrlicht.htm#TrueType
http://www.michaelzeilfelder.de/irrlicht.htm#TrueType
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 135
- Joined: Thu Oct 30, 2008 11:56 am
- Location: UK
- Contact:
sweet, thanks for getting back to me, I have had a play with the version on your site, thou I have run into more interesting issues, again fine on win32 but on ubuntu i am getting a different set of errors
am curious thou, I am using freetype v2.3.7 where as you were using an earlier version, do you think that would account for the issues above??
hmmmm
after looking into it abit more (and having the thought that it cant be the wrong version of freetype as this runs fine against the same version on win32) I am wondering if I am missing a library, considering that i have the two packages libfreetype6 and libfreetype6-dev installed via synaptic package manager on ubuntu. Was wondering if their is another package that i need, another possibility is that my make file isnt quite right, I have directly included the freetypelib.a (and checked that is is in /usr/lib) but am not used to these make files as Viz2008 usually shields me from such things.
FIXED, for anyone with the same issue to fix I needed to add -lfreetype onto the end of the CPPFLAGS line of the makefile
Code: Select all
Makefile:26: Building...
g++ -I./include -I/usr/X11R6/include -L/usr/lib/mqsql -lmysqlclient -L/usr/lib/libfreetype.a -O2 -ffast-math main.cpp murmuurFX.cpp murmuurGUI.cpp murmuurSQL.cpp murmuurBASE.cpp gui_freetype_font.cpp cMirror.cpp -o ./bin/Linux/murmuur -L/usr/X11R6/lib -L./lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11
main.cpp: In function ‘int main()’:
main.cpp:509: warning: deprecated conversion from string constant to ‘char*’
main.cpp:600: warning: deprecated conversion from string constant to ‘char*’
main.cpp:641: warning: deprecated conversion from string constant to ‘char*’
/tmp/ccoslGEU.o: In function `CGUITTFace::load(char const*)':
gui_freetype_font.cpp:(.text+0x49f): undefined reference to `FT_New_Face'
gui_freetype_font.cpp:(.text+0x4c6): undefined reference to `FT_Init_FreeType'
/tmp/ccoslGEU.o: In function `CGUITTFace::~CGUITTFace()':
gui_freetype_font.cpp:(.text+0x4f5): undefined reference to `FT_Done_Face'
gui_freetype_font.cpp:(.text+0x51c): undefined reference to `FT_Done_FreeType'
/tmp/ccoslGEU.o: In function `CGUITTFace::~CGUITTFace()':
gui_freetype_font.cpp:(.text+0x585): undefined reference to `FT_Done_Face'
gui_freetype_font.cpp:(.text+0x5ac): undefined reference to `FT_Done_FreeType'
/tmp/ccoslGEU.o: In function `CGUITTFace::~CGUITTFace()':
gui_freetype_font.cpp:(.text+0x605): undefined reference to `FT_Done_Face'
gui_freetype_font.cpp:(.text+0x62c): undefined reference to `FT_Done_FreeType'
/tmp/ccoslGEU.o: In function `CGUITTGlyph::cache(unsigned int, FT_FaceRec_*, irr::video::IVideoDriver*)':
gui_freetype_font.cpp:(.text+0xa4b): undefined reference to `FT_Set_Pixel_Sizes'
gui_freetype_font.cpp:(.text+0xa5c): undefined reference to `FT_Load_Glyph'
gui_freetype_font.cpp:(.text+0xa88): undefined reference to `FT_Load_Glyph'
gui_freetype_font.cpp:(.text+0xcb5): undefined reference to `FT_Render_Glyph'
/tmp/ccoslGEU.o: In function `CGUIFreetypeFont::getGlyphByChar(wchar_t) const':
gui_freetype_font.cpp:(.text+0xf3d): undefined reference to `FT_Get_Char_Index'
collect2: ld returned 1 exit status
make: *** [all_linux] Error 1
hmmmm
after looking into it abit more (and having the thought that it cant be the wrong version of freetype as this runs fine against the same version on win32) I am wondering if I am missing a library, considering that i have the two packages libfreetype6 and libfreetype6-dev installed via synaptic package manager on ubuntu. Was wondering if their is another package that i need, another possibility is that my make file isnt quite right, I have directly included the freetypelib.a (and checked that is is in /usr/lib) but am not used to these make files as Viz2008 usually shields me from such things.
Code: Select all
Target = murmuur
Sources = main.cpp murmuurFX.cpp murmuurGUI.cpp murmuurSQL.cpp murmuurBASE.cpp gui_freetype_font.cpp cMirror.cpp
# general compiler settings
CPPFLAGS = -I./include -I/usr/X11R6/include -L/usr/lib/mqsql -lmysqlclient -L/usr/lib/libfreetype.a
CXXFLAGS = -O2 -ffast-math
#CXXFLAGS = -g -Wall
#default target is Linux
all: all_linux
ifeq ($(HOSTTYPE), x86_64)
LIBSELECT=64
endif
# target specific settings
all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L./lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11
all_linux clean_linux: SYSTEM=Linux
all_win32: LDFLAGS = -L./lib/Win32-gcc -lIrrlicht -lopengl32 -lm
all_win32 clean_win32: SYSTEM=Win32-gcc
all_win32 clean_win32: SUF=.exe
# name of the binary - only valid for targets which set SYSTEM
DESTPATH = ./bin/$(SYSTEM)/$(Target)$(SUF)
all_linux all_win32:
$(warning Building...)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS)
clean: clean_linux clean_win32
$(warning Cleaning...)
clean_linux clean_win32:
@$(RM) $(DESTPATH)
.PHONY: all all_win32 clean clean_linux clean_win32
-
- Posts: 135
- Joined: Thu Oct 30, 2008 11:56 am
- Location: UK
- Contact:
i have a new question however, while it is perfectly clear how to make the GUI elements use the TTFont I am struggling to get font output to display alongside the meshes.
I have tried to use addBillboardTextSceneNode, which does compile but crashes the program.
I have also tried to use font->print which does compile but isnt printing anything, besides I really need text as a node so that i can manipulate it.
ideazz anyone?
I have tried to use addBillboardTextSceneNode, which does compile but crashes the program.
I have also tried to use font->print which does compile but isnt printing anything, besides I really need text as a node so that i can manipulate it.
ideazz anyone?
Does it also crash if you use one of the usual bitmap fonts?
In that case you should create an own forum thread for that problem. Anyway - we usually can't help fixing crashes without seeing some source.
There is a textscenenode - it sounds like you want to use that one.
In that case you should create an own forum thread for that problem. Anyway - we usually can't help fixing crashes without seeing some source.
There is a textscenenode - it sounds like you want to use that one.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Great work, thx
But i had problems with either memory leaks (not calling drop on the fonts) or exceptions (calling drop on every font).
Here's the code that produced it:
And freeing everything:
The problem was, that you need to call "drop" for a font, but the font manager "forgot" to call "grab()" on a font when it was already there.
I changed (in gui_font_factory.cpp):
to:
and everything works fine!
Hope that helps
lg
Fice
But i had problems with either memory leaks (not calling drop on the fonts) or exceptions (calling drop on every font).
Here's the code that produced it:
Code: Select all
irr::core::stringc str = fontFactory.makeFontName(TrueTypeFontParameters(L"./data/ariblk.ttf", 12, true, true));
irr::gui::IGUIFont* fontDefault = fontFactory.addGUIFont(str.c_str());
g_guienv->getSkin()->setFont(fontDefault, irr::gui::EGDF_DEFAULT);
str = fontFactory.makeFontName(TrueTypeFontParameters(L"./data/ariblk.ttf", 12, true, true));
irr::gui::IGUIFont* fontWindow = fontFactory.addGUIFont(str.c_str());
g_guienv->getSkin()->setFont(fontWindow, irr::gui::EGDF_WINDOW);
Code: Select all
SAFE_DROP(fontDefault);
SAFE_DROP(fontWindow);
I changed (in gui_font_factory.cpp):
Code: Select all
if (itFont != mFontMap.end() )
return itFont->second;
Code: Select all
if (itFont != mFontMap.end() ) {
itFont->second->grab();
return itFont->second;
}
Hope that helps
lg
Fice
Hm, I wont guarantee it, but I don't think that change is necessary. You should never call "drop" in Irrlicht for objects which you got by "add". You only call "drop" for objects which got from a "create" function or if you made a "grab" yourself. "add" basically means that it is handled by the manager and he drops all the object when he closes down.Fice wrote: The problem was, that you need to call "drop" for a font, but the font manager "forgot" to call "grab()" on a font when it was already there.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Do you have some small example where the memory leak can be reproduced? I did run some tests in valgrind yesterday, but I couldn't produce any leaks so far.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
I've been using CuteAlien's version of this and everything works great, except for the dot character. I can't get it to output in any font.
Any ideas on what could be going wrong?
EDIT: So, while I was trying to change something else I noticed this in line 466:
I removed the -1 part, and now the dots appear correctly. I just wonder if this will screw up something else in the code. So far everything has been working fine.
Any ideas on what could be going wrong?
EDIT: So, while I was trying to change something else I noticed this in line 466:
Code: Select all
core::rect<s32>(0,0,imgw-1,imgh-1),
Code: Select all
gui::CGUITTFace face;
face.load("arial.ttf");
gui::CGUITTFont font(driver);
font.attach(&face, 12);
guiEnv->getSkin()->setFont(&font);
Code: Select all
Glyphs.reallocate(tt_face->face->num_glyphs);
@knuck: Thanks, that looks like a good change. As Irrlicht is usually using units and not pixels to describe rects your solution sounds correct to me. I've updated my patch.
@Jookia: Maybe "face" is going out of scope?
But also the font-interface has changed some more in the meantime. I plan to make adding ttf easier soon, but so far I haven't found time for that.
@Jookia: Maybe "face" is going out of scope?
But also the font-interface has changed some more in the meantime. I plan to make adding ttf easier soon, but so far I haven't found time for that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm