Skip to main content

Module ffi

Module ffi 

Source
Expand description

C-ABI compatible types for FFI consumers.

This module provides #[repr(C)] types that can be safely passed across FFI boundaries. These types mirror the internal Rust types but use C-compatible layouts for integration with C, Python (via ctypes/cffi), and other languages.

§Memory Ownership

  • Types ending in C are C-ABI compatible copies
  • Slice views (*const T, len) are borrowed - caller must not free
  • Owned arrays should be freed via the corresponding _free() function

§Example (conceptual C usage)

TypfShapingResultC result;
int err = typf_shape_text("hb", "Hello", "/path/font.ttf", 24.0, &result);
if (err == 0) {
    for (uint32_t i = 0; i < result.glyph_count; i++) {
        printf("Glyph %u at (%.1f, %.1f)\n",
               result.glyphs[i].glyph_id,
               result.glyphs[i].x,
               result.glyphs[i].y);
    }
    typf_shaping_result_free(&result);
}

Structs§

GlyphIterator
Glyph iterator for zero-copy consumption.
GlyphMesh
A mesh of triangles for GPU rendering.
PositionedGlyphC
C-ABI compatible positioned glyph.
RenderMesh
A collection of glyph meshes ready for GPU rendering.
ShapingResultC
C-ABI compatible shaping result.
Vertex2D
Vertex for GPU rendering (2D position only).
VertexColor
Vertex with position and RGBA color.
VertexUV
Vertex with position and UV coordinates for textured rendering.

Enums§

DirectionC
Text direction as a C-compatible enum.