pub trait LinraRenderer: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn render_text(
&self,
text: &str,
font: Arc<dyn FontRef>,
params: &LinraRenderParams,
) -> Result<RenderOutput>;
// Provided methods
fn clear_cache(&self) { ... }
fn supports_format(&self, format: &str) -> bool { ... }
}Expand description
Linra text renderer: shapes AND renders in a single operation
Implementations of this trait bypass the separate shaper/renderer pipeline to achieve maximum performance through platform-native APIs.
§Platform Implementations
- macOS:
CoreTextLinraRendereruses CTLineDraw - Windows:
DirectWriteLinraRendereruses DrawTextLayout
§Usage
use typf_core::linra::{LinraRenderer, LinraRenderParams};
use typf_core::traits::FontRef;
use std::sync::Arc;
fn render_text<R: LinraRenderer>(
renderer: &R,
text: &str,
font: Arc<dyn FontRef>,
) -> typf_core::Result<typf_core::types::RenderOutput> {
let params = LinraRenderParams::with_size(24.0);
renderer.render_text(text, font, ¶ms)
}Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
The renderer’s name (e.g., “coretext-linra”, “directwrite-linra”)
Sourcefn render_text(
&self,
text: &str,
font: Arc<dyn FontRef>,
params: &LinraRenderParams,
) -> Result<RenderOutput>
fn render_text( &self, text: &str, font: Arc<dyn FontRef>, params: &LinraRenderParams, ) -> Result<RenderOutput>
Shape and render text in a single operation
This method performs both text shaping (character→glyph mapping, positioning, feature application) and rendering (rasterization) in a single pass through the platform’s native text API.
§Arguments
text- The text string to renderfont- Font to use for renderingparams- Combined shaping and rendering parameters
§Returns
Rendered output as a bitmap or vector format
Provided Methods§
Sourcefn clear_cache(&self)
fn clear_cache(&self)
Clear any internal caches
Sourcefn supports_format(&self, format: &str) -> bool
fn supports_format(&self, format: &str) -> bool
Check if this renderer supports a given output format