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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//! Text layout for [ab_glyph](https://github.com/alexheretic/ab-glyph).
//!
//! # Example
//!
//! ```
//! use glyph_brush_layout::{ab_glyph::*, *};
//! # fn main() -> Result<(), InvalidFont> {
//!
//! let dejavu = FontRef::try_from_slice(include_bytes!("../../fonts/DejaVuSans.ttf"))?;
//! let garamond = FontRef::try_from_slice(include_bytes!("../../fonts/GaramondNo8-Reg.ttf"))?;
//!
//! // Simple font mapping: FontId(0) -> deja vu sans, FontId(1) -> garamond
//! let fonts = &[dejavu, garamond];
//!
//! // Layout "hello glyph_brush_layout" on an unbounded line with the second
//! // word suitably bigger, greener and serif-ier.
//! let glyphs = Layout::default().calculate_glyphs(
//! fonts,
//! &SectionGeometry {
//! screen_position: (150.0, 50.0),
//! ..SectionGeometry::default()
//! },
//! &[
//! SectionText {
//! text: "hello ",
//! scale: PxScale::from(20.0),
//! font_id: FontId(0),
//! },
//! SectionText {
//! text: "glyph_brush_layout",
//! scale: PxScale::from(25.0),
//! font_id: FontId(1),
//! },
//! ],
//! );
//!
//! assert_eq!(glyphs.len(), 24);
//!
//! let SectionGlyph {
//! glyph,
//! font_id,
//! section_index,
//! byte_index,
//! } = &glyphs[4];
//! assert_eq!(glyph.id, fonts[0].glyph_id('o'));
//! assert_eq!(*font_id, FontId(0));
//! assert_eq!(*section_index, 0);
//! assert_eq!(*byte_index, 4);
//!
//! let SectionGlyph {
//! glyph,
//! font_id,
//! section_index,
//! byte_index,
//! } = &glyphs[14];
//! assert_eq!(glyph.id, fonts[1].glyph_id('u'));
//! assert_eq!(*font_id, FontId(1));
//! assert_eq!(*section_index, 1);
//! assert_eq!(*byte_index, 8);
//!
//! # Ok(())
//! # }
//! ```
/// Re-exported ab_glyph types.
pub use ;
use *;
use Hash;
/// Logic to calculate glyph positioning using [`Font`](struct.Font.html),
/// [`SectionGeometry`](struct.SectionGeometry.html) and
/// [`SectionText`](struct.SectionText.html).