Itijah: Pure Zig Unicode Bidirectional Algorithm — passes full conformance suite

Zig-native implementation of the Unicode Bidirectional Algorithm (UAX #9).

Codepoint-level API with explicit allocator passing and no global state.

Why:
I needed bidi support for RTL text layout in Ghostty, and there wasn’t a pure Zig option. FriBidi and ICU work well, but they add C dependencies and don’t match Zig’s allocator-first style.

Key points:

  • Full conformance in current suite: BidiTest failed=0, BidiCharacterTest failed=0
  • Competitive performance vs FriBidi/ICU across benchmark profiles
  • Scratch APIs for allocation-light render loops
  • Terminal-oriented resolveVisualLayout for one-call line layout

Links:

Feedback welcome, especially from people working on text rendering in Zig.

7 Likes

Nice! I did something in that space myself. I didn’t do serious benchmarking though. I’d love if there could be some comparisons between the two libs.

2 Likes

Observations:

  • Other than summary in the README, no documentation or examples.

  • In a number of structs, I see a pattern of embedding the allocator. This overhead shouldn’t be necessary.

  • What are the tradeoffs between the scratch and non-scratch APIs? Why the complexity of two APIs at all?

  • Is there a good reason why the ShapeFlags and ReorderFlags structs are padded to 32 bits? The largest requires only 4 bits.

1 Like