# Glint stream format

**Status:** NORMATIVE for format version 8. Two documents are part of this specification:
[the frame streams](streams.md) define the bytes of the six streams, and
[the resources](resources.md) define the resource identities and the
resource messages. The format is not declared stable: a reader reads only
format version 8 (see "Versions"). [Glint clips](clips.md) keep the
messages of a connection with the presentation time of each frame, in a
file that a player draws without a network. A program that writes Glint
messages, for a connection or for a clip, starts at "Writing messages".

A Glint server runs a document in a machine without a GPU. A Glint client on
a machine with a GPU draws the document. The server sends the inputs of the
raster plan and the resources that the plan reads. The client prepares the
raster plan and executes it with its own renderer. The client sends input
records to the server.

## Versions

The format is not declared stable. Until it is, a reader reads only the
current version, and no reader reads an older version:

| Data | Version that a reader reads | Another version |
| --- | --- | --- |
| A stream | Format version 8 in the Hello | Error 10: the value is the version read, the offset is the version supported (8) |
| A clip | Clip format version 1, which holds Glint format version 8 | Error 24 of [the clips](clips.md): the error names the version read and the version supported |

A reader does not convert a message of an older version, and it does not
skip a field that it does not know. A writer writes the current version
only. When a version changes, the conformance files are recorded again
with the new version.

## Roles

| Work | Server | Client |
| --- | --- | --- |
| DOM, style, layout, text shaping, paint, hit testing | yes | no |
| Raster planning, GPU execution, glyph generation, presentation | no | yes |
| Endpoint state, encoding, decoding, codec choice | yes | yes |
| Resource selection | yes | no |
| Compression | compresses with the chosen codec | decompresses |

## Implementations

[Sandom](https://sandom.dev/) implements a Glint server and a Glint client.
This specification does not depend on it.

## Streams

A frame has six streams. The stream index is the order of this table.
[The frame streams](streams.md) define each record of each stream, the
order of the commands and the rules that make a frame valid.

| Index | Stream | Content |
| --- | --- | --- |
| 0 | Commands | The paint commands, in paint order |
| 1 | Glyphs | The glyph entries that the text commands address |
| 2 | Scroll table | The scroll offsets that the commands and clip entries select |
| 3 | Gradient stops | The stops that the gradient extensions address |
| 4 | Scrollbar rows | The scrollbar parts that the scrollbar commands paint |
| 5 | Resource requests | The glyphs and paths that the frame draws |

## Resources

A resource message precedes the first frame that reads the resource.
[The resources](resources.md) define the identity of each resource, the
bytes of each resource message and the work of the client.

| Resource | Message | Identity |
| --- | --- | --- |
| Font instance and the skeleton of its file | Font (3) | The font number: the n-th Font message of the connection has number n |
| Glyph data of a font file | Glyphs (13) | A font number on the file |
| Color glyph cache slot and its path slots | Color glyph (14) | The cache slot: the n-th Color glyph message of the connection installs slot n; the n-th path row of the connection installs path slot n |
| SVG path definition | Path (6) | The path kind and the path index in the space of that kind |
| Decoded image or color glyph bitmap | Image (4) | The entry kind and the image index in the space of that kind |

A client draws the glyphs of the text commands and does not shape text.
The server therefore sends each font file as byte ranges at their offsets
in the file: the skeleton of the file in the Font message, and the data of
each glyph that a frame draws in a Glyphs message.

Images carry decoded pixels: a raster image, an SVG image raster and a
bitmap color glyph (`sbix` or `CBDT`). The server sends an image again
when its image entry changes.

A canvas and a video frame have their pixels only in a GPU texture that a
renderer with a GPU draws. A server that has no GPU cannot send them: a
frame that draws one throws, and the server closes the connection with the
image index in the reason.

## Pacing

The server sends each new frame without waiting for the client, within
two limits: at most 16 frames in flight, and fewer than 131,072 payload
bytes in flight before compression. A frame
is in flight from its send until an Acknowledge of it or of a later frame
arrives. When a limit stops the server, it keeps only the newest prepared
frame, and an Acknowledge that brings the frames in flight under both
limits sends that frame.

An Acknowledge of sequence S states that the client holds frame S and
every earlier frame. Frame S becomes the server's base, and the server
writes each later Delta against it. A Delta therefore names a base that
can be older than the frame before it, and each frame that the client
receives replaces the frames before it: the client draws the newest frame
it has, and acknowledges the frame it draws. The client keeps every frame
from the base of the newest Delta on (at most the frames in flight and
that base), because the next Delta can name any of them.

After a Keyframe, the server sends no frame until the Acknowledge of that
Keyframe or a later frame, so that every later Delta has a base that the
client holds. The first frame of each connection has sequence 1.

## Shared sessions

A server can serve one document to more than one client. Each client has
its own connection state: its codec, the resources it holds, its frames in
flight and its base. Every client receives the frames of the document.

One client is the controller. Its Size and Input messages reach the
document, and the document lays out at its viewport. The other clients are
viewers: the server reads their Size and Input messages and gives them to
no document. A viewer draws each frame at the controller's viewport.

- The first client of a session without clients is the controller. A
  later client is a viewer.
- A Take control message from a viewer makes it the controller at once.
  The document then lays out at the new controller's newest Size.
- When the controller leaves, the client that attached first among the
  others becomes the controller.
- After its Hello, and after each change of a role or of the number of
  clients, the server sends each client a Role message.

## Codecs

| Bit | Codec |
| --- | --- |
| 1 | zstd |
| 2 | deflate-raw (RFC 1951) |
| 4 | none: the compressed part is the payload |

The client sends the first message: a Hello with the bits of every codec
that it decompresses. The server answers with a Hello that names one codec:
zstd when the client offers it, else deflate-raw, else none. The client
checks that it offered that codec. Every compressed part of the
connection uses that codec. A browser without a `"zstd"`
`DecompressionStream` offers deflate-raw and none. A browser has no
synchronous compressor, so a server in a browser compresses with none only,
and fails with the chosen codec when the client offers another.

## Resource selection

The server keeps a ledger for each connection: the fonts that it sent, the
glyphs of each font file that it sent, each SVG path definition that it
sent, and each image that it sent. Before each frame, the server sends the
resource messages that the frame reads and the ledger does not hold, in the
order of "Order of the resource messages" in [the resources](resources.md):

- a Configuration when the configuration differs from the one that the
  client has;
- a Font for each font instance that the frame uses for the first time;
- a Glyphs message for each font file that has glyphs that the frame draws
  and that the client does not have;
- a Color glyph message for each color glyph program that the frame draws
  for the first time;
- a Path message for each SVG path definition that the frame draws and that
  the client does not have;
- an Image message for each image that the frame draws and that changed
  since the server sent it, or that the server did not send;
- an Image release message for each image that the client keeps and that
  the server no longer sends.

A canvas or a video frame has its pixels only in a GPU texture. A server
without a GPU does not send it: a frame that draws one is error 16.

## Transports

A connection carries the messages of "Messages" over one of three
transports. The messages are the same on all. Every message other than
Keyframe and Delta is a control message. The resource messages are the
control messages that a frame can read: Configuration, Font, Glyphs,
Color glyph, Image, Image release, Path and Variation.

### WebSocket

Each message is one binary WebSocket message, in order, in both
directions. A frame always follows the control messages it reads, and a
later frame always follows an earlier one.

### QUIC

The connection uses QUIC (RFC 9000) with TLS 1.3 and the application
protocol (ALPN) `glint/8`.

- The client opens one bidirectional stream. The client writes its
  messages on it (Hello, Size, Input, Acknowledge, Take control). The
  server writes its control messages on it, in order.
- The server sends each Keyframe and Delta on a unidirectional stream of
  its own, which holds that one message, and finishes the stream. When the
  server sends a frame, it resets the streams of the earlier frames that
  are still open. A frame needs no frame before it: a Delta names the
  newest acknowledged frame as its base (see "Pacing").
- Each frame names the number of resource messages that the server wrote
  before it (the last field of its header). The client applies a frame
  only when it has received that many resource messages, and keeps a
  frame that arrives earlier until it has. A frame never waits for another
  control message, such as Document state or Role. Of the frames that
  wait, the client keeps the newest. A frame whose sequence is not above
  the newest frame that the client applied is stale; the client drops it.

The server presents a TLS certificate. The client checks it in one of two
ways, which the client's user chooses:

- By the trust anchors of the client's platform and the server's host
  name, as a web browser checks a site.
- By its SHA-256 hash: the client accepts only the certificate whose DER
  encoding has that hash. This is for servers without a public
  certificate, such as a development host or a private network. Web
  browsers check a WebTransport server this way through
  `serverCertificateHashes`, which accepts an ECDSA P-256 certificate
  valid for 14 days or less; a server for browsers keeps to those limits.

### WebTransport

A browser connects over WebTransport (HTTP/3, RFC 9220 extended CONNECT)
to an `https://` URL; the server accepts a session on any path. The
streams of the session are laid out as on QUIC: the client opens one
bidirectional stream for its messages and the server's control messages,
and each frame comes on a unidirectional stream of its own. The rules of
frame order are those of QUIC. A frame stream that the server resets
gives no message.

The browser checks the certificate by its trust anchors, or by
`serverCertificateHashes`: the SHA-256 of an ECDSA P-256 certificate whose
validity period is 14 days or less.

## Messages

All integers are little-endian. A varint is an unsigned LEB128 integer of
at most five bytes. Each message is:

| Field | Size |
| --- | --- |
| kind | u8 |
| body length | varint |
| body | body length bytes |

A reader reads the kind and the body length to find the size of the
complete message. The given bytes can hold less than one message; the
reader then waits for more bytes. An unknown kind or a varint longer than five bytes is an
error that names the kind or the byte offset.

A body that has a compressed part holds a header, then the compressed
bytes to the end of the body. Font, Image, Path, Keyframe, Delta, Glyphs
and Color glyph have a compressed part; the other kinds have none. A
body longer than its fields is error 19 for Input, Document state and
Variation, and error 3 for Image release; a client ignores the bytes
after the fields of another kind without a compressed part, and a writer
writes none.

| Kind | Name | Direction | Body |
| --- | --- | --- | --- |
| 1 | Hello | both | format version (u32, 8), codec bits (u8): a client lists the codecs it decompresses; the server answers with the one codec it chose |
| 2 | Configuration | server | target width and height in device pixels (u32, u32), device scale (f32), render mode (u8: 0 standard, 1 high dynamic range), visible rectangle x, y, width, height (4 × f32), background red, green, blue, alpha (4 × f32), light-ink and dark-ink text thickening (2 × f32): 53 bytes ("Configuration (2)" in [the resources](resources.md)) |
| 3 | Font | server | face index, file source, file length (3 × u32, the file length 0 when the file source is an earlier font), axis count (u16), then for each axis other than `wght` and `opsz` its tag (u32) and normalized coordinate (i16, F2Dot14); compressed: the skeleton ranges of the font file, or nothing when the file source is an earlier font |
| 4 | Image | server | image index (u32, in the space of the entry kind), entry kind (u8: 0 decoded, 1 glyph bitmap), contents opaque (u8), glyph box (5 × f32, kind 1 only), width, height, row stride (3 × u32), channel layout, sample type, bits per sample, alpha mode, transfer function, primaries (6 × u8), gamma, reference white luminance (2 × f64), canvas tone mapping standard (u8); compressed: pixel bytes |
| 5 | Image release | server | image index (u32, in the space of the entry kind), entry kind (u8): 5 bytes |
| 6 | Path | server | path index (u32, in the space of the path kind), path kind (u8: 0 SVG path, 1 color glyph layer, 2 text stroke); compressed: the 40-byte path record with the path's bounds, the path text and the dash floats |
| 7 | Keyframe | server | sequence (u32), command revision (u32: the sequence), resource messages (u32: the number of resource messages the server wrote before the frame); compressed: for each of the six streams, in stream order, its byte length (varint) and its bytes; an empty stream has length 0 |
| 8 | Delta | server | sequence (u32), base sequence (u32), command revision (u32: the sequence), resource messages (u32); compressed: operations |
| 9 | Acknowledge | client | sequence (u32): the client holds this frame and every earlier frame |
| 10 | Input | client | one input record (see "Input and document state records") |
| 11 | Size | client | viewport width and height in CSS pixels (2 × f32), device scale (f32); the server gives it to the worker input protocol as a `size` message |
| 12 | Document state | server | one document state record |
| 13 | Glyphs | server | font number (u32) of a font on the file; compressed: glyph data ranges of the font file |
| 14 | Color glyph | server | font (u32), font size (f32), units per em (u32), text color (4 × f32, zero for a program that does not paint it), box (4 × f32: left, top, right, bottom in CSS px from the glyph origin, y down), cached (u8), path row count (u32); compressed: the path rows (font, glyph (2 × u32), box (4 × f32) in font units, y down), then the program (its operation length (u32), its text color flag (u32), its operations). The n-th Color glyph message of the connection installs cache slot n; the n-th path row installs path slot n |
| 15 | Take control | client | empty: the client asks to be the controller (see "Shared sessions") |
| 16 | Role | server | role (u8: 0 viewer, 1 controller), clients (u32): the client's role and the number of clients of the document |
| 17 | Variation | server | key (u16, 1 to 255), optical sizing off (u8, 0 or 1), pair count (u16), then for each pair its tag (u32) and value (f32): the `font-variation-settings` and `font-optical-sizing` control of one variation key; 5 + 8 × pair count bytes |

Every server writes the sequence of the frame as the command revision of
its Keyframe or Delta. The two fields are equal.

A range of a Font or Glyphs payload is its file offset (u32), its length
(u32) and its bytes. The payload is ranges to its end. A range outside the
file is error 17.

The file source of a Font message is the number of the first earlier font
of the connection whose file holds the same bytes, or 0xFFFFFFFF.
Instances of one font file, such as the weights of a variable font, carry
the file once. A file source that is not an earlier font is error 8. A
Font message whose file source is an earlier font carries payload ranges
only for another face of a collection file.

[The resources](resources.md) give the field tables of the resource
messages and the values of the Image enumerations.

### Compressed parts

The writer compresses the payload of each message with the codec of the
connection ("Codecs"), and the compressed part is the result:

| Codec | Compressed part |
| --- | --- |
| 1 zstd | One zstd frame (RFC 8878) of the payload |
| 2 deflate-raw | One raw deflate stream (RFC 1951) of the payload, without a zlib or gzip header |
| 4 none | The payload bytes |

The writer compresses every payload, also an empty payload, such as the
payload of a Font message that shares the file of an earlier font. The
compressed part carries no length of the payload: the client
decompresses the whole compressed part, and the payload is the result.
The content of each payload is in [the resources](resources.md) for the
resource messages and below for the frames.

### Input and document state records

An Input or Document state body is one record: its type (u8), then the
fields of that type in order.
A field is a u8, a u32, an f32 or an f64, or a string: a varint byte
length, then UTF-8 bytes. A body with fewer bytes than its fields is
error 3. A body with more bytes, or a record type that the message kind
does not have, is error 19. A field of the wrong kind, a field too many or
a missing field is error 19.

An input record carries one page message: an input event of the page,
such as a pointer move or a key press. A number that the message does not give is
NaN; the server leaves it out of the message it delivers.

| Type | Page message | Fields |
| --- | --- | --- |
| 1, 2, 3 | input `pointerDown`, `pointerMove`, `pointerUp` | x, y (f64), flags (u32), button, buttons (f32), pointer ID (f64), pointer type (u8: 0 mouse, 1 pen, 2 touch, 255 not given), pressure, tiltX, tiltY, twist, tangential pressure (f32), time in milliseconds (f64), width, height (f32) |
| 4, 5 | input `pointerLeave`, `pointerCancel` | pointer ID (f64) |
| 6 | input `wheel` | x, y, delta x, delta y (f64), delta mode (u8), flags (u32) |
| 7, 8 | input `keydown`, `keyup` | key, code (strings), location (u8), flags (u32) |
| 9 | input `insertText` | text, input type (strings; an empty input type is not given) |
| 10, 11, 12 | input `compositionStart`, `compositionUpdate`, `compositionEnd` | text (string), flags (u32) |
| 13 | input `systemFocus` | focused (u8) |
| 14 | input `paste` | text (string) |
| 15 | preferences | colour scheme, reduced motion, forced colours (strings) |
| 16, 17 | clipboard `copy`, `cut` | — |

The flags are the DOM core's `INPUT_FLAG_*` bits: 1 primary pointer, 2
Shift, 4 Alt, 8 Control, 16 Meta, 32 a repeated key, 64 a cancelled
composition.

A document state record carries one worker message of the worker input
protocol. After a frame, a server sends a state record to a client when
the document's state differs from the last state record that the client
received. A clipboard or failed record goes each time it occurs.

| Type | Worker message | Fields |
| --- | --- | --- |
| 1 | state | cursor given (u8), cursor keyword (string), text control focused (u8), caret given (u8), caret control (f64), caret point given (u8), caret x, y in CSS pixels (f64) |
| 2 | clipboard | text given (u8), text (string) |
| 3 | failed | message, stack (strings) |

### Delta operations

| Byte | Operation | Fields |
| --- | --- | --- |
| `stream` | `COPY` | source offset (varint), length (varint) |
| `8 + stream` | `INSERT` | length (varint), bytes |
| 255 | end of stream list | — |

`stream` is 0 to 5. The operations of a stream write the new bytes of that
stream in order. The operations of the streams are in stream order, and
one stream can have any number of operations. A stream without
operations is empty. `COPY` reads the base frame's stream of the same
index. A `COPY` outside the base stream, an operation of a stream before
the previous operation's stream, and an unknown operation byte are errors
that name the byte offset and the value. The byte 255 ends the
operations: a payload that ends before it is error 3. A writer writes no
byte after it.

### Encoder

The encoder indexes each base stream by 32-byte windows at each
4-byte-aligned offset, and keeps the first offset of each window hash. For
each offset of a current stream, the encoder tries the source that continues
the previous `COPY`, then the indexed source, and takes the longer match. A
match of at least 32 bytes becomes a `COPY`. Other bytes go into an
`INSERT`. The encoder writes a Keyframe instead of a Delta when the
operations are not smaller than the complete streams, when no base exists,
after a new connection, and after the
server writes a Configuration that differs from the last one it sent.

### Writing frames

A writer gives each frame of a connection these header fields:

- The sequence: 1 for the first frame of the connection, then the
  sequence of the frame before it plus 1.
- The command revision: the sequence.
- The resource messages: the number of resource messages (Configuration,
  Font, Glyphs, Color glyph, Image, Image release, Path and Variation)
  that the writer wrote on the connection before the frame.

A Keyframe is always valid. A Delta is valid only against a base frame
that the client keeps: on a connection, the newest frame that the client
acknowledged ("Pacing"); in a clip, the frame before it
([the clips](clips.md), "Frames"). The writer can choose any operations
that produce the streams of the new frame from the base: the encoder of
"Encoder" is one choice. Two examples:

- An `INSERT` of each whole stream is a valid Delta of every frame.
- A stream that equals the base stream is one `COPY` of the whole stream;
  a stream without operations is empty, not equal to the base.

The streams of a frame follow [the frame streams](streams.md). The
smallest valid frame draws only the background of the Configuration: its
stream 2 is the 8 zero bytes of scroll entry 0, and its other streams
are empty. The payload of its Keyframe is the 14 bytes
`00 00 08 00 00 00 00 00 00 00 00 00 00 00`.

## Writing messages

A writer of Glint messages, for a connection or for a clip, does these
steps. Each step names the section that gives its rules.

1. Write the start of the connection. On a connection, the client sends
   its Hello and the server answers with its Hello ("Codecs",
   "Messages"). In a clip, the Header takes the place of the Hello
   ([the clips](clips.md), "Header").
2. Write a Configuration before the first frame ("Configuration (2)" in
   [the resources](resources.md)).
3. For each frame, make the six streams ([the frame streams](streams.md)):
   the commands in the order of "Order of the commands", the glyph
   entries, the scroll table with entry 0, the gradient stops, the
   scrollbar rows, and the rows of stream 5 in their total order.
4. Give the fonts, the variation keys, the color glyph slots and the
   image and path indices their numbers ("Numbering for a writer" in
   [the resources](resources.md)).
5. Before the frame, write the resource messages that the client does
   not hold: Font with its file ranges, Variation, Glyphs, Color glyph,
   Path, Image and Image release ("Order of the resource messages" and
   the section of each message in [the resources](resources.md)).
   Compress each payload with the codec ("Compressed parts").
6. Write the frame as a Keyframe or a Delta ("Writing frames").
7. In a clip, put each message in its record, with the presentation time
   of each frame, and end the clip with its Index ([the clips](clips.md),
   "Records", "Frames", "Index" and "Writing a clip").
8. Keep each value inside "Limits".

The decoder of the conformance material
([glint.sandom.dev/decode](https://glint.sandom.dev/decode/)) checks a
clip with codec none against the tables of these documents.

## Errors

An error has a code, an offset and a value, as this table gives them. A
client that reports an error closes the connection.

| Code | Name | Value |
| --- | --- | --- |
| 1 | Unknown message kind | the kind |
| 2 | Varint too long | — |
| 3 | Body shorter than its fixed fields | the body length |
| 4 | Unknown delta operation | the operation byte |
| 5 | `COPY` outside the base stream | the end of the copy |
| 6 | Stream out of order | the stream index |
| 7 | Delta base is not a frame that the client keeps | the client's current sequence |
| 8 | Font number without a Font message, or a Font message that the client cannot register | the font number; the offset is the number of Font messages of the connection. A file source that is not an earlier font also gives error 8 |
| 9 | Allocation failed | the byte count |
| 10 | Format version differs | the received version; the offset is the format version of the receiving endpoint (8), so the error names both versions |
| 11 | Acknowledge of a frame that is not in flight | the received sequence |
| 12 | Operation in the wrong endpoint state | the endpoint flags, or the entry kind |
| 13 | The core has no definition of the path | the path index |
| 14 | A glyph stream of more than 161,319 entries ("Limits"), or a frame while the client keeps all its frame slots | the stream length, or the frame's sequence |
| 15 | No codec in common, or a codec the client did not offer | the codec bits |
| 16 | A frame draws a canvas or a video frame | the image index |
| 17 | A font file range or table outside the file, a glyph ID past the file's glyph count, or a malformed table record | the length, glyph count or table tag; the offset is the file offset or the glyph ID |
| 18 | A frame's command stream breaks a rule of [the frame streams](streams.md): a command that format 8 does not have or that the end of the stream cuts, a rect with `flags & 3` = 0, a text glyph span outside stream 1 or a `glyphOffset` that is not a multiple of 14, a gradient stop span outside stream 3, an extend mode of 3 or reflect on a CSS kind, a text weight of 0 or above 1000, a variation key that no Variation message defined, an image kind above 1 or an image with flag bit 7, a path kind above 2 in an SVG path command or a path-mask clip entry, an image index or a path index outside the index space of its kind, a Color glyph command whose slot no Color glyph message installed | the opcode or the field (the index for an index outside its space); the offset is the byte offset of the command in stream 0 |
| 19 | A record type the message kind does not have, a record field of the wrong kind, too many or too few fields, or a body longer than its record; a Variation message whose key is 0, above 255, already defined or not the next key, or whose optical sizing byte is above 1 | the record type, the field code or the field count; the offset is the message kind or the field index; for a Variation message, the key or the optical sizing byte |
| 20 | A Color glyph slot or path slot outside the capacity (the 16129th Color glyph message of the connection, the 16385th path row of the connection, or a program path slot that no path row installed), or a program that breaks a rule of "Color glyph" in [the resources](resources.md): an operation length below 4 or past the program, an unknown operation code, a length that differs from the length of the code, a FILL stop count of 0 or above 255, a pop that does not close the innermost open group, clip or mask, a depth above 32, or an operation that stays open at the end | the slot or the path slot, and the offset is the capacity (16128 or 16384); for a program rule, the length, code, stop count, path slot or depth, and the offset is the byte offset of the operation in the program |
| 21 | A stream of a frame that breaks its record rules before the client plans the frame: a stream 1 length that is not a multiple of 14; a stream 2 length that is not a multiple of 8 or is less than 8; a stream 3 length that is not a multiple of 28; a stream 4 length that is not a multiple of 40; a stream 5 that is not empty and not `4 + 20 × count` bytes; a row kind above 1; a glyph row whose font number has no Font message, whose variation key no Variation message defined, or whose font size or optical size is negative or not finite; a path row whose path kind is above 2, whose path index is outside the index space of its path kind, or whose screen size is negative or not finite | for a stream length, the offset is the length and the value is the stream index; for a row field, the offset is the byte offset of the field in stream 5 and the value is the field |
| 22 | An image whose encoding format 8 does not carry: an ICC transfer function at the server, or an enumeration value outside its table at the client ("Image" in [the resources](resources.md)) | the field; the offset is the byte offset of the field in the Image body |
| 23 | An Image, Image release or Path message names a kind that format 8 does not have, or an index outside the index space of its kind ("Identities" in [the resources](resources.md)) | the index; the offset is the kind |

A frame that breaks a rule of [the frame streams](streams.md) gives error
21, error 18, error 8 or a raster plan failure ("Validation" in the frame
streams). The client
reports a raster plan failure with the code, the command offset, the
value and the limit, and closes the connection.

## Limits

| Limit | Value | Error |
| --- | --- | --- |
| Fonts of a connection | 512 | 8 |
| Variation keys of a connection | 255 (keys 1 to 255) | 18 |
| Glyphs of one text command | 65535 | none: the count is a u16 |
| Glyph entries of stream 1 | 161,319 | 14 |
| Clip entries of one push clip | 8 | raster plan failure 2 |
| Stops of one gradient | 255 | none: the count is a u8 |
| Prepared stops of one gradient | 64 | none |
| Scroll entries | 65536 (u16 references) | raster plan failure 5 |
| Decoded image indices (image kind 0) | 32768 (0 to 32767) | 18, 23 |
| Color glyph bitmap indices (image kind 1) | 16384 (0 to 16383) | 18, 23 |
| SVG path indices (path kind 0) | 32768 (0 to 32767) | 18, 21, 23 |
| Color glyph layer path indices (path kind 1) | 16384 (0 to 16383) | 18, 21, 23 |
| Text stroke path indices (path kind 2) | 16381 (0 to 16380) | 18, 21, 23 |
| Color glyph cache slots | 16128 | 20 |
| Color glyph path slots | 16384 | 20 |
| Color glyph program depth | 32 | 20 |
| Frames that a client keeps | 19 | 14 |

A producer keeps each value at or below its limit. A client that
receives a value above a limit reports the error of the table.
