mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Document the font_metrics module.
This commit is contained in:
parent
858ee1f1ec
commit
68476df18e
1 changed files with 12 additions and 3 deletions
|
@ -2,6 +2,10 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
//! Access to font metrics from the style system.
|
||||||
|
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use Atom;
|
use Atom;
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
|
@ -11,13 +15,19 @@ use std::fmt;
|
||||||
/// value of certain CSS units like `ex`.
|
/// value of certain CSS units like `ex`.
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct FontMetrics {
|
pub struct FontMetrics {
|
||||||
|
/// The x-height of the font.
|
||||||
pub x_height: Au,
|
pub x_height: Au,
|
||||||
|
/// The zero advance.
|
||||||
pub zero_advance_measure: Size2D<Au>,
|
pub zero_advance_measure: Size2D<Au>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The result for querying font metrics for a given font family.
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum FontMetricsQueryResult {
|
pub enum FontMetricsQueryResult {
|
||||||
|
/// The font is available, but we may or may not have found any font metrics
|
||||||
|
/// for it.
|
||||||
Available(Option<FontMetrics>),
|
Available(Option<FontMetrics>),
|
||||||
|
/// The font is not available.
|
||||||
NotAvailable,
|
NotAvailable,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +36,8 @@ pub trait FontMetricsProvider: Send + Sync + fmt::Debug {
|
||||||
/// Obtain the metrics for given font family.
|
/// Obtain the metrics for given font family.
|
||||||
///
|
///
|
||||||
/// TODO: We could make this take the full list, I guess, and save a few
|
/// TODO: We could make this take the full list, I guess, and save a few
|
||||||
/// virtual calls.
|
/// virtual calls in the case we are repeatedly unable to find font metrics?
|
||||||
///
|
/// That is not too common in practice though.
|
||||||
/// This is not too common in practice though.
|
|
||||||
fn query(&self, _font_name: &Atom) -> FontMetricsQueryResult {
|
fn query(&self, _font_name: &Atom) -> FontMetricsQueryResult {
|
||||||
FontMetricsQueryResult::NotAvailable
|
FontMetricsQueryResult::NotAvailable
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue