This topic has not yet been rated - Rate this topic

AddFontResourceEx function

Applies to: desktop apps only

The AddFontResourceEx function adds the font resource from the specified file to the system. Fonts added with the AddFontResourceEx function can be marked as private and not enumerable.

Syntax

int AddFontResourceEx(
  __in  LPCTSTR lpszFilename,
  __in  DWORD fl,
  __in  PVOID pdv
);

Parameters

lpszFilename [in]

A pointer to a null-terminated character string that contains a valid font file name. This parameter can specify any of the following files.

File ExtensionMeaning
.fon

Font resource file.

.fnt

Raw bitmap font file.

.ttf

Raw TrueType file.

.ttc

East Asian Windows: TrueType font collection.

.fot

TrueType resource file.

.otf

PostScript OpenType font.

.mmm

multiple master Type1 font resource file. It must be used with .pfm and .pfb files.

.pfb

Type 1 font bits file. It is used with a .pfm file.

.pfm

Type 1 font metrics file. It is used with a .pfb file.

 

To add a font whose information comes from several resource files, point lpszFileName to a string with the file names separated by a | --for example, abcxxxxx.pfm | abcxxxxx.pfb.

fl [in]

The characteristics of the font to be added to the system. This parameter can be one of the following values.

ValueMeaning
FR_PRIVATE

Specifies that only the process that called the AddFontResourceEx function can use this font. When the font name matches a public font, the private font will be chosen. When the process terminates, the system will remove all fonts installed by the process with the AddFontResourceEx function.

FR_NOT_ENUM

Specifies that no process, including the process that called the AddFontResourceEx function, can enumerate this font.

 

pdv [in]

Reserved. Must be zero.

Return value

If the function succeeds, the return value specifies the number of fonts added.

If the function fails, the return value is zero. No extended error information is available.

Remarks

This function allows a process to use fonts without allowing other processes access to the fonts.

When an application no longer needs a font resource it loaded by calling the AddFontResourceEx function, it must remove the resource by calling the RemoveFontResourceEx function.

This function installs the font only for the current session. When the system restarts, the font will not be present. To have the font installed even after restarting the system, the font must be listed in the registry.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Wingdi.h (include Windows.h)

Library

Gdi32.lib

DLL

Gdi32.dll

Unicode and ANSI names

AddFontResourceExW (Unicode) and AddFontResourceExA (ANSI)

See also

Fonts and Text Overview
Font and Text Functions
RemoveFontResourceEx
SendMessage

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ