Sprites Font Media Storage

A font lives in the data store as one record with two fields: its id and a data object. The metadata is the meta record beside it under the same id. The data object holds a set of glyphs over a shared cell size: its mode and size, and a glyphs array of pixel grids, one per character. A font has no layers and no frames, so it is the flattest of the media. The font editor is not built yet, so nothing writes this format today; it is documented here so the editor, the image text modes and the exporters share one shape. A saved font is what feeds the redefined characters of a text image.

{
  "id": "3a5f80c11e7b42d980c6a2f4b7d1e903",
  "data": {
    "mode": "Spectrum",
    "w": 8,
    "h": 8,
    "freeform": false,
    "first": 32,
    "glyphs": [
      { "cells": [ "... 64 ink and paper bits ..." ] }
    ]
  }
}
The whole data record: the id and the data object. The sections below walk the object down through its size and glyphs.

One shape for every font

A font is a set of glyphs, each a small grid of pixels at one shared cell size. Two things vary across the machines, and the format is the superset of both. First, the cell size: a machine fixes it, 8×8 on the Spectrum and the C64, 6×8 on the Oric, 8×16 on VGA text, while a freeform font takes any size. Second, whether a glyph pixel is one bit or full colour. A machine font is one bit, ink or paper, and the colour is supplied by the image that uses it. A freeform font is full RGBA, each glyph pixel a packed colour, for use anywhere a bitmap font is wanted.

ModeCellGlyph pixelRedefinable on the machine
null (Freeform)Any sizePacked RGBAn/a
"Spectrum"8×8Ink or paper bitYes
"C64"8×8Ink or paper bitYes
"BBC"8×8Ink or paper bitYes
"Oric"6×8Ink or paper bitYes
"Teletext"6×10Ink or paper bitNo, ROM set, editable here
"VGA"8×16Ink or paper bitYes

The size choices a mode allows, and whether its characters can be redefined on the real machine, live on that machine's platform font page. A font names one mode and one size; the size does not change once glyphs are drawn.

Contents

The record in the data store is just the id and the data object. Everything a listing shows is the meta record, so this store carries only the glyphs.

FieldTypeDescription
idStringThe item id, 32 hex characters. The key, shared with the item's meta record.
dataObjectThe font: its mode, size and glyphs. Detailed in Data below.

Data

The data object carries the mode and cell size the whole font is drawn at, whether its glyphs are full colour, the first character code, and the glyphs themselves.

FieldTypeDescription
modeStringThe platform font the set matches, by name, for example "Spectrum". Null, or omitted, for a freeform font that names no mode.
wNumberThe glyph cell width in pixels. Every glyph is this wide.
hNumberThe glyph cell height in pixels. Every glyph is this tall.
freeformBooleanTrue when each glyph pixel is a packed RGBA colour, false when it is a single ink or paper bit. Absent means false.
firstNumberThe character code of the first glyph. The glyph at array index i is character code first + i. Often 32, the space.
glyphsArrayThe glyphs, in code order from first. Detailed in Glyphs below.

Glyphs

glyphs is an array of glyph objects, in character order from first. Each glyph is one cell of pixels in row order, w times h entries, the same shape for every glyph in the font. The pixel at column c, row r is at index r × w + c.

FieldTypeDescription
cellsArrayThe glyph's pixels, row order, w times h entries. Each entry is a glyph pixel, encoded below.

A font has no layers and no attributes, so a glyph is just its grid. There is no transparency: a one bit glyph is ink or paper, and a freeform glyph fills every pixel with a colour.

Pixel encoding

A glyph pixel follows the font's freeform flag.

PixelFontMeaning
0 or 1One bitPaper or ink. The pixel carries no colour of its own; the image that places the character supplies its ink and paper. See image characters.
A packed colourFreeformA 32 bit RGBA colour packed into one integer, as for a freeform image cell. Opaque white is 4294967295.

Full example

A tiny 3×3 one bit font of two glyphs from code 32: a blank space and a filled block. Each glyph is nine ink and paper bits in row order.

{
  "mode": null,
  "w": 3,
  "h": 3,
  "freeform": false,
  "first": 32,
  "glyphs": [
    { "cells": [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ] },
    { "cells": [ 1, 1, 1, 1, 1, 1, 1, 1, 1 ] }
  ]
}
Code 32 is the blank space, code 33 the filled block. A machine font keeps the same shape, at that machine's cell size, and names its mode.