1 | //! API for loading, scaling, positioning and rasterizing OpenType font glyphs. |
2 | //! |
3 | //! # Example |
4 | //! ``` |
5 | //! use ab_glyph::{point, Font, FontRef, Glyph}; |
6 | //! |
7 | //! # fn main() -> Result<(), ab_glyph::InvalidFont> { |
8 | //! let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf" ))?; |
9 | //! |
10 | //! // Get a glyph for 'q' with a scale & position. |
11 | //! let q_glyph: Glyph = font |
12 | //! .glyph_id('q' ) |
13 | //! .with_scale_and_position(24.0, point(100.0, 0.0)); |
14 | //! |
15 | //! // Draw it. |
16 | //! if let Some(q) = font.outline_glyph(q_glyph) { |
17 | //! q.draw(|x, y, c| { /* draw pixel `(x, y)` with coverage: `c` */ }); |
18 | //! } |
19 | //! # Ok(()) } |
20 | //! ``` |
21 | #![warn (missing_debug_implementations)] |
22 | #![cfg_attr (not(feature = "std" ), no_std)] |
23 | |
24 | extern crate alloc; |
25 | |
26 | mod codepoint_ids; |
27 | mod err; |
28 | mod font; |
29 | #[cfg (feature = "std" )] |
30 | mod font_arc; |
31 | mod glyph; |
32 | #[cfg (all(feature = "libm" , not(feature = "std" )))] |
33 | mod nostd_float; |
34 | mod outlined; |
35 | mod scale; |
36 | mod ttfp; |
37 | #[cfg (feature = "variable-fonts" )] |
38 | mod variable; |
39 | |
40 | #[cfg (feature = "std" )] |
41 | pub use crate::font_arc::*; |
42 | #[allow (deprecated)] |
43 | pub use crate::{ |
44 | codepoint_ids::*, |
45 | err::*, |
46 | font::*, |
47 | glyph::*, |
48 | outlined::*, |
49 | scale::*, |
50 | ttfp::{FontRef, FontVec}, |
51 | }; |
52 | pub use ab_glyph_rasterizer::{point, Point}; |
53 | #[cfg (feature = "variable-fonts" )] |
54 | pub use variable::*; |
55 | |