Click here to Skip to main content
13,343,008 members (53,456 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 26 May 2003

XFontCombo - An OpenType-aware font combobox

, 26 May 2003
Rate this:
Please Sign up or sign in to vote.
XFontCombo demonstrates the use of IsOpenType(), a function that determines if a font is OpenType


I remember when I first saw the italic O appear in font selection dialogs, I thought "What could this be? Is it some kind of open-source font technology?" Then I realized I was looking at a Microsoft product, so I quickly decided it must be something else. In fact, I came to learn that the O stood for OpenType, a universal font format introduced by Microsoft and Adobe in 1996 that combines Microsoft's TrueType and Adobe's Type 1 font technologies. You can learn more about OpenType here.

Of course my next question was "How can you tell if it's OpenType?" The answer lies in diving into the font file. Thanks to the work of Philip Patrick, it is easy to construct a function that will determine if a font is OpenType.

The IsOpenType() Function

IsOpenType() returns TRUE if the specified font file is OpenType. Internally, IsOpenType() reads the font file as a memory-mapped file and scans the tables of the font file for the OpenType marker tag.
// IsOpenType()
// Purpose:     Determine if font file is OpenType.
// Parameters:  lpszFilePath - file path of font file
// Returns:     BOOL - TRUE = font file is OpenType

How To Use

To integrate IsOpenType() into your app, you first need to add following files to your project:

  • IsOpenType.cpp
  • IsOpenType.h

If you include IsOpenType.cpp in project that uses precompiled headers, you must change C/C++ Precompiled Headers settings to Not using precompiled headers for IsOpenType.cpp.

Next, include the header file IsOpenType.h in appropriate project files. Now you are ready to start using IsOpenType().

Demo App

The XFontComboTest.exe demo shows how to use IsOpenType() function. Since it is likely you will only have font name (i.e., display name) and not name of font file, you may also need to use my GetFontFile() function.

As a testbed I use Chris Losinger's excellent Font Combo. With addition of IsOpenType(), you can now see which fonts are OpenType. For comparison purposes, I also include button to display standard CFontDialog.

XFontCombo screenshot



Revision History

Version 1.0 - 2003 May 27

  • Initial public release.


This software is released into the public domain. You are free to use it in any way you like. If you modify it or extend it, please to consider posting new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Hans Dietrich
Software Developer (Senior) Hans Dietrich Software
United States United States
I attended St. Michael's College of the University of Toronto, with the intention of becoming a priest. A friend in the University's Computer Science Department got me interested in programming, and I have been hooked ever since.

Recently, I have moved to Los Angeles where I am doing consulting and development work.

For consulting and custom software development, please see

You may also be interested in...

Comments and Discussions

Generalhas a font type is different with my computer Pin
Gempin15-Nov-03 8:16
memberGempin15-Nov-03 8:16 
John R. Shaw2-Jun-03 10:59
memberJohn R. Shaw2-Jun-03 10:59 
:-DVery nice; BUT:

:(1) If you are not logged on as an Administrator on Windows 2000 then you do not have all access permission. Therefore, GetNextNameValue() fails because RegOpenKeyEx() fails when the security access mask is set to KEY_ALL_ACCESS.

:-DSolution: retval = RegOpenKeyEx(key, pszSubkey, 0, KEY_READ, &hkey);

:|2) When an item is selected the icon for it does not change color as is does in a common font selection dialog box.

:(Solution: I have none at this time.

Trust in the code Luke. Yea right!
Hans Dietrich4-Jun-03 17:06
memberHans Dietrich4-Jun-03 17:06 
John R. Shaw5-Jun-03 3:16
memberJohn R. Shaw5-Jun-03 3:16 
GeneralThanks... Pin
Paul Selormey27-May-03 0:31
memberPaul Selormey27-May-03 0:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 26 May 2003
Article Copyright 2003 by Hans Dietrich
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid