Rendro.Adapters.HarfBuzz (Rendro v1.0.0) (adapter)

Copy Markdown View Source

HarfBuzz text shaping adapter via the harfbuzz_ex NIF.

Requires {:harfbuzz_ex, "~> 1.2", optional: true} in your mix.exs and:

config :rendro, shaper: Rendro.Adapters.HarfBuzz

This adapter handles all scripts including Arabic, Indic, Thai, Hebrew, and other complex scripts. It delegates to HarfbuzzEx.get!/3 with a SHA256-keyed font cache kept in a rendro-private (0700) subdirectory of the system temp dir; cached files are content-verified before reuse and written atomically. Cache files persist for the host's lifetime (one file per distinct embedded font).

This module is only compiled when HarfbuzzEx is available at compile time (via Code.ensure_loaded?/1). If harfbuzz_ex is not in your dependencies, this module is absent and core Rendro is unaffected.

Summary

Functions

Shapes text with HarfBuzz (rustybuzz) for embedded fonts; built-in fonts are delegated to Rendro.Text.Shaper.Simple (no NIF required for them).

Functions

shape(font, text, opts)

@spec shape(Rendro.PDF.Font.t(), String.t(), keyword()) ::
  {:ok, [Rendro.Text.Shaper.glyph()]} | {:error, term()}

Shapes text with HarfBuzz (rustybuzz) for embedded fonts; built-in fonts are delegated to Rendro.Text.Shaper.Simple (no NIF required for them).