Skip to content

engine: add standalone native runtime - #8

Draft
mustafa0x wants to merge 1 commit into
DigitalKhatt:stdlibconvfrom
mustafa0x:runtime/native-engine-c-api
Draft

mustafa0x wants to merge 1 commit into
DigitalKhatt:stdlibconvfrom
mustafa0x:runtime/native-engine-c-api

Conversation

@mustafa0x

@mustafa0x mustafa0x commented Sep 16, 2026

Copy link
Copy Markdown

Summary

Add an opt-in, standalone native C ABI for consuming DigitalKhatt runtime fonts without linking Qt, MetaPost, the authoring application, or platform UI code.

The ABI-v1 kernel:

  • loads a font from a file or copied memory;
  • shapes one independent RTL Arabic UTF-16 line;
  • optionally applies the font's JTST target-width pass;
  • returns glyph IDs, UTF-16 clusters, positioning, and normalized LTAT/RTAT values;
  • emits the selected dynamic CFF2 foreground outline through renderer-owned callbacks;
  • propagates callback cancellation or failure;
  • supports concurrent calls on an immutable engine;
  • exposes explicit status codes and opaque ownership.

All requests and outputs are size-versioned. Glyphs are read through accessors rather than a borrowed fixed-stride array, allowing records to grow without changing the ABI contract.

Parent integration is disabled by default through DIGITALKHATT_BUILD_NATIVE_ENGINE.

Font contract

The runtime admits only the deliberately narrow native profile:

  • CFF2, GSUB, GPOS, GDEF, JTST, fvar, and HVAR;
  • exactly two variation axes;
  • LTAT at index 0 and RTAT at index 1;
  • both axes centered at zero with negative and positive ranges.

Validation

Against the corrected deterministic runtime font produced by #7:

  • Release shared build and pure-C ABI compilation passed.
  • ASan and UBSan passed.
  • Natural, stretched, shrunk, and saturated line output matched direct HarfBuzz exactly.
  • Glyph IDs, clusters, advances, offsets, tatweel values, and total widths matched.
  • Base and dynamic CFF2 outline command streams matched direct HarfBuzz.
  • File/memory parity and concurrent shape/outline calls passed.
  • Every required-table omission and invalid axis contract was rejected.
  • Empty outlines, append-only request/output records, append-only path sinks, and callback cancellation passed.
  • The shared-library export surface contains only the ABI-v1 symbols.

Deliberate non-goals

  • FeatureJustifier or Mushaf page policy
  • Page composition
  • Tajweed/COLR/CPAL painting
  • Line breaking and layout UI
  • Android/iOS adapters
  • MetaPost authoring or font generation

The line operation is documented as a low-level JTST primitive; it is not presented as the canonical Madinah page-layout contract.

Dependency

This runtime consumes the LTAT/RTAT font profile produced by #7. Keeping the producer and consumer changes separate makes both reviews smaller and keeps the C ABI out of compiler internals.

@mustafa0x
mustafa0x force-pushed the runtime/native-engine-c-api branch from 478b1b6 to be68f7c Compare September 16, 2026 19:40
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.

1 participant