Skip to main content

Font

Trait Font 

Source
pub trait Font:
    Send
    + Sync
    + Debug {
    // Required methods
    fn codes(&self, bytes: &[u8]) -> Vec<(u32, usize)>;
    fn width(&self, code: u32) -> f64;
    fn unicode(&self, code: u32) -> Option<String>;
    fn name(&self) -> &str;

    // Provided methods
    fn is_vertical(&self) -> bool { ... }
    fn vertical_advance(&self, _code: u32) -> f64 { ... }
}
Expand description

A loaded font, as the interpreter needs it: how a string splits into character codes, how far each code advances, and (for extraction) what text it stands for. Implemented by otf-pdf-font.

Required Methods§

Source

fn codes(&self, bytes: &[u8]) -> Vec<(u32, usize)>

Splits a shown string into (code, byte length) pairs.

Source

fn width(&self, code: u32) -> f64

Horizontal advance of code, in text space units per unit of font size (glyph width / 1000 for most fonts).

Source

fn unicode(&self, code: u32) -> Option<String>

The Unicode text for code, if known.

Source

fn name(&self) -> &str

The font’s name (/BaseFont), for reporting.

Provided Methods§

Source

fn is_vertical(&self) -> bool

Whether the font is written vertically (an -V CMap).

Source

fn vertical_advance(&self, _code: u32) -> f64

Vertical advance of code in vertical writing (negative is down).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§