Loading Windows TT fonts

I have a bit of trouble figuring out what names I need to pass to the typeface parameter of CreateFont to get a specific font...

I have the following functions:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
PGLFONT createGLFont(HDC hDC, const std::string& typeface, int height, int weight, DWORD italic)
{
	PGLFONT font;
	HFONT fontid;
	int charset;

	font = new GLFONT;
	if(!(font->base= glGenLists(256)))
	{
		delete font;
		return NULL;
	}

	charset = ANSI_CHARSET;

	fontid = CreateFont(height,0,0,0,weight, italic, FALSE, FALSE,
						charset, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
						DRAFT_QUALITY, DEFAULT_PITCH, typeface.c_str());

	SelectObject(hDC, fontid);

	wglUseFontBitmaps(hDC, 0, 256, font->base);
	GetCharWidth32(hDC, 0, 255, font->widths);
	font->height = height;

	return font;
}

void printGLFont(PGLFONT font, const std::string& text)
{
	if (font == NULL || text.size() == 0)
		return;
	glPushAttrib(GL_LIST_BIT);
	glListBase(font->base);
	glCallLists(text.size(), GL_UNSIGNED_BYTE, text.c_str());
	glPopAttrib();
	return;
}

void deleteGLFont(PGLFONT font)
{
	if(font == NULL) return;
	glDeleteLists(font->base, 256);
	delete font;
        return;
}


GLFONT is just a struct that holds the information I need about the font in OpenGL (mostly the base index for the display lists):
1
2
3
4
5
6
typedef struct GLFONT
{
	GLuint base;
	int widths[256];
	int height;
} *PGLFONT;


What I have troubles figuring out is, what values I need to pass to the typeface parameter to load a specific font...

In particular:
font = createGLFont(hDC,"Times New Roman",24,700,0);
Works, loads a Times New Roman font
font = createGLFont(hDC,"Serif",24,700,0);
Doesn't work, the default (serife-less) font is loaded.
font = createGLFont(hDC,"Matisse iTC",24,700,0);
Works, Matisse iTC is loaded.
font = createGLFont(hDC,"Webdings",24,700,0);
Doesn't work, default font is loaded.

I have all of those fonts (including those I couldn't load) - now my question is, am I unable to load these fonts due to some technical restriction, or do those have other special names I need to access them with?
Last edited on
have you checked that they are in "C:\windows\fonts"?
Of course I did. I already said I have those fonts, right?
Topic archived. No new replies allowed.