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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mahesh1402IT ProfessionalCommented:
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 :


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?
mahesh1402IT ProfessionalCommented:
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 ?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.