📄 afont.htm
字号:
<html>
<head>
<title>font file format</title>
</head>
<body bgcolor="#ffffff" background="../jpg/di1.JPG">
<p align="center"><font size="6" color="#0000ff"><strong>font file format</strong></font></p>
<div align="center"><center>
<table border="0" width="80%">
<tr>
<td width="100%" height="258">(the original information can be found on page 1801 of
volume iv of the <strong>risc os 3.1 programmer's reference manual</strong>) <br>
<a href="afontz.htm">本文的中文版</a><hr>
<p>fonts are decribed in: <ul>
<li><a href="#intmetrics">intmetrics</a> </li>
<li><a href="#x90y45">x90y45 file</a> (old style 4-bpp bitmaps) </li>
<li><a href="#new_font">new font file formats</a> </li>
</ul>
<a name="intmetrics"><h3>intmetrics</h3>
<pre>
<strong>
size description</strong>
40 name of font, padded with <em>return</em> (&0d) characters
4 16
4 16
1 <em>n</em>=number of defined characters
3 reserved - currently 0
256 character mapping (ie indices into following arrays). for
example, if the 40th byte in this block is 4, then the fourth
entry in each of the following arrays refers to that character.
a zero entry means that character is not defined in this font.
2n x0 |
2n y0 | bounding cox of character (in 1/1000th em)
2n x1 | coordinates are relative to the '<em>origin point</em>'
2n y1 |
2n x-offset after printing this character
2n y-offset after printing this character
</pre>
<p>the bounding boxes and offsets are given as 16-bit signed numbers, with the low byte
first.<br>
</a><a name="x90y45"></p>
<h3>x90y45 font files</h3>
<p>each font file starts with a series of 4-word index entries, corresponding to the sizes
defined: </p>
<pre>
<strong>
size description</strong>
1 point size (not multiplied by 16)
1 bits per pixel (4)
1 pixels per inch (x-direction)
1 pixels per inch (y-direction)
4 reserved - currently 0
4 offset of font data in file
4 size of font data
</pre>
<p>the list is terminated by: </p>
<pre>
1 0
</pre>
<h4>font data</h4>
<p>font data is limited to 64k per block. each block starts word-aligned relative to the
start of the file: <ul>
<pre>
<strong>
size description</strong>
4 x-size in 1/16ths point * x pixels per inch
4 y-size in 1/16ths point * y pixels per inch
4 pixels per inch in the x-direction
4 pixels per inch in the y-direction
1 x0 | maximum bounding box for any character
1 y0 | bottom-left is inclusive
1 x1 | top-rightis exclusive
1 y1 | all coordinates are in pixels
512 2 byte offsets from table start of character data. a zero value
means the character is not defined. these are low/high byte
pairs (ie little-endian)
</pre>
</ul>
<h4>character data</h4>
<ul>
<pre>
<strong>
size description</strong>
1 x0 | bounding box
1 y0 |
1 x1 - x0 = x
1 y1 - y0 = y
x*y/2 4-bits per pixel (bpp), consectutive rows bottom to top.
not aligned until at the end.
0 - 3.5 alignment
</pre>
</ul>
<hr>
<a name="new_font"><h3>new font file formats</h3>
<pre>the new font file formats includes definitions for the following types of font files:
</pre>
<ul>
<li>f9999x9999 (new style 4-bpp anti-aliased fonts) </li>
<li>b9999x9999 (1-bpp bitmaps) </li>
<li>outlines (outline font format, for all sizes) </li>
</ul>
<pre>'<em>9999</em>' = pixel size (ie point size * 16 * dpi / 72) zero-suppressed decimal number.
</pre>
<p>if the length of an outlines file is less than 256 bytes, then contents are the name of
another font whose glyphs are to be used instead (with this fonts metrics). </p>
<p>if the length of a <em>x90y45</em> file is less than 256 bytes then contents are the
name of the <em>f9999x9999</em> file to use as master bit maps. </p>
<h4>file header</h4>
<pre>the file header is of the following form:
</pre>
<pre>
<strong>
size description</strong>
4 "<em>font</em> - identification word
1 bits per pixel:
0 = outlines
1 = 1 bpp
4 = 4 bpp
1 version number of file format
4:no "don't draw skeleton lines unless smaller than this"
byte present
5:byte at [table+512] = max pixel size for skeleton
lines (0 => always do it)
6:byte at [chunk+indexsize] = dependency mask (see below)
</pre>
<h3></a><a name="instrument_data">instrument data</h3>
<pre>instrument names are not recorded; only channel numbers.
</pre>
<pre>
<strong>
size description</strong>
1 3 indicates <em>instrument</em> data follows
</pre>
<pre>this is followed by 8 blocks of 2 bytes each:
</pre>
<pre>
1 channel number. always consecutive 1-8
1 voice number; 0=no voice attached
</pre>
<h3>volume data</h3>
<pre>
<strong>
size description</strong>
1 4 indicates <em>volume</em> data follows
1*8 volume on each channel = 0-7 = ppp-fff. one byte for
each channel.
</pre>
<h3>stereo position data</h3>
<pre>
<strong>
size description</strong>
1 5 indicates <em>stereo</em> data follows
1*8 stereo position of channel n = 0-7 = full left...full right.
one byte for each channel.
</pre>
<h3>tempo data</h3>
<pre>
<strong>
size description</strong>
1 6 indicates <em>tempo</em> data follows
1 0-14, which corresponds to one of:
40, 50, 60, 65, 70, 80, 90, 100, 115, 130, 145, 160, 175, 190, 210
beats per minute
</pre>
<pre>to convert to values to program into swi sound_tempo, use the formula:
sound_tempo value = beats per minute * 128 * 4096/6000
</pre>
<h3>title string</h3>
<pre>
<strong>
size description</strong>
1 7 indicates <em>title string</em> follows
n null terminated string of <em>n</em> characters total length
</pre>
<h3>instrument names</h3>
<pre>
<strong>
size description</strong>
1 8 indicates <em>instrument names</em> follow
n1..n8 8 null terminated strings for each voice number used in
ascending order under </a><a
href="#instrument_data"><em>instrument data</em></a> above.
</pre>
<h3>midi channels</h3>
<pre>
<strong>
size description</strong>
1 9 indicates <em>midi</em> channel numbers follow
1*8 midi channel number from 1-16 on this stave for each
channel. 0 indicates not transmitted over midi.
</pre>
<h3><a name="gates">gates</h3>
<pre>a <em>gate</em> is a point in the music where something is interpreted. eg. a note,
time-signature, key-signature, bar-line or clef can each occupy a gate. the gate data
is one byte for a note or rest; 2 bytes for an attribute (time-signature, key-signature,
bar-line or clef).
</pre>
<h3>note or rest</h3>
<pre>
<strong>
bits description</strong>
0-7 gate mask, bit <em>n</em> set to 1 note or rest from queue <em>n</em>.
</pre>
<h3>attribute</h3>
<pre>
<strong>
byte description</strong>
0 0
1 could be any of the following forms:
<strong>time-signature</strong>
</pre>
<ul>
<strong><pre>bit(s) description</strong>
0 1
1-4 number of beats per bar - 1. in the range 0-15
5-7 beat type (0 = breve, to 7 = hemidemisemiquaver)
</pre>
</ul>
<strong><pre>key-signature</strong>
</pre>
<ul>
<strong><pre>bit(s) description</strong>
0-1 01 binary
2 0=#, 1=b
3-5 0 to 7
</pre>
</ul>
<strong><pre>clef</strong>
</pre>
<ul>
<strong><pre>bit(s) description</strong>
0-2 001 binary
3-4 0 = treble, 1 = alto, 2, = tenor, 3 = bass
5-6 stave - 1. in the range 0-3
</pre>
</ul>
<strong><pre>slur</strong>
</pre>
<ul>
<strong><pre>bit(s) description</strong>
0-3 0001 binary
4 1 = on, 0 = off
5 unused
6-7 stave - 1. in the range 0-3
</pre>
</ul>
<strong><pre>octave shift</strong>
</pre>
<ul>
<strong><pre>bit(s) description</strong>
0-4 00001 binary
5 0 = up, 1 = down
6-7 stave - 1. in the range 0-3
</pre>
</ul>
<strong><pre>bar</strong>
</pre>
<ul>
<strong><pre>bit(s) description</strong>
0-5 000001 binary
</pre>
</ul>
<strong><pre>reserved for future expansion</strong>
</pre>
<ul>
<strong><pre>bit(s) description</strong>
0-6 0000001 binary
</pre>
</ul>
<h3></a><a name="notes&rests">notes and rests</a></h3>
<p>notes and rests are each stored in a 2 byte block that has some common elements. </p>
<h3>notes</h3>
<pre>
<strong>
bit(s) description</strong>
0 stem orientation. 0 for up and 1 for down
1 set to 1 to join beams (barbs) to next note
2 set to 1 to tie with next note
3-7 stave line position 1-31 (16 is the centre line)
8-10 accidental
0 = natural
1 = sharp
2 = flat
3 = double-sharp
4 = double-flat
5 = natural sharp
6 = natural flat
7 = unused
11-12 number of dots, from 0-3
13-15 type. breve = 0 to hemisemidemiquaver = 7
</pre>
<h3>rests</h3>
<pre>
<strong>
bits description</strong>
0-10 unused. set to 0
11-12 number of dots, from 0-3
13-15 type. breve=0 to hemisemidemiquaver=7
</pre>
<p>if a rest coincides with a note, its position is determined by the following note on
the same channel. <br>
<br>
</td>
</tr>
</table>
</center></div>
<p align="center"><a href="../index.htm">返回</a></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -