//! This module exports types related to rendering glyphs.12use bevy_asset::AssetId;3use bevy_image::prelude::*;4use bevy_math::{IVec2, Vec2};5use bevy_reflect::Reflect;67/// A glyph of a font, typically representing a single character, positioned in screen space.8///9/// Contains information about how and where to render a glyph.10///11/// Used in [`TextPipeline::queue_text`](crate::TextPipeline::queue_text) and [`crate::TextLayoutInfo`] for rendering glyphs.12#[derive(Debug, Clone, Reflect)]13#[reflect(Clone)]14pub struct PositionedGlyph {15/// The position of the glyph in the text block's bounding box.16pub position: Vec2,17/// The width and height of the glyph in logical pixels.18pub size: Vec2,19/// Information about the glyph's atlas.20pub atlas_info: GlyphAtlasInfo,21/// The index of the glyph in the [`ComputedTextBlock`](crate::ComputedTextBlock)'s tracked spans.22pub span_index: usize,23/// The index of the glyph's line.24pub line_index: usize,25/// The byte index of the glyph in its line.26pub byte_index: usize,27/// The byte length of the glyph.28pub byte_length: usize,29}3031/// Information about a glyph in an atlas.32///33/// Rasterized glyphs are stored as rectangles34/// in one or more [`FontAtlas`](crate::FontAtlas)es.35///36/// Used in [`PositionedGlyph`] and [`FontAtlasSet`](crate::FontAtlasSet).37#[derive(Debug, Clone, Reflect)]38#[reflect(Clone)]39pub struct GlyphAtlasInfo {40/// An asset ID to the [`Image`] data for the texture atlas this glyph was placed in.41///42/// An asset ID of the handle held by the [`FontAtlas`](crate::FontAtlas).43pub texture: AssetId<Image>,44/// An asset ID to the [`TextureAtlasLayout`] map for the texture atlas this glyph was placed45/// in.46///47/// An asset ID of the handle held by the [`FontAtlas`](crate::FontAtlas).48pub texture_atlas: AssetId<TextureAtlasLayout>,49/// Location and offset of a glyph within the texture atlas.50pub location: GlyphAtlasLocation,51}5253/// The location of a glyph in an atlas,54/// and how it should be positioned when placed.55///56/// Used in [`GlyphAtlasInfo`] and [`FontAtlas`](crate::FontAtlas).57#[derive(Debug, Clone, Copy, Reflect)]58#[reflect(Clone)]59pub struct GlyphAtlasLocation {60/// The index of the glyph in the atlas61pub glyph_index: usize,62/// The required offset (relative positioning) when placed63pub offset: IVec2,64}656667