    Const DEFAULT_CHARSET = 1
	Const TRUETYPE_FONTTYPE   = 0x004
	
	iString lastff[64]
	
	Int Win_HWND ' Handle to user's window.
	
	Int Already
	Int FontsFound = 0
	Int TotalFonts = 0
	Pointer FontList

	Type ENUMLOGFONTEX_B
		LOGFONT elfLogFont
		iString elfFullName[64]
		iString elfStyle[32]
		iString elfScript[32]
	EndType

	Declare "gdi32", EnumFontFamiliesExA(hdc:Int, lpLogfont:LOGFONT, lpEnumFontFamExProc:uInt, lParam:Int, dwFlags:uInt), Int
	Declare EnumFontFamExProc(lpelfe:Pointer, lpntme:Pointer, FontType:uInt, lParam:Int), Int
	
	DECLARE "user32", _GetDC Alias GetDC(hwnd As Int), Int
	DECLARE "user32", _ReleaseDC Alias ReleaseDC(hwnd As Int,hdc As Int), Int

	AutoDefine "Off"
	
	'Export Startup
	'Export GetFontName
	openconsole
	window w1
	openwindow w1,0,0,412,225,@caption,0,"Emergence BASIC Color Picker",&Handler
	FontList = ListCreate()
	startup(w1.hwnd, 0)
	GetFontName(TotalFonts, "Tahoma")
	int run=1
	waituntil run=0
	closeconsole
end

SUB Handler
	int dirty_flag=0
	SELECT @CLASS
		CASE @IDCreate
			centerwindow w1
		CASE @IDCLOSEWINDOW
			run = 0
	endselect
	return
endsub
Sub Startup(Win:Int, FindOnlyTrueType:Int), Int
	'Returns the number of fonts found.
	
	If Already = 1 Then Return -1
	If FindOnlyTrueType <> 0 Or FindOnlyTrueType <> 1 Then FindOnlyTrueType = 0
	Win_HWND = Win
	Already = 1
	


	'Have LoadFonts put the fontnames in our pointer this time:
	LoadFonts(Win_HWND, FindOnlyTrueType)
	TotalFonts = FontsFound
	
	MessageBox(0, "Total: " + Str$(TotalFonts), "")

	Return TotalFonts
EndSub

Sub GetFontName(Index:Int, Name As String ByRef)

	'Index needs to be a number from 1 through TotalFonts
	If Already = 0 Then Return
	If Index > TotalFonts Then Return 
	If Index <= 0 Then Return
	
	Int Count
	Pointer Temp


	For Temp = Each FontList As String
'print "here"
print #<string>Temp
		Count += 1
		If Count = Index Then
		
			'For some reason, the code never makes it here!
		
			Name = #<string>Temp
			'MessageBox(0, "Index = " + Str$(Index) + " ---- Name = " + Name, "")

		EndIf
	Next
	
	
EndSub

Sub LoadFonts(win:int, justtruetype:Int)
	FontsFound = 0
	Int hdc
	LOGFONT want
	want.lfCharset = DEFAULT_CHARSET
	want.lfFaceName = ""
	want.lfPitchAndFamily = 0
	lastff = ""
	hdc = _GetDC(win)
	EnumFontFamiliesExA(hdc, want, &AddFont, justtruetype, 0)
	_ReleaseDC(win, hdc)
	Return
EndSub

Sub AddFont(lpelfe:ENUMLOGFONTEX_B, lpntme:Pointer, FontType:uInt, lParam:Int), Int
	If lParam
		If (FontType & TRUETYPE_FONTTYPE) = 0
			Return 1
		EndIf
	EndIf

	If lpelfe.elfFullName <> lastff
		FontsFound += 1
		pointer Temp '= lpelfe.elfFullName
		temp =ListAdd(FontList, new(string,1))
		#<string>Temp = lpelfe.elfFullName

		lastff = lpelfe.elfFullName
	EndIf
	Return 1
EndSub