PocketMatrix forums

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

CreateFont() returns E_INVALIDARG ???

I've had a problem with tracking fonts. I can load the font image just fine, but when I call CreateFont() it returns 0x80070057 (E_INVALIDARG), which isn't a documented return code for CreateFont(). This all happens after GapiDraw is initialized & whatnot.

Bearing in mind using the font files for the two font types (SimpleFont.png and SampleFont.png from the SDK), if I tell it to create a bitmap font w/ SimpleFont, it works, but when I try a tracking font using SampleFont, it fails with that error code.

My code, for what its worth (surf being a CGapiBitmapFont reference, and IDR_SAMPLEFONT is a valid resource ID w/ data):

HRESULT hr;
hr = surf->CreateSurface(GDSURFACE_SYSTEMMEMORY, hInst, IDR_SAMPLEFONT, _T("PNG"));
hr = surf->CreateFont(NULL, RGB(255,0,255), GDCREATEFONT_TRACKING, NULL);
Hi,

I think when you use the GDCREATEFONT_TRACKING flag you have to give a pointer to a GDFONTFX structure as the 4th argument (pGDFontFx).
The GDCREATEFONT_TRACKING flag indicates that you use the tracking value in pGDFontFX->ITracking to specify the default spacing between characters.
Using this flag you probably have to use a advanced font format with kerning lines.

Hope this helps.

Vincent.
ah! Thanks a lot, that's pretty straight-forward... Cursed cut & paste coding... and documentation neglect heh.

Thanks again