Skip to content
Rebecca G. Bettencourt edited this page Sep 4, 2020 · 1 revision

Bits'N'Picas Vector Font Format

The Bits'N'Picas vector font format, used with the file extension kpcas, is a chunk-based binary file format with implied chunk lengths based on version numbers. It starts with a header and ends with a single tag. All multibyte values are big endian.

Bits'N'Picas Vector Font Format
int32 magic number 0x4B426E50 (KBnP) for start of file
int32 magic number 0x70636173 (pcas) for vector font header
int32 version number; only version 1 is currently defined
double em ascent (corresponds to TrueType hhea ascent)
double em descent (corresponds to TrueType hhea descent)
double line ascent (corresponds to TrueType OS/2 typoAscent)
double line descent (corresponds to TrueType OS/2 typoDescent)
double line gap (corresponds to TrueType OS/2 typoLineGap)
double x height
... chunks
int32 magic number 0x66696E2E (fin.) for end of file

There are two types of chunks currently defined: name and character chunks.

Name Chunks

Name chunks associate strings with the font. These strings may be copyright notices, font names, family names, style names, or so on. They correspond to TrueType name table entries.

Name Chunk Format
int32 magic number 0x6E616D65 (name) for name chunk
int32 version number; only version 1 is currently defined
int32 name type
int16 name length in bytes
byte[] UTF-8 encoded string

The following values are supported for the name type field, inherited from the TrueType name table specification:

Name Type Values
0 copyright notice
1 font family name
2 font style name
3 unique id
4 font family and style name
5 version
6 PostScript font name
7 trademark notice
8 manufacturer name
9 designer name
10 description
11 vendor URL
12 designer URL
13 license description
14 license URL
16 Windows font family name
17 Windows font style name
18 Mac OS font family and style name
19 sample text
20 PostScript CID
21 WWS naming system font family name
22 WWS naming system font style name

Character Chunks

Character chunks define the glyphs in the font. The glyph data is organized as an array of contours.

Character Chunk Format
int32 magic number 0x63686172 (char) for character chunk
int32 version number; only version 1 is currently defined
int32 Unicode code point for this character
double advance width
int32 number of contours
... contours

Each contour is organized as a series of instructions. Each instruction is a 32-bit integer followed by a specific number of double-precision floating point numbers depending on the instruction. There is no instruction count: the end of a contour is indicated by a terminating instruction.

instruction (int32) description parameters (double)
0x6D6F7665 (move) move to point 2: x0, y0
0x6C696E65 (line) line 2: x1, y1
0x71756164 (quad) quadratic curve 4: cx, cy, x1, y1
0x63756265 (cube) cubic curve 6: cx0, cy0, cx1, cy1, x1, y1
0x2F707468 (/pth) close segment 0
0x2F637472 (/ctr) end of contour 0
Clone this wiki locally