pub struct FlexibleTextEngine {
font_system: Arc<Mutex<FontSystem>>,
}Expand description
Cosmic-Text-backed layout engine.
Wraps a FontSystem (which loads system fonts on construction).
Cosmic Text’s FontSystem is !Sync, so we wrap it in a Mutex
so the engine can be shared across threads — necessary for caches
(M-DYN.2-style) and the renderer’s &self access pattern.
Fields§
§font_system: Arc<Mutex<FontSystem>>Implementations§
Source§impl FlexibleTextEngine
impl FlexibleTextEngine
Sourcepub fn with_font_system(font_system: FontSystem) -> Self
pub fn with_font_system(font_system: FontSystem) -> Self
Build the engine with a pre-existing FontSystem.
Useful for tests that want a deterministic font set, or for
hosts that have already loaded a FontSystem for another
purpose.
Sourcepub fn from_font_paths<P: AsRef<Path>>(
paths: impl IntoIterator<Item = P>,
) -> Result<Self>
pub fn from_font_paths<P: AsRef<Path>>( paths: impl IntoIterator<Item = P>, ) -> Result<Self>
Build the engine with a FontSystem seeded from a list of
font file paths. No system fonts are loaded — only the
supplied files are available, and family-name lookups
(WispText::with_font_family)
resolve against this set.
Used by storybook exporters and tests that want byte-identical output across hosts (CI runners have different system fonts).
§Errors
Returns io::Error if any path can’t be opened or isn’t a
recognized font file.
Sourcepub fn from_font_bytes(bytes: impl IntoIterator<Item = Vec<u8>>) -> Self
pub fn from_font_bytes(bytes: impl IntoIterator<Item = Vec<u8>>) -> Self
Build the engine with a FontSystem seeded from raw font
bytes. Useful for wasm32 targets (no FS access) and for
crates that embed their bundled fonts via include_bytes!
— see wisp_chart::chart_text for the canonical caller.
No system fonts are loaded — only the supplied buffers are
available, and family-name lookups
(WispText::with_font_family)
resolve against this set.
Sourcepub fn font_system_handle(&self) -> Arc<Mutex<FontSystem>>
pub fn font_system_handle(&self) -> Arc<Mutex<FontSystem>>
Borrow the shared FontSystem handle. The
FlexibleTextRenderer constructor
uses this to wire layout + rasterization to the same font
database (so glyph metrics agree).
Sourcepub fn layout_concrete(&self, text: &WispText) -> FlexibleTextLayout
pub fn layout_concrete(&self, text: &WispText) -> FlexibleTextLayout
Concrete-typed layout entrypoint — preserves the
FlexibleTextLayout type so the renderer half can read the
buffer without going through dyn downcasting.
Trait Implementations§
Source§impl Debug for FlexibleTextEngine
impl Debug for FlexibleTextEngine
Source§impl Default for FlexibleTextEngine
impl Default for FlexibleTextEngine
Source§impl WispTextEngine for FlexibleTextEngine
impl WispTextEngine for FlexibleTextEngine
Auto Trait Implementations§
impl Freeze for FlexibleTextEngine
impl RefUnwindSafe for FlexibleTextEngine
impl Send for FlexibleTextEngine
impl Sync for FlexibleTextEngine
impl Unpin for FlexibleTextEngine
impl UnsafeUnpin for FlexibleTextEngine
impl UnwindSafe for FlexibleTextEngine
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> 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> 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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().