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
use crate::{Error, RoundFrom, RoundInto};
pub trait Text {
type FontBuilder: FontBuilder<Out = Self::Font>;
type Font: Font;
type TextLayoutBuilder: TextLayoutBuilder<Out = Self::TextLayout>;
type TextLayout: TextLayout;
type Coord: Into<f64> + RoundFrom<f64>;
fn new_font_by_name(
&mut self,
name: &str,
size: impl RoundInto<Self::Coord>,
) -> Result<Self::FontBuilder, Error>;
fn new_text_layout(
&mut self,
font: &Self::Font,
text: &str,
) -> Result<Self::TextLayoutBuilder, Error>;
}
pub trait FontBuilder {
type Out: Font;
fn build(self) -> Result<Self::Out, Error>;
}
pub trait Font {}
pub trait TextLayoutBuilder {
type Out: TextLayout;
fn build(self) -> Result<Self::Out, Error>;
}
pub trait TextLayout {
type Coord: Into<f64> + RoundFrom<f64>;
fn width(&self) -> Self::Coord;
}