PocketMatrix forums

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

Drawing problem.

Code from sample- make font
Code:

Font font;

HRESULT InitialApplication::onInit(Surface* pBackBuffer, Application* application)
{
//Load logo image
surface.create(GLEDPLAY_LOGO, TEXT("LOGO"));

Surface fontSurface;
Surface fontAlpha;
rett=fontSurface.create(TEXT("fontsample.gif"));
fontAlpha.create(TEXT("alphafontsample.gif"));
font.createFont(TEXT(" ABCDEFGHIJKLMNOPQRSTUVWXYZ"), &fontSurface;, &fontAlpha;);
fontSurface.free();
fontAlpha.free();


return ReturnCode::OK;
}


and


Code:
HRESULT InitialApplication::onNextFrame(Surface* pBackBuffer, Panel* panel)
{
pBackBuffer->fillRect(RGB(0, 0, 0));
pBackBuffer->drawText(20, 20,
Font::getSystemFont(),
Font::LEFT_ALIGN, TEXT("Hello!"));

pBackBuffer->drawText(20,55,&font;,Font::CENTER_ALIGN, TEXT("WELCOME"));

return ReturnCode::OK;
}


It write only "hello"...

ReturnCode from font.createFont is ReturnCode::0k

why?
Hi ZugaZoid

When you create the font, you pass this string as an argument

TEXT(" ABCDEFGHIJKLMNOPQRSTUVWXYZ")

this parameter contains the characters of your font in the same order that they appear in the provided image.

As you can see, no '!' character is specified, that's why is printing only "hello"

Hope it helps
Matias,

We need to do a deeper inspection there, because he is also trying to write "WELCOME". The "Hello!" is being written with the system font.

ZugaZoid,
What images are you using? Are they the same from the documentation samples? if not, please send them to us, so we can test it better.

Thank you,
Sergio.
summer_goth · 10 Jan 2007, 06:26 UTC
Actually it makes sense. Matias is correct in that the '!' is not specified. However when the text is rendered the system font is used, so it does not matter.

The onInit function in this example is not called. It's the same problem I had earlier.

Code:
HRESULT InitialApplication::onInit(Surface* pBackBuffer, Application* application)


It needs to be:

Code:
HRESULT InitialApplication::onInit(Surface* pBackBuffer,Panel* mainPanel , Application* application)


Sergio showed this to me in a previous post. So the font is never loaded and hence 'WELCOME' is not displayed.

Enjoy everyone.
Oh, thanks!

I think developers must correct all errors in documentation, and to write many examples.:)))

Have a nice day!
Yes, you are right. We have to correct that in the docs. Sorry for that. And thank you for letting us know about that problem.

Best regards,
Sergio.