pub struct TextSystem { /* private fields */ }Expand description
The GPUI text rendering sub system.
Implementations§
Source§impl TextSystem
impl TextSystem
Sourcepub fn all_font_names(&self) -> Vec<String>
pub fn all_font_names(&self) -> Vec<String>
Get a list of all available font names from the operating system.
Sourcepub fn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<()>
pub fn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<()>
Add a font’s data to the text system.
Sourcepub fn get_font_for_id(&self, id: FontId) -> Option<Font>
pub fn get_font_for_id(&self, id: FontId) -> Option<Font>
Get the Font for the Font Id.
Sourcepub fn resolve_font(&self, font: &Font) -> FontId
pub fn resolve_font(&self, font: &Font) -> FontId
Resolves the specified font, falling back to the default font stack if the font fails to load.
§Panics
Panics if the font and none of the fallbacks can be resolved.
Sourcepub fn bounding_box(&self, font_id: FontId, font_size: Pixels) -> Bounds<Pixels>
pub fn bounding_box(&self, font_id: FontId, font_size: Pixels) -> Bounds<Pixels>
Get the bounding box for the given font and font size. A font’s bounding box is the smallest rectangle that could enclose all glyphs in the font. superimposed over one another.
Sourcepub fn typographic_bounds(
&self,
font_id: FontId,
font_size: Pixels,
character: char,
) -> Result<Bounds<Pixels>>
pub fn typographic_bounds( &self, font_id: FontId, font_size: Pixels, character: char, ) -> Result<Bounds<Pixels>>
Get the typographic bounds for the given character, in the given font and size.
Sourcepub fn advance(
&self,
font_id: FontId,
font_size: Pixels,
ch: char,
) -> Result<Size<Pixels>>
pub fn advance( &self, font_id: FontId, font_size: Pixels, ch: char, ) -> Result<Size<Pixels>>
Get the advance width for the given character, in the given font and size.
Sourcepub fn em_width(&self, font_id: FontId, font_size: Pixels) -> Result<Pixels>
pub fn em_width(&self, font_id: FontId, font_size: Pixels) -> Result<Pixels>
Returns the width of an em.
Uses the width of the m character in the given font and size.
Sourcepub fn em_advance(&self, font_id: FontId, font_size: Pixels) -> Result<Pixels>
pub fn em_advance(&self, font_id: FontId, font_size: Pixels) -> Result<Pixels>
Returns the advance width of an em.
Uses the advance width of the m character in the given font and size.
Sourcepub fn ch_width(&self, font_id: FontId, font_size: Pixels) -> Result<Pixels>
pub fn ch_width(&self, font_id: FontId, font_size: Pixels) -> Result<Pixels>
Returns the width of an ch.
Uses the width of the 0 character in the given font and size.
Sourcepub fn ch_advance(&self, font_id: FontId, font_size: Pixels) -> Result<Pixels>
pub fn ch_advance(&self, font_id: FontId, font_size: Pixels) -> Result<Pixels>
Returns the advance width of an ch.
Uses the advance width of the 0 character in the given font and size.
Sourcepub fn units_per_em(&self, font_id: FontId) -> u32
pub fn units_per_em(&self, font_id: FontId) -> u32
Get the number of font size units per ‘em square’, Per MDN: “an abstract square whose height is the intended distance between lines of type in the same type size”
Sourcepub fn cap_height(&self, font_id: FontId, font_size: Pixels) -> Pixels
pub fn cap_height(&self, font_id: FontId, font_size: Pixels) -> Pixels
Get the height of a capital letter in the given font and size.
Sourcepub fn x_height(&self, font_id: FontId, font_size: Pixels) -> Pixels
pub fn x_height(&self, font_id: FontId, font_size: Pixels) -> Pixels
Get the height of the x character in the given font and size.
Sourcepub fn ascent(&self, font_id: FontId, font_size: Pixels) -> Pixels
pub fn ascent(&self, font_id: FontId, font_size: Pixels) -> Pixels
Get the recommended distance from the baseline for the given font
Sourcepub fn descent(&self, font_id: FontId, font_size: Pixels) -> Pixels
pub fn descent(&self, font_id: FontId, font_size: Pixels) -> Pixels
Get the recommended distance below the baseline for the given font, in single spaced text.
Sourcepub fn baseline_offset(
&self,
font_id: FontId,
font_size: Pixels,
line_height: Pixels,
) -> Pixels
pub fn baseline_offset( &self, font_id: FontId, font_size: Pixels, line_height: Pixels, ) -> Pixels
Get the recommended baseline offset for the given font and line height.
Sourcepub fn line_wrapper(
self: &Arc<Self>,
font: Font,
font_size: Pixels,
) -> LineWrapperHandle
pub fn line_wrapper( self: &Arc<Self>, font: Font, font_size: Pixels, ) -> LineWrapperHandle
Returns a handle to a line wrapper, for the given font and font size.
Auto Trait Implementations§
impl !Freeze for TextSystem
impl !RefUnwindSafe for TextSystem
impl Send for TextSystem
impl Sync for TextSystem
impl Unpin for TextSystem
impl !UnwindSafe for TextSystem
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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