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
Context in which instructions are executed.
See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html
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.
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
Determines the manner in which values are rounded.
See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#round%20state
rp0: usize
First reference point.
See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#rp0
rp1: usize
Second reference point.
See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#rp1
rp2: usize
Third reference point.
See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#rp1
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
First zone pointer.
See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#zp0
zp1: ZonePointer
Second zone pointer.
See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#zp1
zp2: ZonePointer
Third zone pointer.
See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#zp2
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.
is_pedantic: bool
If true, enables more strict error checking.
Defaults to false.
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<'_>
impl GraphicsState<'_>
Sourcepub fn unscaled_to_pixels(&self) -> i32
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.
Sourcepub fn reset_retained(&mut self)
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<'_>
impl GraphicsState<'_>
Sourcepub fn update_projection_state(&mut self)
pub fn update_projection_state(&mut self)
Updates cached state that is derived from projection vectors.
Sourcepub fn project(&self, v1: Point<F26Dot6>, v2: Point<F26Dot6>) -> F26Dot6
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§impl<'a> GraphicsState<'a>
impl<'a> GraphicsState<'a>
Sourcepub fn in_bounds<const N: usize>(
&self,
pairs: [(ZonePointer, usize); N],
) -> bool
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.
pub fn zone(&self, pointer: ZonePointer) -> &Zone<'a>
pub fn zone_mut(&mut self, pointer: ZonePointer) -> &mut Zone<'a>
pub fn zp0(&self) -> &Zone<'a>
pub fn zp0_mut(&mut self) -> &mut Zone<'a>
pub fn zp1(&self) -> &Zone<'_>
pub fn zp1_mut(&mut self) -> &mut Zone<'a>
pub fn zp2(&self) -> &Zone<'_>
pub fn zp2_mut(&mut self) -> &mut Zone<'a>
Source§impl GraphicsState<'_>
impl GraphicsState<'_>
Sourcepub(crate) fn move_original(
&mut self,
zone: ZonePointer,
point_ix: usize,
distance: F26Dot6,
) -> Result<(), HintErrorKind>
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.
Sourcepub(crate) fn move_point(
&mut self,
zone: ZonePointer,
point_ix: usize,
distance: F26Dot6,
) -> Result<(), HintErrorKind>
pub(crate) fn move_point( &mut self, zone: ZonePointer, point_ix: usize, distance: F26Dot6, ) -> Result<(), HintErrorKind>
Moves the requested scaled point by the given distance. See https://gitlab.freedesktop.org/freetype/freetype/-/blob/57617782464411201ce7bbc93b086c1b4d7d84a5/src/truetype/ttinterp.c#L1771
Sourcepub(crate) fn move_zp2_point(
&mut self,
point_ix: usize,
dx: F26Dot6,
dy: F26Dot6,
do_touch: bool,
) -> Result<(), HintErrorKind>
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.
Sourcepub(crate) fn point_displacement(
&mut self,
opcode: u8,
) -> Result<PointDisplacement, HintErrorKind>
pub(crate) fn point_displacement( &mut self, opcode: u8, ) -> Result<PointDisplacement, HintErrorKind>
Computes the adjustment made to a point along the current freedom vector. See https://gitlab.freedesktop.org/freetype/freetype/-/blob/57617782464411201ce7bbc93b086c1b4d7d84a5/src/truetype/ttinterp.c#L5126