| 1 | use crate::interop::AsStr; |
| 2 | use std::ops::Index; |
| 3 | |
| 4 | mod dart_types; |
| 5 | mod font_arguments; |
| 6 | mod font_collection; |
| 7 | mod metrics; |
| 8 | #[allow (clippy::module_inception)] |
| 9 | pub mod paragraph; |
| 10 | mod paragraph_builder; |
| 11 | mod paragraph_cache; |
| 12 | mod paragraph_style; |
| 13 | mod text_shadow; |
| 14 | mod text_style; |
| 15 | mod typeface_font_provider; |
| 16 | |
| 17 | pub use dart_types::*; |
| 18 | pub use font_arguments::*; |
| 19 | pub use font_collection::*; |
| 20 | pub use metrics::*; |
| 21 | pub use paragraph::Paragraph; |
| 22 | pub use paragraph_builder::*; |
| 23 | pub use paragraph_cache::*; |
| 24 | pub use paragraph_style::*; |
| 25 | pub use text_shadow::*; |
| 26 | pub use text_style::*; |
| 27 | pub use typeface_font_provider::*; |
| 28 | |
| 29 | /// Efficient reference type to a C++ vector of font family SkStrings. |
| 30 | /// |
| 31 | /// Use indexer or .iter() to access the Rust str references. |
| 32 | #[derive (Debug)] |
| 33 | pub struct FontFamilies<'a>(&'a [skia_bindings::SkString]); |
| 34 | |
| 35 | impl Index<usize> for FontFamilies<'_> { |
| 36 | type Output = str; |
| 37 | fn index(&self, index: usize) -> &Self::Output { |
| 38 | self.0[index].as_str() |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | impl FontFamilies<'_> { |
| 43 | pub fn iter(&self) -> impl Iterator<Item = &str> { |
| 44 | self.0.iter().map(|str: &SkString| str.as_str()) |
| 45 | } |
| 46 | } |
| 47 | |