Skip to content

[Feature] Glyph atlas texture #144

@vmarcella

Description

@vmarcella

Overview

Create a texture atlas system that packs rasterized glyphs into a single
texture for efficient GPU rendering.

Current State

No response

Scope

Goals:

  • Pack multiple glyphs into one texture
  • Track UV coordinates for each glyph
  • Dynamic atlas growth when full
  • Support multiple fonts/sizes in one atlas

Non-Goals:

  • SDF generation
  • Atlas serialization

Proposed API

pub struct GlyphAtlas {
  texture: Texture,
  glyph_info: HashMap<GlyphKey, GlyphUV>,
}

pub struct GlyphKey {
  pub font_id: u32,
  pub character: char,
  pub size_px: u32, // discretized
}

pub struct GlyphUV {
  pub uv_min: [f32; 2],
  pub uv_max: [f32; 2],
  pub metrics: GlyphMetrics,
}

impl GlyphAtlas {
  pub fn new(gpu: &Gpu, initial_size: u32) -> Self;
  pub fn get_or_insert(&mut self, font: &Font, char: char, size: f32) -> &GlyphUV;
  pub fn texture(&self) -> &Texture;
  pub fn clear(&mut self);
}

Acceptance Criteria

  • Glyphs packed into texture
  • UV coordinates accurate
  • Atlas grows when needed
  • Multiple fonts coexist in atlas
  • Cache hit returns existing glyph

Affected Crates

lambda-rs

Notes

  • Binary tree packing or shelf algorithm
  • Consider max atlas size limit

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIAll things user interface relatedassetsAll things asset/asset management relatedenhancementNew feature or requestlambda-rsIssues pertaining to the core framework

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions