From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- servo/components/style/font_metrics.rs | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 servo/components/style/font_metrics.rs (limited to 'servo/components/style/font_metrics.rs') diff --git a/servo/components/style/font_metrics.rs b/servo/components/style/font_metrics.rs new file mode 100644 index 0000000000..391d3653ee --- /dev/null +++ b/servo/components/style/font_metrics.rs @@ -0,0 +1,58 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +//! Access to font metrics from the style system. + +#![deny(missing_docs)] + +use crate::values::computed::Length; + +/// Represents the font metrics that style needs from a font to compute the +/// value of certain CSS units like `ex`. +#[derive(Clone, Debug, PartialEq)] +pub struct FontMetrics { + /// The x-height of the font. + pub x_height: Option, + /// The zero advance. This is usually writing mode dependent + pub zero_advance_measure: Option, + /// The cap-height of the font. + pub cap_height: Option, + /// The ideographic-width of the font. + pub ic_width: Option, + /// The ascent of the font (a value is always available for this). + pub ascent: Length, + /// Script scale down factor for math-depth 1. + /// https://w3c.github.io/mathml-core/#dfn-scriptpercentscaledown + pub script_percent_scale_down: Option, + /// Script scale down factor for math-depth 2. + /// https://w3c.github.io/mathml-core/#dfn-scriptscriptpercentscaledown + pub script_script_percent_scale_down: Option, +} + +impl Default for FontMetrics { + fn default() -> Self { + FontMetrics { + x_height: None, + zero_advance_measure: None, + cap_height: None, + ic_width: None, + ascent: Length::new(0.0), + script_percent_scale_down: None, + script_script_percent_scale_down: None, + } + } +} + +/// Type of font metrics to retrieve. +#[derive(Clone, Debug, PartialEq)] +pub enum FontMetricsOrientation { + /// Get metrics for horizontal or vertical according to the Context's + /// writing mode, using horizontal metrics for vertical/mixed + MatchContextPreferHorizontal, + /// Get metrics for horizontal or vertical according to the Context's + /// writing mode, using vertical metrics for vertical/mixed + MatchContextPreferVertical, + /// Force getting horizontal metrics. + Horizontal, +} -- cgit v1.2.3