Skip to main content

ttf_rs/
error.rs

1use std::io;
2
3pub type Result<T> = std::result::Result<T, TtfError>;
4
5#[derive(Debug, thiserror::Error)]
6pub enum TtfError {
7    #[error("Invalid TTF signature: expected {expected:#x}, got {actual:#x}")]
8    InvalidSignature { expected: u32, actual: u32 },
9
10    #[error("Invalid table checksum for table: {0}")]
11    InvalidChecksum(String),
12
13    #[error("Required table not found: {0}")]
14    MissingTable(String),
15
16    #[error("Invalid table offset: {0}")]
17    InvalidOffset(u64),
18
19    #[error("Invalid table size: expected {expected}, got {actual}")]
20    InvalidSize { expected: u64, actual: u64 },
21
22    #[error("Unsupported table version: {0}")]
23    UnsupportedVersion(u32),
24
25    #[error("Invalid glyph index: {0}")]
26    InvalidGlyphIndex(u16),
27
28    #[error("Invalid number of glyphs: {0}")]
29    InvalidNumGlyphs(u16),
30
31    #[error("IO error: {0}")]
32    Io(#[from] io::Error),
33
34    #[error("Parse error: {0}")]
35    ParseError(String),
36
37    #[error("Invalid encoding: {0}")]
38    InvalidEncoding(String),
39
40    #[error("Invalid offset in loca table: {0}")]
41    InvalidLocaOffset(u32),
42}