The infamous truetype embedding byte

This page explains how to read and alter the truetype embedding byte in a Windows truetype font using an ordinary off-the-shelf hex editor (hexadecimal digit editor). I use Pascal Rigaud's hexedit program, free open source code for UNIX, but there are plenty of similar free products for the Windows Operating System.

In a hex editor, a truetype font looks like this:

00000000   00 01 00 00  00 0F 00 30  00 03 00 C0  4F 53 2F 32  .......0....OS/2
00000010   93 D5 4D 17  00 01 09 00  00 00 00 4E  63 6D 61 70  ..M........Ncmap
00000020   E0 7D CE A5  00 00 F3 F8  00 00 04 76  63 76 74 20  .}.........vcvt
00000030   F8 9A 5C BE  00 00 03 B8  00 00 00 2C  66 70 67 6D  ..\........,fpgm
00000040   83 33 C2 4F  00 00 03 A4  00 00 00 14  67 6C 79 66  .3.O........glyf
00000050   12 D6 A4 30  00 00 04 20  00 00 E7 A2  68 64 6D 78  ...0... ....hdmx
00000060   B3 3C 73 BA  00 00 F8 B8  00 00 10 48  68 65 61 64  ..s........Hhead
00000070   C2 86 1D 6E  00 01 09 50  00 00 00 36  68 68 65 61  ...n...P...6hhea
00000080   11 5E 05 88  00 01 09 88  00 00 00 24  68 6D 74 78  .^.........$hmtx
00000090   3D E6 32 94  00 00 EF D0  00 00 04 08  6B 65 72 6E  =.2.........kern
000000A0   FE 3A FE A4  00 00 F8 70  00 00 00 48  6C 6F 63 61  .:.....p...Hloca
000000B0   00 70 A2 88  00 00 EB C4  00 00 04 0C  6D 61 78 70  .p..........maxp
000000C0   01 83 01 B2  00 01 09 AC  00 00 00 20  6E 61 6D 65  ........... name
000000D0   49 EE CE 20  00 00 00 FC  00 00 02 A6  70 6F 73 74  I.. ........post
000000E0   FF 66 00 65  00 00 F3 D8  00 00 00 20  70 72 65 70  .f.e....... prep
000000F0   83 EC FE 38  00 00 03 E4  00 00 00 39  00 00 00 15  ...8.......9....
00000100   01 02 00 00  00 00 00 00  00 00 00 5C  00 2E 00 00  ...........\....
00000110   00 00 00 00  00 01 00 10  00 92 00 00  00 00 00 00  ................
00000120   00 02 00 0E  00 A9 00 00  00 00 00 00  00 03 00 40  ...............@
00000130   00 EF 00 00  00 00 00 00  00 04 00 10  00 BF 00 00  ................
00000140   00 00 00 00  00 05 00 3E  01 4E 00 00  00 00 00 00  .........N......
00000150   00 06 00 10  01 94 00 01  00 00 00 00  00 00 00 2E  ................
00000160   00 00 00 01  00 00 00 00  00 01 00 08  00 8A 00 01  ................
00000170   00 00 00 00  00 02 00 07  00 A2 00 01  00 00 00 00  ................
.... (truncated)

Column 1 gives (hex notation) positions. The last column attempts to give ascii (text) interpretations and places a period if it can't find a symbol. The middle 16 columns each have one byte (in this particular example). So, for example, the first four bytes of the file are 00 01 00 and 00. That is in fact always the starting quartet for any Windows truetype file. Now look for the word OS/2, which is usually in the first few rows. It is the name of a table, and the table's position is given if you skip 4 bytes from the name: in this case, skipping 93 D5 4D 17, we get to 00 01 09 00. That is a magic address: it is the place of the OS/2 table's first byte! So, let's go there and check it out.

... (truncated)
000108E0   10 0C 0B 0B  10 10 0E 10  0E 0E 08 08  08 08 10 10  ................
000108F0   12 10 10 10  10 0B 10 0B  08 0D 09 0F  0A 0F 0A 0B  ................
00010900   00 00 03 A5  01 90 00 05  00 01 05 ED  05 80 00 00  ................
00010910   01 36 05 ED  05 80 00 00  03 D6 00 6C  02 31 00 00  .6.........l.1.. 
00010920   00 00 04 00  00 00 00 00  00 00 00 00  00 00 00 00  ................
00010930   00 00 00 00  00 00 00 00  00 00 41 6C  74 73 00 40  ..........Alts.@
00010940   00 20 F0 02  09 79 FE 00  00 00 09 79  01 F9 00 00  . ...y.....y....
... (truncated)

The OS/2 table thus starts with 00 00 03 A5. Now zip forward to the tenth byte in that table: 01. That is our baby. This is the crucial byte of the so-called fsType variable. It controls embedding of a font file. Here are the possible values:

00 or 01: font is embeddable and editable--total freedom
02 or 03: font can neither be embedded nor edited--useless
04, 05, 06 or 07: font can be embedded but not edited
08, 09, 0A, 0B, 0C, 0D, 0E, 0F: font can be edited but not embedded

To make the font embeddable and editable, just set that byte to 00, and save the file. You are done! Have fun.

CONTACT

Luc Devroye
School of Computer Science
McGill University
Montreal, Canada H3A 2K6
luc@cs.mcgill.ca
http://luc.devroye.org/index.html