use crate::{Point, PxScale};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct GlyphId(pub u16);
impl GlyphId {
#[inline]
pub fn with_scale_and_position<S: Into<PxScale>, P: Into<Point>>(
self,
scale: S,
position: P,
) -> Glyph {
Glyph {
id: self,
scale: scale.into(),
position: position.into(),
}
}
#[inline]
pub fn with_scale<S: Into<PxScale>>(self, scale: S) -> Glyph {
self.with_scale_and_position(scale, Point::default())
}
}
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct Glyph {
pub id: GlyphId,
pub scale: PxScale,
pub position: Point,
}
#[deprecated(since = "0.2.22", note = "Deprecated in favor of `v2::GlyphImage`")]
#[derive(Debug, Clone)]
pub struct GlyphImage<'a> {
pub origin: Point,
pub scale: f32,
pub data: &'a [u8],
pub format: GlyphImageFormat,
}
pub mod v2 {
use crate::{GlyphImageFormat, Point};
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct GlyphImage<'a> {
pub origin: Point,
pub width: u16,
pub height: u16,
pub pixels_per_em: u16,
pub data: &'a [u8],
pub format: GlyphImageFormat,
}
}
#[non_exhaustive]
#[derive(Debug, Clone)]
pub enum GlyphImageFormat {
Png,
BitmapMono,
BitmapMonoPacked,
BitmapGray2,
BitmapGray2Packed,
BitmapGray4,
BitmapGray4Packed,
BitmapGray8,
BitmapPremulBgra32,
}