NestGen2.Text (nest_gen2 v0.6.6)

Copy Markdown View Source

Text rendering from Nest's own Akkurat fonts, on the device.

The textrender helper (stb_truetype) rasterises text from the device's /nestlabs/share/fonts, so no font data ships with the SDK (Akkurat is commercially licensed). On the host (see docs/host.md) it reads a copy of your own Nest's fonts from ~/.nest_gen2_sdk/fonts, or the :font_dir config.

Options:

  • :font — :bold (default), :regular, or a path to a TrueType file
  • :size — em size in pixels, default 36
  • :color — text colour (hex string or {r, g, b}), default white
  • :background — colour the text is smoothed onto, default black

Summary

Functions

Returns a specification to start this module under a supervisor.

Width and height the text would render at.

Renders text to an image the exact size of the text.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

measure(text, opts \\ [])

@spec measure(String.t(), keyword()) ::
  {:ok, {pos_integer(), pos_integer()}} | {:error, term()}

Width and height the text would render at.

render(text, opts \\ [])

@spec render(String.t(), keyword()) :: {:ok, NestGen2.Image.t()} | {:error, term()}

Renders text to an image the exact size of the text.

start_link(_)