1.2.0 release notes
Released
daegun no longer ships rasterizers of its own. It hands any rasterizer – CPU, GPU or both, from Rust or from C – everything it needs to draw text well.
Compatibility
1.2.0 removes public API: both rasterizers, the router and their C functions, and Ramp’s variants.
It also reshapes a few calls and types that stayed, listed under API changes. Code that used them stops
compiling. Cargo reads 1.1 to 1.2 as a compatible update, so a project on daegun = "1.1" gets this on
its next cargo update; pin =1.1.7 to stay.
In C, the header’s rule to refuse a different major version does not catch it. A program that calls a
removed function fails to link or to load, but one that uses a call or struct that changed shape
misreads it with no warning, so rebuild against the 1.2.0 header. Five changed: daegun_stat_value is
56 bytes, not 48, with older_sibling after has_name; daegun_shape_options is 88, not 80, with
has_seed_script and seed_script at its end; daegun_font_base_info takes axes;
daegun_font_ligature_carets takes a direction and fills a second list; and daegun_glyph_bitmap_png
gives the image alone, its placement now coming from daegun_glyph_bitmap_placement.
Nothing else that stayed changed its layout or its value, so a C program that used none of those five
and nothing removed (no removed call, type or constant, DAEGUN_UNSUPPORTED included) keeps working,
except where a section below lists an answer that changed. Those a working program is likeliest to
meet: NULL with a count above 0, or as an out-pointer, is now DAEGUN_NULL; a path stroke past
DAEGUN_MAX_FLATTEN_POINTS points, or whose width or points are not finite, is DAEGUN_RANGE;
daegun_font_hinted_glyph past 65,535 ppem, or for a glyph too large to hint at its size, is
DAEGUN_ABSENT; the outline cache charges 176 bytes an outline beyond its points, not 64, so a budget
holds fewer; a gradient blends in linear light with alpha premultiplied, as the spec says, where it
blended sRGB straight, and its colors round rather than truncate; a hinted outline’s flags hold the
on-curve bit and DAEGUN_FLAG_CUBIC alone; a glyph that does not decode is DAEGUN_PARSE from
daegun_font_outline_glyph and its instanced form, not DAEGUN_ABSENT; and input that used to overflow
or exhaust memory is refused.
Security fixes go to 1.2.x from here; 1.1.x and 1.0.x receive none.
Removed
The GPU rasterizer. The Metal, Vulkan, Direct3D 11 and Direct3D 12 backends, their shaders, the
daegun::gpu module, the binding, eval and shader modules with ShaderLanguage and
ShaderStage, GpuBatch and its wire format (GlyphSlot, ColorSlot, GlyphInstance, CurvePoint,
Band, HullVertex, HULL_VERTICES, SubpixelParams, MAX_SUPERSAMPLE), Font::gpu_glyph,
gpu_color_glyph and gpu_color_glyph_with with GpuGlyphError, and the curve cache. Bring your own
GPU rasterizer; glyph_quads, colr_scene and the subpixel layout give it what daegun’s own used.
The router. draw_glyph, draw_glyph_with, DrawTarget, DrawnGlyph, route, Policy,
Prefer, Request, Refusal, Rendered, DeviceKind and DeviceProfile. daegun no longer draws, so
there is nothing for it to route; which of your rasterizers takes a glyph is your code’s call.
From C: every entry point and type above, and DAEGUN_UNSUPPORTED, which only the GPU backends
returned. Its value, -5, will not be reused.
The CPU rasterizer. rasterize_glyph, rasterize_glyph_with, RasterOptions, RasterizedGlyph
and Metrics; the bitmap cache and its three methods; render_colr_glyph, render_colr_glyph_with and
RenderedScene, and the scene renderer behind them; SubpixelLayout::weight_rows. The hidden
daegun::daerizer module is gone; the color-scene parts of it live on in daegun::paint. Bring your
own rasterizer: prepared_outline hands it the outline with the same hinting, transform, oblique,
stroke and embolden options, and flatten, resolve_overlaps, the subpixel layout, colr_scene and
paint::composite cover the rest of what it did, but for gamma: RasterOptions::with_gamma has no
successor, so a rasterizer applies its own curve to coverage.
Moving from rasterize_glyph_with: some of its answers differ, because prepared_outline does not
repeat its mistakes. With hinting on, it read a stroke width as pixels, dropped any transform or
oblique, gave the advance per 1000 em unscaled on a glyph’s first call, and hinted at the nearest whole
size. For any font whose em is not 1000 units, its advance was wrong by that ratio. And with a stroke
and an embolden both set, it drew only the stroke but widened the advance anyway.
From C: daegun_bitmap, daegun_metrics, daegun_font_rasterize_glyph(_with),
daegun_raster_options, the glyph-cache calls, the rendered daegun_scene with
daegun_font_render_colr_glyph(_with), and the scene builder. daegun_outline_options replaces
daegun_raster_options for everything but the layout and gamma.
Two duplicate paths and two dead fields. daegun::paint::paint was the paint module re-exported
inside itself, and daegun::stroke was also a module, a second path to stroke, stroke_simplified,
Cap, Join and StrokeStyle; each keeps its path at the root. JstfModLists’ shrinkage_jstf_max
and extension_jstf_max were raw offsets nothing could use: JstfMax is not applied, as no shipping
software applies it.
daegun is now no_std Rust with no unsafe outside its C interface, and no code specific to an OS or a
processor.
Added
Quadratic curves, the shape a curve-evaluating GPU shader takes. Font::glyph_quads returns a
glyph’s outline as quadratic curves in em units, lines as curves and cubics split to within about 1/4096
em, wound consistently. QuadraticPen does the same for any outline, and normalize_winding rewinds a
set of curves. From C: daegun_font_glyph_quads, daegun_path_quads, daegun_quads_normalize_winding,
daegun_quads_data, daegun_quads_free.
Color glyphs as scenes. Font::colr_scene and colr_scene_with return a COLR v0 or v1 glyph as the
fills, clips and layers that draw it, with paths in font units and a foreground color of your choosing.
C gets a read-only daegun_color_scene – ops, clip shapes, gradients and their resolved stops, path
copies – and daegun_ramp, which samples linear, radial and sweep gradients and their extend modes as
COLR defines them.
Flattening and overlap resolution. flatten turns a path into closed polygons the way daegun’s own
rasterizer did, except that an S-curve or a loop is no longer taken for a line, a contour continued past
a close without a move keeps its start, and a curve past about 1e19 units is split rather than drawn as
its chord. It returns None for polygons of more than MAX_FLATTEN_POINTS points, for a path that
reads more than twice that counting the points it drops, or for a coordinate that is not finite or is
past f32::MAX / 16. max_area_for gives the tolerance the rasterizer used at a size.
resolve_overlaps replaces overlapping contours, or one contour that overlaps itself, with one
counterclockwise boundary, which a coverage-summing rasterizer needs where it would otherwise count a
pixel twice. It works in font units, of an em up to about 2048, and declines past MAX_RESOLVE_EDGES
edges, or when they cross into more than 16 times as many pieces. From C: daegun_path_flatten,
daegun_flatten_max_area_for, daegun_contours_*.
Prepared outlines. Font::prepared_outline hands your pen a glyph’s outline in pixels, hinted,
transformed, slanted, stroked or emboldened as OutlineOptions says, and returns its advances in
PreparedGlyph. The oblique and then the transform apply after hinting, as in FreeType, though FreeType
transforms first and in pixels: here a glyph leans in its own frame, and offsets are in font units. A
stroke takes the place of an embolden, which widens both advances. A size, transform, oblique or
stroke width that is not finite is refused, as is anything that overflows once scaled, or a stroke or
embolden of more than MAX_FLATTEN_POINTS points. Nothing is drawn then. From C:
daegun_font_prepared_outline, daegun_outline_options, daegun_prepared_glyph.
Compositing from C. daegun_composite gives a color scene’s layer blend, any of COLR’s 28
composite modes, for one pixel over another. In Rust, paint::composite.
Subpixel filters from C. daegun_subpixel_layout exposes a layout’s oversampling, taps, origin,
padding, channels, weights and cache key, for a named layout or a filter of your own.
A choice of how a gradient blends. Ramp::new blends as the OpenType spec says; to draw as Chrome
and Cairo do, Ramp::with_interpolation takes Interpolation::Srgb. From C:
daegun_color_scene_ramp_with with DAEGUN_INTERPOLATE_LINEAR_LIGHT or DAEGUN_INTERPOLATE_SRGB.
Bitmap glyphs in every format. EBDT and EBLC strikes are read, and CBDT’s uncompressed images with
them: formats 1, 2, 5, 6, 7, 8 and 9 (composites) at 1, 2, 4 or 8 bits a pixel, decoded to a byte of
coverage a pixel as BitmapImage::Coverage (daegun_glyph_bitmap_coverage in C). Index formats 4 and
5 are read too, and sbix’s dupe records and Apple’s flip, which mirrors another glyph’s image.
COLR clip boxes. A color glyph is clipped to its box in the ClipList, as the spec requires, where
content it says must not render was drawn. Font::colr_clip_box (daegun_font_colr_clip_box) gives the
box, a variable one rounded outward at the location.
Palette entry labels. CPAL version 1 names its entries: Font::palette_entry_labels and
daegun_font_palette_entry_labels give each entry’s name ID.
Glyph names from every post version. Versions 1.0, the 258 standard names, and 2.5, offsets into that order, now name glyphs.
More outlines drawn. Type 2’s twenty arithmetic, storage and conditional operators run, and a composite’s component placed by matching points is placed as the spec describes; both were refused. CFF2’s FDSelect format 4 is read, where a font using it failed to load.
BASE extents and fallbacks. Font::base_extents (daegun_font_base_extents) gives a script’s MinMax
extents by language and feature, and a script without a BASE record of its own falls back to DFLT, as
HarfBuzz does.
STAT and fvar in full. A STAT axis value says whether it describes other fonts of the family
(older_sibling, in Rust and in daegun_stat_value), and daegun_stat_axis_name gives C each axis’s
display name. FvarAxis gains flags, name_id and is_hidden, and C gains daegun_font_axis_flags.
Variation sequences survive a subset. A text subset keeps the variation sequences its text uses: a base followed by a selector keeps its variant glyph, and the cmap gains a format 14 subtable, so Source Han’s U+4FAE U+FE00 and U+845B U+E0100 keep their forms.
Feature variations for the axes a font has. format::FeatureVariations::with_axis_count ignores a
condition on an axis past the count; from C, daegun_feature_variations_find takes the count from
coord_count.
From C, what Rust already had. A CFF glyph’s hint masks (daegun_cff_hints_mask_count and
daegun_cff_hints_mask_at), each of a JSTF level’s eight lookup lists (daegun_jstf_mods_lookups with
the DAEGUN_JSTF_* selectors), a run’s seed script (has_seed_script and seed_script in
daegun_shape_options), whether a gradient stop takes the text color
(daegun_paint_stops_foreground), and DAEGUN_DEFAULT_POINT_SIZE.
API changes
daegun::paint is documented. It holds the types a color scene is made of (Op, Paint,
Gradient, Blend and the rest), which used to be hidden from the docs. gradient::Ramp::new now
applies the gradient’s own transform itself and takes the scene’s space to the device, as
daegun_color_scene_ramp does; it used to want the two composed by the caller.
Ramp is opaque. Its variants were public, so a caller could build one by hand, one with no stops
that panicked among them, and any change inside it broke such a caller. Ramp::new and at are what
it offers.
MAX_SUBPIXEL_TAPS is a usize, like MAX_SUBPIXEL_WEIGHTS beside it, instead of a u32.
GlyphBitmap gives an image and its edges. Its png, origin_x and origin_y are now image, a
BitmapImage that is a PNG or a coverage map, and left and top, the image’s edges for every format;
mirrored says to flip it. sbix stores the image’s bottom edge, which now has the PNG’s height added, as
FreeType does. From C, daegun_glyph_bitmap_png gives the image alone, and
daegun_glyph_bitmap_placement its size, edges and mirroring.
base_info takes axes and answers in the 1000-unit em. Its baselines were design units, 2.048 times
too large at 2048 units an em, and could not vary; they are f64 at the location now, like every other
measure. daegun_font_base_info takes axes too.
ligature_carets gives one entry per caret the font lists. It returns Vec<Option<f64>>, None for
a caret it cannot resolve, which it used to drop, so caret_positions no longer hands a later caret to
an earlier component. It takes vertical to read a format 2 caret’s point on the right axis.
daegun_font_ligature_carets takes the direction and fills a list of which carets are present.
math_kern returns Option, None for a height that is not a number (DAEGUN_RANGE from C), and
it compares the unrounded height, so one just under a threshold takes the kern before it.
paint::lower takes the glyph’s clip box, and returns false, writing nothing, for a glyph the spec
says not to draw.
A STAT axis value carries older_sibling, so a match on StatAxisValue names one more field.
A hinted outline’s flags hold the on-curve bit and FLAG_CUBIC alone. Bytecode hinting handed out
the interpreter’s touched bits there too, where the CFF and autohinted outlines and the header gave only
the on-curve bit.
Performance
Prewarmed outlines serve the outline calls. prewarm used to speed up rasterizing only. Now
outline_glyph, outline_glyph_instanced, glyph_quads, prepared_outline, colr_scene and
glyph_bounds replay a prewarmed outline instead of decoding it. Warm, outline_glyph is about twice
as fast; the others gain less, as they do more besides (glyph_quads 1.4 times, prepared_outline
1.2). So does the autohinter; the bytecode and CFF hinters read the font itself.
Gradients and compositing are faster. Blended as the spec says, now the default, a linear gradient samples in 11.8 ns a pixel where 1.1.7 took 14.6 in sRGB, and a sweep in 23.8 where it took 30.7; a radial takes 23.1 against 21.0, a little slower. Blended in sRGB as before, a linear one takes 7.4. SrcOver, COLR’s usual layer, composites in 4.0 rather than 5.5 (benchmark.md, section 6). A linear t is folded into three numbers when the ramp is built, each stop interval is a factor and bias, and a sweep’s angle comes from a polynomial within 2.9e-7 of a turn: a few pixels in ten thousand land one level of 255 apart from before.
A caller built without LTO inlines the per-pixel calls. Ramp::at takes 3.6 ns rather than 6.8
and composite 2.2 rather than 5.6. With LTO, a direct blend call in its simplest modes costs about a
nanosecond more.
Rounding without std is faster. f64 round takes 0.78 ns rather than 1.40, and trunc, floor,
ceil and f32 floor are faster too, bit for bit as before.
Subsetting is faster, and its layout tables smaller. A layout subtable no longer parses the rules of glyphs
a subset drops, the closure reads GSUB’s substitutions once and walks them on each pass, and a subset
reads the font’s cached instance where it copied the font: subset_text on STIX 516 to 228 µs, EB
Garamond 1.52 to 0.59 ms and Source Han 776 to 408 µs, closures two to four times faster, and a whole
EB Garamond subset 7.4 to 4.4 ms. Identical child tables in GSUB, GPOS and GDEF are written once, as
HarfBuzz and fontTools write them, so layout tables come out 2 to 32% smaller, and AAT lookups take
their smallest format: Lucida Grande’s morx subsets to itself at 406 KB, not 3.78 MB. A whole subset
can still come out larger than 1.1.7’s, since it now keeps the font’s names and every CFF DICT entry
(see Fixed, Subsetting): a paragraph of Inter goes from 24.6 to 25.2 KB, a line of STIX Two Math from
8.7 to 11.5 KB.
A CFF subset keeps only the subroutines its glyphs call. The rest become a bare return, which keeps
every index and bias, and a compacting CID subset keeps only the FDs its glyphs select. Over 133 CFF
faces, text subsets are 37% smaller (Hiragino Sans GB 905 to 106 KB) and one-glyph subsets 44%, and none
grows; a text subset takes longer to make (Hiragino 558 to 792 µs). A glyph that does not draw, or draws
with random, keeps every subroutine.
A face from a collection holds only its own tables. All 12 faces of Avenir Next hold 5.0 MB where they held 58 MB, and one opens in 26 µs, not 144.
Hinting at two sizes no longer starts over at each switch. The contexts of the last four sizes and modes are kept, so 13 Arial glyphs hinted at 12 and 16 px in turn take 116 µs, not 762. The CFF hinter builds its hint maps in buffers kept for the glyph: STIX’s H, a, g and O 8.45 to 7.06 µs.
Outlines. glyph_quads measures a quad’s error from the cubic’s third difference (the first 600
STIX glyphs 787 to 601 µs), flatten keeps each contour as it ends (5 to 8% faster), and the stroker
works out each normal once (an emboldened g 8.42 to 7.29 µs). stroke_simplified resolves within a work
budget over a grid, where it tested every pair of edges: all of Inter’s test strokes take 0.81 s, not
2.40, and wide strokes up to 16,384 edges resolve where they hit the old cap.
Lookups. glyph_id takes 44.5 ns, not 63.2, the best cmap subtable tried first through a choice made
at the font’s first lookup, and the cmap index builds 2.4 times faster. Naming every STIX glyph one at a
time takes 4.6 ms, not 237, a CFF name reading only its own string. Ligature carets at a varied location
take 0.41 µs, not 40.7, the variation store read only for a caret whose device varies, and the outline
only for a format 2 caret: the first call at a new location for a glyph with none takes 1.2 µs, not
2,573, where it instanced the whole font.
Instancing allocates almost nothing a glyph. A varied glyph is written straight into the new glyf, its buffers reused: Inter 3.14 to 2.19 ms and 34,166 to 709 allocations an instance, EB Garamond 5.11 to 3.89 ms.
Slower, because the work is now right. A CFF2 instance draws every glyph to find its true box, which the old code left stale, and a COLR instance is written fresh in static formats where the old code patched a copy and left variable data in it; with threading, as the C library builds, the boxes are found in parallel. Against the code before those fixes, an instance of Source Serif takes 4.5 ms, not 3.7, Source Han 37 ms, not 23 (8.9, not 5.9, with threading), and test_glyphs_variable 113 µs, not 52.
Against 1.1.7 measured the same day (benchmark.md), CFF drawing is 7% slower over STIX’s whole face
and 26% on one long charstring; an earlier pairing put Source Han at 12%. The outlines are identical,
and no single cause stands out among what the fixes added to the outline pens, each measured alone.
Hinting five glyphs with bytecode takes 1.5 µs rather than 0.79, each glyph starting from the state
FreeType gives it, and the autohinter 24 to 37% longer on one glyph, though no longer over a whole face.
A COLR v1 paint graph takes 12% longer, each paint charged against a budget, and 37% at a varied
location, where every axis is checked for a range the spec says to ignore; through FontCache it is 9%.
Security
Untrusted input can no longer exhaust memory or time, or overflow, in any of these places.
- A variation store whose subtable offsets all name one wide subtable held about 1,000 times its own size: 236 MB from 198 KB. A store is now held to about 32 times the bytes from its start to the end of its table, which is all its offsets reach, or a few megabytes when small.
stroke_simplifiedcould take seconds on a glyph whose edges cross each other tens of thousands of times, and reserved room for every edge left with each contour it rebuilt: hundreds of megabytes from a few thousand small contours. It now returns the plain stroke past 16,384 edges, or past 8,192 pieces once they cross, and holds only what its contours take.- Hinting overflowed in two ways: a font with a small em, under about 128 units, at the largest sizes, and bytecode that moves a point to the edge of the coordinate range before IUP. Either was a panic in a debug build and wrong points in a release one.
parse_locasized its answer from the caller’s glyph count, and a huge one overflowed or aborted. It now stops at 65,535 glyphs, which no font exceeds; from C, a larger count isDAEGUN_RANGE.format::parse_item_variation_store, anddaegun_ivs_parsefrom C, overflowed their offsets with a base near the top of the address range. They now decline.- A CFF glyph that calls a hint-masking subroutine over and over kept a copy of the mask each time, gigabytes from a small font. Each mask kept, its bytes and its entry, now counts against the charstring’s work budget.
strokeandstroke_simplifiedadd up to 256 points at every join, so a hostile outline took seconds and hundreds of megabytes. A stroke of more thanMAX_FLATTEN_POINTSpoints now draws nothing; from C it isDAEGUN_RANGE.- Subsetting a font whose pair-kerning classes number in the thousands reserved room for every pair of them before reading one: gigabytes, or an abort, from a small table. It now reserves no more than the table can hold.
- A color scene kept a whole copy of an outline for every layer that named it, so a small font could
make one scene hold gigabytes. Each outline is now held once, and a scene past
MAX_FLATTEN_POINTSpoints in all is refused; from C it isDAEGUN_RANGE. - A color scene looked up each glyph it had already drawn one by one, so a paint graph naming tens of thousands of glyphs took a third of a second for each call. The lookup is keyed now.
- A CFF charstring’s operand stack had no limit: subroutines could stack hundreds of thousands of operands into one stem declaration. It stops at 513, CFF2’s limit, and a charstring past it does not draw.
- Subsetting a COLR v1 font copied a gradient’s color line once for every layer that named it: 25 KB of table became a 6 MB subset. Its stops now count against the million the reader allows.
format::FeatureVariations::atwith an offset near the top of the address range, and from Cdaegun_feature_variations_at, overflowed as they read. Every offset now saturates, so such a view finds nothing.- An AAT state table opened with a huge
extra_wordsoverflowed its entry stride. It does not parse. - A CFF glyph declaring hundreds of thousands of stem hints made one hinted call take minutes, since the hinter maps every point against every stem. Past Type 2’s 96 hints, a glyph is autohinted.
- Subsetting a COLR v0 font whose base glyphs share one long run of layers read and wrote the run once for each glyph, and past 65,535 layers wrapped the count into a corrupt table. Each layer is now read once and a shared run written once; a subset past 65,535 layers leaves v0 out.
- Subsetting CBDT, EBDT or bdat copied an image once for every index record that named it: megabytes from a few kilobytes. Each subtable is now built once, and a subset past twice its source is refused.
- Subsetting GSUB or GPOS whose lookup list names one lookup, or whose lookup names one subtable, thousands of times did the work, and kept the output, once for each naming. Each is now visited once, a subtable named twice in one lookup is kept once, and copies stop at twice the table.
- Subsetting a MATH table whose glyphs share one construction rebuilt it once for each glyph: 8 KB of table became 812 KB. It is now rebuilt once and shared.
- Subsetting sbix copied a strike once for every offset that named it: 2 MB from one image. A strike is now kept once, and a subset past twice its source is refused.
- Subsetting a CID-keyed CFF copied a Private DICT and its Subrs once for every FD that named it, as it read and as it wrote: 10 MB written from 23 KB, and 382 MB held reading 2,000 FDs that share one. Each is now read and written once, and past twice the source the subset is refused.
- Subsetting morx copied a contextual substitution’s lookup, and its closure read it, once for every index that named it: 4 MB from 6 KB. Each is now read and written once.
- Bytecode hinting charged one step an instruction while IUP, the loop instructions, the deltas and MINDEX did work in proportion to the points or the stack, so an 11 KB font forced billions of point visits a call. Heavy instructions now charge their work against a budget, beside FreeType’s limits.
- The autohinter compared every segment with every other, about 10^10 steps a call from a crafted composite. It now searches by position within 256 runs, and a glyph past 65,535 points is drawn unhinted.
- A simple glyph that failed to decode was charged nothing, so one could read two billion end points under the composite budget; its contours are now charged before they are read. And a glyph decodes from its own bytes only, where the decoder read past its loca extent.
- Decoding the name table had no budget, and overlapping strings made 654 MB from 98 KB. It stops at four times the table’s size.
- A glyph name past post’s 63-byte limit counts as absent: a 114 KB CFF naming one 100,000-byte string
for every glyph made
glyph_nameshold 200 MB. - STAT’s names are handed out within a byte budget, so one long name that every axis value names cannot become 12.9 GB.
- AAT’s
Lookup::entrieslisted every segment’s whole range, so overlapping segments multiplied: 3.3 million entries from 312 bytes. It lists each glyph once. - FeatureVariations evaluated a shared condition set once for every record naming it, seconds from half a megabyte, and its substitution scan never stopped. Each set is evaluated once, and the scan stops at a higher index as the spec says.
- A BaseScript or MinMax that many BASE records share is walked once, where a 524 KB BASE cost hours,
reached from
subset_texton any CFF font. - A caret’s VariationIndex delta is worked out once a call however many carets name it: 8,192 carets on one row cost seconds a call.
- Instancing: a composite’s component count stops at the glyph’s end, where it ran to the end of glyf; the GPOS instancer charges every value record, anchor and subtable offset against its budget; and each CFF2 Subrs INDEX is parsed once, not once for every FD.
- On a 32-bit target, offset arithmetic in TTC headers, COLR, CPAL, the bitmap tables, layout class grids and Offset32 children, Zapf, morx and ankr is checked, so such a font is refused where a debug build trapped and a release build wrapped.
- Subsetting GSUB and GPOS: a Device table named thousands of times is borrowed, not copied each time (one 16 KB table held 185 MB); a child table or coverage named again is parsed once; an empty offset slot spends work and a rule set named again is read once, where a context subtable could loop billions of times; and parsing works within 64 units a byte of the table, as HarfBuzz bounds its sanitizer.
- Subsetting MATH: a device table that many value records name is copied once (one MathKern of 4,001 records held 125 MB), and constructions at overlapping offsets stop at the subset budget (270 KB held 128 MB).
- Subsetting bitmaps: sbix strikes and CBDT, EBDT and bdat images are charged against the budget as they are walked and copied, and each index subtable is read once, so records that overlap or repeat stop at the budget, where they cost hours or grew toward 4 GB.
- Subsetting AAT: ligature actions sharing an offset share one range of components (16 KB had grown to 8 MB), a Zapf GlyphInfo many glyphs share is written once (52 KB had become 25 MB), and rebuilt lookups take their smallest format within the budget (100 one-segment subtables made 26 MB).
- Subsetting JSTF: mod lists, priorities, language systems and scripts are rebuilt once for each source offset, so 1,442 bytes no longer become 20.5 MB.
- Subsetting glyf stops at the budget: loca ranges that overlap copied the same bytes once a glyph, a 200 KB glyf becoming 40 MB, and past 4 GB the offsets wrapped. hdmx and LTSH refuse a subset naming a glyph past the font’s.
- A seac’s components are found through a map built once a font, where each lookup walked the charset from its start: closing over 65,000 seac glyphs took 664 ms and drawing them 333 ms, now 6.5 and 6.1.
From C, a path drawn into a pen that adds to it read freed memory. Replaying or stroking a path into
a pen that appends to the same path, through daegun_path_as_pen or a pointer of its own, grew the path
while it was read. It is now replayed as it was when the call began.
Fixed
Hinting
Hinting stops at 65,535 ppem instead of shrinking the glyph. Past that size hinted_glyph hinted the
glyph as if it were 65,535 ppem, so a 100,000 px glyph came back about two thirds of its size. It now
returns None there, and prepared_outline draws such sizes unhinted at their true size.
A fractional size is hinted at that size. Hinting used the nearest whole ppem, so hinted_glyph at
16.4 px came out the size of a 16 px glyph. All three hinters now scale by the size to 1/64 px, so
16.4 px hints at 16.40625. Only the TrueType instructions that read the size, MPPEM and MPS, see it in
whole pixels, as in FreeType. Whole sizes hint exactly as before.
A glyph too large to hint at its size is drawn unhinted. With an em of a few units, the largest sizes
scale a glyph past what the hinters can add, so every coordinate was pinned and the glyph collapsed,
still flagged hinted. hinted_glyph now returns None there, and prepared_outline draws the outline
unhinted.
TrueType’s single width is scaled to the size. SSW kept its value in font units while MDRP and MIRP compare it with distances in pixels, so it snapped at the wrong sizes and to the wrong width. It is now scaled when stored, as FreeType does. 1.1.7 had the same fault.
cff_hints reads a CFF2 font, from its default instance as the CFF hinter does, where it answered
None for every glyph.
TrueType bytecode hints as FreeType hints it. The interpreter runs every instruction FreeType 2.14.3 runs, where it stopped at or skipped 25 of them (SPVTL, ISECT, IP, SHP, MSIRP, the DELTAs and FLIPPT among them). With the fixes below, every glyph it hints in Times New Roman, Arial, Georgia, Verdana, Courier New, Tahoma, Trebuchet MS and Irianis matches FreeType’s points at 13 sizes from 7 to 72 px under both interpreters, where none of Times New Roman’s 3,376 glyphs did at 16 px. Fonts that came back unhinted, though reported hinted, are hinted:
- each glyph program starts from the graphics state FreeType gives it rather than all of what prep left, and from the twilight points prep set, which were lost;
- JROT and JROF jump from their opcode, where every taken conditional jump landed a byte early and ran fpgm data as code;
- composite glyphs are hinted, each component with its own program and the composite’s over the assembled points, so accented letters are no longer unhinted beside hinted bases;
- the four phantom points come from the metrics, where they sat at the origin, and the outline is placed at phantom point 1;
- INSTCTRL is honored, so prep can turn glyph programs off, and a failing fpgm or prep leaves the size unhinted rather than half run;
- the stack holds what a font declares and half again (Arial Unicode’s prep stopped before its CVT setup at 4,096), the twilight zone holds maxTwilightPoints and four more, and function ids run to 65,535;
- a font whose glyphs carry instructions but has no fpgm, prep or cvt is hinted, and a glyph whose instructions run past its own end is refused, where they ran into the next glyph;
- Subpixel applies all of FreeType v40’s backward-compatibility rules, and GETINFO answers as v40 does;
- RTHG, ODD, EVEN, DIV, MD’s sign, MDRP’s minimum distance, SHPIX, IUP, MIAP and MIRP’s twilight points and out-of-range CVT entries, and original distances all follow the spec and FreeType.
MPS reads the point size, in 26.6 as the spec and FreeType v40 give it, under Classic too: at 16.4 px it reads 1,050, not 1,024.
The CFF hinter keeps points in order. A point outside every stem moved by its nearest edge alone, so points either side of the midpoint between two stems swapped and the outline folded: 1,031 reversals in 535 STIX glyphs at 16 px. Points between edges now interpolate, as FreeType’s hint map does. An edge hint marks one edge, where it was taken for a stem a pixel deep and put about 45% of STIX’s top-edge points a pixel high; hint masks switch at the point they name, where later ones came late; and fractional coordinates, which CFF2 instances write, are scaled and rounded once rather than truncated first.
Hinted CFF outlines keep their cubics. The autohinter and the CFF hinter drew each cubic as two
quadratics through its controls’ midpoint, 7 px off STIX’s O at 200 px. FLAG_CUBIC
(DAEGUN_FLAG_CUBIC) marks a cubic control in a hinted outline.
The autohinter’s blue zones are FreeType’s. All 18 zone values of Inter, EB Garamond and STIX match FreeType 2.14.3’s, and a zone catches an edge within half a pixel and switches off once its overshoot passes 3/4 px, where its reach grew with the size: EB Garamond’s N moved 38 px at 2000 px. A contour’s last run no longer takes two edges’ deltas (EB Garamond’s Ccaron caron sat 1.2 px off at 11 px), and points drawn before a move open a contour of their own.
draw_hinted draws a hinted outline built by hand with contour ends out of order, or fewer y than x,
as far as it can, where it panicked.
Outlines and strokes
outline_glyph draws CFF2 fonts. It returned None for every CFF2 glyph, where
outline_glyph_instanced drew a variable font’s.
Static CFF2 fonts draw and subset. A CFF2 font with no fvar table drew no outlines, subset and
glyph_closure failed with “missing CFF”, and subset_text with “CFF2 instancing produced no CFF
table”. It now draws and subsets as its default instance, its style as stored whatever axes a call
names.
An emboldened glyph keeps its ink under a non-zero fill. The ring an embolden adds wound one way whatever the outline did, so for every CFF and CFF2 font, and for any glyph under a mirroring transform, it canceled the fill where the two overlap: STIX’s H lost 59% of its ink, in hollow stems. The ring now winds as the fill does. 1.1.7’s emboldened rasterizing drew the same hollow stems.
stroke_simplified resolves a stroke at any scale. Its tolerances are absolute, so a stroke reaching
past about 16,000 units came back wrong or empty, still OK from C: Inter’s H at 16 times its size covered
far more than its stroke. A stroke past 4,096 units is now resolved scaled down by a power of two, which
f32 undoes exactly. From 1e30 units up a ring still lost its hole, or all of it: the scale-down now
goes as far as f32 does, an inner join past 1.8e19 units is found in f64, and each resolved edge ends
exactly where the next begins. 1.1.7 had the same fault.
A stroke past about 1.8e19 units keeps its width. A segment’s length overflowed f32 there, so every normal collapsed and the stroke traced its own path with no width, answering OK. 1.1.7 had the same fault.
A stroke whose width or points are not finite draws nothing. From C, daegun_path_stroke and
daegun_path_stroke_simplified handed the pen points past f32 when a miter’s tip overflowed, and drew
nothing for a NaN width, both with OK; they now answer DAEGUN_RANGE, as prepared_outline does. In
Rust, stroke and stroke_simplified draw nothing.
TrueType outlines are drawn at their origin. A glyph was drawn as stored, ignoring the origin that phantom point 1 sets, so one whose left side bearing is not its xMin, static or instanced, drew offset. It draws where FreeType and HarfBuzz draw it now, and the shaper’s extents follow.
A composite with several scale flags reads WE_HAVE_A_SCALE first, as the spec, FreeType, HarfBuzz and fontTools do, where the 2x2 came first.
A malformed simple glyph is an error, where it answered OK, drawing nothing or points at 0. From C,
daegun_font_outline_glyph and daegun_font_outline_glyph_instanced answer DAEGUN_PARSE with the
decoder’s reason, DAEGUN_ABSENT kept for a glyph past the font.
CFF charstrings end and close as Type 2 says. endchar ends the charstring, where operators after it kept drawing. A seac is resolved wherever its endchar is reached, after hints or in a subroutine, and never in a CID-keyed font, which has no glyph names to find its components by. A path drawn before any moveto opens at the current point, every contour reaches the pen closed, and the deprecated dotsection does nothing, where it was refused.
Strokes keep their width and ink. A U-turn was taken for a straight line, so an open out-and-back lost half its width and a closed two-point contour drew nothing; a stroke wider than the feature it outlines left holes, a 10-unit square at width 12 bare in its middle; a round join collapsed to one chord once the tolerance was fine; a lone point’s dot wound against the rest and cut a hole; an open path ending where it began lost its last segment; and one continued after a close lost its first. A reversal now ends flat across the corner or round through the tip, an inner corner is trimmed only within half of each shared segment as Skia’s is, an arc takes up to 256 steps, and dots wind clockwise.
stroke_simplified keeps only a union that holds. Its boundary could fail to chain shut and still
report success: 83 of Inter’s 444 test strokes were wrong by more than 0.5% against a distance oracle.
Each crossing is found once and given to both edges as one point, every tolerance is a distance, and a
union is adopted only when it closes, keeps its box and agrees with the input on both sides of every
edge; otherwise the plain stroke comes back. No stroke of Inter, Source Serif or EB Garamond is wrong.
resolve_overlaps finds an overlap away from every edge’s midpoint. It looked for one only beside
each edge’s midpoint, so two squares overlapping in a corner, or Inter’s #, came back None (from C,
DAEGUN_ABSENT) and a coverage-summing rasterizer counted the overlap twice. It now looks beside every
piece of every edge once they are split where they cross. 1.1.7 had the same fault.
Color
Gradients blend as the OpenType spec says. A color line blended the sRGB values its stops store,
with alpha straight. The spec asks for linear light with alpha premultiplied (CPAL, “Interpolation of
colors”): halfway from black to white is now 188 rather than 128, and halfway from opaque red to clear
blue is red at half alpha rather than purple. Chrome and Cairo blend as daegun did, which
Interpolation::Srgb keeps. The result is exact to the nearest of 255 levels, through tables proven
against the sRGB curve for every f32 from 0 to 1, as no_std has no pow. 1.1.7 blended in sRGB.
Gradients extend over their own color line. A COLR color line runs from its first stop to its last,
which may lie past or within 0 to 1. Its stops were clamped to 0 to 1, and repeat and reflect cycled over
0 to 1, so the COLR test font’s linear_repeat_0.2_0.8 drew solid red where it repeats red to blue. A
scene’s gradient now comes with its geometry moved to its first and last stop and its stops within 0
to 1, and Ramp does the same for a gradient of your own; a hard edge past 0 to 1, every stop at one
offset, moves likewise. 1.1.7’s renderer drew these the same way.
A gradient’s colors round to the nearest level. A channel between two stops was truncated, so every gradient came out a shade dark. It now rounds, which raises most pixels’ channels by one level of 255.
COLR v1 draws as the spec says in five more ways. A fill reached through transforms, layers or a composite inside a PaintGlyph fills that glyph, where only a fill directly under it drew: the nested-glyph conformance glyphs and 1,603 of Noto’s 4,012 emoji lost fills. An x skew leans by -tan of its angle, where every one leaned the other way. A fill outside every PaintGlyph fills the clip box or the glyph’s bounded content, and a glyph the spec calls unbounded with no clip box is not drawn, its v0 layers drawn instead if it has them: Noto’s group-opacity composites drew nothing. An unknown composite mode clears, where it drew source over. And a paint that cannot be read, or names its own ancestor, is left out with what is under it and the rest of the glyph draws, where one bad node refused the glyph.
Variable COLR values keep their range. Varied angles, scales, radii and stop offsets are not clamped to their stored type, as the spec allows, nor rounded to its unit, as fontTools and HarfBuzz read them: rotate_10 at ROTA 450 turns 451.68 degrees, not 359.99. With no DeltaSetIndexMap, a variation index is outer in its high word and inner in its low, where it was read as outer 0. An index map that cannot be read leaves the table unvaried.
A COLR instance is static and whole. Its paints are written in their static formats with no index map or store, each variable clip box at the location, rounded outward, where they kept their defaults; a value past its stored type is written another way rather than clamped; each shared paint is walked once; and a paint that cannot be read no longer strips every variation from the table.
A COLR subset keeps what its source draws. It reads each paint once and writes each shared paint once, in source order: one budget across the subset dropped COLR outright past about 1,300 Noto emoji, and the closure lost most of their outlines. Clip boxes are kept under their new glyph IDs, where every subset wrote none; a glyph whose graph cannot be read is written empty, where it dropped every glyph’s COLR v1; and a glyph as deep as the reader draws, 65 levels, survives.
A bitmap strike without the glyph defers to the next nearest, as the sbix spec asks of any strike, for sbix, CBDT and EBDT alike, and an sbix strike whose header cannot be read is passed over, where it failed every lookup.
Palettes and v0 layers stay inside their tables. A palette entry past the color records is refused, where it read the bytes after them as a color, and a v0 glyph’s layers stop at numLayerRecords, where version 1 data was read as layers.
Variations
A variation region that runs backwards or crosses zero is ignored, as the spec says, where it scaled deltas down: such an axis now counts as 1, as in fontTools and HarfBuzz. And a gvar or cvar tuple with no intermediate region reaches from the default to its peak and no further, where it reached on to the end of the axis. Fonts built by fontTools write neither case. 1.1.7 had the same faults.
Instances match fontTools and FreeType. A glyph’s advance moves by phantom point 2’s delta less phantom point 1’s, where it moved by the second alone. An instanced composite’s side bearings, the head box, the hhea and vhea extremes and xAvgCharWidth are worked out from the instance, matching fontTools on all 2,937 Inter glyphs. Axes normalize in 16.16 as FreeType’s do, where f64 came out a 2.14 step off at many locations, wght 700 on Inter among them. A point named twice in a tuple takes every delta it is given, and VVAR’s vertical origins and side bearings, HVAR’s left side bearings and MVAR’s caret, vhea and gasp values vary, where they were ignored.
Layout tables vary. PairPos format 1’s device offsets were read from the subtable rather than the PairSet, so every format 1 kerning variation was dropped, in the shaper and the instancer: 3,360 values on Inter at wght 900. An instance also resolves GPOS’s FeatureVariations, and GSUB’s where an alternate FeatureTable lies more than 64 KB past the FeatureList; adds a value field a delta needs rather than dropping the delta; and keeps device tables of sizes, clearing only VariationIndex ones. HarfBuzz shapes 14,400 pairs alike on daegun’s and fontTools’ Inter at wght 900.
One bad table or glyph no longer spoils an instance. Malformed variation data for one glyph leaves that glyph at its default, a cvar tuple without its own peak is skipped, and a broken HVAR, VVAR, MVAR or cvar is treated as absent, where each made every location draw the default. A gvar whose counts disagree with fvar or maxp is not read, as FreeType refuses it; a point list longer than the glyph’s is read whole; an out-of-range point number no longer shifts every delta after it; and a NULL ItemVariationData offset, an empty DeltaSetIndexMap or a store of any format but 1 means no variation.
CFF2 instances and conversions are complete. A Private DICT with blended hints kept its local Subrs, where subroutinized CFF2 fonts drew nothing; each FD’s Private DICT carries its blue zones and stems at the location; a font past 65,146 glyphs, or with several FDs, is written CID-keyed, where its charset overflowed; a subroutine index grown by blend no longer overflows; a CFF2 font is written with the sfntVersion OTTO; and an INDEX of more than 65,535 objects is refused, where its count wrapped.
An instance names and describes itself. Its weight and width classes come from the clamped location, where asking for wght 2000 wrote 2000; an ExtraBold or Black instance is not named Bold; off a named instance it gets an Adobe TN 5902 PostScript name; its English names are rewritten and other languages’ stale ones dropped, where every language was relabeled English; post’s italic angle follows slnt; GDEF’s format 3 carets, BASE 1.1’s coordinates and STAT’s touching ranges are settled at the location; a default instance asked for by value equals one asked for with no axes; and a variable font without OS/2 can be instanced.
hmtx and vmtx counts travel with their data. With numberOfHMetrics or numOfLongVerMetrics 0, an instance claimed a long metric for every glyph over a table it had not expanded.
Subsetting
CFF2 fonts instanced or subset to CFF are valid for other readers. CFF2 allows 513 operands to an operator and CFF’s Type 2 only 48, but the conversion wrote them as they came, which FreeType and others refuse: in Source Han Sans JP, 175 glyphs. A longer operator is now written as several that draw the same. daegun still reads up to 513, so a font 1.1.7 converted keeps drawing here; for other readers, convert it again.
A subset keeps the components of a .notdef built from other glyphs, as glyph_closure always said
it would.
A subset COLR v1 keeps a layer list nested in a layer list. The inner list’s layers were written first, so the outer list’s first-layer index named them in place of its own, and the subset drew the wrong layers, as fontTools’ layer reuse writes such lists.
A subset ignores a substitute past the font’s end. A GSUB, COLR or MATH output naming a glyph the font lacks was found again on every closure pass, never added, and the subset gave up after 64.
A subset keeps its kern pairs sorted, and its AAT postcompensation offsets right. Kern pairs the
font listed out of order stayed that way, against a reader’s binary search, and failed an assertion in a
debug build; so did a just lookup naming a glyph twice, whose action offsets then pointed past them.
A MATH subset too large for its 16-bit offsets is refused, where it kept its counts and pointed at nothing.
A subset GDEF keeps its offsets in range. Its parts are written in a fixed order, so a large one early pushed a later one’s 16-bit offset past 64 KB, where it was cut short and pointed into the wrong data. The largest part now goes last when that keeps every offset in range; otherwise GDEF is left out.
A compacted CFF subset counts only the glyphs its CFF holds. subset_text on a CFF font counted a
glyph past the font’s end, named by its cmap or GSUB, in maxp and the metrics, though the CFF had
dropped it.
A subset keeps the source’s character map and names. Font::subset by glyph ids writes a cmap of the
source’s mappings it keeps, renumbered, with format 14, where a TrueType subset had none and a CFF one
kept the source’s, mapping dropped characters to blank glyphs; a symbol font keeps its (3,0). Records are
sorted by platform and encoding, format 4 merges runs and gives way to format 12 only when it still
cannot fit (8,300 ideographs failed at 8,189), and a mapped U+FFFF sits in format 4’s final segment. Name
IDs 0 to 6 are kept with the IDs GSUB, GPOS and CPAL name, and a text subset of an instance keeps the
instance’s names, so a bold instance says Bold.
GSUB, GPOS and GDEF subset as written. A PairSet no longer takes another’s VariationIndex (EB Garamond: 398 kerning pairs wrong); a covered array’s coverage is written first, so a PairPos 1 or LigatureSubst that fits is no longer dropped; Device tables are written within reach of every child naming them; an unsorted coverage’s records move with it; a NULL LigatureAttach keeps its place; a glyph in a class past the count kerns nothing, as in the source; format 3 carets keep their devices; ReverseChainSingleSubst keeps one substitute per covered glyph; class definitions reaching glyph 65,535 are written whole; a contextual lookup left empty names an empty lookup, where offset 0 read the offset array as a lookup and made a kept glyph .notdef; a ligature or rule of no components is left out alone; a substitution to the deleted glyph 0xFFFF is kept; a ValueFormat’s reserved byte is not written back; version 1.1 tables are trimmed as 1.0 tables are, where the whole source was kept and pushed some past 64 KB; mark filtering sets follow the GDEF written, as OTS requires; and a single-format subtable of an undefined format is refused.
A layout feature with no lookups stays where the shaper asks after it by name: a GPOS kern feature keeps the legacy kern table off, and pref stays as HarfBuzz keeps it. Iowan, Charter and Didot subsets kerned with a table their source never used.
A kern table’s class kerning survives a subset. Format 2 class kerning is kept, in OpenType and Apple kern tables alike, where Apple Chancery lost r-o and o-w, and the last subtable is read to the table’s end whatever its 16-bit length says, as HarfBuzz reads it, so a source’s later pairs kern.
CFF subsets keep the font whole. Every Top DICT and FD DICT entry is kept (FontBBox, the names, the underline metrics, ROS), where only the offsets rewritten survived; an Expert charset stays one, where every glyph was renamed; a seac’s base and accent are kept wherever its endchar is reached; FDSelect is read as drawing reads it; a compacted subset rebuilds every table, EBSC included, from the glyphs its CFF holds; and DSIG leaves every CFF subset, its signature over bytes the subset no longer has.
MATH survives a subset. It stays whenever it has constants, where a math font subset to a space lost it; a MathKern many corners share is written once, where 2,000 sharing glyphs passed 64 KB and lost MathKernInfo; and constants that cannot be read are left out, not written as zeros.
Bitmap subsets keep their images. EBDT composites keep their components; sbix flip records are
renumbered like dupe, so a compacted Apple Color Emoji subset no longer mirrors the wrong emoji; dupe
and flip targets join the closure; and a glyph ID past the font’s end no longer takes a record from the
bytes after the offsets.
AAT tables subset as Apple’s tools read them. A morx subtable left with no glyph gets an empty lookup and one that cannot be rebuilt is left out alone, where the whole morx went: Zapfino, Skia and Apple Chancery kept no shaping subset to “Hello”. The morx closure follows only entries a run over the kept glyphs reaches (Zapfino to “Hello” keeps 31 glyphs, not 1,052) and keeps placeholder glyphs past the font’s last; kerx formats 2 and 6 measure offsets from the subtable’s start; Zapf’s flagged groups and version 2, just’s category table and 16-bit offsets, prop’s bracket offsets, a postcompensation value of 0, padding and terminators are read and written as the spec lays them out; and bsln’s and fmtx’s glyphs join the closure, so both survive text subsets. 239 system morx faces subset to themselves shape alike.
The glyph closure is bounded by what it reads, 64 passes’ worth of bytes and 16 MB more, not 64 passes, so a substitution chain of 100 closes. A component past the font’s glyphs stays past the subset’s, as in the source; any negative contour count is a composite; and a source without hhea gets no hhea.
A TrueType subset keeps gasp, VDMX, meta, PCLT and a glyph-free BASE, as a CFF one does, and
subset_ttf subsets a variable font at its default instance, where it dropped fvar and kept GDEF’s
variation store, which OTS rejects.
Font loading
A font with a damaged directory opens. One entry past the file, or with a junk tag, refused the whole
font; entries are skipped as FreeType skips them, hmtx and vmtx are clipped, and a table of no length
counts as missing. A tag listed twice takes its first non-empty entry, a TrueType-signed font with stray
CFF2 keeps glyf, and ttc_font_count counts the faces whose offsets the file holds, where it returned
the header’s count: 4,294,967,295 for 16 bytes.
Names are looked up as FreeType looks them up, English Windows, any Windows, Mac Roman, then Unicode, skipping empty records, where only (3,1,0x409) and Mac were read and Mac Japanese was decoded as Roman.
USE_TYPO_METRICS and the oblique bit need OS/2 version 4, which defines them, in the decoder, the
shaper and Os2Info.
Character maps
A cmap subtable is chosen by its platform and encoding, not its format. Unicode comes from platform 0, (3,1) and (3,10), symbol from (3,0) and Mac Roman from (1,0), and others are skipped; over 825 faces the lookup and the index now agree on every code point. A symbol font’s (3,0) answers for 0x20 to 0xFF through U+F020 to U+F0FF, as Windows reads it, so Wingdings draws the glyphs it should. Mac Roman is read through MacRoman in every format, so U+0080 no longer draws Ä in Georgia, and a format 14 variant mapped to glyph 0 leaves the base glyph.
The cmap index counts distinct code points, so a font past about 50,000 in the usual four-record
layout keeps coverage() and its index.
Glyph names
glyph_name and glyph_names agree. glyph_names fills the names post leaves out from the CFF, as
glyph_name does; a CFF charset cut short keeps the names read before the cut; and a predefined charset
smaller than the font names no glyph, as FreeType refuses it, where glyph_name invented names past its
end.
Layout tables
GPOS finds its own feature variations. The shaper used GSUB’s FeatureVariations record for GPOS too.
FeatureVariations are read as the spec reads them: a record with no condition set always matches, a condition on an axis the font lacks never does, and a substitution of an unknown version is passed over.
ankr’s point count is what the table holds, no more than a 16-bit index reaches, not its raw 32-bit count.
BASE, JSTF, MATH, STAT and carets
BASE coordinates of formats 2 and 3 are read, format 3 varied by BASE 1.1’s store, so Source Han’s icfb and icft come back as fontTools has them. FeatMinMax records are read 8 bytes apart, not 6.
Carets are read from the correct end. Right-to-left and vertical carets were read from the other one, and a format 2 caret reads its point on the composed outline at the location, so composites and gvar reach it.
MATH values read as stored. delimitedSubFormulaMinHeight and displayOperatorMinHeight are unsigned
(40,000 came back as -25,536), math_top_accent_attachment is unrounded like every other value, and a
NULL subtable offset is no subtable, where the MATH header was read as one.
JSTF and BASE match tags and languages as the spec does. A JSTF language without its own data takes the script’s default, one past 64 levels keeps its first 64 where it got none, and both tables compare tags as bytes, so an empty tag no longer matches one that is not UTF-8.
A STAT value naming an axis past designAxisCount is left out, rather than handed to a caller who indexes with it.
Subpixel filters
SubpixelLayout::from_weights refuses zero taps, a filter that weights nothing, as C always did.
The subpixel pad covers a window that reaches past its pixel, not only one that starts before it.
Caches
Lowering the instance cache budget frees memory at once. set_instance_cache_bytes used to wait for
the next new axis location before evicting, so a font that had instanced 16 MB of weights kept all of it
under a 2 MB budget for as long as it reused them.
A shape cache budget of zero caches nothing. The cache still kept the newest run, however small its budget.
prewarm counts only the outlines the cache took, where it also counted one larger than the whole
outline budget, which the cache refuses.
The outline cache holds about its budget. It charged a path’s bytes and 64 more, while a kept path also held its growth slack and about 176 bytes of place in the cache: 1.5 to 1.6 times the budget on the heap. A path is now kept without slack and charged 176 bytes beyond its points. 1.1.7 did the same.
C interface
From C, NULL with a count above 0 is DAEGUN_NULL, as rule 2 says, now that the header spells out
that such a count makes its pointer required unless the call says otherwise. The raw readers, the table
map, the axis and feature lists and daegun_path_verbs read it as empty and answered OK.
From C, a NULL out-pointer is DAEGUN_NULL, as rule 2 says. A call that did its work before writing
its result answered DAEGUN_ABSENT, DAEGUN_RANGE or DAEGUN_PARSE for a NULL out when there was
nothing to give or the input was wrong, so a caller’s mistake read as a missing glyph or a bad table.
Every call now checks its out-pointer first.
From C, owned font buffers. daegun_font_buffer_new aborted the process when the allocation failed;
it now returns NULL. daegun_font_open_owned with a NULL out kept the buffer the header says it takes;
it now frees it.
From C, the last error is safe after a thread’s storage is gone. daegun_last_error, and any call
that records a reason, aborted the process from an atexit handler, a static destructor or a thread’s
exit. The reason now reads empty there and is not recorded. 1.1.7 had the same fault.
From C, the table map’s tag_at and bytes_at give their reason for DAEGUN_RANGE, as the header
says the table map calls do, where they left an older reason in place.
Documentation
The C thread-safety rule says what was always true. Rule 5 said any handle could be shared by threads. Only a handle a call takes as const can be: a path being built, quads being rewound, a packer, a table map or a pen’s target needs its call to itself, and nothing ever locked them.
From C, hinted contour ends are documented as they always worked. 1.1.7’s header said
daegun_hinted_outline_contours gives one past each contour’s last point; it gives the last point’s
index. Code written to the old text gives each contour’s last point to the next one.
The header says a contextual substitution’s state table entries carry two extra words, as they do, not one.
The header’s account of three calls is corrected. daegun_font_instance_tables was said to answer
DAEGUN_ABSENT when a variable font’s tables do not parse; it answers OK with the tables as stored, as
it always did. STAT values were said not to be exposed, which three calls expose. And a fixed weight
was said never to instance, which a CFF2 font always does.
The header documents five more answers. daegun_font_hinted_glyph‘s DAEGUN_ABSENT; the
coordinates daegun_feature_variations_find takes, which are 2.14 integers rather than what
daegun_font_normalized_axes gives; daegun_math_construction_variants’ required count; and the
optional outs of daegun_stat_axes and daegun_glyph_bitmap_png.
The header says what an absent glyph name is: one the font gives empty or longer than 63 bytes counts
as none, an empty string with out_present 0.
The stroke tolerance’s rules are stated, in the header and on stroke: a tolerance not above zero,
or NaN, means 0.1 path units, and a curve, round join or cap takes at most 256 segments.
The header counts COLR v1’s tree right: fourteen variants, ten holding children, where it said fifteen and nine.
daegun_flatten_max_area_for names its source, 1.1.7’s CPU rasterizer, where it named daegun’s own,
which this release removes.
Build
Linking needs no frameworks. The static library links on macOS with plain cc. The header’s link
lines now list exactly what Rust’s standard library needs on each platform, where 1.1.7’s Linux and
Windows lines were missing some (-lgcc_s -lutil -lrt, dbghelp.lib). They also name the files the
build makes, libdaegun.a and daegun.lib, where 1.1.7 named libdaegun_c.a and daegun_c.lib, which
no build produced.
The C layer cannot fall behind the Rust types it carries. Every Rust struct that crosses to C is built or taken apart with every field named, so a field Rust gains does not compile until C carries it, and a test reads every enum variant C names back from its code.
The repository moved to github.com/zztaeha/daegun, with the
GitHub account’s new name. The crate’s repository field, the README’s images and the security
policy’s reporting link point there; the old address redirects.