1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
//! Text functionality for Piet svg backend

use piet::kurbo::Point;
use piet::{Error, HitTestPoint, HitTestTextPosition, LineMetric};

type Result<T> = std::result::Result<T, Error>;

/// SVG text (unimplemented)
pub struct Text(());

impl Text {
    #[allow(clippy::new_without_default)]
    pub fn new() -> Self {
        Text(())
    }
}

impl piet::Text for Text {
    type Font = Font;
    type FontBuilder = FontBuilder;
    type TextLayout = TextLayout;
    type TextLayoutBuilder = TextLayoutBuilder;

    fn new_font_by_name(&mut self, _name: &str, _size: f64) -> FontBuilder {
        FontBuilder(())
    }

    fn new_text_layout(
        &mut self,
        _font: &Self::Font,
        _text: &str,
        _width: impl Into<Option<f64>>,
    ) -> TextLayoutBuilder {
        TextLayoutBuilder(())
    }
}

/// SVG font builder (unimplemented)
pub struct FontBuilder(());

impl piet::FontBuilder for FontBuilder {
    type Out = Font;

    fn build(self) -> Result<Font> {
        Err(Error::NotSupported)
    }
}

/// SVG font (unimplemented)
pub struct Font(());

impl piet::Font for Font {}

pub struct TextLayoutBuilder(());

impl piet::TextLayoutBuilder for TextLayoutBuilder {
    type Out = TextLayout;

    fn build(self) -> Result<TextLayout> {
        Err(Error::NotSupported)
    }
}

/// SVG text layout (unimplemented)
#[derive(Clone)]
pub struct TextLayout(());

impl piet::TextLayout for TextLayout {
    fn width(&self) -> f64 {
        unimplemented!()
    }

    #[allow(clippy::unimplemented)]
    fn update_width(&mut self, _new_width: impl Into<Option<f64>>) -> Result<()> {
        unimplemented!();
    }

    #[allow(clippy::unimplemented)]
    fn line_text(&self, _line_number: usize) -> Option<&str> {
        unimplemented!();
    }

    #[allow(clippy::unimplemented)]
    fn line_metric(&self, _line_number: usize) -> Option<LineMetric> {
        unimplemented!();
    }

    #[allow(clippy::unimplemented)]
    fn line_count(&self) -> usize {
        unimplemented!();
    }

    fn hit_test_point(&self, _point: Point) -> HitTestPoint {
        unimplemented!()
    }

    fn hit_test_text_position(&self, _text_position: usize) -> Option<HitTestTextPosition> {
        unimplemented!()
    }
}