Package: pango

Function pango-layout-line-x-to-index

Lambda List

pango-layout-line-x-to-index (line x-pos)

Arguments

iter -- a pango-layout-iter instance
x-pos -- an integer with the x offset (in Pango units) from the left edge of the line

Return Value

index -- an integer with the calculated byte index for the grapheme in which the user clicked
trailing -- an integer indicating where in the grapheme the user clicked. It will either be zero, or the number of characters in the grapheme. 0 represents the leading edge of the grapheme. bool -- false if x-pos was outside the line, true if inside

Details

Converts from x offset to the byte index of the corresponding character within the text of the layout. If x-pos is outside the line, index and trailing will point to the very first or very last position in the line. This determination is based on the resolved direction of the paragraph; for example, if the resolved direction is right-to-left, then an x position to the right of the line (after it) results in 0 being stored in index and trailing. An x position to the left of the line results in index pointing to the (logical) last grapheme in the line and trailing being set to the number of characters in that grapheme. The reverse is true for a left-to-right line.
 

See also

2021-1-16