//! Font store — stub for v1.0.0. Font rendering delegated to egui in editor.

use crate::FontHandle;

/// Font store (stub). Font rendering is handled by egui in the editor
/// and will be implemented as an SDF atlas renderer for the runtime.
#[derive(Debug, Default)]
pub struct FontStore {
    next_id: u32,
}

impl FontStore {
    pub fn new() -> Self {
        Self::default()
    }

    /// Reserve a font handle (actual font loading is not yet implemented).
    pub fn reserve(&mut self) -> FontHandle {
        let id = self.next_id;
        self.next_id += 1;
        FontHandle(id)
    }

    /// Number of reserved font handles.
    pub fn len(&self) -> usize {
        self.next_id as usize
    }

    /// Whether no fonts have been reserved.
    pub fn is_empty(&self) -> bool {
        self.next_id == 0
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn new_store_is_empty() {
        let store = FontStore::new();
        assert!(store.is_empty());
        assert_eq!(store.len(), 0);
    }

    #[test]
    fn reserve_increments() {
        let mut store = FontStore::new();
        let h0 = store.reserve();
        let h1 = store.reserve();
        assert_eq!(h0, FontHandle(0));
        assert_eq!(h1, FontHandle(1));
        assert_eq!(store.len(), 2);
        assert!(!store.is_empty());
    }

    #[test]
    fn default_is_empty() {
        let store = FontStore::default();
        assert!(store.is_empty());
    }
}
