Debian Codegraph @

src/variable.rs

raw symbols SCIP
1 #[cfg(not(feature = "std"))]
2 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
3 #[cfg(not(feature = "std"))]
4 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#;
5
6 /// Logic for variable fonts.
7 ///
8 /// Requires feature `variable-fonts` (enabled by default).
9 pub trait VariableFontrust-analyzer cargo ab_glyph 0.2.32 variable/VariableFont# {
10 /// Sets a variation axis coordinate value by it's tag.
11 ///
12 /// Returns false if there is no such axis tag.
13 ///
14 /// # Example
15 /// ```
16 /// use ab_glyph::{FontRef, VariableFont};
17 ///
18 /// # fn main() -> Result<(), ab_glyph::InvalidFont> {
19 /// let mut font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Cantarell-VF.otf"))?;
20 ///
21 /// // set weight to 600
22 /// assert!(font.set_variation(b"wght", 600.0));
23 ///
24 /// // no such variation tag "foob" so return false
25 /// assert!(!font.set_variation(b"foob", 200.0));
26 /// # Ok(()) }
27 /// ```
28 fn set_variationrust-analyzer cargo ab_glyph 0.2.32 variable/VariableFont#set_variation().(&mut self, tag: &[u8; 4], value: f32) -> bool;
29
30 /// Returns variation axes.
31 ///
32 /// # Example
33 /// ```
34 /// use ab_glyph::{FontRef, VariableFont};
35 ///
36 /// # fn main() -> Result<(), ab_glyph::InvalidFont> {
37 /// let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Cantarell-VF.otf"))?;
38 /// let var = &font.variations()[0];
39 /// # eprintln!("{var:#?}");
40 ///
41 /// assert_eq!(var.tag, *b"wght");
42 /// assert_eq!(var.name.as_deref(), Some("Weight"));
43 /// assert!((var.min_value - 100.0).abs() < f32::EPSILON);
44 /// assert!((var.default_value - 400.0).abs() < f32::EPSILON);
45 /// assert!((var.max_value - 800.0).abs() < f32::EPSILON);
46 /// assert!(!var.hidden);
47 /// # Ok(()) }
48 /// ```
49 fn variationsrust-analyzer cargo ab_glyph 0.2.32 variable/VariableFont#variations().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<VariationAxisrust-analyzer cargo ab_glyph 0.2.32 variable/VariationAxis#>;
50 }
51
52 #[non_exhaustive]
53 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
54 pub struct VariationAxisrust-analyzer cargo ab_glyph 0.2.32 variable/VariationAxis# {
55 /// Tag identifying the design variation for the axis.
56 pub tagrust-analyzer cargo ab_glyph 0.2.32 variable/VariationAxis#tag.: [u8; 4],
57 /// Unicode name.
58 pub namerust-analyzer cargo ab_glyph 0.2.32 variable/VariationAxis#name.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
59 /// The minimum coordinate value for the axis.
60 pub min_valuerust-analyzer cargo ab_glyph 0.2.32 variable/VariationAxis#min_value.: f32,
61 /// The default coordinate value for the axis.
62 pub default_valuerust-analyzer cargo ab_glyph 0.2.32 variable/VariationAxis#default_value.: f32,
63 /// The maximum coordinate value for the axis.
64 pub max_valuerust-analyzer cargo ab_glyph 0.2.32 variable/VariationAxis#max_value.: f32,
65 /// Whether the axis should be exposed directly in user interfaces.
66 pub hiddenrust-analyzer cargo ab_glyph 0.2.32 variable/VariationAxis#hidden.: bool,
67 }