//! This module exports types related to rendering glyphs.12use bevy_asset::AssetId;3use bevy_image::prelude::*;4use bevy_math::{Rect, 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::update_text_layout_info`](crate::TextPipeline::update_text_layout_info) and [`TextLayoutInfo`](`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/// Information about the glyph's atlas.18pub atlas_info: GlyphAtlasInfo,19/// The index of the glyph in the [`ComputedTextBlock`](crate::ComputedTextBlock)'s tracked spans.20pub span_index: usize,21/// The index of the glyph's line.22pub line_index: usize,23/// The byte index of the glyph in its line.24pub byte_index: usize,25/// The byte length of the glyph.26pub byte_length: usize,27}2829/// Information about a glyph in an atlas.30///31/// Rasterized glyphs are stored as rectangles32/// in one or more [`FontAtlas`](crate::FontAtlas)es.33///34/// Used in [`PositionedGlyph`] and [`FontAtlasSet`](crate::FontAtlasSet).35#[derive(Debug, Clone, Reflect)]36#[reflect(Clone)]37pub struct GlyphAtlasInfo {38/// An asset ID to the [`Image`] data for the texture atlas this glyph was placed in.39///40/// An asset ID of the handle held by the [`FontAtlas`](crate::FontAtlas).41pub texture: AssetId<Image>,42/// Bounds of the glyph in the atlas texture43pub rect: Rect,44/// The required offset (relative positioning) when placed45pub offset: Vec2,46}4748/// The location of a glyph in an atlas,49/// and how it should be positioned when placed.50///51/// Used in [`GlyphAtlasInfo`] and [`FontAtlas`](crate::FontAtlas).52#[derive(Debug, Clone, Copy, Reflect)]53#[reflect(Clone)]54pub struct GlyphAtlasLocation {55/// The index of the glyph in the atlas56pub glyph_index: usize,57/// The required offset (relative positioning) when placed58pub offset: Vec2,59}606162