-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add system for conveniently loading fonts * Use the font plugin to only specify a font family, not each font individually * Simplify querying for a font handle * Improve structure of font module and exports * Improve syntax for configuring font folder and make it optional * Example setup doesn't need the AssetServer anymore
- Loading branch information
1 parent
f05e5a0
commit 9fb125e
Showing
14 changed files
with
274 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Credits | ||
|
||
| Path | License | | ||
| ------- | --------- | | ||
| `fonts` | `OFL.txt` | |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod plugin; | ||
mod registry; | ||
|
||
pub use plugin::FontPlugin; | ||
pub use registry::FontRegistry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use bevy::prelude::*; | ||
|
||
use super::registry::FontRegistry; | ||
|
||
#[derive(Debug)] | ||
pub struct FontPlugin; | ||
|
||
impl Plugin for FontPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.init_resource::<FontRegistry>() | ||
.add_systems(Update, update_font_registry); | ||
} | ||
} | ||
|
||
/// Track when fonts are loaded, modified or removed and update the font registry accordingly. | ||
fn update_font_registry( | ||
mut font_registry: ResMut<FontRegistry>, | ||
mut font_changes: EventReader<AssetEvent<Font>>, | ||
font_assets: Res<Assets<Font>>, | ||
) { | ||
for change in font_changes.read() { | ||
match *change { | ||
AssetEvent::Added { id } => font_registry.add(id, font_assets.as_ref()), | ||
AssetEvent::Modified { id } => font_registry.update(id, font_assets.as_ref()), | ||
AssetEvent::Removed { id } => font_registry.remove(id), | ||
AssetEvent::Unused { id: _ } => {} | ||
AssetEvent::LoadedWithDependencies { id: _ } => {} | ||
} | ||
} | ||
} |
Oops, something went wrong.