read_fonts/tables/glyf/outline/
error.rs1use super::super::bytecode::HintError;
4use crate::ReadError;
5
6#[derive(Clone, PartialEq, Debug)]
12pub enum OutlineError {
13 MissingGlyph,
15 RecursionLimitExceeded,
18 TooManyComponents,
21 TooManyPoints,
24 InvalidAnchorPoint,
26 InsufficientMemory,
28 Hinting(HintError),
30 Malformed,
34}
35
36impl From<ReadError> for OutlineError {
37 fn from(_: ReadError) -> Self {
38 Self::Malformed
39 }
40}
41
42impl From<HintError> for OutlineError {
43 fn from(value: HintError) -> Self {
44 Self::Hinting(value)
45 }
46}
47
48impl core::fmt::Display for OutlineError {
49 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
50 match self {
51 Self::MissingGlyph => f.write_str("requested glyph was not found in the font"),
52 Self::RecursionLimitExceeded => {
53 f.write_str("glyph exceeded the composite recursion limit")
54 }
55 Self::TooManyComponents => f.write_str("glyph referenced too many components"),
56 Self::TooManyPoints => f.write_str("glyph has too many points"),
57 Self::InvalidAnchorPoint => f.write_str("glyph referenced a nonexistent anchor point"),
58 Self::InsufficientMemory => f.write_str("outline buffers were too small"),
59 Self::Hinting(err) => write!(f, "{err}"),
60 Self::Malformed => f.write_str("font data was malformed"),
61 }
62 }
63}
64
65#[cfg(feature = "std")]
66impl std::error::Error for OutlineError {}