Archived

This topic is now archived and is closed to further replies.

Why is this happening ? - font stuff

This topic is 5499 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

my outlined font prints ok bu my pro is that when i tell it to put K it puts J ... L it prints K .. one letter back.. what could cause this.. ? here is the code to print and to build

void S_Font::Print3D (char* String,sfont3d Font)
{
float Lenght = 0;

for (unsigned int Loop = 0 ; Loop < (strlen (String)); Loop++)
Lenght += Font.Gmf[String[Loop]].gmfCellIncX;

glTranslatef (- Lenght / 2,0,0);
glPushAttrib (GL_LIST_BIT);
glListBase (Font.Base);
glCallLists (strlen (String),GL_UNSIGNED_BYTE,String);
glPopAttrib ();
}

bool S_Font::Build3DFont (sfont3d Font,HDC Hdc)
{
HFONT New;

Font.Base = glGenLists (256);
if (!glIsList (Font.Base))
return false;

New = CreateFont (0,0,0,0,Font.Weight,Font.Italic,Font.Underline,Font.Strike,ANSI_CHARSET,OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_DONTCARE|DEFAULT_PITCH,Font.Face);

SelectObject (Hdc,New);
wglUseFontOutlines (Hdc,0,255,Font.Base,0.0f,Font.Depth,WGL_FONT_POLYGONS,Font.Gmf);
return true;
};

here is the struct typedef struct { int Depth; int Weight; bool Italic; bool Strike; bool Underline; char* Face; unsigned int Base; GLYPHMETRICSFLOAT Gmf[256]; }sfont3d; and on the main project i call this. sfont3d Font3d = {0.2f,100,false,false,false,"IMPACT"}; and after enabling Ogl i do Build3DFont. thx in advance [edited by - Metal Typhoon on February 2, 2003 4:30:28 PM]

Share on other sites
You mispelled length. That could be the problem.

Share on other sites
You passed Font to Build3DFont by value. Changing Font.anything will have no effect. So, when you call Print3D, the Font members are probably not what you think they are.

You need to pass by reference or by address.

Share on other sites
quote:

You mispelled length. That could be the problem.

That must been sarcastic remark, because we all know that if he mispelled length wrong he would get a compiler error.

Check to see if your indexing into the display list properly... You seem to be off by one char.

quote:

You passed Font to Build3DFont by value. Changing Font.anything will have no effect. So, when you call Print3D, the Font members are probably not what you think they are.

You need to pass by reference or by address.

The only way to find out is that he prints out A and see if he gets garbage back, if not just try + 1 when you index and see what the results are...

Share on other sites
quote:
Original post by ANSI2000
[quote]
You mispelled length. That could be the problem.

That must been sarcastic remark, because we all know that if he mispelled length wrong he would get a compiler error.

Check to see if your indexing into the display list properly... You seem to be off by one char.

quote:

You passed Font to Build3DFont by value. Changing Font.anything will have no effect. So, when you call Print3D, the Font members are probably not what you think they are.

You need to pass by reference or by address.

The only way to find out is that he prints out A and see if he gets garbage back, if not just try + 1 when you index and see what the results are...

i hate this kind of people.. i wonder if he can speak portuguese better than me ... anyways yes if i ad + 1 it works i knew that.. but i really dont underdstand why i have to add one. it''s way supposed to work just like that...

Share on other sites
Did you try changing the Build3DFont function to take a sfont3d * and call it with the address of the font object?

Without that, Font.Base and Font.Gmf aren't getting set because only a copy of the object was passed on the stack. The copy is being modified, not the actual object.

[edited by - Dave Hunt on February 4, 2003 1:47:12 AM]