Cauldron2D.GameMaker.Font (Cauldron2D.GameMaker v0.2.1)

Copy Markdown View Source

A font (a FONT entry): glyphs cut from one picture on a texture page.

picture is the Cauldron2D.GameMaker.Region holding every glyph. Each glyph in glyphs, keyed by its character's code point, is a map of source {x, y, width, height} inside that picture, advance (pixels the pen moves after it), offset (pixels right of the pen it is drawn) and kerning, a map from the next character's code point to an extra advance. size is the point size it was made at, from the typeface typeface.

Summary

Functions

The font at at; format says where its glyph list sits.

Types

glyph()

@type glyph() :: %{
  source:
    {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()},
  advance: integer(),
  offset: integer(),
  kerning: %{required(non_neg_integer()) => integer()}
}

t()

@type t() :: %Cauldron2D.GameMaker.Font{
  bold: boolean(),
  glyphs: %{required(non_neg_integer()) => glyph()},
  italic: boolean(),
  name: String.t(),
  picture: Cauldron2D.GameMaker.Region.t() | nil,
  scale: {number(), number()},
  size: number(),
  typeface: String.t() | nil
}

Functions

read(data, at, regions, format)

@spec read(
  binary(),
  non_neg_integer(),
  %{required(non_neg_integer()) => Cauldron2D.GameMaker.Region.t()},
  atom()
) :: t()

The font at at; format says where its glyph list sits.