text/outline.rs#
Source: lib/text/outline.rs
outline -- glyph outline buffer, path emitter and the operations of synthetic styles
[src/text/outline.s]
Outline::reset / point / reserve / close / contour / npts / bbox
emit(path, gp, zones) append the buffer to the path with the gp transform (TrueType
contours exactly like glyph_path; cubic contours flattened like
path_cubic); zones = FS_SHARP grid fitting (fit_zones)
embolden(strength) FreeType FT_Outline_EmboldenXY(strength, strength)
shear(k), transform(from, a, b, c, d), translate(from, dx, dy)
owner_set / owner_is "prepared" tracking: a box query leaves the untransformed
outline of (font context, glyph) in the buffer
Points f32 x, y (font units, y up) + u8 tags; contour ends u32 (last point index).
TrueType contours (OLT_ON / OLT_OFF) follow the implied-midpoint rules; cubic contours
(CFF) start with an on-curve point, two OLT_CUBIC points between on-curve points.
OLT_OFF: u8 = 0 // quadratic control point
OLT_ON: u8 = 1 // on-curve point
OLT_CUBIC: u8 = 2 // cubic control point
OL_MAX_PTS: usize = 1 << 20
OL_MAX_CONT: usize = 1 << 18
F_TAN12: f32 = 0.21255656
F_INV30: f32 = 0.033333335
struct ZonesFS_SHARP zones: {z (font units), p (px)} ascendingn: usizez: [(f32, f32); ZONE_MAX]
impl Zones
fn fit(desc: i32, xh: i32, caph: i32, asc: i32, sy: f32) -> Zonesdescender, 0, x-height, cap height, ascender snapped with sy [ol_fit_zones]struct Outlinepts: Vec<(f32, f32)>tags: Vec<u8>ends: Vec<u32>err: bool
impl Outline
fn reset(&mut self)empty the buffer (owner cleared) [ol_reset]fn npts(&self) -> usizefn point(&mut self, x: f32, y: f32, tag: u8) -> boolappend a point (font units, OLT_*) [ol_point]fn reserve(&mut self, n: usize) -> Option<usize>append n points (0, 0, OLT_OFF) to be filled in; the index of the first [ol_reserve]fn close(&mut self)end the current contour [ol_close]fn contour(&mut self, last: u32) -> boolend a contour at point index last (last < cstart: empty, ignored) [ol_contour]fn owner_set(&mut self, serial: u64, glyph: u32)fn owner_is(&self, serial: u64, glyph: u32) -> boolfn bbox(&self) -> Option<[i32; 4]>control box {xmin, ymin, xmax, ymax} (floor / ceil, clamped to +-1e6) [ol_box]fn shear(&mut self, k: f32)x += y * k [ol_shear]fn transform(&mut self, from: usize, a: f32, b: f32, c: f32, d: f32)points from..n: (x, y) -> (a x + c y, b x + d y) [ol_transform]fn translate(&mut self, from: usize, dx: f32, dy: f32)points from..n += (dx, dy) [ol_translate]fn embolden(&mut self, strength: f32)FreeType FT_Outline_EmboldenXY(strength, strength): every edge moves outwards by strength / 2, the glyph grows up / right by strength [ol_embolden]fn emit(&self, path: &mut Path, gp: &Gp, zones: Option<&Zones>)append every contour to the path (gp transform, composite offset dx / dy honoured; zones: FS_SHARP vertical fitting) [ol_emit]fn cubic(path: &mut Path, p: [f32; 8])flatten the cubic {p0, c1, c2, p3} (device px; p0 is the current point) into the path, the subdivision of path_cubic (tolerance 0.2 px) [ol_cubic]