Skip to content

Commit 4da3a40

Browse files
committed
check-dock and ci
1 parent f0014bf commit 4da3a40

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

crates/bevy_text/src/font.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use bevy_asset::Asset;
22
use bevy_reflect::{TypePath, TypeUuid};
33

4-
/// An [`Asset`](bevy_asset::Asset) that contains the data for a loaded font, if loaded as an asset.
4+
/// An [`Asset`] that contains the data for a loaded font, if loaded as an asset.
55
///
66
/// Loaded by [`FontLoader`](crate::FontLoader).
77
#[derive(Debug, TypeUuid, TypePath, Clone, Asset)]

crates/bevy_text/src/font_atlas_set.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ type FontSizeKey = u32;
4747

4848
/// Provides the interface for adding and retrieving rasterized glyphs, and manages the [`FontAtlas`]es.
4949
///
50-
/// A `FontAtlasSet` is an [`Asset`](bevy_asset::Asset).
50+
/// A `FontAtlasSet` is an [`Asset`].
5151
///
5252
/// There is one `FontAtlasSet` for each font:
53-
/// - When a [`Font`](crate::Font) is loaded as an asset and then used in [`Text`](crate::Text),
53+
/// - When a [`Font`] is loaded as an asset and then used in [`Text`](crate::Text),
5454
/// a `FontAtlasSet` asset is created from a weak handle to the `Font`.
5555
/// - When a font is loaded as a system font, and then used in [`Text`](crate::Text),
5656
/// a `FontAtlasSet` asset is created and stored with a strong handle to the `FontAtlasSet`.
@@ -172,6 +172,10 @@ impl FontAtlasSet {
172172
pub fn len(&self) -> usize {
173173
self.font_atlases.len()
174174
}
175+
/// Returns the number of font atlases in this set
176+
pub fn is_empty(&self) -> bool {
177+
self.font_atlases.len() == 0
178+
}
175179

176180
/// Get the texture of the glyph as a rendered image, and its offset
177181
pub fn get_outlined_glyph_texture(

crates/bevy_text/src/font_loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl AssetLoader for FontLoader {
2727
Box::pin(async move {
2828
let mut bytes = Vec::new();
2929
reader.read_to_end(&mut bytes).await?;
30-
let font = Font::from_bytes(bytes.into());
30+
let font = Font::from_bytes(bytes);
3131
// load_context.set_default_asset(LoadedAsset::new(font));
3232
Ok(font)
3333
})

crates/bevy_text/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
//! A font *face* is part of a font family,
99
//! and is distinguished by its style (e.g. italic), its weight (e.g. bold) and its stretch (e.g. condensed).
1010
//!
11-
//! In Bevy, [`Font`]s are loaded by the [`FontLoader`](FontLoader) as assets,
11+
//! In Bevy, [`Font`]s are loaded by the [`FontLoader`] as assets,
1212
//!
1313
//! # `TextPipeline`
1414
//!
1515
//! The [`TextPipeline`] resource does all of the heavy lifting for rendering text.
1616
//!
17-
//! [`Text`](Text) is first measured by creating a [`TextMeasureInfo`] in [`TextPipeline::create_text_measure`],
17+
//! [`Text`] is first measured by creating a [`TextMeasureInfo`] in [`TextPipeline::create_text_measure`],
1818
//! which is called by a system.
1919
//!
2020
//! Note that text measurement is only relevant in a UI context.
@@ -23,7 +23,7 @@
2323
//!
2424
//! 1. creates a [`Buffer`](cosmic_text::Buffer) from the [`TextSection`]s, generating new [`FontAtlasSet`]s if necessary.
2525
//! 2. iterates over each glyph in the [`Buffer`](cosmic_text::Buffer) to create a [`PositionedGlyph`],
26-
//! retrieving glyphs from the cache, or rasterizing to a [`FontAtlas`](FontAtlas) if necessary.
26+
//! retrieving glyphs from the cache, or rasterizing to a [`FontAtlas`] if necessary.
2727
//! 3. [`PositionedGlyph`]s are stored in a [`TextLayoutInfo`],
2828
//! which contains all the information that downstream systems need for rendering.
2929

crates/bevy_text/src/pipeline.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Default for SwashCache {
5353
/// See the [crate-level documentation](crate) for more information.
5454
#[derive(Default, Resource)]
5555
pub struct TextPipeline {
56-
/// Identifies a font [`ID`](cosmic_text::fontdb::ID) by its [`Font`] [`Asset`](bevy_asset::Asset) [`HandleId`].
56+
/// Identifies a font [`ID`](cosmic_text::fontdb::ID) by its [`Font`] [`Asset`](bevy_asset::Asset).
5757
map_handle_to_font_id: HashMap<AssetId<Font>, cosmic_text::fontdb::ID>,
5858
/// The font system is used to retrieve fonts and their information, including glyph outlines.
5959
///
@@ -87,7 +87,7 @@ impl TextPipeline {
8787
let (font_size, line_height) = (font_size as f32, line_height as f32);
8888
let metrics = Metrics::new(font_size, line_height);
8989

90-
let mut font_system = &mut acquire_font_system(&mut self.font_system)?;
90+
let font_system = &mut acquire_font_system(&mut self.font_system)?;
9191

9292
let spans: Vec<(&str, Attrs)> = sections
9393
.iter()
@@ -96,9 +96,9 @@ impl TextPipeline {
9696
(
9797
&section.value[..],
9898
get_attrs(
99-
&section,
99+
section,
100100
section_index,
101-
&mut font_system,
101+
font_system,
102102
&mut self.map_handle_to_font_id,
103103
fonts,
104104
),
@@ -348,7 +348,7 @@ fn get_attrs<'a>(
348348
.db_mut()
349349
.load_font_source(cosmic_text::fontdb::Source::Binary(data));
350350
// TODO: it is assumed this is the right font face
351-
ids.last().unwrap().clone()
351+
*ids.last().unwrap()
352352

353353
// TODO: below may be required if we need to offset by the baseline (TBC)
354354
// see https://github.com/pop-os/cosmic-text/issues/123

0 commit comments

Comments
 (0)