Struct GraphicsState

Source
pub struct GraphicsState<'a> {
Show 22 fields pub retained: RetainedGraphicsState, pub proj_vector: Point<i32>, pub proj_axis: CoordAxis, pub dual_proj_vector: Point<i32>, pub dual_proj_axis: CoordAxis, pub freedom_vector: Point<i32>, pub freedom_axis: CoordAxis, pub fdotp: i32, pub round_state: RoundState, pub rp0: usize, pub rp1: usize, pub rp2: usize, pub loop_counter: u32, pub zp0: ZonePointer, pub zp1: ZonePointer, pub zp2: ZonePointer, pub zones: [Zone<'a>; 2], pub is_composite: bool, pub backward_compatibility: bool, pub is_pedantic: bool, pub did_iup_x: bool, pub did_iup_y: bool,
}
Expand description

Fields§

§retained: RetainedGraphicsState

Fields of the graphics state that persist between calls to the interpreter.

§proj_vector: Point<i32>

A unit vector whose direction establishes an axis along which distances are measured.

See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#projection%20vector

§proj_axis: CoordAxis

Current axis for the projection vector.

§dual_proj_vector: Point<i32>

A second projection vector set to a line defined by the original outline location of two points. The dual projection vector is used when it is necessary to measure distances from the scaled outline before any instructions were executed.

See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#dual%20projection%20vector

§dual_proj_axis: CoordAxis

Current axis for the dual projection vector.

§freedom_vector: Point<i32>

A unit vector that establishes an axis along which points can move.

See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#freedom%20vector

§freedom_axis: CoordAxis

Current axis for point movement.

§fdotp: i32

Dot product of freedom and projection vectors.

§round_state: RoundState§rp0: usize§rp1: usize§rp2: usize§loop_counter: u32

Makes it possible to repeat certain instructions a designated number of times. The default value of one assures that unless the value of loop is altered, these instructions will execute one time.

See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#loop

§zp0: ZonePointer§zp1: ZonePointer§zp2: ZonePointer§zones: [Zone<'a>; 2]

Outline data for each zone.

This array contains the twilight and glyph zones, in that order.

§is_composite: bool

True if the current glyph is a composite.

§backward_compatibility: bool

If true, enables a set of backward compatibility heuristics that prevent certain modifications to the outline. The purpose is to support “modern” vertical only hinting that attempts to preserve outline shape and metrics in the horizontal direction. This is enabled by default, but fonts (and specific glyphs) can opt out of this behavior using the INSTCTRL instruction. In practice, opting out is usually only done by “ClearType native” fonts.

See https://learn.microsoft.com/en-us/typography/cleartype/truetypecleartype for more background and some gory details.

Defaults to true.

See https://gitlab.freedesktop.org/freetype/freetype/-/blob/57617782464411201ce7bbc93b086c1b4d7d84a5/src/truetype/ttinterp.h#L344

§is_pedantic: bool§did_iup_x: bool

Set to true when IUP has been executed in the horizontal direction.

§did_iup_y: bool

Set to true when IUP has been executed in the vertical direction.

Implementations§

Source§

impl GraphicsState<'_>

Source

pub fn unscaled_to_pixels(&self) -> i32

Returns the factor for scaling unscaled points to pixels.

For composite glyphs, “unscaled” points are already scaled so we return the identity.

Source

pub fn reset(&mut self)

Resets the non-retained portions of the graphics state.

Source

pub fn reset_retained(&mut self)

Resets the retained portion of the graphics state to default values while saving the user instance settings.

Source§

impl GraphicsState<'_>

Source

pub fn update_projection_state(&mut self)

Updates cached state that is derived from projection vectors.

Source

pub fn project(&self, v1: Point<F26Dot6>, v2: Point<F26Dot6>) -> F26Dot6

Computes the projection of vector given by (v1 - v2) along the current projection vector.

Source

pub fn dual_project(&self, v1: Point<F26Dot6>, v2: Point<F26Dot6>) -> F26Dot6

Computes the projection of vector given by (v1 - v2) along the current dual projection vector.

Source

pub fn dual_project_unscaled(&self, v1: Point<i32>, v2: Point<i32>) -> i32

Computes the projection of vector given by (v1 - v2) along the current dual projection vector for unscaled points.

Source§

impl GraphicsState<'_>

Source

pub fn round(&self, distance: F26Dot6) -> F26Dot6

Source§

impl<'a> GraphicsState<'a>

Source

pub fn in_bounds<const N: usize>( &self, pairs: [(ZonePointer, usize); N], ) -> bool

Takes an array of (zone pointer, point index) pairs and returns true if all accesses would be valid.

Source

pub fn zone(&self, pointer: ZonePointer) -> &Zone<'a>

Source

pub fn zone_mut(&mut self, pointer: ZonePointer) -> &mut Zone<'a>

Source

pub fn zp0(&self) -> &Zone<'a>

Source

pub fn zp0_mut(&mut self) -> &mut Zone<'a>

Source

pub fn zp1(&self) -> &Zone<'_>

Source

pub fn zp1_mut(&mut self) -> &mut Zone<'a>

Source

pub fn zp2(&self) -> &Zone<'_>

Source

pub fn zp2_mut(&mut self) -> &mut Zone<'a>

Source§

impl GraphicsState<'_>

Source

pub(crate) fn move_original( &mut self, zone: ZonePointer, point_ix: usize, distance: F26Dot6, ) -> Result<(), HintErrorKind>

Moves the requested original point by the given distance.

Source

pub(crate) fn move_point( &mut self, zone: ZonePointer, point_ix: usize, distance: F26Dot6, ) -> Result<(), HintErrorKind>

Source

pub(crate) fn move_zp2_point( &mut self, point_ix: usize, dx: F26Dot6, dy: F26Dot6, do_touch: bool, ) -> Result<(), HintErrorKind>

Moves the requested scaled point in the zone referenced by zp2 by the given delta.

This is a helper function for SHP, SHC, SHZ, and SHPIX instructions.

See https://gitlab.freedesktop.org/freetype/freetype/-/blob/57617782464411201ce7bbc93b086c1b4d7d84a5/src/truetype/ttinterp.c#L5170

Source

pub(crate) fn point_displacement( &mut self, opcode: u8, ) -> Result<PointDisplacement, HintErrorKind>

Trait Implementations§

Source§

impl<'a> Debug for GraphicsState<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GraphicsState<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for GraphicsState<'_>

Source§

type Target = RetainedGraphicsState

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for GraphicsState<'_>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a> Freeze for GraphicsState<'a>

§

impl<'a> RefUnwindSafe for GraphicsState<'a>

§

impl<'a> Send for GraphicsState<'a>

§

impl<'a> Sync for GraphicsState<'a>

§

impl<'a> Unpin for GraphicsState<'a>

§

impl<'a> !UnwindSafe for GraphicsState<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.