Skip to main content

Scale

Trait Scale 

Source
pub trait Scale: Sized {
    type Coord: PointCoord + NoUninit;
    type Delta: PointCoord + NoUninit;

    const NEEDS_UNSCALED: bool;

    // Required methods
    fn is_scaled(&self) -> bool;
    fn phantom_from_font_units(&self, value: i32) -> Self::Coord;
    fn coord_to_hinting_raw(&self, value: Self::Coord) -> i32;
    fn scale_phantom(&self, point: Point<Self::Coord>) -> Point<Self::Coord>;
    fn add_phantom_delta(
        &self,
        point: Point<Self::Coord>,
        delta: Point<Self::Delta>,
    ) -> Point<Self::Coord>;
    fn round_phantom(&self, point: Point<Self::Coord>) -> Point<Self::Coord>;
    fn load_empty_phantom(
        &self,
        phantom: &mut [Point<Self::Coord>; 4],
        deltas: Option<[Point<Fixed>; 4]>,
    );
    fn load_simple_points(
        &self,
        pass: SimplePass<'_, '_, Self>,
    ) -> Result<[Point<Self::Coord>; 4], Error>;
    fn transform_points(
        &self,
        points: &mut [Point<Self::Coord>],
        transform: &Transform,
    );
    fn component_offset(
        &self,
        offset: Point<i32>,
        transform: &Transform,
        scale_offset: bool,
        delta: Option<Point<Self::Delta>>,
        rounding: OffsetRounding,
    ) -> Point<Self::Coord>;
}
Expand description

How coordinates are represented and rounded while loading an outline.

This trait is sealed. load_simple_points takes a type this crate does not export, so the implementations here are the only ones.

Required Associated Constants§

Source

const NEEDS_UNSCALED: bool

True if the scale keeps a parallel copy of the points in font units, which hinting needs and which sparse delta interpolation uses as its reference coordinates.

Required Associated Types§

Source

type Coord: PointCoord + NoUninit

Coordinate type of the loaded outline.

Source

type Delta: PointCoord + NoUninit

Accumulator type for variation deltas.

Required Methods§

Source

fn is_scaled(&self) -> bool

True if a size was supplied. When false the outline comes back in font units, expressed in Self::Coord.

Source

fn phantom_from_font_units(&self, value: i32) -> Self::Coord

Converts a font unit value into the representation phantom points use before they are scaled.

Source

fn coord_to_hinting_raw(&self, value: Self::Coord) -> i32

Reinterprets an output coordinate as the integer a hinter’s font unit buffer holds.

A composite has no font unit points of its own, so FreeType fills that buffer with the loaded coordinates as they stand. For Scale26Dot6 that means raw fixed point bits rather than font units, which is what the interpreter expects.

Source

fn scale_phantom(&self, point: Point<Self::Coord>) -> Point<Self::Coord>

Scales a phantom point that still holds font units.

Source

fn add_phantom_delta( &self, point: Point<Self::Coord>, delta: Point<Self::Delta>, ) -> Point<Self::Coord>

Adds a composite glyph’s phantom point delta.

Source

fn round_phantom(&self, point: Point<Self::Coord>) -> Point<Self::Coord>

Rounds a phantom point, which FreeType does before hinting.

Source

fn load_empty_phantom( &self, phantom: &mut [Point<Self::Coord>; 4], deltas: Option<[Point<Fixed>; 4]>, )

Sets the phantom points of a glyph with no outline.

deltas are this glyph’s phantom point deltas, if the font is variable and has them. They apply whether or not the font has HVAR: the phantom points are seeded from unvaried metrics, so gvar is their only source of variation.

Source

fn load_simple_points( &self, pass: SimplePass<'_, '_, Self>, ) -> Result<[Point<Self::Coord>; 4], Error>

Reads a simple glyph’s points, applies variation deltas, appends the phantom points and writes the scaled result.

Returns the phantom points as they ended up, which the caller carries forward.

Source

fn transform_points( &self, points: &mut [Point<Self::Coord>], transform: &Transform, )

Applies a component’s 2x2 transform to points that have already been placed.

Takes the whole slice so a scale converts the transform once rather than once per point.

Source

fn component_offset( &self, offset: Point<i32>, transform: &Transform, scale_offset: bool, delta: Option<Point<Self::Delta>>, rounding: OffsetRounding, ) -> Point<Self::Coord>

Computes the translation for a component given as an offset.

scale_offset is set when the component carries SCALED_COMPONENT_OFFSET without UNSCALED_COMPONENT_OFFSET, delta is the component’s variation delta if there is one, and rounding selects the axes that are rounded to the pixel grid. No axis is rounded unless the component carries ROUND_XY_TO_GRID and the outline is being hinted.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§