1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#![allow(clippy::tabs_in_doc_comments)]
#![warn(rust_2018_idioms)]
#![deny(unreachable_pub)]
#![forbid(elided_lifetimes_in_paths, unsafe_code)]
use std::{io, str::FromStr};
use thiserror::Error;
mod bitmap;
mod font;
mod reader;
mod tokens;
pub use bitmap::Bitmap;
pub use font::{BoundingBox, Font, Glyph, Size, Value};
use reader::State;
use tokens::Token;
#[derive(Debug, Error)]
pub enum Error {
#[error("I/O Error: {0}")]
IOError(#[from] io::Error),
#[error("Syntax Error: {0}")]
SyntaxError(#[from] tokens::Error),
#[error("The token {0:?} may only appear in {2:?}, but is in {1:?}")]
InvalidContext(Token, State, &'static str),
#[error("Unexpected end of context {0}")]
UnexpectedEnd(&'static str),
#[error("Missing font name")]
MissingFontName,
#[error("Missing font size")]
MissingFontSize,
#[error("Missing font bounding box")]
MissingFontBoundingBox,
#[error("Missing glyph encoding")]
MissingGlyphEncoding,
#[error("Missing glyph bounding box")]
MissingGlyphBoundingBox,
#[error("Invalid Property Value: {0}. Note that strings need to be quoted.")]
InvalidPropertyValue(#[source] <i32 as FromStr>::Err),
#[error("Invalid bitmap value: {0}")]
InvalidBitmapValue(String)
}