Skip to main content

text_block_top

Function text_block_top 

Source
pub fn text_block_top(inner_h: f32, line_height: f32, stacked: bool) -> f32
Expand description

Offset from the inner content box top to the top of the FIRST line box, in logical pixels. line_height is the resolved CSS line height (see resolve_line_height) - the caller passes resolve_line_height(style.line_height, size_px) so an authored line-height moves the block origin the same way it moves the line box.

A lone line centers in the inner box, which is what QLineEdit does with its lineRect. A stacked block starts at the top, as every multi-line editor does, so line i occupies [top + i * line_height, top + (i + 1) * line_height); that is the band TextGeometry::x_to_byte resolves a pointer y against.

stacked is true for a text area (which stays top-aligned however little it holds, so the first newline does not make the content jump) and for any run that already occupies more than one line.

This is the single origin the drawn baseline and the hit test share; the layout producer evaluates it against the SHAPED (soft-wrap aware) line count and publishes the result as TextBlockOrigin.