Font appears completely black

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Font appears completely black

Post by slavik262 »

I've created fonts using the advanced font tool, but the characters always appear completely black, regardless of what colors I use.

Any ideas what could be happening?
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

The font tool create an image at the desired size ? It's seem strange but if I get you it's like only alpha channel is working .
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Yes, the font image looks perfect, but when I load it into Irrlicht, it only gives respect to alpha, like you said. Every character is completely black.
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

I thinked about it and really have no idea. Maybe you should try to create a small project just drawing font character to be sure that it's not linked with an error elsewhere.
Dareltibus
Posts: 115
Joined: Mon May 17, 2010 7:42 am

Post by Dareltibus »

very strange! it always worked for me importing a "font.xml" from the advanced tool. yaeah create a small projects and post to us (and if you don't want to use your font use another font type, if other fonts give you the same result)
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Font image (a PNG):
Image

Code (MSVC 2010, Irrlicht 1.7.1 standard build):

Code: Select all

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace gui;

#pragma comment(lib, "irrlicht.lib")

int main()
{
	SIrrlichtCreationParameters cp;
	cp.AntiAlias = 8;
	cp.Bits = 32;
	cp.DriverType = video::EDT_DIRECT3D9;

	IrrlichtDevice* device = createDeviceEx(cp);

	IVideoDriver* vd = device->getVideoDriver();
	vd->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
	ISceneManager* sm = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();
	guienv->getSkin()->setFont(guienv->getFont("displayfont.png"));
	guienv->addStaticText(L"Woohoo!", rect<s32>(10, 10, 200, 100));

	while(device->run())
	{
			vd->beginScene(true, true, SColor(255, 127, 127, 127));
			guienv->drawAll();
			vd->endScene();
	}
	return 0;
}
Result:
Image
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

slavik262 wrote:

Code: Select all

	guienv->getSkin()->setFont(guienv->getFont("displayfont.png"));
isn't there a xml file creates by the font tool you should load ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

Yes like Acki said your xml file should load the font handling alpha and other purpose.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

You can also export from the font tool a single .png.

Loading an xml font generated from the tool gives the same results. If you don't believe me, I can post another example, but this doesn't seem to be the issue here.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Confirmed. It's happening with an XML font too (same code as above, substituting the png for the appropriate xml file). Plus to make sure it wasn't something I broke, I just did a fresh download of 1.7.1, and the same thing still happens.

Could this be some material thing? I have no idea why this is happening. It's not like I have weird setup either (GTX 260, Windows 7 32-bit, latest drivers).
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

Hi I have TEH clue. After seeing your post I downloaded Irrlicht (what a shame that I didn't have it already and made investigation).

Your text is displaying black cause it's the skin's text color. So to display it at the image just change :

Code: Select all

IGUIStaticText* staticText = guienv->addStaticText(L"Woohoo!", rect<s32>(10, 10, 200, 100));
   staticText->setOverrideColor(SColor(255, 255, 255, 255));
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Awesome! I figured it would be something silly. :oops: Thanks for the help!
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

I was having the same problem and I still have :roll:
The solution worked for textbox, but it didn't work for Button, it has no setOverrideColor function :(
Working on game: Marrbles (Currently stopped).
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Instead of setting the override color, go into the skin your GUI is using and set the color that the text is drawn with.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

Im using advanced font tool, and the letter color is set to gradient, so what am I going to set there ? :/
Working on game: Marrbles (Currently stopped).
Post Reply