printfb bug
  • FuzzyFuzzy January 2010
    hi all

    after going on with the porting of my code i have run into this weird bug...

    i'll work around it for now, however i'm wondering if it could not cause memory corruption in the long run...

    how to raise the bug:

    load your font (i used the default font1.fnt).

    print something to the screen
    1
    fnt->printfb(0,0,500,10,HGETEXT_LEFT, "qsdfjklqsdfjlkdfqsklmjdfqsjklm");


    then print something that doesnt fit in the box margins of printfb
    1
    fnt->printfb(0,fnt->GetHeight(),10,10,HGETEXT_LEFT, "test");


    you will notice how it prints:
    the first line ("qsdfjklqsdfjlkdfqsklmjdfqsjklm")
    the test line ("test"), which it should cut off since it doesnt fit in the box
    and below that it prints an unwanted line ... ("klqsdfjlkdfqsklmjdfqsjklm")

    i believe it's because the buffer isnt cleared when the printfb function is called but since i'm currently too unexperienced in c++ i cannot verify this (havent learned buffer stuff yet).

    greetings Fuzzy
  • ProfEclipseProfEclipse January 2010
    You are correct that there is a huge bug in printfb. However, it's not because the buffer isn't being cleared. It shows up because the buffer isn't being cleared, but it probably shouldn't have been coded quite the way it was.

    At any rate, a simple fix would be to put a memset(buffer,0,sizeof(buffer)) before the call to _vsnprintf.
  • JeffreyJeffrey June 2012
    Can you please elaborate on the fix. I've run into the same problem. The render isn't being contained in the box that is defined.
    1
    2
    3
    Engine->Gfx_SetTransform(0,0,x,y,0,1,1);
    fnt->printfb(0+textOffset,0, w-textOffset, fnt->GetHeight(),HGETEXT_LEFT, content.c_str());
    Engine->Gfx_SetTransform();


    The render of the fnt is being rendered even outside the box. Is this a bug or is that how it should be.

    N.B: I am trying to print the text in a textbox.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion

Who's Online (1)