Struct zng::font::ShapedLine

source ·
pub struct ShapedLine<'a> { /* private fields */ }
Expand description

Represents a line selection of a ShapedText.

Implementations§

source§

impl<'a> ShapedLine<'a>

source

pub fn height(&self) -> Px

Height of the line.

source

pub fn rect(&self) -> Rect<Px, Px>

Bounds of the line.

source

pub fn original_size(&self) -> Size2D<Px, Px>

Initial size of the line, before any line reshaping.

This can be different then the current rect size if the parent inline changed the size, usually to inject blank spaces to justify the text or to visually insert a bidirectional fragment of another widget.

source

pub fn overline(&self) -> (Point2D<Px, Px>, Px)

Full overline, start point + width.

source

pub fn strikethrough(&self) -> (Point2D<Px, Px>, Px)

Full strikethrough line, start point + width.

source

pub fn underline(&self) -> (Point2D<Px, Px>, Px)

Full underline, not skipping.

The y is defined by the font metrics.

Returns start point + width.

source

pub fn underline_descent(&self) -> (Point2D<Px, Px>, Px)

Full underline, not skipping.

The y is the baseline + descent + 1px.

Returns start point + width.

source

pub fn underline_skip_spaces( &self, ) -> impl Iterator<Item = (Point2D<Px, Px>, Px)> + 'a

Underline, skipping spaces.

The y is defined by the font metrics.

Returns and iterator of start point + width for each word.

source

pub fn underline_descent_skip_spaces( &self, ) -> impl Iterator<Item = (Point2D<Px, Px>, Px)> + 'a

Underline, skipping spaces.

The y is the baseline + descent + 1px.

Returns and iterator of start point + width for each word.

source

pub fn underline_skip_glyphs( &self, thickness: Px, ) -> impl Iterator<Item = (Point2D<Px, Px>, Px)> + 'a

Underline, skipping glyph descends that intersect the underline.

The y is defined by the font metrics.

Returns an iterator of start point + width for continuous underline.

source

pub fn underline_skip_glyphs_and_spaces( &self, thickness: Px, ) -> impl Iterator<Item = (Point2D<Px, Px>, Px)> + 'a

Underline, skipping spaces and glyph descends that intersect the underline

The y is defined by font metrics.

Returns an iterator of start point + width for continuous underline.

source

pub fn glyphs( &self, ) -> impl Iterator<Item = (&'a Font, &'a [GlyphInstance])> + 'a

Glyphs in the line.

The glyphs are in text order by segments and in visual order (LTR) within segments, so the RTL text “لما “ will have the space glyph first, then “’álif”, “miim”, “láam”.

All glyph points are set as offsets to the top-left of the text full text.

source

pub fn glyphs_with_x_advance( &self, ) -> impl Iterator<Item = (&'a Font, impl Iterator<Item = (GlyphInstance, f32)> + 'a)> + 'a

Glyphs in the line paired with the x-advance.

source

pub fn segs(&self) -> impl DoubleEndedIterator + ExactSizeIterator

Iterate over word and space segments in this line.

source

pub fn segs_len(&self) -> usize

Number of segments in this line.

source

pub fn seg(&self, seg_idx: usize) -> Option<ShapedSegment<'_>>

Get the segment by index.

The first segment of the line is 0.

source

pub fn started_by_wrap(&self) -> bool

Returns true if this line was started by the wrap algorithm.

If this is false then the line is the first or the previous line ends in a LineBreak.

source

pub fn ended_by_wrap(&self) -> bool

Returns true if this line was ended by the wrap algorithm.

If this is false then the line is the last or ends in a LineBreak.

source

pub fn actual_line_start(&self) -> ShapedLine<'a>

Returns the line or first previous line that is not started_by_wrap.

source

pub fn actual_line_end(&self) -> ShapedLine<'a>

Returns the line or first next line that is not ended_by_wrap.

source

pub fn text_range(&self) -> Range<usize>

Get the text bytes range of this line in the original text.

source

pub fn text_caret_range(&self) -> Range<usize>

Get the text bytes range of this line in the original text, excluding the line break to keep end in the same line.

source

pub fn actual_text_range(&self) -> Range<usize>

Gets the text range of the actual line, joining shaped lines that are started by wrap.

source

pub fn actual_text_caret_range(&self) -> Range<usize>

Gets the text range of the actual line, excluding the line break at the end.

source

pub fn text<'s>(&self, full_text: &'s str) -> &'s str

Select the string represented by this line.

The full_text must be equal to the original text that was used to generate the parent ShapedText.

source

pub fn nearest_seg(&self, x: Px) -> Option<ShapedSegment<'a>>

Gets the segment that contains x or is nearest to it.

source

pub fn index(&self) -> usize

Gets the line index.

source

pub fn directions(&self) -> LayoutDirections

Layout directions of segments in this line.

Trait Implementations§

source§

impl<'a> Clone for ShapedLine<'a>

source§

fn clone(&self) -> ShapedLine<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for ShapedLine<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'a> Copy for ShapedLine<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ShapedLine<'a>

§

impl<'a> !RefUnwindSafe for ShapedLine<'a>

§

impl<'a> Send for ShapedLine<'a>

§

impl<'a> Sync for ShapedLine<'a>

§

impl<'a> Unpin for ShapedLine<'a>

§

impl<'a> !UnwindSafe for ShapedLine<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FsChangeNote for T
where T: Debug + Any + Send + Sync,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Access any.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

source§

impl<T> StateValue for T
where T: Any + Send + Sync,