Struct zng_ext_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) -> PxRect

Bounds of the line.

source

pub fn original_size(&self) -> PxSize

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) -> (PxPoint, Px)

Full overline, start point + width.

source

pub fn strikethrough(&self) -> (PxPoint, Px)

Full strikethrough line, start point + width.

source

pub fn underline(&self) -> (PxPoint, Px)

Full underline, not skipping.

The y is defined by the font metrics.

Returns start point + width.

source

pub fn underline_descent(&self) -> (PxPoint, 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 = (PxPoint, 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 = (PxPoint, 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 = (PxPoint, 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 = (PxPoint, 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<Item = ShapedSegment<'a>> + 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) -> Self

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

source

pub fn actual_line_end(&self) -> Self

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

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: Copy,

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

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

source§

default 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
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, 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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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

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

§

impl<T> MaybeSendSync for T

source§

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