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