enumfonts???

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wickedRush.

Hello, I've been trying to get the installed font list from my machine into an array. I know enumfonts is the answer (and I have a working VB6 project) but I cannot figure it out w/PB. Any help or code samples would be great :)
Thanks!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.


Here is a sample..

Code: Select all

OpenConsole()

; Internal PB ENUMLOGFONT structure is broken.. Fixed now.
;
Structure ENUMLOGFONT2
  elfLogFont.LOGFONT
  elfFullName.b[#LF_FULLFACESIZE]
  elfStyle.b[#LF_FACESIZE]
EndStructure

Procedure EnumFontFamProc(*lpelf.ENUMLOGFONT2, *lpntm.NEWTEXTMETRIC, FontType, lParam)

  PrintN("Name: "+PeekS(@*lpelf\elfFullName[0]))
  
  ProcedureReturn 1
EndProcedure

*Win = GetForegroundWindow_()
*DC = GetDC_(*Win)
If *DC
  EnumfontFamilies_(*DC, @EnumFontFamProc(), 0)
  ReleaseDC_(*Win,*DC)
EndIf

Print("Press a ENTER to quit")
Input()

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wickedRush.

I get a syntax error at line 19: EnumfontFamilies_(*DC, @EnumFontFamProc(), 0) which after reading the win32api manual I changed to EnumfontFamilies_(*DC,#NULL,@EnumFontFamProc(), 0) now the program compiles but errors and closes.?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Ho, sorry, I'm coding on the new version of PB. You have to change the following line:

Procedure EnumFontFamProc(*lpelf.ENUMLOGFONT2, *lpntm.NEWTEXTMETRIC, FontType, lParam)

with

Procedure EnumFontFamProc(lParam, FontType, *lpntm.NEWTEXTMETRIC, *lpelf.ENUMLOGFONT2)



Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wickedRush.

Thanks Fred! That did the trick.
Post Reply