2.21 <PangoLayoutLine>

Structure: <PangoLayoutLine>

A <PangoLayoutLine> represents one of the lines resulting from laying out a paragraph via <PangoLayout>.

<PangoLayoutLine> structures are obtained by calling layout:get-line and are only valid until the text, attributes, or settings of the parent <PangoLayout> are modified.

Fields

layout

the layout this line belongs to, might be #f

start-index

start of line as byte index into layout->text

length

length of line in bytes

runs

list of runs in the line, from left to right

is-paragraph-start

TRUE if this is the first line of the paragraph

resolved-dir

Resolved PangoDirection of line

Procedures

Method: layout-line:get-extents! self ink-rect logical-rect ⇒ ink-rect logical-rect
Method: get-extents! self ink-rect logical-rect ⇒ ink-rect logical-rect

Computes the logical and ink extents of a layout line.

See font:get-glyph-extents! for details about the interpretation of the rectangles.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

ink-rect

Passed, filled in, and returned: a <PangoRectangle>.

rectangle used to store the extents of the glyph string as drawn

logical-rect

Passed, filled in, and returned: a <PangoRectangle>.

rectangle used to store the logical extents of the glyph string

Method: layout-line:get-height self ⇒ height
Method: get-height self ⇒ height

Computes the height of the line, as the maximum of the heights of fonts used in this line.

Note that the actual baseline-to-baseline distance between lines of text is influenced by other factors, such as layout:set-spacing and layout:set-line-spacing.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

height

Returned: a 32-bit integer.

return location for the line height

Method: layout-line:get-length self ⇒ %return
Method: get-length self ⇒ %return

Returns the length of the line, in bytes.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

%return

Returned: a 32-bit integer.

the length of the line

Method: layout-line:get-pixel-extents! self ink-rect logical-rect ⇒ ink-rect logical-rect
Method: get-pixel-extents! self ink-rect logical-rect ⇒ ink-rect logical-rect

Computes the logical and ink extents of self in device units.

This function just calls layout-line:get-extents! followed by two extents_to_pixels calls, rounding ink-rect and logical-rect such that the rounded rectangles fully contain the unrounded one (that is, passes them as first argument to extents_to_pixels).

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

ink-rect

Passed, filled in, and returned: a <PangoRectangle>.

rectangle used to store the extents of the glyph string as drawn

logical-rect

Passed, filled in, and returned: a <PangoRectangle>.

rectangle used to store the logical extents of the glyph string

Method: layout-line:get-resolved-direction self ⇒ %return
Method: get-resolved-direction self ⇒ %return

Returns the resolved direction of the line.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

%return

Returned: a <PangoDirection>.

the resolved direction of the line

Method: layout-line:get-start-index self ⇒ %return
Method: get-start-index self ⇒ %return

Returns the start index of the line, as byte index into the text of the layout.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

%return

Returned: a 32-bit integer.

the start index of the line

Method: layout-line:get-x-ranges self start-index end-index ⇒ ranges
Method: get-x-ranges self start-index end-index ⇒ ranges

Gets a list of visual ranges corresponding to a given logical range.

This list is not necessarily minimal - there may be consecutive ranges which are adjacent. The ranges will be sorted from left to right. The ranges are with respect to the left edge of the entire layout, not with respect to the line.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

start-index

Passed: a 32-bit integer.

Start byte index of the logical range. If this value is less than the start index for the line, then the first range will extend all the way to the leading edge of the layout. Otherwise, it will start at the leading edge of the first character.

end-index

Passed: a 32-bit integer.

Ending byte index of the logical range. If this value is greater than the end index for the line, then the last range will extend all the way to the trailing edge of the layout. Otherwise, it will end at the trailing edge of the last character.

ranges

Returned: a s32vector.

location to store a pointer to an array of ranges. The array will be of length 2*n_ranges, with each range starting at (*ranges)[2*n] and of width (*ranges)[2*n + 1] - (*ranges)[2*n]. This array must be freed with byte-array:free. The coordinates are relative to the layout and are in Pango units.

n-ranges

Not returned: it is the length of ranges.

The number of ranges stored in ranges

Method: layout-line:index-to-x self index- trailing ⇒ x-pos
Method: index-to-x self index- trailing ⇒ x-pos

Converts an index within a line to a X position.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

index-

Passed: a 32-bit integer.

byte offset of a grapheme within the layout

trailing

Passed: a boolean.

an integer indicating the edge of the grapheme to retrieve the position of. If > 0, the trailing edge of the grapheme, if 0, the leading of the grapheme

x-pos

Returned: a 32-bit integer.

location to store the x_offset (in Pango units)

Method: layout-line:is-paragraph-start? self ⇒ %return
Method: is-paragraph-start? self ⇒ %return

Returns whether this is the first line of the paragraph.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

%return

Returned: a boolean.

#t if this is the first line

Method: layout-line:ref self ⇒ %return
Method: ref self ⇒ %return

Increase the reference count of a <PangoLayoutLine> by one.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

%return

Returned: a <PangoLayoutLine>, or #f.

the line passed in.

Method: layout-line:unref self
Method: unref self

Decrease the reference count of a <PangoLayoutLine> by one.

If the result is zero, the line and all associated memory will be freed.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

Method: layout-line:x-to-index self x-pos ⇒ %return index- trailing
Method: x-to-index self x-pos ⇒ %return index- trailing

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.

self

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

x-pos

Passed: a 32-bit integer.

the X offset (in Pango units) from the left edge of the line.

%return

Returned: a boolean.

#f if x-pos was outside the line, #t if inside

index-

Returned: a 32-bit integer.

location to store calculated byte index for the grapheme in which the user clicked

trailing

Returned: a 32-bit integer.

location to store 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.