drawing_impeller 1002.0.1

Impeller backend for 2D graphics library
Documentation
use drawing_api::{PixelPoint, PixelSize};

pub struct GlyphInfo {
    pub(crate) glyph_info: impellers::GlyphInfo,
}

impl drawing_api::GlyphInfo for GlyphInfo {
    fn get_grapheme_cluster_code_unit_range_begin_utf16(&self) -> usize {
        self.glyph_info
            .get_grapheme_cluster_code_unit_range_begin_utf16()
    }

    fn get_grapheme_cluster_code_unit_range_end_utf16(&self) -> usize {
        self.glyph_info
            .get_grapheme_cluster_code_unit_range_end_utf16()
    }

    fn get_grapheme_cluster_bounds(&self) -> drawing_api::PixelRect {
        let rect = self.glyph_info.get_grapheme_cluster_bounds();
        drawing_api::PixelRect::new(
            // TODO: a bug in impeller - x & y are swapped (?!)
            PixelPoint::new(rect.origin.y, rect.origin.x),
            PixelSize::new(rect.size.width, rect.size.height),
        )
    }

    fn is_ellipsis(&self) -> bool {
        self.glyph_info.is_ellipsis()
    }

    fn get_text_direction(&self) -> drawing_api::TextDirection {
        match self.glyph_info.get_text_direction() {
            impellers::TextDirection::RTL => drawing_api::TextDirection::RTL,
            impellers::TextDirection::LTR => drawing_api::TextDirection::LTR,
        }
    }
}