IDWriteTextLayout.HitTestTextRange

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

The function returns E_NOT_SUFFICIENT_BUFFER, which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), when the buffer size of hitTestMetrics is too small to hold all the regions calculated by the function. In such situation, the function sets the output value *actualHitTestMetricsCount to the number of geometries calculated. The application is responsible to allocate a new buffer of greater size and call the function again.

A good value to use as an initial value for maxHitTestMetricsCount may be calculated from the following equation: maxHitTestMetricsCount = lineCount * maxBidiReorderingDepth

where lineCount is obtained from the value of the output argument *actualLineCount from the function IDWriteTextLayout::GetLineMetrics, and the maxBidiReorderingDepth value from the DWRITE_TEXT_METRICS structure of the output argument *textMetrics from the function IDWriteFactory::CreateTextLayout. </summary> <param name="textPosition">First text position of the specified range.</param> <param name="textLength">Number of positions of the specified range.</param> <param name="originX">Offset of the X origin (left of the layout box) which is added to each of the hit-test metrics returned.</param> <param name="originY">Offset of the Y origin (top of the layout box) which is added to each of the hit-test metrics returned.</param> <param name="hitTestMetrics">Pointer to a buffer of the output geometry fully enclosing the specified position range.</param> <param name="maxHitTestMetricsCount">Maximum number of distinct metrics it could hold in its buffer memory.</param> <param name="actualHitTestMetricsCount">Actual number of metrics returned or needed.</param> <returns> Standard HRESULT error code. </returns> <remarks> There are no gaps in the returned metrics. While there could be visual gaps, depending on bidi ordering, each range is contiguous and reports all the text, including any hidden characters and trimmed text. The height of each returned range will be the same within each line, regardless of how the font sizes vary. </remarks>

interface IDWriteTextLayout
extern (Windows)
HRESULT
HitTestTextRange

Meta