Introduction
XFont comprises two functions that are useful when trying to determine the name of the font file given the font name, and conversely when trying to find the font name from the font file. I have already introduced
GetFontFile()
in a
previous article. This article presents a new non-MFC version of
GetFontFile()
and also
GetFontProperties()
, which together allow you to find the name of the font or the name of the font file.
First, let me acknowledge the work of Philip Patrick, who researched the font file format to come up with GetFontProperties()
. I have taken his code and removed the MFC dependencies, added Unicode support, and converted the CFile file I/O to a memory-mapped file.
XFont Functions
- GetFontFile() - Find the name of font file.
- GetFontProperties() - Get font name from font file.
How To Use
To integrate XFont into your app, you first need to add following files to your project:
If you include XFont in project that uses precompiled headers, you must change C/C++ Precompiled Headers settings to Not using precompiled headers for XFont.cpp.
Next, include the header file XFont.h in appropriate project files. Now you are ready to start using XFont. The two XFont functions are demonstrated fully in the XFont demo app.
Demo App
The
XFontTest.exe demo tests the APIs in
XFont. Here is some of the output:
Revision History
Version 1.1 - 2003 May 21
- Removed MFC dependency from
GetFontProperties
- Converted
CFile
file I/O to memory mapped file
- Added Unicode support
- Combined with my
GetFontFile
routine
Version 1.0
- Initial (separate) release of
GetFontFile
and GetFontProperties
Usage
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.