M193 Fonts

M193 is a font format that uses opcodes to describe which is which.

The Opcodes

0x5a   Point         int16 x,y;
0x3f   Line          int16 x1,y1,x2,y2;
0x7c   Oval          int16 x1,y1,x2,y2;
0x7e   Circle        int16 cx,cy; int8 radius;
0xfc   Arc           int16 cx,cy,startAngle,sweepAngle; int8 radius;
0xfe   Oval Arc      int16 x1,y1,x2,y2,startAngle,sweepAngle;
0xfd   Rect.         int16 x1,y1,x2,y2;

The Header

Offset  Size  Description
=========================
0       5     Always "M193F".
5       4     Amount of 9 byte structures.

Followed by a contiguous array of this 9 byte structure:

Offset  Size  Description
=========================
0       4     UTF-32 character.
4       4     Pointer to the opcode list.
8       1     Size in bytes of the opcode list.

Integers

An "integer" is no ordinary integer.

Offset  Size  Description
=========================
0       1     A descriptor:
                  Bit    Description
                  ==================
                  0      1 for a math integer, otherwise 0. If 0, next 2 bits must be 0.
                  1      1 if this uses height, otherwise 0.
                  2      1 if this uses width, otherwise 0.
                  3-7    Unused. Always 0.
1       VAR   Amount of the following structure. Or if bit D0 of descriptor is 0, this is the integer.

Offset  Size  Description
=========================
0       1     Math opcode and integer size.
1       VAR   Integer.

Height and width number reservations

If only the height bit is set, the highest integer is for height.
If only the width bit is set, the highest integer is for width.
If the height and width bits are set, the highest integer is for height and the second-highest for width.

Math Opcodes

Opcode   Description
====================
0x0      Used only at the beginning.
0x1      Add.
0x2      Subtract.
0x3      Multiply.
0xe      Divide.
0xf      Modulo.

Integer Sizes

Size    Bits in integer
0       8
1       16
2       32

Math Opcode and Integer Size Structures

These are generated by (mathOpcode << 4) | integerSize.