Here is the binary version of a DRW file with the various components colored:
68 61 72 70 66 6c 61 74 20 73 74 61 63 63 74 72 69 6c 6c 77 68 6f 6c 65 74
65 6e 75 74 62 61 73 73 20 61 6c 74 6f 20 70 65 72 63 20 6d 6f 72 64 20 48
81 5a 00 7e ff 01 00 5b 00 14 00 00 00 5c 00 15 00 02 00 00 00 16 00 00 00
01 00 e0 ff 00 00 5f 00 eb ff 00 00 5d 00 16 00 00 00 5c 00 0f 00 03 00 5b
00 f2 ff 00 00 04 00 f3 ff 00 00 05 00 0d 00 00 00 50 00 0d 00 00 00 5a 00
8c 00 01 00 5c 00 eb ff 00 00 6a 00 ec ff 02 00 00 00 e9 ff 00 00 00 00 18
00 00 00 50 00 16 00 00 00 55 00 eb ff 00 00 58 00 f4 ff 03 00 5a 00 0e 00
00 00 05 00 81 81 0e 00 00 00 01 00 f4 ff 00 00 5a 00 f3 ff 00 00 2f 00 6d
ff 01 00 2d 00 14 00 00 00 31 00 15 00 02 00 01 00 16 00 00 00 00 00 eb ff
00 00 2d 00 e9 ff 00 00 2c 00 16 00 00 00 2b 00 0b 00 03 00 2a 00 f5 ff 00
00 05 00 f3 ff 00 00 03 00 0d 00 00 00 2e 00 0e 00 00 00 30 00 8c 00 01 00
30 00 eb ff 00 00 31 00 ec ff 02 00 01 00 e9 ff 00 00 00 00 16 00 00 00 28
00 16 00 00 00 2a 00 eb ff 81 81 00 00 2e 00 f1 ff 03 00 2e 00 0f 00 00 00
02 00 0f 00 00 00 02 00 f1 ff 00 00 2e 00 f1 ff 00 00 30 00 19 00 02 00 00
00 19 00 00 00 00 00 e7 ff 00 00 30 00 e7 ff 00 00 30 00 19 00 00 00 2a 00
0f 00 03 00 2a 00 f1 ff 00 00 06 00 f1 ff 00 00 04 00 0f 00 00 00 2c 00 0f
00 00 00 30 00 19 00 02 00 02 00 19 00 00 00 02 00 e9 ff 00 00 30 00 e9 ff
00 00 2e 00 17 00 00 00 19 00 16 00 02 00 81 81 00 00 00 00 00 00 17 00 ea
ff 00 00 2b 00 02 00 00 00 17 00 18 00 00 00 0d 00 0d 00 03 00 2b 00 fd ff
00 00 21 00 f3 ff 00 00 08 00 03 00 00 00 0d 00 0d 00 00 00 17 00 17 00 02
00 00 00 00 00 00 00 17 00 e6 ff 00 00 2b 00 00 00 00 00 17 00 1a 00 00 00
17 00 7f 00 01 00 17 00 19 00 00 00 17 00 14 00 02 00 00 00 00 00 00 00 17
00 ea ff 00 00 2b 00 00 00 00 00 17 00 0c 00 00 00 0d 00 81 46 0c 00 02 00
28 00 f8 ff 00 00 1c 00 ee ff 00 00 07 00 06 00 00 00 0f 00 10 00 00 00 16
00 7e 00 01 00 17 00 17 00 00 00 18 00 17 00 02 00 00 00 00 00 00 00 1a 00
e6 ff 00 00 27 00 00 00 00 00 17 00 1a 00 00 00
The meaning of each colored section:
- first byte — The first byte in a DRW file is always hex 4b, or decimal 180.
- starting chunk size — Data bytes are stored in chunks, with each chunk starting with a single byte chunk size. This is the number of bytes in the chunk following the value which are data bytes. The header chunk always has 72 (hex 48) bytes. Vector data chunks usually have 129
- ending chunk size — All chunks except the last one are terminated with a duplicate byte count for the chunk. This byte is not considered when counting the bytes in the header chunk, but is considered when counting the bytes in subsequent vector data chunks.
- vector word offsets — This
is a list of the two-byte word offsets for the vectors describing
each symbol. The offsets are themselves given as two-byte integers
in little endian format. There are always 11 offset numbers (22 bytes),
with the first offset always being 1. The count of numbers in
each symbol's vector is the next offset minus the current offset, with
the last offset giving the total count of numbers in the list of
vectors.
For this example:
01 00 → 1 → 37 – 1 = 36 numbers = 12 vectors for symbol 0
25 00 → 37 → 73 – 37 = 36 numbers = 12 vectors for symbol 1
49 00 → 73 → 109 – 73 = 36 numbers = 12 vectors for symbol 2
6d 00 → 109 → 145 – 109 = 36 numbers = 12 vectors for symbol 3
91 00 → 145 → 175 – 145 = 30 numbers = 10 vectors for symbol 4
af 00 → 175 → 190 – 175 = 15 numbers = 5 vectors for symbol 5
be 00 → 190 → 220 – 190 = 30 numbers = 10 vectors for symbol 6
dc 00 → 200 → 235 – 220 = 15 numbers = 5 vectors for symbol 7
eb 00 → 235 → 271 – 235 = 36 numbers = 12 vectors for symbol 8
0f 01 → 271 → 292 – 271 = 21 numbers = 7 vectors for symbol 9
24 01 → 292 → 291 data numbers in file → 97 vectors in file.The offset values should always increase, but may be set to 0 if there is no symbol for the given position. The last number is always the total number of bytes in the vectors plus one (which may repeat the value of the last non-zero entry.
The differences between successive offsets must always be divisible by three without a remainder. The byte size of the first symbol in this example is 37 – 1 = 36, which is divisible by three. This means that there are 12 vectors defining the first symbol in the file.
- symbol labels —
Each symbol can be given a five-character (ASCII bytes) name. If the name
is less than five characters, then the rest of the space for a name is padded
with space characters. The names cannot exceed five characters.
Here are the ten symbol names for the example file:
73 68 61 72 70 → "sharp"
66 6c 61 74 20 → "flat"
73 74 61 63 63 → "stacc"
74 72 69 6c 6c → "trill"
77 68 6f 6c 65 → "whole"
74 65 6e 75 74 → "tenut"
62 61 73 73 20 → "bass"
61 6c 74 6f 20 → "alto"
70 65 72 63 20 → "perc"
6d 6f 72 64 20 → "mord"These labels are not used by the SCORE editor, but can be useful for figuring out the purpose of the symbol.
- vector data —
For each symbol in the file a list of vectors is given in
all subsequent chunks after the header chunk. Each vector consists
of three numbers, and each number is stored as a two-byte signed
little endian integer. The byte offsets in the header are used to
count the number of vector bytes for each symbol. The chunk byte
sizes are not counted in the header offsets.
Here are the bytes describing the vectors of the first symbol:
5a 00 7e ff 01 00 → (90, -130, 1)
5b 00 14 00 00 00 → (91, 20, 0)
5c 00 15 00 02 00 → (92, 21, 2)
00 00 16 00 00 00 → (0, 22, 0
01 00 e0 ff 00 00 → (1, -32, 0)
5f 00 eb ff 00 00 → (95, -21, 0)
5d 00 16 00 00 00 → (93, 22, 0)
5c 00 0f 00 03 00 → (92, 15, 3)
5b 00 f2 ff 00 00 → (91, -14, 0)
04 00 f3 ff 00 00 → (4, -13, 0)
05 00 0d 00 00 00 → (5, 13, 0)
50 00 0d 00 00 00 → (80, 13 ,0)The first two numbers describe the horizontal and vertical positions of a point in the outline of a font. The origin is at (0, 0) and coordinates can be positive or negative. Coordinates can only be two-byte signed integers. The default scale means that the height of a staff space is 7 units. Typically symbols will be described at a larger scale and then shrunk when placing on the page. For example the treble clef symbol is described at 8 times its normal scaling. This is equivalent to allowing fractional values for the coordinates.
The third number in a vector triplet describes operations on the outline:
- 0 = draw a straight line from the previous point to the current point.
- 1 = start a new line.
- 2 = start a filled area. Note that all fill areas are also stroked (with the width determined at print time, so filled areas are thinner than the final graphical shape which has an extra border due to the stroking.
- 3 = start an unfilled area within a filled area.
ASCII encodings of DRAW data
Here are several sample encodings of the DRAW files in ASCII formats, which match to the above binary example data. First in the ATON format:@@BEGIN: MUSIC_FONT_LIBRARY @@BEGIN: SYMBOL @LABEL: sharp @LIBINDEX: 0 @DEFINITION: 90 -130 1 91 20 0 92 21 2 0 22 0 1 -32 0 95 -21 0 93 22 0 92 15 3 91 -14 0 4 -13 0 5 13 0 80 13 0 @@END: SYMBOL @@BEGIN: SYMBOL @LABEL: flat @LIBINDEX: 1 @DEFINITION: 90 140 1 92 -21 0 106 -20 2 0 -23 0 0 24 0 80 22 0 85 -21 0 88 -12 3 90 14 0 5 14 0 1 -12 0 90 -13 0 @@END: SYMBOL @@BEGIN: SYMBOL @LABEL: stacc @LIBINDEX: 2 @DEFINITION: 47 -147 1 45 20 0 49 21 2 1 22 0 0 -21 0 45 -23 0 44 22 0 43 11 3 42 -11 0 5 -13 0 3 13 0 46 14 0 @@END: SYMBOL @@BEGIN: SYMBOL @LABEL: trill @LIBINDEX: 3 @DEFINITION: 48 140 1 48 -21 0 49 -20 2 1 -23 0 0 22 0 40 22 0 42 -21 0 46 -15 3 46 15 0 2 15 0 2 -15 0 46 -15 0 @@END: SYMBOL @@BEGIN: SYMBOL @LABEL: whole @LIBINDEX: 4 @DEFINITION: 48 25 2 0 25 0 0 -25 0 48 -25 0 48 25 0 42 15 3 42 -15 0 6 -15 0 4 15 0 44 15 0 @@END: SYMBOL @@BEGIN: SYMBOL @LABEL: tenut @LIBINDEX: 5 @DEFINITION: 48 25 2 2 25 0 2 -23 0 48 -23 0 46 23 0 @@END: SYMBOL @@BEGIN: SYMBOL @LABEL: bass @LIBINDEX: 6 @DEFINITION: 25 22 2 0 0 0 23 -22 0 43 2 0 23 24 0 13 13 3 43 -3 0 33 -13 0 8 3 0 13 13 0 @@END: SYMBOL @@BEGIN: SYMBOL @LABEL: alto @LIBINDEX: 7 @DEFINITION: 23 23 2 0 0 0 23 -26 0 43 0 0 23 26 0 @@END: SYMBOL @@BEGIN: SYMBOL @LABEL: perc @LIBINDEX: 8 @DEFINITION: 23 127 1 23 25 0 23 20 2 0 0 0 23 -22 0 43 0 0 23 12 0 13 12 2 40 -8 0 28 -18 0 7 6 0 15 16 0 @@END: SYMBOL @@BEGIN: SYMBOL @LABEL: mord @LIBINDEX: 9 @DEFINITION: 22 126 1 23 23 0 24 23 2 0 0 0 26 -26 0 39 0 0 23 26 0 @@END: SYMBOL @@END: MUSIC_FONT_LIBRARY
In the JSON format:
[ { "label" : "sharp", "libindex" : 0, "definition": [ [90, -130, 1], [91, 20, 0], [92, 21, 2], [0, 22, 0], [1, -32, 0], [95, -21, 0], [93, 22, 0], [92, 15, 3], [91, -14, 0], [4, -13, 0], [5, 13, 0], [80, 13, 0] ] }, { "label" : "flat", "libindex" : 1, "definition": [ [90, 140, 1], [92, -21, 0], [106, -20, 2], [0, -23, 0], [0, 24, 0], [80, 22, 0], [85, -21, 0], [88, -12, 3], [90, 14, 0], [5, 14, 0], [1, -12, 0], [90, -13, 0] ] }, { "label" : "stacc", "libindex" : 2, "definition": [ [47, -147, 1], [45, 20, 0], [49, 21, 2], [1, 22, 0], [0, -21, 0], [45, -23, 0], [44, 22, 0], [43, 11, 3], [42, -11, 0], [5, -13, 0], [3, 13, 0], [46, 14, 0] ] }, { "label" : "trill", "libindex" : 3, "definition": [ [48, 140, 1], [48, -21, 0], [49, -20, 2], [1, -23, 0], [0, 22, 0], [40, 22, 0], [42, -21, 0], [46, -15, 3], [46, 15, 0], [2, 15, 0], [2, -15, 0], [46, -15, 0] ] }, { "label" : "whole", "libindex" : 4, "definition": [ [48, 25, 2], [0, 25, 0], [0, -25, 0], [48, -25, 0], [48, 25, 0], [42, 15, 3], [42, -15, 0], [6, -15, 0], [4, 15, 0], [44, 15, 0] ] }, { "label" : "tenut", "libindex" : 5, "definition": [ [48, 25, 2], [2, 25, 0], [2, -23, 0], [48, -23, 0], [46, 23, 0] ] }, { "label" : "bass", "libindex" : 6, "definition": [ [25, 22, 2], [0, 0, 0], [23, -22, 0], [43, 2, 0], [23, 24, 0], [13, 13, 3], [43, -3, 0], [33, -13, 0], [8, 3, 0], [13, 13, 0] ] }, { "label" : "alto", "libindex" : 7, "definition": [ [23, 23, 2], [0, 0, 0], [23, -26, 0], [43, 0, 0], [23, 26, 0] ] } { "label" : "perc", "libindex" : 8, "definition": [ [23, 127, 1], [23, 25, 0], [23, 20, 2], [0, 0, 0], [23, -22, 0], [43, 0, 0], [23, 12, 0], [13, 12, 2], [40, -8, 0], [28, -18, 0], [7, 6, 0], [15, 16, 0] ] }, { "label" : "mord", "libindex" : 9, "definition": [ [22, 126, 1], [23, 23, 0], [24, 23, 2], [0, 0, 0], [26, -26, 0], [39, 0, 0], [23, 26, 0] ] } ]
And in the XML format:
<?xml version="1.0" encoding="UTF-8"?> <MusicFontLibrary> <symbol label="sharp" libIndex="0"> <definition> <vector x="90" y="-130" type="1"/> <vector x="91" y="20" type="0"/> <vector x="92" y="21" type="2"/> <vector x="0" y="22" type="0"/> <vector x="1" y="-32" type="0"/> <vector x="95" y="-21" type="0"/> <vector x="93" y="22" type="0"/> <vector x="92" y="15" type="3"/> <vector x="91" y="-14" type="0"/> <vector x="4" y="-13" type="0"/> <vector x="5" y="13" type="0"/> <vector x="80" y="13" type="0"/> </definition> </symbol> <symbol label="flat" libIndex="1"> <definition> <vector x="90" y="140" type="1"/> <vector x="92" y="-21" type="0"/> <vector x="106" y="-20" type="2"/> <vector x="0" y="-23" type="0"/> <vector x="0" y="24" type="0"/> <vector x="80" y="22" type="0"/> <vector x="85" y="-21" type="0"/> <vector x="88" y="-12" type="3"/> <vector x="90" y="14" type="0"/> <vector x="5" y="14" type="0"/> <vector x="1" y="-12" type="0"/> <vector x="90" y="-13" type="0"/> </definition> </symbol> <symbol label="stacc" libIndex="2"> <definition> <vector x="47" y="-147" type="1"/> <vector x="45" y="20" type="0"/> <vector x="49" y="21" type="2"/> <vector x="1" y="22" type="0"/> <vector x="0" y="-21" type="0"/> <vector x="45" y="-23" type="0"/> <vector x="44" y="22" type="0"/> <vector x="43" y="11" type="3"/> <vector x="42" y="-11" type="0"/> <vector x="5" y="-13" type="0"/> <vector x="3" y="13" type="0"/> <vector x="46" y="14" type="0"/> </definition> </symbol> <symbol label="trill" libIndex="3"> <definition> <vector x="48" y="140" type="1"/> <vector x="48" y="-21" type="0"/> <vector x="49" y="-20" type="2"/> <vector x="1" y="-23" type="0"/> <vector x="0" y="22" type="0"/> <vector x="40" y="22" type="0"/> <vector x="42" y="-21" type="0"/> <vector x="46" y="-15" type="3"/> <vector x="46" y="15" type="0"/> <vector x="2" y="15" type="0"/> <vector x="2" y="-15" type="0"/> <vector x="46" y="-15" type="0"/> </definition> </symbol> <symbol label="whole" libIndex="4"> <definition> <vector x="48" y="25" type="2"/> <vector x="0" y="25" type="0"/> <vector x="0" y="-25" type="0"/> <vector x="48" y="-25" type="0"/> <vector x="48" y="25" type="0"/> <vector x="42" y="15" type="3"/> <vector x="42" y="-15" type="0"/> <vector x="6" y="-15" type="0"/> <vector x="4" y="15" type="0"/> <vector x="44" y="15" type="0"/> </definition> </symbol> <symbol label="tenut" libIndex="5"> <definition> <vector x="48" y="25" type="2"/> <vector x="2" y="25" type="0"/> <vector x="2" y="-23" type="0"/> <vector x="48" y="-23" type="0"/> <vector x="46" y="23" type="0"/> </definition> </symbol> <symbol label="bass" libIndex="6"> <definition> <vector x="25" y="22" type="2"/> <vector x="0" y="0" type="0"/> <vector x="23" y="-22" type="0"/> <vector x="43" y="2" type="0"/> <vector x="23" y="24" type="0"/> <vector x="13" y="13" type="3"/> <vector x="43" y="-3" type="0"/> <vector x="33" y="-13" type="0"/> <vector x="8" y="3" type="0"/> <vector x="13" y="13" type="0"/> </definition> </symbol> <symbol label="alto" libIndex="7"> <definition> <vector x="23" y="23" type="2"/> <vector x="0" y="0" type="0"/> <vector x="23" y="-26" type="0"/> <vector x="43" y="0" type="0"/> <vector x="23" y="26" type="0"/> </definition> } <symbol label="perc" libIndex="8"> <definition> <vector x="23" y="127" type="1"/> <vector x="23" y="25" type="0"/> <vector x="23" y="20" type="2"/> <vector x="0" y="0" type="0"/> <vector x="23" y="-22" type="0"/> <vector x="43" y="0" type="0"/> <vector x="23" y="12" type="0"/> <vector x="13" y="12" type="2"/> <vector x="40" y="-8" type="0"/> <vector x="28" y="-18" type="0"/> <vector x="7" y="6" type="0"/> <vector x="15" y="16" type="0"/> </definition> </symbol> <symbol label="mord" libIndex="9"> <definition> <vector x="22" y="126" type="1"/> <vector x="23" y="23" type="0"/> <vector x="24" y="23" type="2"/> <vector x="0" y="0" type="0"/> <vector x="26" y="-26" type="0"/> <vector x="39" y="0" type="0"/> <vector x="23" y="26" type="0"/> </definition> </symbol> <MusicFontLibrary>