StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | /// Various metrics that apply to the entire font. |
| 2 | #[derive(Clone, Copy, Debug)] |
| 3 | pub struct Metrics { |
| 4 | /// The number of font units per em. |
| 5 | /// |
| 6 | /// Font sizes are usually expressed in pixels per em; e.g. `12px` means 12 pixels per em. |
| 7 | pub units_per_em: u32, |
| 8 | |
| 9 | /// The maximum amount the font rises above the baseline, in font units. |
| 10 | pub ascent: i16, |
| 11 | |
| 12 | /// The maximum amount the font descends below the baseline, in font units. |
| 13 | /// |
| 14 | /// NB: This is typically a negative value to match the definition of `sTypoDescender` in the |
| 15 | /// `OS/2` table in the OpenType specification. If you are used to using Windows or Mac APIs, |
| 16 | /// beware, as the sign is reversed from what those APIs return. |
| 17 | pub descent: i16, |
| 18 | |
| 19 | /// Distance between baselines, in font units. |
| 20 | pub line_gap: i16, |
| 21 | } |
| 22 | |
| 23 | #[cfg(native)] |
| 24 | impl From<font_kit::metrics::Metrics> for Metrics { |
| 25 | fn from(value: font_kit::metrics::Metrics) -> Self { |
| 26 | Self { |
| 27 | units_per_em: value.units_per_em, |
| 28 | ascent: value.ascent as i16, |
| 29 | descent: value.descent as i16, |
| 30 | line_gap: value.line_gap as i16, |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 |