Rendro.PDF.Font (Rendro v1.3.4) (stable)

Copy Markdown View Source

Font representation passed to text shapers.

A Rendro.PDF.Font struct carries the metrics and embedding data a Rendro.Text.Shaper needs to lay out a run of text — name, source kind, units-per-em, ascent/descent, advance widths, and the cmap. It appears in the public Rendro.Text.Shaper.shape/3 contract, so any custom shaper receives values of this type.

You normally obtain a t/0 from the rendering pipeline rather than building one by hand; the struct's internal field layout may evolve, but t/0 remains the stable type referenced by the shaping API.

Summary

Functions

Checks if the font has explicitly defined glyphs for all codepoints in the text.

Types

t()

@type t() :: %Rendro.PDF.Font{
  ascent: integer(),
  base_font: String.t(),
  cmap: %{required(non_neg_integer()) => non_neg_integer()} | nil,
  default_width: non_neg_integer(),
  descent: integer(),
  embedded?: boolean(),
  font_bytes: binary() | nil,
  glyph_widths: %{required(non_neg_integer()) => non_neg_integer()},
  logical_name: atom() | nil,
  name: String.t(),
  source: :built_in | :embedded,
  source_kind: :built_in | :path | :binary,
  subtype: :type1 | :truetype,
  units_per_em: pos_integer(),
  widths: %{required(non_neg_integer()) => non_neg_integer()}
}

Functions

embedded(opts)

@spec embedded(keyword()) :: t()

has_glyph?(font, text)

@spec has_glyph?(t(), String.t()) :: boolean()

Checks if the font has explicitly defined glyphs for all codepoints in the text.

helvetica()

@spec helvetica() :: t()

text_width(font, text, font_size)

@spec text_width(t(), String.t(), number()) :: float()