Obtain Font information from EMF files

Posted on 2006-04-26
Last Modified: 2013-12-03
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..

Question by:hbarisxx
    LVL 22

    Accepted Solution

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

    Refer : <== 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 : <====== Full EMF file explorer with src code

    Also other useful articles :


    LVL 49

    Assisted Solution

    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

    Author Comment

    Hi again,

    OK, but I need Visual basic code,
    Can you please?
    LVL 22

    Expert Comment

    hbarisxx  this is MFC topic area ..if you want VB code you need to ask this in Visual Basic Topic Area.

    Author Comment


    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 ?

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    maxBlock challenge 30 90
    centeredAverage challenge 8 92
    java ^ examples 8 51
    Window placement 17 56
    Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
    Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now