devela 0.27.0

A development layer of coherence.
Documentation
// devela::lang::prog::ffi::js::types::text

#[cfg(doc)]
use crate::Web;

#[doc = crate::_tags!(runtime text layout)]
/// Text Metrics.
#[doc = crate::_doc_location!("lang/prog/ffi/js")]
///
/// Represents the size of rendered text, measured by [`Web::measure_text`].
///
/// - <https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics>
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, PartialEq)]
pub struct JsTextMetrics {
    /// The width of the rendered text.
    pub width: f32,
    /// The distance from the baseline to the highest point.
    pub ascent: f32,
    /// The distance from the baseline to the lowest point.
    pub descent: f32,
}

#[doc = crate::_tags!(runtime text layout)]
/// Full Text Metrics.
#[doc = crate::_doc_location!("lang/prog/ffi/js")]
///
/// Represents the size of rendered text, measured by [`Web::measure_text_full`].
///
/// Includes all available text measurement properties.
/// - <https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics>
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, PartialEq)]
pub struct JsTextMetricsFull {
    /// The width of the rendered text.
    pub width: f32,
    /// Distance from the alignment point to the leftmost glyph edge.
    pub left: f32,
    /// Distance from the alignment point to the rightmost glyph edge.
    pub right: f32,
    /// Distance from the baseline to the highest glyph edge.
    pub ascent: f32,
    /// Distance from the baseline to the lowest glyph edge.
    pub descent: f32,
    /// The topmost possible bounding box for text.
    pub font_ascent: f32,
    /// The lowest possible bounding box for text.
    pub font_descent: f32,
    /// Height from the baseline to the top of the `em` square.
    pub em_ascent: f32,
    /// Height from the baseline to the bottom of the `em` square.
    pub em_descent: f32,
    /// Hanging baseline position.
    pub hanging_baseline: f32,
    /// Alphabetic baseline position.
    pub alphabetic_baseline: f32,
    /// Ideographic baseline position.
    pub ideographic_baseline: f32,
}