Skip to main content

HintOptions

Struct HintOptions 

Source
pub struct HintOptions {
    engine: EngineRequest,
    target: RasterTarget,
    classic_cleartype: bool,
    symmetric_rendering: bool,
    preserve_linear_metrics: bool,
    pedantic: bool,
}
Expand description

Hinting configuration for a ScalerFont.

Create one with a constructor and adjust it with the with_* methods:

use skrifa::{HintOptions, RasterTarget};

let hinting = HintOptions::interpreter()
    .with_target(RasterTarget::Lcd)
    .with_classic_cleartype(true);
assert_eq!(hinting.target(), RasterTarget::Lcd);

Fields§

§engine: EngineRequest§target: RasterTarget§classic_cleartype: bool§symmetric_rendering: bool§preserve_linear_metrics: bool§pedantic: bool

Implementations§

Source§

impl HintOptions

Source

pub fn auto_fallback() -> Self

Creates a configuration that chooses the engine based on the font, with a grayscale target.

Uses the font’s own instructions when it has any, and the automatic hinter otherwise. A TrueType font with no glyph, font or control value program is autohinted.

Source

pub fn interpreter() -> Self

Creates a configuration that uses the instructions embedded in the font.

This runs the TrueType interpreter or the PostScript hinter, depending on which kind of instructions the font contains.

Source

pub fn auto() -> Self

Creates a configuration that uses the automatic hinter, which ignores the font’s instructions.

A TrueType font that needs its instructions to draw correct contours always runs the interpreter.

The data the hinter derives from a font is stored with the font. All scalers for that font share it at every size.

Source

fn with_engine(engine: EngineRequest) -> Self

Creates the defaults for a grayscale target that uses engine.

Source

pub fn with_target(self, target: RasterTarget) -> Self

Sets the rasterization target.

Source

pub fn with_classic_cleartype(self, classic_cleartype: bool) -> Self

Sets whether the TrueType interpreter uses the classic ClearType behavior.

By default, a version 1 gasp table selects symmetric smoothing and grid fitting per size, and glyphs that opt out of backward compatibility with INSTCTRL selector 3 keep fractional horizontal positions. With the classic behavior, every glyph is grid fitted, the symmetric rendering bit of GETINFO follows symmetric_rendering alone, and horizontal moves round to whole pixels. This is the behavior of HintingInstance. Defaults to off.

See https://github.com/googlefonts/fontations/issues/2112.

Source

pub fn with_symmetric_rendering(self, symmetric_rendering: bool) -> Self

Sets whether TrueType bytecode may assume vertical supersampling during rasterization.

This is the symmetric rendering bit of the GETINFO instruction. When it is set, ClearType fonts often generate wider horizontal stems that look blurry with an analytic area rasterizer. It is set by default. Unless classic ClearType is on, the font’s gasp table can also clear it per size. Only the TrueType interpreter reads it. See https://github.com/googlefonts/fontations/issues/1080.

Source

pub fn with_preserve_linear_metrics(self, preserve_linear_metrics: bool) -> Self

Sets whether hinting leaves the outline unchanged horizontally.

Hinting then moves points only vertically, so a glyph keeps its unhinted horizontal shape and spacing. The advance a draw reports is still rounded to a whole pixel, as for any hinted draw. The TrueType interpreter runs in backward compatibility mode, and the automatic hinter works as it does for a RasterTarget::Light target. Defaults to off.

Source

pub fn with_pedantic(self, pedantic: bool) -> Self

Sets whether an error in a glyph’s instructions fails the draw.

When off, the draw keeps the outline as the instructions left it. Defaults to off.

Source

pub(super) fn engine(&self) -> EngineRequest

Returns the hinting engine.

Source

pub fn target(&self) -> RasterTarget

Returns the rasterization target.

Source

pub fn classic_cleartype(&self) -> bool

Returns whether the TrueType interpreter uses the classic ClearType behavior.

Source

pub fn symmetric_rendering(&self) -> bool

Returns whether the GETINFO symmetric rendering bit may be set.

Source

pub fn preserve_linear_metrics(&self) -> bool

Returns whether hinting preserves the font’s advance widths.

Source

pub fn pedantic(&self) -> bool

Returns whether an instruction error fails the draw.

Source

pub(super) fn outline_target(&self) -> Target

Returns the target in the form the hinting engines use.

Trait Implementations§

Source§

impl Clone for HintOptions

Source§

fn clone(&self) -> HintOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for HintOptions

Source§

impl Debug for HintOptions

Source§

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

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

impl Default for HintOptions

Source§

fn default() -> Self

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

impl Eq for HintOptions

Source§

impl Hash for HintOptions

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for HintOptions

Source§

fn eq(&self, other: &HintOptions) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HintOptions

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.