Link to home
Start Free TrialLog in
Avatar of cierech
cierech

asked on

VMWare Virtual Machine, Windows Server 2003 DataCenter Edition, Apache 2.2.10 and TrueType fonts issue

Hi experts,

I am having an issue with a CGI script written in C++ that lists all fonts installed in the system using Windows API calls.

My script lists all types of fonts when I run it as a standalone program or in Apache installed on my Windows XP machine. But when I run it in the environment described in the Title, it doesn't list any TrueType fonts (OpenType and others are being listed fine).

The CGI script was created in VC6 (UNICODE), but that shouldn't matter it uses the simplest EnumFontFamiliesEx implementation, so it should work.... and yet it doesn't....

Any help would be appreciated


#include "stdafx.h"
 
#include <windows.h>
 
 
int EnumerateFontsClassLibrary();
static int CALLBACK EnumerateFullFontName(const ENUMLOGFONTEX *lpelfe,const NEWTEXTMETRICEX *lpntme, DWORD FontType, LPARAM lParam);
 
 
int iFontCounter;
 
int _tmain(int argc, _TCHAR* argv[])
{
	iFontCounter = 0;
 
	_tprintf(_T("Content-Type: text/plain;charset=us-ascii\n\n"));
 
	EnumerateFontsClassLibrary();
 
	_tprintf(_T("\n\n Found %d fonts."), iFontCounter);
	
	return 0;
}
 
 
static int CALLBACK EnumerateFullFontName(const ENUMLOGFONTEX *lpelfe,const NEWTEXTMETRICEX *lpntme, DWORD FontType, LPARAM lParam)
{
	TCHAR *fontname = (TCHAR *)lpelfe->elfFullName;
	TCHAR *characterset = (TCHAR *)lpelfe->elfScript;
 
	iFontCounter++;
 
	_tprintf(_T("\n"));
	_tprintf(fontname);
 
 
	return 1;
}
 
 
int EnumerateFontsClassLibrary()
{
	HDC dc;
	
	dc=GetDC(0);
 
	LOGFONT logfont;
 
	/*set up default logfont structure*/
    ZeroMemory(&logfont, sizeof LOGFONT);
 
    logfont.lfCharSet = DEFAULT_CHARSET;
 
EnumFontFamiliesEx(dc,														/* handle to device context*/
								&logfont,										/* pointer to logical font information*/
								(FONTENUMPROC)EnumerateFullFontName,			/* pointer to callback function*/
								0,												/* application-supplied data*/
								0																			/* reserved; must be zero*/
								);
 
 
	ReleaseDC(0,dc);
 
	return 0;
}

Open in new window

Avatar of cierech
cierech

ASKER

Wow. Really? Nothing? Should I move this over to another Zone?
Avatar of cierech

ASKER

I have been playing around with this a bit. It seems that the problem is only apparent when Apache is started as a service. If I run it from command line, all the fonts are listed (both TrueType and OpenType).

The user used to run the service and the command line httpd is the same, so that's not the issue...
ASKER CERTIFIED SOLUTION
Avatar of cierech
cierech

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial