pub struct TextStyle {
pub color: Color,
pub size_px: f32,
pub align: TextAlign,
pub wrap: TextWrap,
pub max_lines: Option<u32>,
pub family: Option<Arc<str>>,
pub weight: u16,
pub selection_color: Option<Color>,
pub line_height: Option<LineHeightSpec>,
}Expand description
Text style record carrying fill color, size, family/weight, alignment, wrap policy, and optional max-line cap.
TextContent is stored separately so keystrokes do not bump change detection on these cold fields.
Default: near-white at 16px, weight 400, platform sans-serif, left-aligned, no wrap, unbounded lines.
Fields§
§color: ColorFill color. Default is Color::rgb(0.92, 0.92, 0.94).
size_px: f32Font size in logical pixels.
align: TextAlignHorizontal alignment inside the content rect.
wrap: TextWrapWrap policy passed to the shaper.
max_lines: Option<u32>Hard cap on lines after shaping; None is unbounded.
family: Option<Arc<str>>CSS font-family fallback chain as authored (comma-separated;
the shaper strips quotes and resolves the first available family
against the system font database, honouring the CSS generic
keywords). None = platform sans-serif. Shared Arc so clones
(extract, cache keys) don’t copy the string.
weight: u16CSS font-weight (1-1000; 400 = normal, 700 = bold).
selection_color: Option<Color>Selection highlight background (selection-color in CSS; the
default skin routes it through the --lumen-selection token) -
Qt’s QPalette::Highlight / Slint’s selection-background-color.
None falls back to the renderer’s single built-in highlight
(crate::render_world::DEFAULT_SELECTION_BG).
The paired caret color and selected-glyph color live on the
separate TextInputPaint component so adding them never forces
every TextStyle literal to change.
line_height: Option<LineHeightSpec>CSS line-height. Inherits down the tree like Self::size_px
(the IR resolves inheritance before this field is populated).
None => DEFAULT_LINE_HEIGHT_MULTIPLIER (line-height: normal),
resolved via resolve_line_height.
Trait Implementations§
Source§impl Component for TextStyle
impl Component for TextStyle
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor] required for working with relationships in dynamic contexts. Read more§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreimpl StructuralPartialEq for TextStyle
Auto Trait Implementations§
impl Freeze for TextStyle
impl RefUnwindSafe for TextStyle
impl Send for TextStyle
impl Sync for TextStyle
impl Unpin for TextStyle
impl UnsafeUnpin for TextStyle
impl UnwindSafe for TextStyle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
§impl<T> FromTemplate for T
impl<T> FromTemplate for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
§impl<T> Template for T
impl<T> Template for T
§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.