IDWriteTextLayout.HitTestTextPosition

<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>

interface IDWriteTextLayout
extern (Windows)
HRESULT
HitTestTextPosition

Meta