1use thiserror::Error;
2
3use crate::PositionedChar;
4
5#[derive(Error, Debug)]
6pub enum Error {
7 #[error("Unrecognized buffer")]
8 UnrecognizedBuffer,
9 #[error("MIME {0} not supported as a font")]
10 UnsupportedMIME(&'static str),
11 #[error("Font doesn't have a proper name")]
12 EmptyName,
13 #[error(transparent)]
14 Parser(#[from] ttf_parser::FaceParsingError),
15 #[error(transparent)]
16 Io(#[from] std::io::Error),
17 #[error("Glyph {c} not found in font")]
18 GlyphNotFound { c: char },
19 #[cfg(feature = "woff2-patched")]
20 #[error(transparent)]
21 Woff2(#[from] woff2_patched::decode::DecodeError),
22 #[error("Metrics mismatch: values {value:?} metrics {metrics:?}")]
23 MetricsMismatch {
24 value: Vec<char>,
25 metrics: Vec<PositionedChar>,
26 },
27 #[cfg(feature = "png")]
28 #[error("Color space not support when decoding rastered image, {0:?}")]
29 PngNotSupported(png::ColorType),
30 #[cfg(feature = "png")]
31 #[error(transparent)]
32 PngDocde(#[from] png::DecodingError),
33 #[error(transparent)]
34 Utf8(#[from] std::string::FromUtf8Error),
35}