No description
a74ce29c1a
The `TextAtlas` will have an initial size of `256` (we could make this configurable) and `try_allocate` will keep track of the glyphs in use in the current frame, returning `None` when the LRU glyph is in use. In that case, `TextRenderer::prepare` will return `PrepareError::AtlasFull` with the `ContentType` of the atlas that is full. The user of the library can then call `TextAtlas::grow` with the provided `ContentType` to obtain a bigger atlas (by `256`). A `TextAtlas::grow` call clears the whole atlas and, as a result, all of the `prepare` calls need to be repeated in a frame until they all succeed. Overall, the atlas will rarely need to grow and so the calls will not need to be repated often. Finally, the user needs to call `TextAtlas::trim` at the end of the frame. This allows us to clear the glyphs in use collection in the atlas. Maybe there is a better way to model this in an API that forces the user to trim the atlas (e.g. make `trim` return a new type and changing `prepare` and `render` to take that type instead). |
||
---|---|---|
.github | ||
examples | ||
src | ||
.gitignore | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
LICENSE-ZLIB | ||
README.md |
🦅 glyphon 🦁
Fast, simple 2D text rendering for
wgpu
What is this?
This crate provides a simple way to render 2D text with wgpu
by:
- shaping/calculating layout/rasterizing glyphs (with
cosmic-text
) - packing the glyphs into texture atlas (with
etagere
) - sampling from the texture atlas to render text (with
wgpu
)
To avoid extra render passes, rendering uses existing render passes (following the middleware pattern described in wgpu
's Encapsulating Graphics Work wiki page.
License
This project is licensed under either Apache License, Version 2.0, zlib License, or MIT License, at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache 2.0 license, shall be triple licensed as above, without any additional terms or conditions.