Obtain Font information from EMF files

Hi everybody,

I want to ask sth about LOGFONT structure and EMF files..

How can we obtain font informations from EMF files?

(Which fonts are used in EMF file)..

Can sb explain it to me or send a code snippet about this topic..

Who is Participating?
Here is useful stuff for you which will guide you towards right direction..

Refer :

http://undocprint.printassociates.com/formats/winspool/emf <== EMF - Enhanced Metafile Format

Refer above full page.

There is zipped .hlp file describes FORMAT of EMF file its here :

Finally intersting 'EMFexplorerOpen Source Project' Get it from Here :

http://frazmitic.free.fr/emfexplorer/index.htm <====== Full EMF file explorer with src code

Also other useful articles :


It looks to me like you must enumerate the records in the metafile, then in your enumerating proc, look for SelectObject records and then if the object is a font, you can examine it via its entry in the handle table.   For instance...

int CALLBACK EnumEnhMetafileProc(
      HDC hDC,
      HANDLETABLE *lpHTable,
      int nObj, LPARAM lpData )
    HGDIOBJ  hObj;

      if ( lpEMFR->iType == EMR_SELECTOBJECT ) { // It's a SelectObject() record
            hObj= lpHTable->objectHandle[lpEMFR->dParm[0]];
            if ( GetObjectType(hObj) == OBJ_FONT ) {
                  LOGFONT rLF;
                  int nRet= GetObject( hObj, sizeof(LOGFONT), &eLF );
                  if (nRet == 0 ) {
                        // ... the fn failed for some reason
                  else {
                        MessageBox( rLF.lfFaceName, "the font selecte is..." );

I suppose you could also just run through the handle table directly, but I did not research that.  

To see how to enumerate the records, see:

It's pretty straight forward, but if you need more help, just ask.

-- Dan
hbarisxxAuthor Commented:
Hi again,

OK, but I need Visual basic code,
Can you please?
hbarisxx  this is MFC topic area ..if you want VB code you need to ask this in Visual Basic Topic Area.
hbarisxxAuthor Commented:

how can I write a dll in Visual C++ 6 for the code snippet above..Which headers I have t&#305; include, etc..?

I will use the dll from Visual basic.



I also use the code snippet above in visual basic..(with vb syntax of course). But  not worked..
I think in these lines there is a problem or I writed with wrongs:
    hObj= lpHTable->objectHandle[lpEMFR->dParm[0]];
          if ( GetObjectType(hObj) == OBJ_FONT ) {
               LOGFONT rLF;
               int nRet= GetObject( hObj, sizeof(LOGFONT), &eLF );
My EnhMetaFileProc functionin VB is here....

Public Function EnhMetaFileProc( _
    ByVal ClientHDC As Long, _
    ByRef lpHandTab As HANDLETABLE, _
    ByRef MetaRec As ENHMETARECORD, _
    ByVal nHandles As Long, _
    ByVal OptData As Long) As Integer

Dim hObj As Long
Dim lfn As LOGFONT
Dim ret2 As Integer

Dim plFont As LOGFONT
i = i + 1
If MetaRec.iType = EMR_SELECTOBJECT Then
    hObj = GetCurrentObject(ClientHDC, OBJ_FONT)
    hObj = lpHandTab.objectHandle(MetaRec.lpParm)
       If GetObjectType(hObj) = OBJ_FONT Then
        ret2 = GetObject(hObj, Len(lfn), lfn)
        MsgBox lfn.lfFaceName
    End If
End If
EnhMetaFileProc = 1  

End Function
Where is wrong ?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.