IDWriteTextLayout1

<summary> The IDWriteTextLayout1 interface represents a block of text after it has been fully analyzed and formatted.

All coordinates are in device independent pixels (DIPs). </summary>

Members

Functions

GetCharacterSpacing
HRESULT GetCharacterSpacing(UINT32 currentPosition, FLOAT* leadingSpacing, FLOAT* trailingSpacing, FLOAT* minimumAdvanceWidth, DWRITE_TEXT_RANGE* textRange = null)

<summary> Gets the spacing between characters. </summary> <param name="currentPosition">The current text position.</param> <param name="leadingSpacing">The spacing before each character, in reading order.</param> <param name="trailingSpacing">The spacing after each character, in reading order.</param> <param name="minimumAdvanceWidth">The minimum advance of each character, to prevent characters from becoming too thin or zero-width. This must be zero or greater.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetPairKerning
HRESULT GetPairKerning(UINT32 currentPosition, BOOL* isPairKerningEnabled, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get whether or not pair-kerning is enabled at given position. </summary> <param name="currentPosition">The current text position.</param> <param name="isPairKerningEnabled">The Boolean flag indicates whether text is pair-kerned.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

SetCharacterSpacing
HRESULT SetCharacterSpacing(FLOAT leadingSpacing, FLOAT trailingSpacing, FLOAT minimumAdvanceWidth, DWRITE_TEXT_RANGE textRange)

<summary> Sets the spacing between characters. </summary> <param name="leadingSpacing">The spacing before each character, in reading order.</param> <param name="trailingSpacing">The spacing after each character, in reading order.</param> <param name="minimumAdvanceWidth">The minimum advance of each character, to prevent characters from becoming too thin or zero-width. This must be zero or greater.</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetPairKerning
HRESULT SetPairKerning(BOOL isPairKerningEnabled, DWRITE_TEXT_RANGE textRange)

<summary> Enables/disables pair-kerning on the given range. </summary> <param name="isPairKerningEnabled">The Boolean flag indicates whether text is pair-kerned.</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

Inherited Members

From IDWriteTextLayout

SetMaxWidth
HRESULT SetMaxWidth(FLOAT maxWidth)

<summary> Set layout maximum width </summary> <param name="maxWidth">Layout maximum width</param> <returns> Standard HRESULT error code. </returns>

SetMaxHeight
HRESULT SetMaxHeight(FLOAT maxHeight)

<summary> Set layout maximum height </summary> <param name="maxHeight">Layout maximum height</param> <returns> Standard HRESULT error code. </returns>

SetFontCollection
HRESULT SetFontCollection(IDWriteFontCollection fontCollection, DWRITE_TEXT_RANGE textRange)

<summary> Set the font collection. </summary> <param name="fontCollection">The font collection to set</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetFontFamilyName
HRESULT SetFontFamilyName(const(WCHAR)* fontFamilyName, DWRITE_TEXT_RANGE textRange)

<summary> Set null-terminated font family name. </summary> <param name="fontFamilyName">Font family name</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetFontWeight
HRESULT SetFontWeight(DWRITE_FONT_WEIGHT fontWeight, DWRITE_TEXT_RANGE textRange)

<summary> Set font weight. </summary> <param name="fontWeight">Font weight</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetFontStyle
HRESULT SetFontStyle(DWRITE_FONT_STYLE fontStyle, DWRITE_TEXT_RANGE textRange)

<summary> Set font style. </summary> <param name="fontStyle">Font style</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetFontStretch
HRESULT SetFontStretch(DWRITE_FONT_STRETCH fontStretch, DWRITE_TEXT_RANGE textRange)

<summary> Set font stretch. </summary> <param name="fontStretch">font stretch</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetFontSize
HRESULT SetFontSize(FLOAT fontSize, DWRITE_TEXT_RANGE textRange)

<summary> Set font em height. </summary> <param name="fontSize">Font em height</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetUnderline
HRESULT SetUnderline(BOOL hasUnderline, DWRITE_TEXT_RANGE textRange)

<summary> Set underline. </summary> <param name="hasUnderline">The Boolean flag indicates whether underline takes place</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetStrikethrough
HRESULT SetStrikethrough(BOOL hasStrikethrough, DWRITE_TEXT_RANGE textRange)

<summary> Set strikethrough. </summary> <param name="hasStrikethrough">The Boolean flag indicates whether strikethrough takes place</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetDrawingEffect
HRESULT SetDrawingEffect(IUnknown drawingEffect, DWRITE_TEXT_RANGE textRange)

<summary> Set application-defined drawing effect. </summary> <param name="drawingEffect">Pointer to an application-defined drawing effect.</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns> <remarks> This drawing effect is associated with the specified range and will be passed back to the application via the callback when the range is drawn at drawing time. </remarks>

SetInlineObject
HRESULT SetInlineObject(IDWriteInlineObject inlineObject, DWRITE_TEXT_RANGE textRange)

<summary> Set inline object. </summary> <param name="inlineObject">Pointer to an application-implemented inline object.</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns> <remarks> This inline object applies to the specified range and will be passed back to the application via the DrawInlineObject callback when the range is drawn. Any text in that range will be suppressed. </remarks>

SetTypography
HRESULT SetTypography(IDWriteTypography typography, DWRITE_TEXT_RANGE textRange)

<summary> Set font typography features. </summary> <param name="typography">Pointer to font typography setting.</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

SetLocaleName
HRESULT SetLocaleName(const(WCHAR)* localeName, DWRITE_TEXT_RANGE textRange)

<summary> Set locale name. </summary> <param name="localeName">Locale name</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

GetMaxWidth
FLOAT GetMaxWidth()

<summary> Get layout maximum width </summary>

GetMaxHeight
FLOAT GetMaxHeight()

<summary> Get layout maximum height </summary>

GetFontCollection
HRESULT GetFontCollection(UINT32 currentPosition, IDWriteFontCollection* fontCollection, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the font collection where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="fontCollection">The current font collection</param> <param name="textRange">Text range to which this change applies.</param> <returns> Standard HRESULT error code. </returns>

GetFontFamilyNameLength
HRESULT GetFontFamilyNameLength(UINT32 currentPosition, UINT32* nameLength, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the length of the font family name where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="nameLength">Size of the character array in character count not including the terminated NULL character.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetFontFamilyName
HRESULT GetFontFamilyName(UINT32 currentPosition, WCHAR* fontFamilyName, UINT32 nameSize, DWRITE_TEXT_RANGE* textRange = null)

<summary> Copy the font family name where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="fontFamilyName">Character array that receives the current font family name</param> <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetFontWeight
HRESULT GetFontWeight(UINT32 currentPosition, DWRITE_FONT_WEIGHT* fontWeight, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the font weight where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="fontWeight">The current font weight</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetFontStyle
HRESULT GetFontStyle(UINT32 currentPosition, DWRITE_FONT_STYLE* fontStyle, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the font style where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="fontStyle">The current font style</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetFontStretch
HRESULT GetFontStretch(UINT32 currentPosition, DWRITE_FONT_STRETCH* fontStretch, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the font stretch where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="fontStretch">The current font stretch</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetFontSize
HRESULT GetFontSize(UINT32 currentPosition, FLOAT* fontSize, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the font em height where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="fontSize">The current font em height</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetUnderline
HRESULT GetUnderline(UINT32 currentPosition, BOOL* hasUnderline, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the underline presence where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="hasUnderline">The Boolean flag indicates whether text is underlined.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetStrikethrough
HRESULT GetStrikethrough(UINT32 currentPosition, BOOL* hasStrikethrough, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the strikethrough presence where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="hasStrikethrough">The Boolean flag indicates whether text has strikethrough.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetDrawingEffect
HRESULT GetDrawingEffect(UINT32 currentPosition, IUnknown* drawingEffect, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the application-defined drawing effect where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="drawingEffect">The current application-defined drawing effect.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetInlineObject
HRESULT GetInlineObject(UINT32 currentPosition, IDWriteInlineObject* inlineObject, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the inline object at the given position. </summary> <param name="currentPosition">The given text position.</param> <param name="inlineObject">The inline object.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetTypography
HRESULT GetTypography(UINT32 currentPosition, IDWriteTypography* typography, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the typography setting where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="typography">The current typography setting.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetLocaleNameLength
HRESULT GetLocaleNameLength(UINT32 currentPosition, UINT32* nameLength, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the length of the locale name where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="nameLength">Size of the character array in character count not including the terminated NULL character.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

GetLocaleName
HRESULT GetLocaleName(UINT32 currentPosition, WCHAR* localeName, UINT32 nameSize, DWRITE_TEXT_RANGE* textRange = null)

<summary> Get the locale name where the current position is at. </summary> <param name="currentPosition">The current text position.</param> <param name="localeName">Character array that receives the current locale name</param> <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param> <param name="textRange">The position range of the current format.</param> <returns> Standard HRESULT error code. </returns>

Draw
HRESULT Draw(void* clientDrawingContext, IDWriteTextRenderer renderer, FLOAT originX, FLOAT originY)

<summary> Initiate drawing of the text. </summary> <param name="clientDrawingContext">An application defined value included in rendering callbacks.</param> <param name="renderer">The set of application-defined callbacks that do the actual rendering.</param> <param name="originX">X-coordinate of the layout's left side.</param> <param name="originY">Y-coordinate of the layout's top side.</param> <returns> Standard HRESULT error code. </returns>

GetLineMetrics
HRESULT GetLineMetrics(DWRITE_LINE_METRICS* lineMetrics, UINT32 maxLineCount, UINT32* actualLineCount)

<summary> GetLineMetrics returns properties of each line. </summary> <param name="lineMetrics">The array to fill with line information.</param> <param name="maxLineCount">The maximum size of the lineMetrics array.</param> <param name="actualLineCount">The actual size of the lineMetrics array that is needed.</param> <returns> Standard HRESULT error code. </returns> <remarks> If maxLineCount is not large enough E_NOT_SUFFICIENT_BUFFER, which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), is returned and *actualLineCount is set to the number of lines needed. </remarks>

GetMetrics
HRESULT GetMetrics(DWRITE_TEXT_METRICS* textMetrics)

<summary> GetMetrics retrieves overall metrics for the formatted string. </summary> <param name="textMetrics">The returned metrics.</param> <returns> Standard HRESULT error code. </returns> <remarks> Drawing effects like underline and strikethrough do not contribute to the text size, which is essentially the sum of advance widths and line heights. Additionally, visible swashes and other graphic adornments may extend outside the returned width and height. </remarks>

GetOverhangMetrics
HRESULT GetOverhangMetrics(DWRITE_OVERHANG_METRICS* overhangs)

<summary> GetOverhangMetrics returns the overhangs (in DIPs) of the layout and all objects contained in it, including text glyphs and inline objects. </summary> <param name="overhangs">Overshoots of visible extents (in DIPs) outside the layout.</param> <returns> Standard HRESULT error code. </returns> <remarks> Any underline and strikethrough do not contribute to the black box determination, since these are actually drawn by the renderer, which is allowed to draw them in any variety of styles. </remarks>

GetClusterMetrics
HRESULT GetClusterMetrics(DWRITE_CLUSTER_METRICS* clusterMetrics, UINT32 maxClusterCount, UINT32* actualClusterCount)

<summary> Retrieve logical properties and measurement of each cluster. </summary> <param name="clusterMetrics">The array to fill with cluster information.</param> <param name="maxClusterCount">The maximum size of the clusterMetrics array.</param> <param name="actualClusterCount">The actual size of the clusterMetrics array that is needed.</param> <returns> Standard HRESULT error code. </returns> <remarks> If maxClusterCount is not large enough E_NOT_SUFFICIENT_BUFFER, which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), is returned and *actualClusterCount is set to the number of clusters needed. </remarks>

DetermineMinWidth
HRESULT DetermineMinWidth(FLOAT* minWidth)

<summary> Determines the minimum possible width the layout can be set to without emergency breaking between the characters of whole words. </summary> <param name="minWidth">Minimum width.</param> <returns> Standard HRESULT error code. </returns>

HitTestPoint
HRESULT HitTestPoint(FLOAT pointX, FLOAT pointY, BOOL* isTrailingHit, BOOL* isInside, DWRITE_HIT_TEST_METRICS* hitTestMetrics)

<summary> Given a coordinate (in DIPs) relative to the top-left of the layout box, this returns the corresponding hit-test metrics of the text string where the hit-test has occurred. This is useful for mapping mouse clicks to caret positions. When the given coordinate is outside the text string, the function sets the output value *isInside to false but returns the nearest character position. </summary> <param name="pointX">X coordinate to hit-test, relative to the top-left location of the layout box.</param> <param name="pointY">Y coordinate to hit-test, relative to the top-left location of the layout box.</param> <param name="isTrailingHit">Output flag indicating whether the hit-test location is at the leading or the trailing side of the character. When the output *isInside value is set to false, this value is set according to the output *position value to represent the edge closest to the hit-test location. </param> <param name="isInside">Output flag indicating whether the hit-test location is inside the text string. When false, the position nearest the text's edge is returned.</param> <param name="hitTestMetrics">Output geometry fully enclosing the hit-test location. When the output *isInside value is set to false, this structure represents the geometry enclosing the edge closest to the hit-test location.</param> <returns> Standard HRESULT error code. </returns>

HitTestTextPosition
HRESULT HitTestTextPosition(UINT32 textPosition, BOOL isTrailingHit, FLOAT* pointX, FLOAT* pointY, DWRITE_HIT_TEST_METRICS* hitTestMetrics)

<summary> Given a text position and whether the caret is on the leading or trailing edge of that position, this returns the corresponding coordinate (in DIPs) relative to the top-left of the layout box. This is most useful for drawing the caret's current position, but it could also be used to anchor an IME to the typed text or attach a floating menu near the point of interest. It may also be used to programmatically obtain the geometry of a particular text position for UI automation. </summary> <param name="textPosition">Text position to get the coordinate of.</param> <param name="isTrailingHit">Flag indicating whether the location is of the leading or the trailing side of the specified text position. </param> <param name="pointX">Output caret X, relative to the top-left of the layout box.</param> <param name="pointY">Output caret Y, relative to the top-left of the layout box.</param> <param name="hitTestMetrics">Output geometry fully enclosing the specified text position.</param> <returns> Standard HRESULT error code. </returns> <remarks> When drawing a caret at the returned X,Y, it should be centered on X and drawn from the Y coordinate down. The height will be the size of the hit-tested text (which can vary in size within a line). Reading direction also affects which side of the character the caret is drawn. However, the returned X coordinate will be correct for either case. You can get a text length back that is larger than a single character. This happens for complex scripts when multiple characters form a single cluster, when diacritics join their base character, or when you test a surrogate pair. </remarks>

HitTestTextRange
HRESULT HitTestTextRange(UINT32 textPosition, UINT32 textLength, FLOAT originX, FLOAT originY, DWRITE_HIT_TEST_METRICS* hitTestMetrics, UINT32 maxHitTestMetricsCount, UINT32* actualHitTestMetricsCount)

<summary> The application calls this function to get a set of hit-test metrics corresponding to a range of text positions. The main usage for this is to draw highlighted selection of the text string.

Meta