word_cloud/words/
glyph_data.rs

1use rusttype::PositionedGlyph;
2
3use crate::geometry::{Orientation, Rectangle};
4
5#[derive(Clone, Debug)]
6pub struct GlyphData<'font> {
7    pub width: u32,
8    pub height: u32,
9    pub glyphs: Vec<PositionedGlyph<'font>>,
10}
11
12impl<'font> GlyphData<'font> {
13    pub fn bounding_box(&self, orientation: &Orientation) -> Rectangle {
14        match orientation {
15            Orientation::Horizontal => Rectangle::new(0, 0, self.width, self.height),
16            Orientation::Vertical => Rectangle::new(0, 0, self.height, self.width),
17        }
18    }
19}