pub struct WindowTextSystem { /* private fields */ }Expand description
The GPUI text layout subsystem.
Implementations§
Source§impl WindowTextSystem
impl WindowTextSystem
Sourcepub fn new(text_system: Arc<TextSystem>) -> Self
pub fn new(text_system: Arc<TextSystem>) -> Self
Create a new WindowTextSystem with the given TextSystem.
Sourcepub fn shape_line(
&self,
text: SharedString,
font_size: Pixels,
runs: &[TextRun],
force_width: Option<Pixels>,
) -> ShapedLine
pub fn shape_line( &self, text: SharedString, font_size: Pixels, runs: &[TextRun], force_width: Option<Pixels>, ) -> ShapedLine
Shape the given line, at the given font_size, for painting to the screen.
Subsets of the line can be styled independently with the runs parameter.
Note that this method can only shape a single line of text. It will panic
if the text contains newlines. If you need to shape multiple lines of text,
use Self::shape_text instead.
Sourcepub fn shape_text(
&self,
text: SharedString,
font_size: Pixels,
runs: &[TextRun],
wrap_width: Option<Pixels>,
line_clamp: Option<usize>,
) -> Result<SmallVec<[WrappedLine; 1]>>
pub fn shape_text( &self, text: SharedString, font_size: Pixels, runs: &[TextRun], wrap_width: Option<Pixels>, line_clamp: Option<usize>, ) -> Result<SmallVec<[WrappedLine; 1]>>
Shape a multi line string of text, at the given font_size, for painting to the screen.
Subsets of the text can be styled independently with the runs parameter.
If wrap_width is provided, the line breaks will be adjusted to fit within the given width.
Sourcepub fn layout_line(
&self,
text: &str,
font_size: Pixels,
runs: &[TextRun],
force_width: Option<Pixels>,
) -> Arc<LineLayout> ⓘ
pub fn layout_line( &self, text: &str, font_size: Pixels, runs: &[TextRun], force_width: Option<Pixels>, ) -> Arc<LineLayout> ⓘ
Layout the given line of text, at the given font_size.
Subsets of the line can be styled independently with the runs parameter.
Generally, you should prefer to use Self::shape_line instead, which
can be painted directly.
Sourcepub fn layout_width(
&self,
font_id: FontId,
font_size: Pixels,
ch: char,
) -> Pixels
pub fn layout_width( &self, font_id: FontId, font_size: Pixels, ch: char, ) -> Pixels
Returns the shaped layout width of for the given character, in the given font and size.
Sourcepub fn em_layout_width(&self, font_id: FontId, font_size: Pixels) -> Pixels
pub fn em_layout_width(&self, font_id: FontId, font_size: Pixels) -> Pixels
Returns the shaped layout width of an em.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WindowTextSystem
impl !RefUnwindSafe for WindowTextSystem
impl !Sync for WindowTextSystem
impl !UnwindSafe for WindowTextSystem
impl Send for WindowTextSystem
impl Unpin for WindowTextSystem
impl UnsafeUnpin for WindowTextSystem
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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