Page 9 of 13

Posted: Tue Nov 10, 2009 2:21 am
by CuteAlien
Yes, I've updated the gui_freetype_font files recently so they should work now with 1.6

Posted: Tue Nov 10, 2009 10:48 pm
by stefbuet
Well, I tryed you code and I get a runtime error (error repport...) :?

Code: Select all



CGUITTFace face;
face.load("GameData/showcard.ttf");
CGUIFreetypeFont *font=new CGUIFreetypeFont(device->getVideoDriver());
font->grab();
font->attach(&face, 12); //runtime error here
font->AntiAlias=true;



Edit : the error occurs when calling the "attach" function.

Posted: Wed Nov 11, 2009 5:50 am
by CuteAlien
Probably because you allocate face on the stack. Try it with face = new CGUITTFace;

Posted: Wed Nov 11, 2009 11:22 am
by stefbuet
Ok, I made it working.

I had a problem with the attach function call. I was sending the value of my face variable instead of its memory adress. So it's now working, however I got a problem as this is getting more and more time to attach faces to font... Morover there're some bad values comming from getWidth/getHeight functions. All there problems are not in the original version I modified to fit in Irrlicht 1.6 however your version don't make some letters desapearing randomly when using the attach function :shock:
Also my version wasn't making chars desapearing randomly when used with Irrlicht 1.4.2, so there must be something I changed which do that strange stuff.

I'll try to mix both versions :)

EDIT : I think characters are not rendering randomly because of a bug in FreeType.
Thanks.

Posted: Wed Nov 11, 2009 5:30 pm
by CuteAlien
The original version had several memory bugs, so I wouldn't be too surprised on some random behaviour. I don't think I changed the width, but the height is more or less wrong in both versions. My latest workaround does return as height the largest height of any single characters used so far - which is why I initialize in CGUIFreetypeFont::attach a bunch of characters which formerly caused trouble. If some more cause problems please tell me which ones. There is possibly a better solution as TrueType actually knows the correct height itself but I found no way to access it without doing some calculations for which I didn't manage to find all necessary values (but I only invested a few hours before I gave and used my workaround).

edit: If you have an example which compiles and can be used to reproduce any problems ... I'm always glad to get those.

Posted: Wed Nov 11, 2009 6:16 pm
by t0rt0r0
To get memory back you should also remove the textures used to draw the font (tex && tex16 iirc) in the destructor ;)

Posted: Wed Nov 11, 2009 6:52 pm
by CuteAlien
Textures are not grab()'ed so no need to release them. Though they should probably be grab()'ed usually.

Posted: Wed Nov 11, 2009 7:24 pm
by t0rt0r0
I mean by calling driver->removeTexture()
But maybe I'm wrong ;)

Posted: Mon Nov 23, 2009 7:47 am
by Nalin
I have recently gone through and made many changes to CGUITTFont, making it work for Irrlicht 1.6+.

Some changes I have made:
  • Compiles with Irrlicht 1.6 and up (added missing functionality).
  • You can turn hinting on or off.
  • Kerning.
  • Multi-line text.
  • Ability to specify font sizes in pixels or points.
  • Comments to the source files.
  • Various bug fixes.
You can download my changes here:
http://nalin.suckerfree.org/public/code ... _Nalin.zip

Update 11/23/2009:
I fixed a problem where a glyph's true height was not calculated correctly. Also, I added some code to work around Irrlicht's handling of text height. Irrlicht assumes you will be using bitmapped fonts with a set size. FreeType has a set glyph size, but the glyph may hang under the origin, giving it a larger "true" height. This fixes a problem where characters like 'j' and 'g' would get cut off in tooltip text, which calculates the text size based on the single character 'A', instead of the whole text string.

Posted: Tue Nov 24, 2009 4:00 pm
by thespecial1
good work mate, just re enabled freetype with 1.6, had some errors, started to fix and then spotted your post, multi line is especially useful ;0)

Posted: Thu Dec 10, 2009 8:42 am
by CuteAlien
I haven't found time yet to merge Nalin's changes, but I found a bug in my bugfix for the font-heights. I had cached the largest Glyph for a Face instead for the Font - so it was messed up if you used the same Font with different Sizes. An updated version is as usual on my website.

I've also put my fontmanager back on the website, as it allows using fonts easier without the need to patch the engine. So unless you need serialization that is easier to use.

Posted: Thu Dec 10, 2009 2:50 pm
by tinhtoitrangtay
WOW very great
thank CuteAlien i hope next version support font unicode

Posted: Sat Jan 09, 2010 4:18 pm
by Bate
thanks Nalin, looks very nice ingame 8)

Posted: Fri Jan 22, 2010 8:11 pm
by Nalin
I got an e-mail from a Mr. Hong about a crash issue he encountered with my modified class. I have fixed the issue he encountered as well as a separate crash issue and uploaded a fixed version.

The issue Mr. Hong discovered was a crash if you tried to delete a CGUITTFont object. CGUITTGlyph was improperly reference counted. The other issue is if you tried to delete a CGUITTFace object and create a new one (a class static variable wasn't being reset correctly on the first deletion.)

You can download my changes here:
http://nalin.suckerfree.org/public/code ... _Nalin.zip

---

Also, I made a version of my CGUITTFont class that works in conjunction with my UTF-16 string class, which can be found here:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=36406

You can download the class here:
http://nalin.suckerfree.org/public/code ... _Nalin.zip

Basically, this version will allow you to have proper multi-byte character support in Windows.

Posted: Fri Jan 22, 2010 8:50 pm
by Bate

Code: Select all

  myFace = new CGUITTFace;
  myFace->load("data/font.ttf");

  myFont = new CGUITTFont(guienv);
  myFont->attach(myFace, 8, true);
  myFont->AntiAlias    = true;
  myFont->Transparency = true;
  myFont->AutoHinting  = true;
  myFont->FontHinting  = true;

  mySkin->setFont(myFont);

  std::cout << myFont->getReferenceCount() << std::endl; // = 2
  std::cout << myFace->getReferenceCount() << std::endl; // = 1
There is still something mysterious to me :) Is there a reason why the refcount for myFont is 2? So, do I have to drop it twice? Also, "delete myFont" doesn't work for me (delete myFace does). It crashes in

IrrArray.h

Code: Select all

	//! Clears the array and deletes all allocated memory.
	void clear()
	{
		for (u32 i=0; i<used; ++i)
			allocator.destruct(&data[i]); // CRASH HERE

		allocator.deallocate(data); // delete [] data;
		data = 0;
		used = 0;
		allocated = 0;
		is_sorted = true;
	}
or is it my bad?