From 64f938b449b7ff5e53b6a06ed943bf9dedc1014b Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 8 Dec 2019 11:15:04 +0100 Subject: =?UTF-8?q?Improve=20testers=20=E2=99=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index afdab1ef..7f9b9b95 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -45,6 +45,21 @@ pub struct Layout { pub actions: Vec, } +impl Layout { + /// Returns a vector with all used font indices. + pub fn find_used_fonts(&self) -> Vec { + let mut fonts = Vec::new(); + for action in &self.actions { + if let LayoutAction::SetFont(index, _) = action { + if !fonts.contains(index) { + fonts.push(*index); + } + } + } + fonts + } +} + /// The general context for layouting. #[derive(Debug, Clone)] pub struct LayoutContext<'a, 'p> { -- cgit v1.2.3