43 releases
Uses new Rust 2024
new 0.16.0-rc.5 | Apr 15, 2025 |
---|---|
0.16.0-rc.3 | Mar 31, 2025 |
0.15.0 | Nov 29, 2024 |
0.14.0 | Jul 4, 2024 |
0.3.0 | Nov 3, 2020 |
#2924 in Game dev
82,084 downloads per month
Used in 334 crates
(13 directly)
8.5MB
148K
SLoC
This crate provides the tools for positioning and rendering text in Bevy.
Font
Fonts contain information for drawing glyphs, which are shapes that typically represent a single character, but in some cases part of a "character" (grapheme clusters) or more than one character (ligatures).
A font face is part of a font family, and is distinguished by its style (e.g. italic), its weight (e.g. bold) and its stretch (e.g. condensed).
In Bevy, Font
s are loaded by the FontLoader
as assets.
TextPipeline
The TextPipeline
resource does all of the heavy lifting for rendering text.
UI Text
is first measured by creating a TextMeasureInfo
in TextPipeline::create_text_measure
,
which is called by the measure_text_system
system of bevy_ui
.
Note that text measurement is only relevant in a UI context.
With the actual text bounds defined, the bevy_ui::widget::text::text_system
system (in a UI context)
or text2d::update_text2d_layout
system (in a 2d world space context)
passes it into TextPipeline::queue_text
, which:
- updates a
Buffer
from theTextSpan
s, generating newFontAtlasSet
s if necessary. - iterates over each glyph in the
Buffer
to create aPositionedGlyph
, retrieving glyphs from the cache, or rasterizing to aFontAtlas
if necessary. PositionedGlyph
s are stored in aTextLayoutInfo
, which contains all the information that downstream systems need for rendering.
Bevy Text
Dependencies
~45–77MB
~1.5M SLoC