Macaw.Layers.Text.Measurer (macaw_layers v0.6.0)

Copy Markdown View Source

A resolved measurer (spec/05 §3.1, #62): the measurer and the font its texts are set in, judged once by Macaw.Layers.Text.measurer/1, so that Macaw.Layers.Text.width/3 and Macaw.Layers.Text.lines/4 on it cost the measurer's own work and a constant.

iex> {:ok, measurer} = Macaw.Layers.Text.measurer(font: "sans-serif")
iex> Macaw.Layers.Text.width(measurer, "Wednesday", 11)
{:ok, 59.4}

It is opaque: build one only through Macaw.Layers.Text.measurer/1, which is what makes its measurer a measurer and its font a string. A struct written by hand is not judged.

Summary

Types

t()

A measurer and a font, judged once.

Types

t()

@type t() :: %Macaw.Layers.Text.Measurer{font: String.t(), metrics: module()}

A measurer and a font, judged once.