pub struct FlexibleTextRenderer {
font_system: Arc<Mutex<FontSystem>>,
swash_cache: SwashCache,
atlas: TextAtlas,
viewport: Viewport,
text_renderer: TextRenderer,
device: Device,
queue: Queue,
resolution: Resolution,
}Expand description
Wgpu glyph rasterizer wrapping glyphon’s pipeline.
Owns the glyphon-side GPU resources (atlas, viewport, renderer,
swash cache) plus a shared handle to the font system used by the
paired FlexibleTextEngine.
Fields§
§font_system: Arc<Mutex<FontSystem>>§swash_cache: SwashCache§atlas: TextAtlas§viewport: Viewport§text_renderer: TextRenderer§device: Device§queue: Queue§resolution: ResolutionImplementations§
Source§impl FlexibleTextRenderer
impl FlexibleTextRenderer
Sourcepub fn new(
app: &Application,
format: TextureFormat,
font_system: Arc<Mutex<FontSystem>>,
) -> Self
pub fn new( app: &Application, format: TextureFormat, font_system: Arc<Mutex<FontSystem>>, ) -> Self
Build the renderer for a target color format.
format MUST match the format of every TextureView later
passed to Self::draw. Multisample is fixed at 1× and depth
stencil is unused — glyphon writes directly to the color
attachment.
Sourcepub fn set_resolution(&mut self, width_px: u32, height_px: u32)
pub fn set_resolution(&mut self, width_px: u32, height_px: u32)
Update the rasterization resolution. Call whenever the target view’s dimensions change.
Sourcepub fn draw(
&mut self,
target_view: &TextureView,
layouts: &[(&FlexibleTextLayout, Vec2, Color)],
clear: bool,
)
pub fn draw( &mut self, target_view: &TextureView, layouts: &[(&FlexibleTextLayout, Vec2, Color)], clear: bool, )
Stage layouts and emit draw calls into a fresh render pass on
target_view. clear chooses whether to clear the target
before drawing — set false when compositing on top of
existing content.
Each entry is (layout, position_ndc, color):
position_ndcis the top-left of the layout box in NDC ([-1, +1]). It’s converted to glyphon pixel space using the current resolution.colorprovides the default per-glyph color.
Sourcepub fn trim_atlas(&mut self)
pub fn trim_atlas(&mut self)
Trim atlas LRU entries that haven’t been referenced since the last call. Call between frames to keep the atlas bounded.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FlexibleTextRenderer
impl !RefUnwindSafe for FlexibleTextRenderer
impl Send for FlexibleTextRenderer
impl Sync for FlexibleTextRenderer
impl Unpin for FlexibleTextRenderer
impl UnsafeUnpin for FlexibleTextRenderer
impl !UnwindSafe for FlexibleTextRenderer
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