CD2DTextLayout Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CD2DTextLayout Class.

A wrapper for IDWriteTextLayout.

class CD2DTextLayout : public CD2DResource;  

Public Constructors

NameDescription
CD2DTextLayout::CD2DTextLayoutConstructs a CD2DTextLayout object.
CD2DTextLayout::~CD2DTextLayoutThe destructor. Called when a D2D text layout object is being destroyed.

Public Methods

NameDescription
CD2DTextLayout::CreateCreates a CD2DTextLayout. (Overrides CD2DResource::Create.)
CD2DTextLayout::DestroyDestroys a CD2DTextLayout object. (Overrides CD2DResource::Destroy.)
CD2DTextLayout::GetReturns IDWriteTextLayout interface
CD2DTextLayout::GetFontFamilyNameCopies the font family name of the text at the specified position.
CD2DTextLayout::GetLocaleNameGets the locale name of the text at the specified position.
CD2DTextLayout::IsValidChecks resource validity (Overrides CD2DResource::IsValid.)
CD2DTextLayout::ReCreateRe-creates a CD2DTextLayout. (Overrides CD2DResource::ReCreate.)
CD2DTextLayout::SetFontFamilyNameSets null-terminated font family name for text within a specified text range
CD2DTextLayout::SetLocaleNameSets the locale name for text within a specified text range

Public Operators

NameDescription
CD2DTextLayout::operator IDWriteTextLayout*Returns IDWriteTextLayout interface

Protected Data Members

NameDescription
CD2DTextLayout::m_pTextLayoutA pointer to an IDWriteTextLayout.

CObject

CD2DResource

CD2DTextLayout

Header: afxrendertarget.h

The destructor. Called when a D2D text layout object is being destroyed.

virtual ~CD2DTextLayout();

Constructs a CD2DTextLayout object.

CD2DTextLayout(
    CRenderTarget* pParentTarget,  
    const CString& strText,  
    CD2DTextFormat& textFormat,  
    const CD2DSizeF& sizeMax,  
    BOOL bAutoDestroy = TRUE);

Parameters

pParentTarget
A pointer to the render target.

strText
A CString object that contains the string to create a new CD2DTextLayout object from.

textFormat
A CString object that contains the format to apply to the string.

sizeMax
The size of the layout box.

bAutoDestroy
Indicates that the object will be destroyed by owner (pParentTarget).

Creates a CD2DTextLayout.

virtual HRESULT Create(CRenderTarget* */);

Return Value

If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Destroys a CD2DTextLayout object.

virtual void Destroy();

Returns IDWriteTextLayout interface

IDWriteTextLayout* Get();

Return Value

Pointer to an IDWriteTextLayout interface or NULL if object is not initialized yet.

Copies the font family name of the text at the specified position.

CString GetFontFamilyName(
    UINT32 currentPosition,  
    DWRITE_TEXT_RANGE* textRange = NULL) const;  

Parameters

currentPosition
The position of the text to examine.

textRange
The range of text that has the same formatting as the text at the position specified by currentPosition. This means the run has the exact formatting as the position specified, including but not limited to the font family name.

Return Value

CString object that contains the current font family name.

Gets the locale name of the text at the specified position.

CString GetLocaleName(
    UINT32 currentPosition,  
    DWRITE_TEXT_RANGE* textRange = NULL) const;  

Parameters

currentPosition
The position of the text to inspect.

textRange
The range of text that has the same formatting as the text at the position specified by currentPosition. This means the run has the exact formatting as the position specified, including but not limited to the locale name.

Return Value

CString object that contains the current locale name.

Checks resource validity

virtual BOOL IsValid() const;  

Return Value

TRUE if resource is valid; otherwise FALSE.

A pointer to an IDWriteTextLayout.

IDWriteTextLayout* m_pTextLayout;  

Returns IDWriteTextLayout interface

operator IDWriteTextLayout*();

Return Value

Pointer to an IDWriteTextLayout interface or NULL if object is not initialized yet.

Re-creates a CD2DTextLayout.

virtual HRESULT ReCreate(CRenderTarget* */);

Return Value

If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Sets null-terminated font family name for text within a specified text range

BOOL SetFontFamilyName(
    LPCWSTR pwzFontFamilyName,  
    DWRITE_TEXT_RANGE textRange);

Parameters

pwzFontFamilyName
The font family name that applies to the entire text string within the range specified by textRange

textRange
Text range to which this change applies

Return Value

If the method succeeds, it returns TRUE. Otherwise, it returns FALSE

Sets the locale name for text within a specified text range

BOOL SetLocaleName(
    LPCWSTR pwzLocaleName,  
    DWRITE_TEXT_RANGE textRange);

Parameters

pwzLocaleName
A null-terminated locale name string

textRange
Text range to which this change applies

Return Value

If the method succeeds, it returns TRUE. Otherwise, it returns FALSE

Classes

Show: