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