Antialiased fonts with wglUseFontBitmaps possible???

Hi all,

I tried to get antialiased bitmap without any success -
it’s always non-antialised, e.g. with:
++++++++++++++++++++++++++++++++++++++++
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), 1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
PFD_SUPPORT_GDI | PFD_GENERIC_FORMAT,
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0};

HFONT font = CreateFont(-18, 0, 0, 0, FW_NORMAL, FALSE,
FALSE, FALSE, ANSI_CHARSET, OUT_TT_ONLY_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
FF_DONTCARE | VARIABLE_PITCH, “Arial”);

SelectObject(currentHdc, font);
int base = glGenLists(256);
wglUseFontBitmaps(currentHdc, 0, 255, base);
++++++++++++++++++++++++++++++++++++++++++
Are there other configurations necessary or
is it not possible to get antialiased fonts
using wglUseFontBitmaps() in principle?

Many thanks for all comments.
Ralf

Originally posted by ravo:
HFONT font = CreateFont(-18, 0, 0, 0, FW_NORMAL, FALSE,
FALSE, FALSE, ANSI_CHARSET, OUT_TT_ONLY_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
FF_DONTCARE | VARIABLE_PITCH, “Arial”);

Try using GetGlyphOutline to put the character set onto a single texture. Here’s some pseudo code:

GLYPHMETRICS gm;
MAT2 matrix={{0, 1}, {0, 0}, {0, 0}, {0, -1}};
int uFormat=GGO_GRAY8_BITMAP;
int minChar=32, maxChar=127;

hScreenDC=CreateDC(“DISPLAY”, NULL, NULL, NULL);
hdc=CreateCompatibleDC(hScreenDC);
saveDC=SaveDC(hdc);
hBitmap=CreateCompatibleBitmap(hScreenDC, 100, 100);
SelectObject(hdc, (HGDIOBJ)hBitmap);
hFont=::CreateFont(-(pointSize*10)*GetDeviceCaps(hdc, LOGPIXELSY)/720, 0, 0, 0, (bBold?700:400), (bItalic?1:0), 0, 0, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, pszFontName);
SelectObject(hdc, (HGDIOBJ)hFont);

for (i=minChar;i<=maxChar;i++)
{
size=GetGlyphOutline(hdc, (UINT)i, uFormat, &gm, 0, NULL, &matrix);
pBuffer=new BYTE[size];
GetGlyphOutline(hdc, (UINT)i, uFormat, &gm, size, pBuffer, &matrix);
GetGlyphOutline(hdc, (UINT)i, GGO_METRICS, &gm, 0, NULL, &matrix);
// Store bitmap data in pBuffer to a texture (256x256 bitmap for example)
// Store the data in gm for each char to be used later with glVertex and glTexture
}