[Webinar] Learn how to a build a cloud-first strategyRegister Now


Obtain Font information from EMF files

Posted on 2006-04-26
Medium Priority
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
  • 2
  • 2
LVL 22

Accepted Solution

mahesh1402 earned 1000 total points
ID: 16546299
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 :


LVL 49

Assisted Solution

DanRollins earned 1000 total points
ID: 16547471
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

ID: 16550728
Hi again,

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

Expert Comment

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

Author Comment

ID: 16551679

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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…
Suggested Courses

864 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