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 ..." ] }
]
}
}
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.
| Mode | Cell | Glyph pixel | Redefinable on the machine |
|---|---|---|---|
| null (Freeform) | Any size | Packed RGBA | n/a |
"Spectrum" | 8×8 | Ink or paper bit | Yes |
"C64" | 8×8 | Ink or paper bit | Yes |
"BBC" | 8×8 | Ink or paper bit | Yes |
"Oric" | 6×8 | Ink or paper bit | Yes |
"Teletext" | 6×10 | Ink or paper bit | No, ROM set, editable here |
"VGA" | 8×16 | Ink or paper bit | Yes |
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.
| Field | Type | Description |
|---|---|---|
id | String | The item id, 32 hex characters. The key, shared with the item's meta record. |
data | Object | The 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.
| Field | Type | Description |
|---|---|---|
mode | String | The platform font the set matches, by name, for example "Spectrum". Null, or omitted, for a freeform font that names no mode. |
w | Number | The glyph cell width in pixels. Every glyph is this wide. |
h | Number | The glyph cell height in pixels. Every glyph is this tall. |
freeform | Boolean | True when each glyph pixel is a packed RGBA colour, false when it is a single ink or paper bit. Absent means false. |
first | Number | The character code of the first glyph. The glyph at array index i is character code first + i. Often 32, the space. |
glyphs | Array | The 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.
| Field | Type | Description |
|---|---|---|
cells | Array | The 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.
| Pixel | Font | Meaning |
|---|---|---|
0 or 1 | One bit | Paper 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 colour | Freeform | A 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 ] }
]
}