pub struct LineBoxMetrics { /* private fields */ }Expand description
Accumulates metrics for a single line box during inline layout.
Implements the CSS 2.2 §10.8.1 “half-leading” model:
- Each inline item has a content area (ascent + descent from font metrics)
- CSS
line-heightdistributes “half-leading” equally above and below - The line box height is the maximum extent of all items after leading
Usage: create a new LineBoxMetrics, call add_item() for each inline
item on the line, then call line_height() and baseline_offset().
Implementations§
Source§impl LineBoxMetrics
impl LineBoxMetrics
pub fn new() -> Self
Sourcepub fn add_item(&mut self, ascent: f32, descent: f32, line_height: f32)
pub fn add_item(&mut self, ascent: f32, descent: f32, line_height: f32)
Add an inline item’s metrics to this line box.
ascent: font ascent (positive, distance from baseline to top of text)descent: font descent (positive, distance from baseline to bottom of text)line_height: the computed CSSline-heightfor this item
Half-leading = (line_height - (ascent + descent)) / 2, added above and below.
Sourcepub fn line_height(&self) -> f32
pub fn line_height(&self) -> f32
The total height of the line box.
Sourcepub fn baseline_offset(&self) -> f32
pub fn baseline_offset(&self) -> f32
The offset from the top of the line box to the baseline.
Trait Implementations§
Source§impl Clone for LineBoxMetrics
impl Clone for LineBoxMetrics
Source§fn clone(&self) -> LineBoxMetrics
fn clone(&self) -> LineBoxMetrics
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for LineBoxMetrics
impl RefUnwindSafe for LineBoxMetrics
impl Send for LineBoxMetrics
impl Sync for LineBoxMetrics
impl Unpin for LineBoxMetrics
impl UnsafeUnpin for LineBoxMetrics
impl UnwindSafe for LineBoxMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more