v1.2.0

Rust constants

14 constants in daegun 1.2.0, as the compiler exports them. The list is generated from the source, not written out by hand.

Curves and polygons

The shapes a GPU or scanline rasterizer wants: quadratic curves for a shader, flattened polygons for edge walking, and overlaps resolved for a rasterizer that sums coverage.

MAX_CURVES_PER_GLYPH
pub const MAX_CURVES_PER_GLYPH: usize = 16_384;

The most quadratic curves glyph_quads or a QuadraticPen gives for one glyph: 16,384.

Past it they answer QuadError::TooComplex. A font is untrusted input, and this bounds what one glyph can cost.

MAX_FLATTEN_POINTS
pub const MAX_FLATTEN_POINTS: usize = 1_048_576;

The most points flatten returns, and the most a stroke or embolden may hold: 1,048,576.

One curve can flatten to thousands of points, so without a bound a single hostile glyph could reach hundreds of millions. prepared_outline draws nothing for a stroke or embolden past it.

MAX_RESOLVE_EDGES
pub const MAX_RESOLVE_EDGES: usize = 512;

The most edges resolve_overlaps takes: 512.

It tests every pair of edges for a crossing, and a font is untrusted input. Past it the call answers None.

Hinting

Fitting outlines to the pixel grid: the hinters HintMode chooses, and the hinted points they produce.

FLAG_CUBIC
pub const FLAG_CUBIC: u8 = 0x02;

The HintedOutline flag bit for a cubic control point, which only a hinted CFF outline has.

FreeType calls it FT_CURVE_TAG_CUBIC. Two of them come between each pair of on-curve points of a cubic segment.

FLAG_ON_CURVE
pub const FLAG_ON_CURVE: u8 = 0x01;

The HintedOutline flag bit for a point that lies on the curve.

A point without it is a control point: quadratic unless FLAG_CUBIC is also set.

Metrics

What the font says about itself: its names, its axes, its vertical metrics. Every measurement here comes back on a 1000-unit em, whatever the font's own units are, so a value in pixels is value * px / 1000.0. Outlines are the exception and stay in font units, which upm reports.

DEFAULT_POINT_SIZE
pub const DEFAULT_POINT_SIZE: f64 = 12.0;

The point size shaping reads trak tracking at when ShapeOptions::point_size is not set: 12.

Subpixel

Subpixel antialiasing filters, described for a rasterizer that applies them itself: how many samples a pixel takes, the weights, and how far a glyph's box must grow.

MAX_OVERSAMPLE
pub const MAX_OVERSAMPLE: u8 = 4;

The most samples a SubpixelLayout takes a pixel along one axis: 4.

MAX_SUBPIXEL_TAPS
pub const MAX_SUBPIXEL_TAPS: usize = MAX_OVERSAMPLE as usize + 4;

The widest filter window along one axis, in samples: 8.

MAX_SUBPIXEL_WEIGHTS
pub const MAX_SUBPIXEL_WEIGHTS: usize = MAX_SUBPIXEL_TAPS * MAX_SUBPIXEL_TAPS;

The most weights one channel holds: MAX_SUBPIXEL_TAPS squared, 64.

SubpixelLayout::GRAYSCALE
pub const GRAYSCALE: SubpixelLayout;

The layout of a plain grayscale rasterizer: one sample a pixel, one channel, weight 1.

The default, and the same as SubpixelLayout::grayscale().

daegun::format

Readers for structures many tables share: Coverage, AAT lookups and state tables, FeatureVariations, and item variation stores.

format::class::DELETED_GLYPH
pub const DELETED_GLYPH: u16 = 2;

The AAT class of a deleted glyph, 0xFFFF in the glyph stream: 2.

format::class::END_OF_TEXT
pub const END_OF_TEXT: u16 = 0;

The AAT class of the end of the text: 0.

format::state::START_OF_TEXT
pub const START_OF_TEXT: u16 = 0;

The AAT state a state machine starts in: 0.

daegun::paint

What a color scene is made of, and the math to draw it: gradient ramps sampled as COLR defines them, and COLR's 28 composite modes for one pixel over another.

paint::IDENTITY
pub const IDENTITY: Matrix = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0];

Also reachable as paint::matrix::IDENTITY.

The transform that changes nothing.

Type to search.