use crate::{
draw_target::DrawTarget, geometry::Point, pixelcolor::PixelColor, primitives::Rectangle,
};
mod character_style;
pub use character_style::{CharacterStyle, DecorationColor};
pub trait TextRenderer {
type Color: PixelColor;
fn draw_string<D>(
&self,
text: &str,
position: Point,
target: &mut D,
) -> Result<Point, D::Error>
where
D: DrawTarget<Color = Self::Color>;
fn draw_whitespace<D>(
&self,
width: u32,
position: Point,
target: &mut D,
) -> Result<Point, D::Error>
where
D: DrawTarget<Color = Self::Color>;
fn measure_string(&self, text: &str, position: Point) -> TextMetrics;
fn vertical_offset(&self, position: Point, vertical_alignment: VerticalAlignment) -> Point;
fn line_height(&self) -> u32;
}
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub struct TextMetrics {
pub bounding_box: Rectangle,
pub next_position: Point,
}
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub enum VerticalAlignment {
Top,
Bottom,
Center,
Baseline,
}
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub enum HorizontalAlignment {
Left,
Center,
Right,
}