ITextRange::SetFont method

Sets this range's character attributes to those of the specified ITextFont object.

Syntax


HRESULT SetFont(
  [in]  ITextFont *pFont
);

Parameters

pFont [in]

Type: ITextFont*

A font object with the desired character format.

Return value

Type: HRESULT

The method returns an HRESULT value. If the method succeeds, it returns S_OK. If the method fails, it returns one of the following error codes. For more information about COM error codes, see Error Handling in COM.

Return codeDescription
Value

Meaning

E_ACCESSDENIED

Text is protected.

E_INVALIDARG

pFont is null.

E_OUTOFMEMORY

Out of memory.

 

Remarks

For occasional format changes, use the ITextRange::SetFont method. However, to make a number of character formatting changes, it is more efficient to use a font duplicate. This is because every time you execute a statement like range.font.bold = tomTrue, a font object is allocated and freed. However, a font duplicate can be allocated once and used many times. Furthermore, you can save the font duplicate, reset it to the default or undefined states with the Reset method, and give it values as needed for your rich-text processing. For sample code that shows how to use font duplicates, see Using a Font Duplicate.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Tom.h

DLL

Msftedit.dll

See also

Reference
ITextRange
Reset
Conceptual
Text Object Model

 

 

Community Additions

ADD
Show:
© 2014 Microsoft