diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-04-18 19:04:46 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-04-18 19:04:46 +0200 |
| commit | 35302d20047c58baa99065a4574eafe1920e7be6 (patch) | |
| tree | b9c7dbf3e15c24cc063da70dbc2fa3d5befa41d4 /src/font | |
| parent | bce83d330f0efc0f8cdd6fb01d8244cb9f01ac27 (diff) | |
Handle SVG with text
Diffstat (limited to 'src/font')
| -rw-r--r-- | src/font/book.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/font/book.rs b/src/font/book.rs index a6e41860..5af2ccb2 100644 --- a/src/font/book.rs +++ b/src/font/book.rs @@ -39,6 +39,11 @@ impl FontBook { self.infos.push(info); } + /// Get the font info for the given index. + pub fn info(&self, index: usize) -> Option<&FontInfo> { + self.infos.get(index) + } + /// An ordered iterator over all font families this book knows and details /// about the fonts that are part of them. pub fn families( @@ -53,8 +58,8 @@ impl FontBook { }) } - /// Try to find and load a font from the given `family` that matches - /// the given `variant` as closely as possible. + /// Try to find a font from the given `family` that matches the given + /// `variant` as closely as possible. /// /// The `family` should be all lowercase. pub fn select(&self, family: &str, variant: FontVariant) -> Option<usize> { @@ -62,6 +67,16 @@ impl FontBook { self.find_best_variant(None, variant, ids.iter().copied()) } + /// Iterate over all variants of a family. + pub fn select_family(&self, family: &str) -> impl Iterator<Item = usize> + '_ { + self.families + .get(family) + .map(|vec| vec.as_slice()) + .unwrap_or_default() + .iter() + .copied() + } + /// Try to find and load a fallback font that /// - is as close as possible to the font `like` (if any) /// - is as close as possible to the given `variant` |
