PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Font problems

I've been recently having trouble getting fonts working in GD (3.50) and I'm not sure why.

I created a font using FontMaker. Nothing fancy, just a 16-point bold Arial font. The font file is attached.

Here's how I'm using it:
Code:

CGapiBitmapFont* pFont1;
pFont1 = new CGapiBitmapFont(m_pGapiDraw);
pFont1->CreateSurface(NULL, hInst, FNT_FONT1, TEXT("FONTS"));
pFont1->CreateFont(NULL, TRANSPARENT_COLOR, GDCREATEFONT_TRACKING, NULL);

The pFont1->CreateFont call fails, but the return code is not one of the three specified in the docs. Specifically, the result is 2147942487.

HELP!! Thanks! :)
Attachments:
fnt_font1.png
Hi,

I would add something like:

GDFONTFX GDFont;
GDFont.lTracking=1;

CGapiBitmapFont* pFont1;
pFont1 = new CGapiBitmapFont(m_pGapiDraw);
pFont1->CreateSurface(NULL, hInst, FNT_FONT1, TEXT("FONTS"));
pFont1->CreateFont(NULL, TRANSPARENT_COLOR, GDCREATEFONT_TRACKING,&GDFont;);


It worked for me...

Vincent.
Yes indeed, that did the trick! Thank you!

Johan, can you explain why this is? Is it by design? I'm not seeing anything about it in the docs. Is it a bug or just something I didn't know?
Hi Frank,

As PPCStudios always says - Check your return values! :)

Why on earth do you pass the GDCREATEFONT_TRACKING flag when you do not pass a value for tracking? Your font creation fails since the function expects you to also pass a tracking value, as vince_mad showed you.

You could simply remove the GDCREATEFONT_TRACKING flag and it should work as well. All this is well documented.
Johan wrote:As PPCStudios always says - Check your return values! :)


LOL! I was going to say this yesterday, but I figured Frank would slap me! :wink:
I WAS checking the return codes. The value returned was NOT one of the three documented possible return codes.

Your right, it IS documented, and I frankly didn't read carefully enough (I didn't see the important part until I looked again after reading your reply). That is my fault absolutely. But, checking the return codes was no help in this case. I only knew that a failure had occurred with that call, and that's it.
:) Ok, glad to hear that it's solved anyhow!
fzammetti wrote:I WAS checking the return codes. The value returned was NOT one of the three documented possible return codes.


What code did you get back?
2147942487
This error (0x80070057) is defined as E_INVALIDARG in GapiDrawDefines.h :)
That would make sense :)

Johan, documentation update :)