ITextRange::SetFont method (tom.h)
Sets this range's character attributes to those of the specified ITextFont object.
Syntax
HRESULT SetFont(
[in] ITextFont *pFont
);
Parameters
[in] pFont
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 code | Description |
---|---|
|
Meaning |
|
Text is protected. |
|
pFont is null. |
|
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
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps only] |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | tom.h |
DLL | Msftedit.dll |
See also
Conceptual
Reference