pub struct TextPipeline { /* private fields */ }Expand description
End-to-end text shaping + rasterization pipeline for OxiUI.
Wraps oxitext::Pipeline and maps errors to TextError / UiError.
Implementations§
Source§impl TextPipeline
impl TextPipeline
Sourcepub fn from_bytes(font_bytes: &[u8]) -> Result<Self, TextError>
pub fn from_bytes(font_bytes: &[u8]) -> Result<Self, TextError>
Create a new pipeline from raw font bytes (TTF or OTF).
§Errors
Returns TextError::Pipeline if the font bytes are invalid or
unparseable.
Sourcepub fn from_system_font(family: &str) -> Result<Self, TextError>
pub fn from_system_font(family: &str) -> Result<Self, TextError>
Create a pipeline using a named system font family.
§Errors
Returns TextError::Pipeline if no matching system font is found.
Sourcepub fn set_fallback_fonts(&mut self, fonts: Vec<Vec<u8>>)
pub fn set_fallback_fonts(&mut self, fonts: Vec<Vec<u8>>)
Configure a font fallback chain.
When a glyph is .notdef in the primary font the pipeline walks
this list to find a substitute.
Sourcepub fn shape(
&mut self,
text: &str,
style: &TextStyle,
) -> Result<ShapedText, TextError>
pub fn shape( &mut self, text: &str, style: &TextStyle, ) -> Result<ShapedText, TextError>
Shape and lay out text under style, returning per-line glyph
positions without rasterizing.
§Errors
Propagates shaping/layout errors.
Sourcepub fn measure(
&mut self,
text: &str,
style: &TextStyle,
) -> Result<(f32, f32), TextError>
pub fn measure( &mut self, text: &str, style: &TextStyle, ) -> Result<(f32, f32), TextError>
Measure total bounding box without rasterizing.
Returns (width, height) in pixels.
§Errors
Propagates shaping/layout errors.
Sourcepub fn glyph_positions(
&mut self,
text: &str,
style: &TextStyle,
) -> Result<Vec<GlyphPosition>, TextError>
pub fn glyph_positions( &mut self, text: &str, style: &TextStyle, ) -> Result<Vec<GlyphPosition>, TextError>
Sourcepub fn render(
&mut self,
text: &str,
style: &TextStyle,
) -> Result<RenderResult, UiError>
pub fn render( &mut self, text: &str, style: &TextStyle, ) -> Result<RenderResult, UiError>
Shape and rasterize text with the given style.
Returns a RenderResult containing per-glyph bitmaps.
§Errors
Propagates pipeline errors as UiError::Render.
Auto Trait Implementations§
impl !Freeze for TextPipeline
impl !RefUnwindSafe for TextPipeline
impl Send for TextPipeline
impl Sync for TextPipeline
impl Unpin for TextPipeline
impl UnsafeUnpin for TextPipeline
impl !UnwindSafe for TextPipeline
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> 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