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: boolImplementations§
Source§impl HintOptions
impl HintOptions
Sourcepub fn auto_fallback() -> Self
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.
Sourcepub fn interpreter() -> Self
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.
Sourcepub fn auto() -> Self
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.
Sourcefn with_engine(engine: EngineRequest) -> Self
fn with_engine(engine: EngineRequest) -> Self
Creates the defaults for a grayscale target that uses engine.
Sourcepub fn with_target(self, target: RasterTarget) -> Self
pub fn with_target(self, target: RasterTarget) -> Self
Sets the rasterization target.
Sourcepub fn with_classic_cleartype(self, classic_cleartype: bool) -> Self
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.
Sourcepub fn with_symmetric_rendering(self, symmetric_rendering: bool) -> Self
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.
Sourcepub fn with_preserve_linear_metrics(self, preserve_linear_metrics: bool) -> Self
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.
Sourcepub fn with_pedantic(self, pedantic: bool) -> Self
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.
Sourcepub(super) fn engine(&self) -> EngineRequest
pub(super) fn engine(&self) -> EngineRequest
Returns the hinting engine.
Sourcepub fn target(&self) -> RasterTarget
pub fn target(&self) -> RasterTarget
Returns the rasterization target.
Sourcepub fn classic_cleartype(&self) -> bool
pub fn classic_cleartype(&self) -> bool
Returns whether the TrueType interpreter uses the classic ClearType behavior.
Sourcepub fn symmetric_rendering(&self) -> bool
pub fn symmetric_rendering(&self) -> bool
Returns whether the GETINFO symmetric rendering bit may be set.
Sourcepub fn preserve_linear_metrics(&self) -> bool
pub fn preserve_linear_metrics(&self) -> bool
Returns whether hinting preserves the font’s advance widths.
Sourcepub(super) fn outline_target(&self) -> Target
pub(super) fn outline_target(&self) -> Target
Returns the target in the form the hinting engines use.
Trait Implementations§
Source§impl Clone for HintOptions
impl Clone for HintOptions
Source§fn clone(&self) -> HintOptions
fn clone(&self) -> HintOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more