11//! BSN scene function for displaying a plain text string in the correct font.
22use bevy_app:: PropagateOver ;
3- use bevy_asset:: AssetServer ;
4- use bevy_ecs:: template:: template;
53use bevy_scene:: { bsn, Scene } ;
6- use bevy_text:: { FontSource , FontWeight , TextFont } ;
4+ use bevy_text:: { FontSourceTemplate , FontWeight , TextFont } ;
75use bevy_ui:: widget:: Text ;
86
9- use crate :: {
10- constants:: { fonts, size} ,
11- theme:: ThemeTextColor ,
12- tokens,
13- } ;
7+ use crate :: { constants:: size, theme:: ThemeTextColor , tokens} ;
148
159/// A text label.
1610pub fn label ( text : impl Into < String > ) -> impl Scene {
1711 bsn ! {
1812 Text ( text)
19- template( |ctx| {
20- Ok ( TextFont {
21- font: FontSource :: Handle ( ctx. resource:: <AssetServer >( ) . load( fonts:: REGULAR ) ) ,
22- font_size: size:: MEDIUM_FONT ,
23- weight: FontWeight :: NORMAL ,
24- ..Default :: default ( )
25- } )
26- } )
13+ TextFont {
14+ font: FontSourceTemplate :: Handle ( "fonts/FiraSans-Bold.ttf" ) ,
15+ font_size: size:: MEDIUM_FONT ,
16+ weight: FontWeight :: NORMAL ,
17+ }
2718 PropagateOver <TextFont >
2819 ThemeTextColor ( tokens:: TEXT_MAIN )
2920 }
@@ -33,14 +24,11 @@ pub fn label(text: impl Into<String>) -> impl Scene {
3324pub fn label_dim ( text : impl Into < String > ) -> impl Scene {
3425 bsn ! {
3526 Text ( text)
36- template( |ctx| {
37- Ok ( TextFont {
38- font: FontSource :: Handle ( ctx. resource:: <AssetServer >( ) . load( fonts:: REGULAR ) ) ,
39- font_size: size:: MEDIUM_FONT ,
40- weight: FontWeight :: NORMAL ,
41- ..Default :: default ( )
42- } )
43- } )
27+ TextFont {
28+ font: FontSourceTemplate :: Handle ( "fonts/FiraSans-Bold.ttf" ) ,
29+ font_size: size:: MEDIUM_FONT ,
30+ weight: FontWeight :: NORMAL ,
31+ }
4432 PropagateOver <TextFont >
4533 ThemeTextColor ( tokens:: TEXT_DIM )
4634 }
@@ -50,14 +38,11 @@ pub fn label_dim(text: impl Into<String>) -> impl Scene {
5038pub fn label_small ( text : impl Into < String > ) -> impl Scene {
5139 bsn ! {
5240 Text ( text)
53- template( |ctx| {
54- Ok ( TextFont {
55- font: FontSource :: Handle ( ctx. resource:: <AssetServer >( ) . load( fonts:: REGULAR ) ) ,
56- font_size: size:: EXTRA_SMALL_FONT ,
57- weight: FontWeight :: NORMAL ,
58- ..Default :: default ( )
59- } )
60- } )
41+ TextFont {
42+ font: FontSourceTemplate :: Handle ( "fonts/FiraSans-Bold.ttf" ) ,
43+ font_size: size:: EXTRA_SMALL_FONT ,
44+ weight: FontWeight :: NORMAL ,
45+ }
6146 PropagateOver <TextFont >
6247 ThemeTextColor ( tokens:: TEXT_MAIN )
6348 }
0 commit comments