aboutsummaryrefslogtreecommitdiff
path: root/man/man7/font.7
blob: c9ebb9197fb337f416486ae057c3987a8b53e711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
.TH FONT 7
.SH NAME
font, subfont \- external format for fonts and subfonts
.SH SYNOPSIS
.B #include <draw.h>
.SH DESCRIPTION
Fonts and subfonts are described in
.MR cachechars (3) .
.PP
External bitmap fonts are described by a plain text file that can be read using
.IR openfont .
The format of the file is a header followed by any number of
subfont range specifications.
The header contains two numbers: the height and the ascent, both in pixels.
The height is the inter-line spacing and the ascent is the distance
from the top of the line to the baseline.  These numbers are chosen
to display consistently all the subfonts of the font.
A subfont range specification contains two or three numbers and a file name.
The numbers are the inclusive range of characters covered by the subfont,
with an optional starting position within the subfont,
and the file name names an external file suitable for
.I readsubfont
(see
.MR graphics (3) ).
The minimum number of a covered range is mapped to the specified starting position
(default zero) of the
corresponding subfont.
If the subfont file name does not begin with a slash, it is taken relative to the
directory containing the font file.
Each field must be followed by some white space.
Each numeric field may be C-format decimal, octal, or hexadecimal.
.PP
External subfonts are represented in a more rigid format
that can be read and written using
.I readsubfont
and
.I writesubfont
(see
.MR subfont (3) ).
The format for subfont files is: an image containing character glyphs,
followed by a subfont header, followed by character information.
The image has the format for external image files described in
.MR image (7) .
The subfont header has 3
decimal strings:
.BR n ,
.BR height ,
and
.BR ascent .
Each number is right-justified and blank padded in 11 characters, followed by a blank.
The character
.B info
consists of
.BR n +1
6-byte entries, each giving the
.B Fontchar
.B x
(2 bytes, low order byte first),
.BR top ,
.BR bottom ,
.BR left ,
and
.BR width .
The
.B x
field of the last
.B Fontchar
is used to calculate the image width
of the previous character; the other fields in the last
.B Fontchar
are irrelevant.
.PP
Note that the convention of using the character with value zero (NUL) to represent
characters of zero width (see
.MR draw (3) )
means that fonts should have, as their zeroth character,
one with non-zero width.
.SS "Font Names
.PP
Font names in Plan 9 from User Space are
a small language describing a font.
The most basic form is the name of an existing bitmap font file,
following the convention:
.IP
.B /lib/font/bit/\fIname\fP/\fIrange\fP.\fIsize\fP.font
.PD
.PP
where
.I size
is approximately the height in pixels of the lower case letters
(without ascenders or descenders).
.I Range
gives some indication of which characters will be available: for example
.BR ascii ,
.BR latin1 ,
.BR euro ,
or
.BR unicode .
.B Euro
includes most European languages, punctuation marks, the International Phonetic
Alphabet, etc., but no Oriental languages.
.B Unicode
includes every character for which appropriate-sized images exist on the system.
.PP
In Plan 9 from User Space, the font files are rooted in
.B $PLAN9/font
instead of
.BR /lib/font/bit ,
but to keep old references working, paths beginning with
.B /lib/font/bit
are interpreted as references to the actual font directory.
.PP
Fonts need not be stored on disk in the Plan 9 format.
If the font name has the form
.BR /mnt/font/\fIname\fP/\fIsize\fP/font ,
.I fontsrv
is invoked to synthesize a bitmap font from the operating system's installed vector fonts.
The command
.B fontsrv
.B -p
.B .
lists the available fonts.
See
.MR fontsrv (4)
for more.
.PP
If the font name has the form
.BR \fIscale\fP*\fIfontname\fP ,
where
.I scale
is a small decimal integer, the 
.I fontname
is loaded and then scaled by pixel repetition.
.PP
The Plan 9 bitmap fonts were designed for screens with pixel density around 100 DPI.
When used on screens with pixel density above 200 DPI,
the bitmap fonts are automatically pixel doubled.
Similarly, fonts loaded from
.MR fontsrv (4)
are automatically doubled in size by varying the effective
.I size
path element.
In both cases, the effect is that a single font name
can be used on both low- and high-density displays (or even in a window moved between differing displays)
while keeping roughly the same effective size.
.PP
For more control over the fonts used on low- and high-density displays,
if the font name has the form
.BR \fIlowfont\fP,\fIhighfont\fP ,
.I lowfont
is used on low-density displays and
.I highfont
on high-density displays.
In effect, the behavior described above is that the font name
.IP
.B /lib/font/bit/lucsans/euro.8.font
.PD
.PP
really means
.IP
.B /lib/font/bit/lucsans/euro.8.font,2*/lib/font/bit/lucsans/euro.8.font
.PD
.PP
and similarly
.IP
.B /mnt/font/LucidaGrande/15a/font
.PD
.PP
really means
.IP
.B /mnt/font/LucidaGrande/15a/font,/mnt/font/LucidaGrande/30a/font
.PD
.PP
Using an explicit comma-separated font pair allows finer control, such as
using a Plan 9 bitmap font on low-density displays but switching to
a system-installed vector font on high-density displays:
.IP
.B /lib/font/bit/lucsans/euro.8.font,/mnt/font/LucidaGrande/30a/font
.PD
.PP
.SH FILES
.TF \*9/font/*
.TP
.B \*9/font/*
font directories
.SH "SEE ALSO"
.MR graphics (3) ,
.MR draw (3) ,
.MR cachechars (3) ,
.MR subfont (3)