1// font-kit/src/metrics.rs
2//
3// Copyright © 2018 The Pathfinder Project Developers.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11//! Various metrics that apply to the entire font.
12//!
13//! For OpenType fonts, these mostly come from the `OS/2` table.
14
15use pathfinder_geometry::rect::RectF;
16
17/// Various metrics that apply to the entire font.
18///
19/// For OpenType fonts, these mostly come from the `OS/2` table.
20#[derive(Clone, Copy, Debug)]
21pub struct Metrics {
22 /// The number of font units per em.
23 ///
24 /// Font sizes are usually expressed in pixels per em; e.g. `12px` means 12 pixels per em.
25 pub units_per_em: u32,
26
27 /// The maximum amount the font rises above the baseline, in font units.
28 pub ascent: f32,
29
30 /// The maximum amount the font descends below the baseline, in font units.
31 ///
32 /// NB: This is typically a negative value to match the definition of `sTypoDescender` in the
33 /// `OS/2` table in the OpenType specification. If you are used to using Windows or Mac APIs,
34 /// beware, as the sign is reversed from what those APIs return.
35 pub descent: f32,
36
37 /// Distance between baselines, in font units.
38 pub line_gap: f32,
39
40 /// The suggested distance of the top of the underline from the baseline (negative values
41 /// indicate below baseline), in font units.
42 pub underline_position: f32,
43
44 /// A suggested value for the underline thickness, in font units.
45 pub underline_thickness: f32,
46
47 /// The approximate amount that uppercase letters rise above the baseline, in font units.
48 pub cap_height: f32,
49
50 /// The approximate amount that non-ascending lowercase letters rise above the baseline, in
51 /// font units.
52 pub x_height: f32,
53
54 /// A rectangle that surrounds all bounding boxes of all glyphs, in font units.
55 ///
56 /// This corresponds to the `xMin`/`xMax`/`yMin`/`yMax` values in the OpenType `head` table.
57 pub bounding_box: RectF,
58}
59