summaryrefslogtreecommitdiff
path: root/src/font/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/font/mod.rs')
-rw-r--r--src/font/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/font/mod.rs b/src/font/mod.rs
index 98875d8f..13189b6d 100644
--- a/src/font/mod.rs
+++ b/src/font/mod.rs
@@ -69,6 +69,12 @@ impl Font {
})))
}
+ /// Parse all fonts in the given data.
+ pub fn iter(data: Buffer) -> impl Iterator<Item = Self> {
+ let count = ttf_parser::fonts_in_collection(&data).unwrap_or(1);
+ (0..count).filter_map(move |index| Self::new(data.clone(), index))
+ }
+
/// The underlying buffer.
pub fn data(&self) -> &Buffer {
&self.0.data