View Full Version : Fonts

08-18-2006, 06:03 AM

I need to display fonts of particular height and width. I created fonts using wglOutlines. But i could not vary the height and width of the font. The code is as follows:

HFONT hFont;

LOGFONT logfont;
logfont.lfHeight = 12;
logfont.lfWidth = 100;
logfont.lfEscapement = 0;
logfont.lfOrientation = 0;
logfont.lfWeight = 400;
logfont.lfItalic = 0;
logfont.lfUnderline = 0;
logfont.lfStrikeOut = 0;
logfont.lfCharSet = DEFAULT_CHARSET;
logfont.lfOutPrecision = OUT_TT_PRECIS;
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logfont.lfQuality = ANTIALIASED_QUALITY;
logfont.lfPitchAndFamily = DEFAULT_PITCH;

strcpy(logfont.lfFaceName, "Arial");

hFont = CreateFontIndirect(&logfont);

SelectObject(hdc, hFont);

nFontList = glGenLists(128);

wglUseFontOutlines(hdc, 0, 128, nFontList, 0.0f, 0.0f, WGL_FONT_POLYGONS, agmf);

DeleteObject(hFont);Sangeetha. J

08-18-2006, 06:52 AM
Read the wglUseFontOutlines manual.
Here's the relevant line:

"The em square size of the font, the notional grid size of the original font outline from which the font is fitted, is mapped to 1.0 in the x- and y-coordinates in the display lists. The extrusion parameter sets how much depth the font has in the z direction."

Means, it ignores the font's lfHeight and uses the em square to generate the full spline data in the [0.0, 1.0] range from the full presicion font data. The em square of TrueType fonts I looked at was 2048.
You need to scale your OpenGL matrices to adjust font sizes rendered from wglUseFontOutlines.
When doing that with the modelview matrix on polygonal fonts, enable GL_NORMALIZE to get the lighting right.

08-21-2006, 03:04 AM

I scale the font to the level i need it to be displayed. Its working. But if a word is there means say, for example, "OpenGL".., then sometimes the starting letter of the word should be at the given coordinate and sometime the last letter should be at the given coordinate. For this, i need to know how much i can translate the X Coordinate.. To translate , each letter has different GLYMPHMETRICS parameter values. Is there any other way to do this..?

08-21-2006, 04:38 AM

I corrected the problem. Thanks for replying.


08-21-2006, 08:38 AM

I successfully displayed the font at whatever location i want. But one problem i am facing is the weight of the font is not upto the expected. There is no lot of difference if i gave the font weight a different value. But i need to display the font from very thin to thick. Please anyone help me.