use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MathError {
Parse(String),
Unsupported(String),
MissingGlyph(String),
}
impl fmt::Display for MathError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
MathError::Parse(msg) => write!(f, "MATH_PARSE: {msg}"),
MathError::Unsupported(msg) => write!(f, "MATH_UNSUPPORTED: {msg}"),
MathError::MissingGlyph(msg) => write!(f, "MATH_MISSING_GLYPH: {msg}"),
}
}
}
impl std::error::Error for MathError {}
pub(crate) fn from_shape_error(err: String) -> MathError {
if err.contains("MISSING_GLYPH") {
MathError::MissingGlyph(err)
} else {
MathError::Unsupported(format!("font shaping failed: {err}"))
}
}