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>
impl<'a> ShapedLine<'a>
sourcepub fn original_size(&self) -> Size2D<Px, Px>
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.
sourcepub fn strikethrough(&self) -> (Point2D<Px, Px>, Px)
pub fn strikethrough(&self) -> (Point2D<Px, Px>, Px)
Full strikethrough line, start point + width.
sourcepub fn underline(&self) -> (Point2D<Px, Px>, Px)
pub fn underline(&self) -> (Point2D<Px, Px>, Px)
Full underline, not skipping.
The y is defined by the font metrics.
Returns start point + width.
sourcepub fn underline_descent(&self) -> (Point2D<Px, Px>, Px)
pub fn underline_descent(&self) -> (Point2D<Px, Px>, Px)
Full underline, not skipping.
The y is the baseline + descent + 1px.
Returns start point + width.
sourcepub fn underline_skip_spaces(
&self,
) -> impl Iterator<Item = (Point2D<Px, Px>, Px)> + 'a
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.
sourcepub fn underline_descent_skip_spaces(
&self,
) -> impl Iterator<Item = (Point2D<Px, Px>, Px)> + 'a
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.
sourcepub fn underline_skip_glyphs(
&self,
thickness: Px,
) -> impl Iterator<Item = (Point2D<Px, Px>, Px)> + 'a
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.
sourcepub fn underline_skip_glyphs_and_spaces(
&self,
thickness: Px,
) -> impl Iterator<Item = (Point2D<Px, Px>, Px)> + 'a
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.
sourcepub fn glyphs(
&self,
) -> impl Iterator<Item = (&'a Font, &'a [GlyphInstance])> + 'a
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.
sourcepub fn glyphs_with_x_advance(
&self,
) -> impl Iterator<Item = (&'a Font, impl Iterator<Item = (GlyphInstance, f32)> + 'a)> + 'a
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.
sourcepub fn segs(&self) -> impl DoubleEndedIterator + ExactSizeIterator
pub fn segs(&self) -> impl DoubleEndedIterator + ExactSizeIterator
Iterate over word and space segments in this line.
sourcepub fn seg(&self, seg_idx: usize) -> Option<ShapedSegment<'_>>
pub fn seg(&self, seg_idx: usize) -> Option<ShapedSegment<'_>>
Get the segment by index.
The first segment of the line is 0
.
sourcepub fn started_by_wrap(&self) -> bool
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
.
sourcepub fn ended_by_wrap(&self) -> bool
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
.
sourcepub fn actual_line_start(&self) -> ShapedLine<'a>
pub fn actual_line_start(&self) -> ShapedLine<'a>
Returns the line or first previous line that is not started_by_wrap
.
sourcepub fn actual_line_end(&self) -> ShapedLine<'a>
pub fn actual_line_end(&self) -> ShapedLine<'a>
Returns the line or first next line that is not ended_by_wrap
.
sourcepub fn text_range(&self) -> Range<usize>
pub fn text_range(&self) -> Range<usize>
Get the text bytes range of this line in the original text.
sourcepub fn text_caret_range(&self) -> Range<usize>
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.
sourcepub fn actual_text_range(&self) -> Range<usize>
pub fn actual_text_range(&self) -> Range<usize>
Gets the text range of the actual line, joining shaped lines that are started by wrap.
sourcepub fn actual_text_caret_range(&self) -> Range<usize>
pub fn actual_text_caret_range(&self) -> Range<usize>
Gets the text range of the actual line, excluding the line break at the end.
sourcepub fn text<'s>(&self, full_text: &'s str) -> &'s str
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
.
sourcepub fn nearest_seg(&self, x: Px) -> Option<ShapedSegment<'a>>
pub fn nearest_seg(&self, x: Px) -> Option<ShapedSegment<'a>>
Gets the segment that contains x
or is nearest to it.
sourcepub fn directions(&self) -> LayoutDirections
pub fn directions(&self) -> LayoutDirections
Layout directions of segments in this line.
Trait Implementations§
source§impl<'a> Clone for ShapedLine<'a>
impl<'a> Clone for ShapedLine<'a>
source§fn clone(&self) -> ShapedLine<'a>
fn clone(&self) -> ShapedLine<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for ShapedLine<'a>
impl<'a> Debug for ShapedLine<'a>
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> 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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