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

Thanks,
Regards.
hbarisxxAsked:
Who is Participating?
 
mahesh1402Commented:
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 :
http://undocprint.printassociates.com/_media/formats/winspool/enhmet.zip?id=formats%3Awinspool%3Aemf&cache=cache

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 :
http://www.codeproject.com/dotnet/EMFSpoolViewer.asp
http://www.codeproject.com/vcpp/gdiplus/emfexplorer.asp

-MAHESH

0
 
DanRollinsCommented:
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,
      ENHMETARECORD *lpEMFR,
      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:
    EnumEnhMetaFile
    http://msdn.microsoft.com/library/en-us/gdi/metafile_42qt.asp

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

-- Dan
0
 
hbarisxxAuthor Commented:
Hi again,

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

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.

Thanks.


P.S

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 ?
0
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.