pub struct TextSystem { /* private fields */ }Expand description
The font and layout contexts a thread lays text out with.
One system per thread keeps parley’s non-Send contexts out of shared
state. The system is inert state: creating, replacing or dropping one
touches nothing but this thread.
Implementations§
Source§impl TextSystem
impl TextSystem
Sourcepub fn bundled_only() -> TextSystem
pub fn bundled_only() -> TextSystem
Creates a system that sees only the bundled fonts.
Without the bundled-fonts feature the system starts empty and every
glyph lays out as missing.
Sourcepub fn with_system_fonts() -> TextSystem
pub fn with_system_fonts() -> TextSystem
Creates a system that sees the system fonts plus the bundled ones as a fallback.
System fonts are discovered only when the system-fonts feature is
enabled, which is impossible on wasm. Without it this behaves like
TextSystem::bundled_only.
Sourcepub fn install(self)
pub fn install(self)
Installs this system for the current thread, replacing whatever the thread owned before.
§Panics
Panics if the thread’s system is in use, because a system cannot be replaced while a layout borrows it.
Sourcepub fn with<R>(f: impl FnOnce(&mut TextSystem) -> R) -> R
pub fn with<R>(f: impl FnOnce(&mut TextSystem) -> R) -> R
Runs f with the current thread’s system, creating one on first use:
TextSystem::with_system_fonts on native targets and
TextSystem::bundled_only on wasm.
§Panics
Panics if called from inside another with call on the same thread,
for example from a crate::TextLayout constructor, because a system
cannot be handed out twice at once.