• Advertisement
Sign in to follow this  

GetGlyphOutline failing

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to get the GLYPHMETRICS structure for a character but GetGlyphOutline keeps failing and I don't know why
//Create the handle we'll be returning
	//Pointer to the soon to be created game font
	boost::shared_ptr<GameFont> gameFont;

	//Create Win32 Font handles for the font we're creating and the current font in use
	HFONT newFont;
	HFONT oldFont;

	//Get our DeviceContext from the OpenGL Class
	HDC hDC = COpenGL::GetSingleton().GetDeviceContext();

	//Generate 128 display lists for our font, save the start of the list in listBase
	GLuint listBase = glGenLists(255);

	//Generate a Win32 Font
	newFont = CreateFont(-fontSize,						//Font height
							0,							//Font width (chooses closes match)
							0,							//Escapement (angle)
							0,							//Orientation
							fontWeight,					//Font Weight
							fontItalic,					//Italic?
							fontUnderline,				//Underline?
							0,							//Strike through
							ANSI_CHARSET,				//Character set to use
							OUT_TT_PRECIS,				//Output precision (use TT if available)
							CLIP_DEFAULT_PRECIS,		//Default cliping precision
							ANTIALIASED_QUALITY,		//Antialias our font
							FF_DONTCARE|DEFAULT_PITCH,	//Font Family and pitch
                            fontFace.c_str());					//Font face

	//If font creation failed return a null handle
	if(newFont == NULL)
		return h;

	//Set the new font as the current fond and save the old one
	oldFont = (HFONT)SelectObject(hDC, newFont);
	if(oldFont == NULL)
		return h;
	int r = GetGlyphOutline(hDC, 'a', GGO_METRICS, &g, 0, 0, 0);
	if (r == GDI_ERROR)
			r = GetLastError();

	//Generate display list for our font
	if(!(wglUseFontBitmaps(hDC, 0, 255, listBase)))
		return h;

GetGlyphOutline returns GDI_ERROR but when I do GetLastError() it returns 0 (No Error). Anything wrong with the above code? Thanks

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement