plotters/style/font/
mod.rs
1#[cfg(all(not(target_arch = "wasm32"), feature = "ttf"))]
10mod ttf;
11#[cfg(all(not(target_arch = "wasm32"), feature = "ttf"))]
12use ttf::FontDataInternal;
13
14#[cfg(all(not(target_arch = "wasm32"), not(feature = "ttf")))]
15mod naive;
16#[cfg(all(not(target_arch = "wasm32"), not(feature = "ttf")))]
17use naive::FontDataInternal;
18
19#[cfg(target_arch = "wasm32")]
20mod web;
21#[cfg(target_arch = "wasm32")]
22use web::FontDataInternal;
23
24mod font_desc;
25pub use font_desc::*;
26
27pub type LayoutBox = ((i32, i32), (i32, i32));
28
29pub trait FontData: Clone {
30 type ErrorType: Sized + std::error::Error + Clone;
31 fn new(family: FontFamily, style: FontStyle) -> Result<Self, Self::ErrorType>;
32 fn estimate_layout(&self, size: f64, text: &str) -> Result<LayoutBox, Self::ErrorType>;
33 fn draw<E, DrawFunc: FnMut(i32, i32, f32) -> Result<(), E>>(
34 &self,
35 _pos: (i32, i32),
36 _size: f64,
37 _text: &str,
38 _draw: DrawFunc,
39 ) -> Result<Result<(), E>, Self::ErrorType> {
40 panic!("The font implementation is unable to draw text");
41 }
42}