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