Skip to content

C API: add optional Skrifa draw and paint features - #519

Merged
behdad merged 23 commits into
mainfrom
capi/skrifa-draw-paint
Oct 17, 2026
Merged

behdad merged 23 commits into
mainfrom
capi/skrifa-draw-paint

Conversation

@behdad

@behdad behdad commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Add optional draw and paint features backed by published Skrifa, using the existing face/font handles and C library. paint enables draw; both remain off by default.

Drawing supports unhinted glyf, CFF/CFF2 and VARC outlines at the font's variation coordinates and X/Y scales. Painting supports COLRv0/v1 palettes, gradients, transforms, clips, composites, cached glyph callbacks, SVG, and CBDT/sbix images. Custom font callbacks and parent-font inheritance work with both features. Failed paint traversal unwinds outstanding scopes, and clients can retain image blobs beyond a callback.

Native hr-draw.h / hr-paint.h headers and HarfBuzz compatibility headers expose the APIs. Callback faces use a cached rendering SFNT without requiring table enumeration. The painting adapter follows HarfBuzz's Rust font adapter and preserves its license. Packed color definitions stay in the core API, and the core header is unchanged.

Validation after merging current main and the released C API stack:

  • Full Rust suite: 6,074 shaping tests and 160 C API tests pass with all features. Default and draw-only C API suites also pass.
  • 2,862 outline/state comparisons against HarfBuzz, including CFF/CFF2, VARC, variable coordinates, zero/negative scales, and cubic fallback; 48 semantic paint comparisons pass.
  • All 63 released subset comparisons pass; the combined stack also passes all 79 comparisons with the plan extension enabled.
  • GCC/Clang C99 and C++11 rendering consumers pass with shared and static linking. C++11/C++17 ownership/include-order consumers and the same C99 rendering consumer against HarfBuzz pass.
  • Rust 1.85, formatting, Clippy, generated headers, and default/draw-only/subset+paint exports pass. Linux/macOS CI checks the rendering combinations and consumers.

Documented limits remain: hinting, bitmap masks, shape convenience functions, configurable budgets, and gradient preprocessing/tiling helpers are not mapped. Skrifa's traversal limits apply. VARC transform precision and bitmap extent rounding may differ slightly from native HarfBuzz; rendering tables are copied once per face.

Stacked on #546 using published dependencies. Merge order: #544 → #545 → #546 → #519 → #547. Only the final draft #547 waits for a Skera release.

behdad added 14 commits October 7, 2026 15:57
Support Skia face setup and callback-backed table enumeration. Keep collection selection separate from mutable face index metadata.

Assisted-by: OpenAI Codex
Map strided batches in public queries and shaping, with scalar/batch fallback and callback precedence through subfonts.

Assisted-by: OpenAI Codex
Keep the package version unchanged while making hb_version and HB_VERSION aliases report the matched shaping release. Add hr-hb-ot.h and generate portable include guards.

Assisted-by: OpenAI Codex
Provide Skia glyph/Unicode selection, retained IDs, notdef outlines, and hint removal through hr_subset APIs and hr-hb-subset.h. Import the core C ABI instead of embedding a second shaping library.

Assisted-by: OpenAI Codex
@behdad
behdad requested a review from dfrg October 8, 2026 18:06
Base automatically changed from capi/skia-subset to main October 16, 2026 20:14
Base automatically changed from capi/released-skia-runtime to main October 17, 2026 17:41
@behdad
behdad merged commit 15cd3b5 into main Oct 17, 2026
10 checks passed
@behdad
behdad deleted the capi/skrifa-draw-paint branch October 17, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants