Repository navigation
Releases
daegun 2.0.0
The daegun crate is the public API, over daecore, which holds daetype, daegun's font engine, the shaper
daeshaper and daemachine's math. daetype was audited end to end for this release, then the rest of the core and
the public API, the shaper and the C interface. Fonts that could hang it, crash it or make it hold gigabytes no longer
can, and a caller's axes or text can no longer grow a cache past its budget or take quadratic time. Where the engine
read one table two or more ways, it now reads it one way, so a font, its subset and its instance give the same answers.
Alongside the audits, 2.0.0 came to read fonts past 65,535 glyphs, which keep their glyphs and metrics in tables of
their own and name glyphs in 24 bits, and brought its shaping, subsetting, instancing and hinting up to date: its
shaper, TrueType interpreter and CFF hinter are written anew from the specifications, with no mode kept for older
screens.
Contents
Each area names the changes most readers will meet and, where there are others, counts the rest at its end.
- Compatibility: what code built against 1.2.0 must change, and the answers that moved
- Security: what an untrusted font or caller could do
- Added: what's new
- Fixed: what was wrong, from loading a font to the C interface
- Performance: what got faster
Compatibility
2.0.0 changes the public API, in Rust and in C, wherever a wrong answer could only be fixed that way. Code built against
1.2.0 needs the changes below. DAEGUN_ABI_VERSION and daegun_abi_version read 2.0.0, the C ABI's own version
(Compatibility, C). The minimum Rust version is 1.99, from 1.97.1.
Rust
The Rust API was rebuilt for 2.0.0 on the rules below, so nearly every call changed shape. The renames follow them.
Units
- Every metric, advance, offset, box and outline is in the font's own units,
f64, y up and unrounded, where 1.2.0 put
shaped advances and layout on a 1000-unit em and rounded metrics on it. A pen position is
advance * px / units_per_em. Layout and justification take their sizes in font units too. - Only the calls that take a pixel size answer in pixels:
prepared_outline, andhinted_outline, whose points are
f32pixels whereHintedOutlineheld 26.6 fields.
Text positions
- Every position in text is a UTF-8 byte offset, where 1.2.0 counted characters: a run's clusters, a
Feature's range,
the ranges a bidi run, a laid-out run, a line and a visual run cover (each field namedbytes),
TextLayout::truncated, line breaks, grapheme and word boundaries, script runs, a bidi paragraph's levels and visual
order, and the offsets aWordSegmentergives back. Each falls on a character boundary, so&text[range]slices it.
A bidi paragraph has a level for every byte, and its visual order lists each character's first byte.caret_positions
givestext.len() + 1carets, every byte of a character at its leading edge.
Locations
- A variable font's axes are resolved once,
font.location(&[(Tag, f64)]), into aLocationthat every call depending
on one takes by reference, where each call tookaxes: &[(&str, f64)]and rebuilt it. A tag the font lacks is
ignored, a value is clamped to its axis, and the last of a tag named twice wins. Location::default()is the default instance of any font. A location keeps the values it was asked for, and another
font resolves it again from them, sowght=400made by a font whose default it is still means 400 to one whose
default is 250.normalized_axesisLocation::normalized, andLocation::coordsgives the resolved coordinates.math_constants,math_italics_correction,math_top_accent_attachment,math_kern,math_glyph_variantsand
cff_hintstake aLocation, as the BASE calls do. Each read the default alone.
Errors
- One
daegun::Error, withkind()(ErrorKind:Malformed,Unsupported,Missing,InvalidArgument,
LimitExceeded,NoOutline,Overflow) andmessage(), anddaegun::Result, replaceFontErrorandQuadError. - A call returns
Resultwhere it can fail for a reason to act on: opening,instance,instance_tables, subsets and
closures,outline,quads,prepared_outline,color_scene,math_kernandraw::build_font, which refuses more
than 65,535 tables, or a table that starts 4 GiB into the file or is that long.Optionmeans the font has none of
something. Rust gets every reason C does.
Types
Tagwherever a tag goes,Tag::new(b"wght")or parsed from a string, in place of&strand[u8; 4]. A string
parses as one to four printable ASCII characters, padded with spaces, as the specification has a tag; anything else is
anInvalidArgumenterror.GlyphId, a transparentu32, wherever a glyph goes, for fonts past 65,535 glyphs: a run holds 4 bytes a glyph where
it held 2.charis a code point, soglyph_id,has_glyph,variation_glyph_idandcoveragetake or give
chars.- Enums replace bools:
Orientationforvertical,BaseDirectionforOption<bool>in bidi,Adjustmentfor
shrink(shape_justified's argument andJustified::adjustment) andFontStylefor a style string.
unicode::vertical_orientationgives a character'sVerticalOrientation(UAX #50's four values) where
is_upright(c, has_vertical_form)gave a bool, andScript::directionaScriptDirectionwhereis_rtlgave
Option<bool>. - A name table ID is a
NameId, with the specification's IDs as constants (NameId::FAMILY_NAMEand the rest),
wherever one goes:name, the keys ofnames,Axis::name_id,Palette::name_idandpalette_entry_labels. - Every public type is
Debug.LocationisEqandHashby the values it was asked for, so it keys a map. Results
that hold data alike areCloneandPartialEq. Results areSend + Syncin every build, andFontandLocation
are withthreading. Bounds { x_min, y_min, x_max, y_max }is every box.ColrLayer, palettes and BASE'sExtentsare named structs,
not tuples.ShapeOptions,LayoutOptions,JustifyOptions,OutlineOptionsandSceneOptionsare#[non_exhaustive], built
fromDefaultor theirDEFAULT(JustifyOptionsfromnew) with theirwith_*methods. So is every struct a call
returns and every enum that may gain a variant, so a later field or variant comes in a minor release: match them with
a_arm. AStrokeStyleisStrokeStyle::new(width)withwith_joinandwith_cap, aGradientis
Gradient::new, andJstfModListsandItemVariationStorestart fromDefault. Plain values (GlyphId,Bounds,
Point,Offset,Feature,Rgba,Stop,Rect,WordSegmenter),raw::format'sEntryandRegionAxis, and
sets a specification closes (Orientation,Direction,Verb,FillRuleand the like) stay exhaustive, as the
crate docs list.unicode::Script's id is private, as a release renumbers the ids when Unicode adds scripts, soScript(n)and.0
are gone. A script comes fromscript_runs, a constant such asScript::ARABIC,Script::from_iso15924orparse,
given its Unicode name or its ISO 15924 code.
Modules
- The root holds
Font,Location,Tag,GlyphId,NameId,Error,ErrorKind,Result,Bounds,
Orientation,Axis(1.2.0'sFvarAxis),NamedInstance,FontStyle,GlyphClass,CacheandCacheStats.
Every other item moved to its area's module:metrics,shape,layout,unicode,outline,color(1.2.0's
paint, with the color glyph calls' types),math,tables,raw(bytes,format,build_font,parse_loca
andoutline_glyf_bytes) andraster. daecoreis private. What it held that a caller needs is in those modules.
One call a job
- Opening.
from_ttcisfrom_collection, which opens a font file at index 0 asfrom_bytesdoes, and
ttc_font_countisface_count, which counts a font file as one face where it gave 0. Opening refuses a font whose
head (or Apple's bhed) gives no unitsPerEm, or whose maxp gives no glyph count.upmisunits_per_em,num_glyphs
isglyph_countandbboxisbounds.from_vectakes a face index, 0 for a font file, asfrom_staticdoes. - Names and instances.
name_stringisname(NameId, &Location).instancegives the instance as shared bytes, an
Arc<[u8]>that its location's cache hands out again without a copy.instanceandinstance_tablesreturn the
instancer's error at a location it can't build, where they returned the font as stored;instance_tableskeys its
tables byTag, andtable_tagsis an iterator. - Metrics. Every metric takes a
Location.os2_infoisos2,stat_infoisstatandflagsispdf_flags, a
typedPdfFlags.line_metricstakes anOrientation, andTypoLineMetricsfolds intoLineMetrics.
typographic_metricsgives each part as anOption, so a missing field is no longer 0, andSubSuperMetricsis
ScriptMetrics. - Glyphs.
advance_widthsisadvances(glyphs, &Location, Orientation, &mut out), filling the caller's buffer
after clearing it.vertical_advanceisadvance(glyph, &Location, Orientation).codepointsfolds intocoverage,
which withglyph_idsis an iterator where they gave aVec.mark_attachment_classreturnsOption<NonZeroU32>,
none for no class where it gave 0, andvertical_originreturnsf64.glyph_namereturnsOption<&str>and
glyph_namesan iterator of them, each name lent from post or CFF where it was aString. - Shaping.
shape(text, &Location, &ShapeOptions)returnsArc<ShapedRun>in every build, where it was anRc
withoutthreading, and replacesshape_with_language,shape_with_featuresandshape_with_options; every run
shaping gives comes as anArcalike.shape_bidi_withfolds into ...
daegun 1.2.0
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
com...
daegun 1.1.7
Two spec-conformance fixes in the subsetter, both found while extracting it into a separate project
and validating the output against the OpenType spec and fontTools rather than against daegun
itself. Output bytes move for anything that rebuilds a font, so pinned subset fingerprints need
re-recording. Nothing in the public API changed.
Fixed
head's directory checksum was computed over the wrong bytes.build_ttfchecksummed the
table as written, including whatevercheckSumAdjustmentthe incoming font happened to carry.
The spec computes that entry with the field read as zero, since it is derived from the very
checksum it would otherwise feed into. 26 of 27 test fonts came out with a wrong entry. Nothing
caught it because the whole-file adjustment subtracted the stale value straight back out, so the
file checksum validated and the one rule nobody was checking stayed broken. OTS runs over every
font a browser downloads, and fontbakery checks the same field.- A subset could not address any codepoint above U+FFFF. Format 4 covers the BMP and nothing
else, and nothing emitted a format 12 subtable, so a supplementary-plane glyph was embedded and
named correctly in the glyph map while the cmap had no way back to it.STIX2Mathwent from 5 of
16 requested codepoints addressable to all 16, and the plane 15 private-use test fonts from none
to all of theirs. Fonts living entirely in the BMP emit nothing extra and their bytes are
unchanged.
Changed
build_format4_cmapis nowbuild_unicode_cmap. It emits a format 12 subtable beside the format
4 one, with the(0, 4)and(3, 10)encoding records, whenever a mapping sits above the BMP.
It is internal to the subsetter and absent from the C API.- The
subset fontsandinstanced fontsfingerprints moved. Theheadfix changes exactly two
fields in every rebuilt font: its directory entry checksum, andcheckSumAdjustment, which
shifts with it because the entry sits inside the header the file checksum covers. No other table
and no glyph data changes.
Both fixes carry a test that was confirmed to fail without it, which the head bug in particular
earned: it had already survived one checksum rule that passed the whole time.
daegun 1.1.6
A fix to the fuzz harness, which is a development tool rather than part of the published crate. The
library is byte-identical to 1.1.5 and there is nothing here to upgrade for.
Fixed
- The fuzz harness moved a field out of a shaped run, which stopped compiling once
Font::shape
began handing back aShared<ShapedRun>. It sits outside the workspace, so the change that broke
it never built it, and only the full gate caught it.
daegun 1.1.5
The measurement release. Testing the engine against real fonts and a real frame budget turned up
seven correctness defects and two paths doing far more work than they needed to.
Fixed
- A contour started at the wrong point whenever its first point was off-curve. TrueType begins at
point 0 if it is on-curve, otherwise at the last point if that one is, and only failing both at
the midpoint. No rasterized comparison can catch this – a closed contour fills identically
whichever vertex it starts from. - CFF2 blending rounded every delta to a whole unit. Charstring coordinates are relative, so the
error accumulated along the outline. - CFF contours restated the closing segment that
closealready draws. - A font carrying both
glyfandCFFalways read CFF.sfntVersionis what breaks the tie. - Macintosh cmap subtables were all read as MacRoman, so a MacOS Turkish subtable resolved six
letters to.notdef. - An axis tag shorter than four bytes matched nothing, because
fvarstores short tags
space-padded.("wght", …)worked and("M1", …)was silently ignored. - Tai Tham was scored against the Universal Shaping Engine's vowel ordering, which the script does
not follow, so ordinary words came back marked as broken clusters. daegun now gives Tai Tham a
cluster grammar of its own, scoped to that script so nothing else changes.
Performance
Two root causes account for most of it. Resolving an axis position built a BTreeMap and two
intermediate vectors to hold what is almost always a single axis; and the rasterizer's overlap
resolution divided in its innermost loop.
| before | after | ||
|---|---|---|---|
Font::shape, cache hit |
285 ns, 13 allocations | 88 ns, 3 | −69% |
rasterize_glyph, first time |
25.7 µs, 31 allocations | 20.8 µs, 16 | −19% |
rasterize_glyph, cached |
73.4 ns | 63.5 ns | −13% |
advance_widths ×1 |
26.0 ns | 19.6 ns | −25% |
colr_v1_paint_graph_variable |
621.7 µs | 555.6 µs | −11% |
CPU raster pipeline, B at 16px |
4.999 µs | 4.543 µs | −9% |
Measured at the frame rather than the call, in a scrolling GPU app: re-laying-out a document of
unchanged text fell from 0.0105 ms to 0.0048 ms a frame, and a page zoom from 12 to 96 pixels fell
from 0.507 ms to 0.284 ms of rasterization a frame.
Bytes allocated per shape fell furthest of all, from 1,033 to 53.
Full figures in benchmark.md, which
is re-measured for this release as the best of three runs.
Added
- Every cache budget is the caller's. The glyph cache took a budget already; the curve,
outline, shape and variable-instance caches now do too, each with a_statscall, and the cmap
index takes an allowance. In Rust and in C alike. Those five were compile-time constants, which
meant a CPU-only program carried the GPU curve cache, a Latin-only one carried a cmap index sized
for CJK, and a fixed-weight one carried 64 MB of variable-instance headroom it never touched. daegun_vulkan_renderer_handles,daegun_d3d11_renderer_handlesand
daegun_d3d12_renderer_handles, the interop escape hatch that existed in Rust and had no C entry
point.
Changed
Font::shapereturnsShared<ShapedRun>rather than an owned run. This is a breaking change.
Sharedderefs toShapedRun, so field reads compile unchanged; moving a field out of the
returned run now needs a.clone(). Three call sites needed that across daegun's own tree.- The default glyph cache is 8 MB, up from 4. A full 12 to 96 pixel page zoom holds 6.9 MB of
rasterized glyphs, so the old default evicted continuously through one. Measured: 8 MB removes
that and 16 MB adds nothing. - Resizing a cache evicts down to the new bound and keeps what still fits. It used to discard
everything, so making a cache smaller cost you a warm one.
daegun 1.1.0
The refining release. Driving 1.0.0 from a real-time app turned up defects a static capture never
would, and the capability that app needed most.
Fixed
- COLR v0 glyphs rendered nothing at all. Both entry points resolved color through the v1 paint
graph, so a v0 font came back empty on the CPU and GPU paths alike. - Two fonts in one
GpuBatchreturned each other's outlines. The slot key carried no font identity. - COLR layers that defer to the caller's text color rendered as nothing.
- Degenerate gradients flooded their shape with the last stop color instead of painting nothing.
- A draw with no instances was a validation error rather than a no-op.
- A borrowed Vulkan target leaked its image view and framebuffer.
- Metal was the one backend with no C entry point for adopting a device or borrowing a surface.
DAEGUN_SURFACE_RGBA8andDAEGUN_SURFACE_BGRA8sat inside the__APPLE__guard, so no caller
on Windows or Linux had the constants their own calls take.- The C wrapper had never been compiled for Windows. It now type-checks and builds there.
Added
- Render into a surface you own, on Metal, Vulkan, D3D11 and D3D12.
from_deviceadopts the
device you already made, and a target can wrap your swapchain image directly. No readback, no
copy. See the GPU path. - The four backends are a documented module,
daegun::gpu, each one gated to the platform that
has it. They were reachable before but hidden from the reference, so a Rust caller had no
documentation for calls the C header described in full. - On Metal, daegun presents the drawable on the command buffer carrying the draw, so the queue
orders the two and neither waits on the other. - A caller-supplied text color for COLR layers that defer to it:
render_colr_glyph_with,
gpu_color_glyph_withanddraw_glyph_with. See color. - A target's byte order is yours to choose, RGBA8 or BGRA8, which is what it takes to match a
swapchain without swizzling every frame. - A target's clear color is yours to choose, and
Nonekeeps what the target already holds, so
several geometries layer into one surface rather than erasing each other. - One
GpuBatchnow holds any number of fonts, so a mixed-font page uploads once and draws once. Rgbais public at the crate root. It is in the signature of every_withcolor call, so it had
to be documented beside them rather than reachable only through a hidden module.
Changed
GpuGlyphKeygains afontfield and#[non_exhaustive]. It is internal and#[doc(hidden)],
constructed only inside daegun, and absent from the C API. This is why the release is 1.1.0
rather than 1.0.1.
No documented signature changed and nothing was removed, so 1.0.0 code compiles against 1.1.0
untouched.
Install:
[dependencies]
daegun = "1.1.0"Full changelog: https://dg.calia.cc/changelog/
Documentation: https://dg.calia.cc
daegun 1.0.0
The first release.
daegun turns a font file and a string into positioned, rasterized glyphs. It parses TrueType and OpenType, shapes complex scripts, breaks and lays out lines, hints, rasterizes on the CPU or the GPU, and subsets a font down to the glyphs a page actually uses. One crate does all of it, and a C ABI sits alongside the Rust API rather than behind it.
[dependencies]
daegun = "1.0.0"What it does
| Outlines | TrueType glyf, CFF, CFF2, and variable fonts on any number of axes |
| Color | COLR v0 and v1 paint graphs, CPAL palettes, and sbix and CBDT bitmap strikes |
| Shaping | GSUB and GPOS in full, Apple morx and kerx, and shapers for Arabic, Hebrew, Thai, Hangul, Khmer, Myanmar, nine Indic scripts and 84 more through the Universal Shaping Engine |
| Text | Bidi, line breaking greedy or optimal, justification, vertical writing, math |
| Rasterizing | CPU everywhere, and GPU through Metal on Apple platforms, Direct3D 11 and 12 on Windows, and Vulkan anywhere |
| And | Subsetting to the glyphs a page uses, TrueType and CFF hinting, an autohinter, and collections |
What holds it up
- No dependencies at all, so the supply chain is the Rust compiler and nothing else.
- Unsafe code is forbidden in every parser and in the shaper, enforced by the compiler rather than by discipline. An inner
allowis a hard error. Only the GPU backends and the C layer opt back in, and they say so at the top of their own files. - Every call in the Rust API is reachable from C, and the build fails if that stops being true.
- 500 mutated fonts on every build, each reproducible from its seed. The C round trip runs under AddressSanitizer and UndefinedBehaviorSanitizer.
unwrapandexpectare linted against outside tests, and the library is built withpanic = "abort", so it never unwinds into a caller.
One command runs all of it, along with the tests, clippy, the shader compilers, two cross-compiled Windows targets, and the minimum supported Rust version:
sh scripts/tools/perf/gate.shDocumentation
Every public name in both APIs is written up at dg.calia.cc — 122 Rust methods, 33 Rust types, 420 C functions, 86 C types and 215 C constants, each with what it returns, what it does when it cannot, and the units it answers in.
benchmark.md carries every latency benchmark in the tree, with the machine and build they were measured on. SECURITY.md sets out the threat model.
MIT · Rust 1.97.1 or newer