1                  FreeType font driver for BDF fonts
2
3                       Francesco Zappa Nardelli
4                  <francesco.zappa.nardelli@ens.fr>
5
6
7Introduction
8************
9
10BDF (Bitmap Distribution Format) is a bitmap font format defined by Adobe,
11which is intended to be easily understood by both humans and computers.
12This code implements a BDF driver for the FreeType library, following the
13Adobe Specification V 2.2.  The specification of the BDF font format is
14available from Adobe's web site:
15
16  https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5005.BDF_Spec.pdf
17
18Many good bitmap fonts in bdf format come with XFree86 (www.XFree86.org).
19They do not define vertical metrics, because the X Consortium BDF
20specification has removed them.
21
22
23Encodings
24*********
25
26The variety of encodings that accompanies bdf fonts appears to encompass the
27small set defined in freetype.h.  On the other hand, two properties that
28specify encoding and registry are usually defined in bdf fonts.
29
30I decided to make these two properties directly accessible, leaving to the
31client application the work of interpreting them.  For instance:
32
33
34  #include FT_INTERNAL_BDF_TYPES_H
35
36  FT_Face          face;
37  BDF_Public_Face  bdfface;
38
39
40  FT_New_Face( library, ..., &face );
41
42  bdfface = (BDF_Public_Face)face;
43
44  if ( ( bdfface->charset_registry == "ISO10646" ) &&
45       ( bdfface->charset_encoding == "1" )        )
46    [..]
47
48
49Thus the driver always exports `ft_encoding_none' as face->charmap.encoding.
50FT_Get_Char_Index's behavior is unmodified, that is, it converts the ULong
51value given as argument into the corresponding glyph number.
52
53If the two properties are not available, Adobe Standard Encoding should be
54assumed.
55
56
57Anti-Aliased Bitmaps
58********************
59
60The driver supports an extension to the BDF format as used in Mark Leisher's
61xmbdfed bitmap font editor.  Microsoft's SBIT tool expects bitmap fonts in
62that format for adding anti-aliased them to TrueType fonts.  It introduces a
63fourth field to the `SIZE' keyword which gives the bpp value (bits per
64pixel) of the glyph data in the font.  Possible values are 1 (the default),
652 (four gray levels), 4 (16 gray levels), and 8 (256 gray levels).  The
66driver returns either a bitmap with 1 bit per pixel or a pixmap with 8bits
67per pixel (using 4, 16, and 256 gray levels, respectively).
68
69
70Known problems
71**************
72
73- A font is entirely loaded into memory.  Obviously, this is not the Right
74  Thing(TM).  If you have big fonts I suggest you convert them into PCF
75  format (using the bdftopcf utility): the PCF font drive of FreeType can
76  perform incremental glyph loading.
77
78When I have some time, I will implement on-demand glyph parsing.
79
80- Except for encodings properties, client applications have no visibility of
81  the PCF_Face object.  This means that applications cannot directly access
82  font tables and must trust FreeType.
83
84- Currently, glyph names are ignored.
85
86  I plan to give full visibility of the BDF_Face object in an upcoming
87  revision of the driver, thus implementing also glyph names.
88
89- As I have never seen a BDF font that defines vertical metrics, vertical
90  metrics are (parsed and) discarded.  If you own a BDF font that defines
91  vertical metrics, please let me know (I will implement them in 5-10
92  minutes).
93
94
95License
96*******
97
98Copyright (C) 2001-2002 by Francesco Zappa Nardelli
99
100Permission is hereby granted, free of charge, to any person obtaining
101a copy of this software and associated documentation files (the
102"Software"), to deal in the Software without restriction, including
103without limitation the rights to use, copy, modify, merge, publish,
104distribute, sublicense, and/or sell copies of the Software, and to
105permit persons to whom the Software is furnished to do so, subject to
106the following conditions:
107
108The above copyright notice and this permission notice shall be
109included in all copies or substantial portions of the Software.
110
111THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
112EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
113MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
114IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
115CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
116TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
117SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
118
119*** Portions of the driver (that is, bdflib.c and bdf.h):
120
121Copyright 2000 Computing Research Labs, New Mexico State University
122Copyright 2001-2002, 2011 Francesco Zappa Nardelli
123
124Permission is hereby granted, free of charge, to any person obtaining a
125copy of this software and associated documentation files (the "Software"),
126to deal in the Software without restriction, including without limitation
127the rights to use, copy, modify, merge, publish, distribute, sublicense,
128and/or sell copies of the Software, and to permit persons to whom the
129Software is furnished to do so, subject to the following conditions:
130
131The above copyright notice and this permission notice shall be included in
132all copies or substantial portions of the Software.
133
134THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
135IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
136FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
137THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
138CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
139OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
140THE USE OR OTHER DEALINGS IN THE SOFTWARE.
141
142
143Credits
144*******
145
146This driver is based on excellent Mark Leisher's bdf library.  If you
147find something good in this driver you should probably thank him, not
148me.
149