Instantiate builder from within FontFeatures
This commit is contained in:
parent
dd27285cda
commit
04dee44812
@ -367,10 +367,10 @@ impl Default for TextFont {
|
|||||||
///
|
///
|
||||||
/// # Usage:
|
/// # Usage:
|
||||||
/// ```
|
/// ```
|
||||||
/// use bevy_text::{FontFeatures, FontFeaturesBuilder};
|
/// use bevy_text::FontFeatures;
|
||||||
///
|
///
|
||||||
/// // Create using FontFeaturesBuilder
|
/// // Create using the builder
|
||||||
/// let font_features = FontFeaturesBuilder::new()
|
/// let font_features = FontFeatures::builder()
|
||||||
/// .enable(FontFeatures::STANDARD_LIGATURES)
|
/// .enable(FontFeatures::STANDARD_LIGATURES)
|
||||||
/// .set(FontFeatures::WEIGHT, 300)
|
/// .set(FontFeatures::WEIGHT, 300)
|
||||||
/// .build();
|
/// .build();
|
||||||
@ -454,6 +454,11 @@ impl FontFeatures {
|
|||||||
/// Varies between upright and slanted text. Must be a value greater than -90 and less than +90.
|
/// Varies between upright and slanted text. Must be a value greater than -90 and less than +90.
|
||||||
/// A value of 0 is upright.
|
/// A value of 0 is upright.
|
||||||
pub const SLANT: [u8; 4] = *b"slnt";
|
pub const SLANT: [u8; 4] = *b"slnt";
|
||||||
|
|
||||||
|
/// Create a new [`FontFeaturesBuilder`].
|
||||||
|
pub fn builder() -> FontFeaturesBuilder {
|
||||||
|
FontFeaturesBuilder::default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A builder for [`FontFeatures`].
|
/// A builder for [`FontFeatures`].
|
||||||
@ -463,11 +468,6 @@ pub struct FontFeaturesBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FontFeaturesBuilder {
|
impl FontFeaturesBuilder {
|
||||||
/// Create a new [`FontFeaturesBuilder`].
|
|
||||||
pub fn new() -> Self {
|
|
||||||
FontFeaturesBuilder::default()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Enable an OpenType feature.
|
/// Enable an OpenType feature.
|
||||||
///
|
///
|
||||||
/// Most OpenType features are on/off switches, so this is a convenience method that sets the
|
/// Most OpenType features are on/off switches, so this is a convenience method that sets the
|
||||||
|
@ -7,7 +7,7 @@ use bevy::{
|
|||||||
color::palettes::css::GOLD,
|
color::palettes::css::GOLD,
|
||||||
diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin},
|
diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
text::{FontFeatures, FontFeaturesBuilder},
|
text::FontFeatures,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -144,7 +144,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
TextFont {
|
TextFont {
|
||||||
font: opentype_font_handle.clone(),
|
font: opentype_font_handle.clone(),
|
||||||
font_size: 24.0,
|
font_size: 24.0,
|
||||||
font_features: FontFeaturesBuilder::new().enable(feature).build(),
|
font_features: FontFeatures::builder().enable(feature).build(),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
@ -15,7 +15,7 @@ commands.spawn((
|
|||||||
TextSpan::new("Ligatures: ff, fi, fl, ffi, ffl"),
|
TextSpan::new("Ligatures: ff, fi, fl, ffi, ffl"),
|
||||||
TextFont {
|
TextFont {
|
||||||
font: opentype_font_handle,
|
font: opentype_font_handle,
|
||||||
font_features: FontFeaturesBuilder::new()
|
font_features: FontFeatures::builder()
|
||||||
.enable(FontFeatures::STANDARD_LIGATURES)
|
.enable(FontFeatures::STANDARD_LIGATURES)
|
||||||
.set(FontFeatures::WIDTH, 300)
|
.set(FontFeatures::WIDTH, 300)
|
||||||
.build(),
|
.build(),
|
||||||
|
Loading…
Reference in New Issue
Block a user