-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Generic font families #22396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ickshonpe
wants to merge
43
commits into
bevyengine:main
Choose a base branch
from
ickshonpe:generic-font-families
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+224
−7
Open
Generic font families #22396
Changes from 19 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
3118fd9
Added variants to `FontSource` representing generic font families.
ickshonpe c179b3d
update pipeline
ickshonpe c504530
After he new font families changes `update_buffer` now leaks font IDs…
ickshonpe f4436ad
Add migration guide, and fixed font in text example.
ickshonpe ff3501f
delete unused
ickshonpe c1c67a5
Add `load_font_assets_into_fontdb_system` to the text2d tests schedule.
ickshonpe fb3aba8
Try to fix text2d test setup
ickshonpe 40183df
Fixed text2d tests
ickshonpe 88d6c29
Added explanation how the font family is chosen if the font file is a…
ickshonpe 140f0fb
Merge branch 'fix-font-id-leak' into generic-font-families
ickshonpe 3052c13
Merge branch 'main' into generic-font-families
ickshonpe 8842107
Removed changes to text example
ickshonpe ecad430
Merge branch 'main' into generic-font-families
ickshonpe ad0f601
Removed redundant comment
ickshonpe 4d9f6b3
Merge branch 'main' into generic-font-families
ickshonpe e0d0d6a
added generic_font_families example
ickshonpe 3e90b67
reverted text example changes
ickshonpe 152dfcc
Cleaned up example
ickshonpe 3bd1e7f
Merge branch 'main' into generic-font-families
ickshonpe 633917d
Improved the example
ickshonpe c214049
Merge branch 'generic-font-families' of https://github.com/ickshonpe/…
ickshonpe 5d6829a
Updated and expanded the doc comments.
ickshonpe 1f1ae68
Added `as_family` helper function to `FontSource`
ickshonpe f3563ea
Added `resolve_font_source` method to `CosmicFontSystem` which looks …
ickshonpe d36e5ff
Renamed `resolve_font_source` to `get_family`
ickshonpe 1f9e2d2
Updated example
ickshonpe e1b945f
more doc comments
ickshonpe 15dc9f0
Cleanup doc example
ickshonpe 75f740d
Added import to FontSource doc example
ickshonpe 32308eb
Added example to release note.
ickshonpe cc35eeb
Removed unused import
ickshonpe 6f17de9
Unwrapped family name in FontSource doc test
ickshonpe 9ae6abf
fixed doctest import
ickshonpe e965518
another doc test fix
ickshonpe 5319905
another, another doc test fix
ickshonpe 553c4ae
Fix doctest again
ickshonpe 831f0d7
Update examples/ui/generic_font_families.rs
ickshonpe f55950a
Rewrote description again.
ickshonpe 8eff600
Added motivation paragraph.
ickshonpe fa14f94
Merge branch 'main' into generic-font-families
ickshonpe d38e3a1
Fixed release note's example code
ickshonpe f76dc81
Merge branch 'generic-font-families' of https://github.com/ickshonpe/…
ickshonpe 2ef99fa
Improved release note text..
ickshonpe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
| //! This example demonstrates generic font families | ||
|
|
||
| use bevy::{prelude::*, text::CosmicFontSystem}; | ||
|
|
||
| fn main() { | ||
| let mut app = App::new(); | ||
| app.add_plugins(DefaultPlugins).add_systems(Startup, setup); | ||
|
|
||
| app.world_mut() | ||
| .resource_mut::<CosmicFontSystem>() | ||
| .db_mut() | ||
| .load_system_fonts(); | ||
|
|
||
| app.run(); | ||
| } | ||
|
|
||
| fn setup(mut commands: Commands) { | ||
| // UI camera | ||
| commands.spawn(Camera2d); | ||
|
|
||
| commands.spawn(( | ||
| Node { | ||
| flex_direction: FlexDirection::Column, | ||
| left: px(250), | ||
| top: px(250), | ||
| row_gap: px(10.), | ||
| ..Default::default() | ||
| }, | ||
| children![ | ||
| ( | ||
| Text::new("generic sans serif font"), | ||
| TextFont::from(FontSource::SansSerif).with_font_size(30.) | ||
| ), | ||
| ( | ||
| Text::new("generic serif font"), | ||
| TextFont::from(FontSource::Serif).with_font_size(30.) | ||
| ), | ||
| ( | ||
| Text::new("generic fantasy font"), | ||
| TextFont::from(FontSource::Fantasy).with_font_size(30.) | ||
| ), | ||
| ( | ||
| Text::new("generic cursive font"), | ||
| TextFont::from(FontSource::Cursive).with_font_size(30.) | ||
| ), | ||
| ( | ||
| Text::new("generic monospace font"), | ||
| TextFont::from(FontSource::Monospace).with_font_size(30.) | ||
| ) | ||
| ], | ||
| )); | ||
| } | ||
This file contains hidden or 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,7 @@ | ||
| --- | ||
| title: "Generic Font Families" | ||
| authors: ["@ickshonpe"] | ||
| pull_requests: [] | ||
| --- | ||
|
|
||
| Support for generic font families has been added through new `FontSource` variants: `Serif`, `SansSerif`, `Cursive`, `Fantasy`, and `Monospace`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not quite right, generic font families can be used without loading system fonts, and they are probably best used in conjunction with fallback fonts, but they aren't the fallbacks themselves.
Agonising, but after mashing this up with a bit I wrote, it seems like it's okay now.