The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

RemoveFontResource function

The RemoveFontResource function removes the fonts in the specified file from the system font table.

If the font was added using the AddFontResourceEx function, you must use the RemoveFontResourceEx function.


BOOL RemoveFontResource(
  _In_ LPCTSTR lpFileName


lpFileName [in]

A pointer to a null-terminated string that names a font resource file.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.


We recommend that if an app adds or removes fonts from the system font table that it notify other windows of the change by sending a WM_FONTCHANGE message to all top-level windows in the system. The app sends this message by calling the SendMessage function with the hwnd parameter set to HWND_BROADCAST.

If there are outstanding references to a font, the associated resource remains loaded until no device context is using it. Furthermore, if the font is listed in the font registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts) and is installed to any location other than the %windir%\fonts\ folder, it may be loaded into other active sessions (including session 0).

When you try to replace an existing font file that contains a font with outstanding references to it, you might get an error that indicates that the original font can't be deleted because it’s in use even after you call RemoveFontResource. If your app requires that the font file be replaced, to reduce the resource count of the original font to zero, call RemoveFontResource in a loop as shown in this example code. If you continue to get errors, this is an indication that the font file remains loaded in other sessions. Make sure the font isn't listed in the font registry and restart the system to ensure the font is unloaded from all sessions.

Note  Apps where the original font file is in use will still be able to access the original file and won't use the new font until the font reloads. Call AddFontResource to reload the font. We recommend that you call AddFontResource the same number of times as the call to RemoveFontResource succeeded as shown in this example code.

int i = 0;
while( RemoveFontResource( FontFile ) )

// TODO: Replace font file

while( i-- )
    AddFontResource( FontFile );


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]


Wingdi.h (include Windows.h)





Unicode and ANSI names

RemoveFontResourceW (Unicode) and RemoveFontResourceA (ANSI)

See also

Fonts and Text Overview
Font and Text Functions