Export (0) Print
Expand All
4 out of 5 rated this helpful - Rate this topic

CreateFontIndirect function

The CreateFontIndirect function creates a logical font that has the specified characteristics. The font can subsequently be selected as the current font for any device context.

Syntax


HFONT CreateFontIndirect(
  _In_  const LOGFONT *lplf
);

Parameters

lplf [in]

A pointer to a LOGFONT structure that defines the characteristics of the logical font.

Return value

If the function succeeds, the return value is a handle to a logical font.

If the function fails, the return value is NULL.

Remarks

The CreateFontIndirect function creates a logical font with the characteristics specified in the LOGFONT structure. When this font is selected by using the SelectObject function, GDI's font mapper attempts to match the logical font with an existing physical font. If it fails to find an exact match, it provides an alternative whose characteristics match as many of the requested characteristics as possible.

To get the appropriate font on different language versions of the OS, call EnumFontFamiliesEx with the desired font characteristics in the LOGFONT structure, retrieve the appropriate typeface name, and create the font using CreateFont or CreateFontIndirect.

When you no longer need the font, call the DeleteObject function to delete it.

The fonts for many East Asian languages have two typeface names: an English name and a localized name. CreateFont and CreateFontIndirect take the localized typeface name only on a system locale that matches the language, while they take the English typeface name on all other system locales. The best method is to try one name and, on failure, try the other. Note that EnumFonts, EnumFontFamilies, and EnumFontFamiliesEx return the English typeface name if the system locale does not match the language of the font.

The font mapper for CreateFont, CreateFontIndirect, and CreateFontIndirectEx recognizes both the English and the localized typeface name, regardless of locale.

Examples

For an example, see Creating a Logical Font.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Wingdi.h (include Windows.h)

Library

Gdi32.lib

DLL

Gdi32.dll

Unicode and ANSI names

CreateFontIndirectW (Unicode) and CreateFontIndirectA (ANSI)

See also

Fonts and Text Overview
Font and Text Functions
CreateFont
CreateFontIndirectEx
DeleteObject
EnumFonts
EnumFontFamilies
EnumFontFamiliesEx
LOGFONT
SelectObject

 

 

Build date: 6/12/2013

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.