pub mod auto_spacing;

pub use auto_spacing::AutoSpacing;
use lotus_script::{content::ContentId, font::BitmapFont};

/// Calculates the rendered length of text using a bitmap font.
///
/// Measures the pixel width that the given text would occupy when rendered
/// with the specified bitmap font and character spacing.
///
/// # Arguments
///
/// * `font` - The content ID of the bitmap font to use for measurement
/// * `text` - The text string to measure
/// * `spacing` - Additional spacing between characters in pixels
///
/// # Returns
///
/// The total width in pixels that the text would occupy, or 0 if the font
/// cannot be loaded
///
/// # Examples
///
/// ```
/// # use your_crate::helper::get_text_len;
/// # use lotus_script::content::ContentId;
/// // Measure text width with a specific font
/// let font_id = ContentId::from("my_font");
/// let width = get_text_len(font_id, "Hello World", 2);
/// // width contains the pixel width of "Hello World" with 2px character spacing
/// ```
pub fn get_text_len(font: ContentId, text: &str, spacing: i32) -> i32 {
    if let Some(f) = BitmapFont::try_load(font) {
        //
        f.text_len(text, spacing) as i32
    } else {
        0
    }
}
