pub struct GlyphAtlas { /* private fields */ }Expand description
A cache of rasterised glyphs, packed into a single texture.
The GPU backends cannot draw text directly: WebGPU and WebGL2 have no text API. The atlas solves that by rasterising each glyph once into an offscreen canvas and then drawing the glyphs as textured quads. The canvas is handed to the GPU as a texture source, so no pixel read-back is ever needed.
The Canvas2D backend does not use the atlas at all — it has a real text API — but it shares the measurer, so the three backends lay text out identically.
Implementations§
Source§impl GlyphAtlas
Inherent implementation of GlyphAtlas.
impl GlyphAtlas
Inherent implementation of GlyphAtlas.
Sourcepub fn canvas(&self) -> &HtmlCanvasElement
pub fn canvas(&self) -> &HtmlCanvasElement
Returns the canvas the glyphs are rasterised into.
The GPU backends upload this canvas straight into a texture.
§Returns
&HtmlCanvasElement- AHtmlCanvasElementvalue.
Sourcepub fn mark_clean(&mut self)
pub fn mark_clean(&mut self)
Marks the atlas as uploaded.
Trait Implementations§
Source§impl Clone for GlyphAtlas
impl Clone for GlyphAtlas
Auto Trait Implementations§
impl Freeze for GlyphAtlas
impl RefUnwindSafe for GlyphAtlas
impl Send for GlyphAtlas
impl Sync for GlyphAtlas
impl Unpin for GlyphAtlas
impl UnsafeUnpin for GlyphAtlas
impl UnwindSafe for GlyphAtlas
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
Mutably borrows from an owned value. Read more