rpdfium-doc 7676.6.2

Document-level features for rpdfium
Documentation
// Derived from PDFium's cpvt_fontmap.h / ipvt_fontmap.h
// Original: Copyright 2014 The PDFium Authors
// Licensed under BSD-3-Clause / Apache-2.0
// See pdfium-upstream/LICENSE for the original license.

//! Variable text font provider trait (`IPVT_FontMap` / `CPVT_FontMap`).
//!
//! Abstracts font metric access for the variable text layout engine,
//! corresponding to PDFium's `IPVT_FontMap` interface.

/// Abstract font metrics provider.
///
/// Implementations supply character widths and font metrics to the
/// layout engine without coupling to a specific font library.
/// Corresponds to upstream `IPVT_FontMap` / `CPVT_FontMap`.
pub trait VtFontProvider {
    /// Return the width of a character at the given font size.
    fn char_width(&self, font_index: usize, word: u16, font_size: f32) -> f32;
    /// Return the ascent of the font at the given size.
    fn ascent(&self, font_index: usize, font_size: f32) -> f32;
    /// Return the descent of the font at the given size (typically negative).
    fn descent(&self, font_index: usize, font_size: f32) -> f32;
}