Newbie prob with EnumFontFamilies()

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 sk.

While coming from VB I've still have some difficulties in "adapting" PB, specially with this "pointer stuff" ...:)

Code: Select all

;// =====================================================================================;// Structure ENUMLOGFONT 
;//           elfLogFont.LOGFONT   60 Byte 
;//           elfFullName.b[64]    64 Byte 
;//           elfStyle.b[32]       32 Byte = 156 Byte 
;// EndStructure 
;// Structure LOGFONT 
;//           lfHeight.l            4 Byte 
;//           lfWidth.l             4 Byte 
;//           lfEscapement.l        4 Byte 
;//           lfOrientation.l       4 Byte 
;//           lfWeight.l            4 Byte 
;//           lfItalic.b            1 Byte 
;//           lfUnderline.b         1 Byte 
;//           lfStrikeOut.b         1 Byte    
;//           lfCharSet.b           1 Byte 
;//           lfOutPrecision.b      1 Byte 
;//           lfClipPrecision.b     1 Byte    
;//           lfQuality.b           1 Byte 
;//           lfPitchAndFamily.b    1 Byte 
;//           lfFaceName.b[32]     32 Byte =  60 Byte 
;// EndStructure 
;// =====================================================================================
    Procedure EnumFontFamProc(*lpelf.ENUMLOGFONT, *lpntm.NEWTEXTMETRIC, FontType, lParam) 
    ;// int CALLBACK EnumFontFamProc( 
    ;//     ENUMLOGFONT *lpelf,    // logical-font Data 
    ;//     NEWTEXTMETRIC *lpntm,  // physical-font Data 
    ;//     DWORD FontType,        // type of font 
    ;//     LPARAM lParam          // application-defined Data 
    ;// ); 
    ;?? access to ??: lpelf\LOGFONT\lfFaceName 
        Debug PeekS(@lpelf + 29, 32) 
        ProcedureReturn 1 

    EndProcedure 

    Procedure SysInfo_Fonts() 
    ;// int EnumFontFamilies( 
    ;//     HDC hdc,                        // handle To DC 
    ;//     LPCTSTR lpszFamily,             // font family 
    ;//     FONTENUMPROC lpEnumFontFamProc, // callback function 
    ;//     LPARAM lParam                   // additional Data 
    ;// ); 
        hDC.l = GetDC_(GetDesktopWindow_()) 
        EnumFontFamilies_ (hDC.l, 0, @EnumFontFamProc(), lParam) 
        ReleaseDC_ (hWnd, hDC) 

    EndProcedure
Trying to get all installed fonts I used the EnumFontFamilies() function. It would be nice if someone can explain to me how to get the lfFaceName data.

Thanks!

sk
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 El_Choni.

Oops, saw it in the German forum first:

Code: Select all

Procedure EnumFontFamProc(*lpelf.ENUMLOGFONT, *lpntm.NEWTEXTMETRIC, FontType, lParam)
  Debug PeekS(@*lpelf\elfLogFont\lfFaceName[0])
  ProcedureReturn 1
EndProcedure
Procedure SysInfo_Fonts()
  hWnd = GetDesktopWindow_()
  hDC = GetDC_(hWnd)
  EnumFontFamilies_(hDC, 0, @EnumFontFamProc(), 0)
  ReleaseDC_ (hWnd, hDC)
EndProcedure
SysInfo_Fonts()
*lpelf\elfLogFont\lfFaceName[0] is the first character of the lfFaceName string. So, to get its pointer, you put an @ before.

Bye,

El_Choni
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 sk.

Thanks a lot!

sk
Post Reply