devela 0.28.0

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

#[cfg(doc)]
#[cfg(feature = "web")]
use crate::Web;

#[doc = crate::_tags!(runtime text layout)]
/// Text Metrics.
#[doc = crate::_doc_meta!{
    location("lang/prog/ffi/js"),
    test_size_of(JsTextRenderMetrics = 12|96),
}]
///
/// 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 JsTextRenderMetrics {
    /// 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_meta!{
    location("lang/prog/ffi/js"),
    test_size_of(JsTextRenderMetricsFull = 48|384),
}]
///
/// 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 JsTextRenderMetricsFull {
    /// 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,
}