Glyph Bitmap Distribution Format: Difference between revisions

Content deleted Content added
Ph9000 (talk | contribs)
Wrote entry to replace stub.
MOS:HEADCAPS
 
(55 intermediate revisions by 43 users not shown)
Line 1:
{{Infobox file format
The '''Glyph Bitmap Distribution Format''' (BDF) by [[Adobe Systems|Adobe]] is a file format for storing [[bitmap font]]s. The content is presented as a text file that is intended to be human and computer readable. BDF is typically used in [[Unix]] environments.
| name = Glyph Bitmap Distribution Format
| extension = .bdf
| mime = application/x-font-bdf<ref name="P1">[https://mimetype.io/application/x-font-bdf .bdf] [[MIME]] type not [https://www.iana.org/assignments/media-types/media-types.xhtml#image registered] at [[Internet Assigned Numbers Authority|IANA]]</ref>
| owner = [[Adobe Inc.]]
| genre = [[Computer_font#Bitmap_font_formats|Bitmap font format]]
| released = {{start date and age|1987|df=yes}}
| latest_release_version = 2.2
| latest_release_date = {{start date and age|1993|03|22|df=yes}}
| open = yes
| url = [https://www.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5005.BDF_Spec.pdf Adobe Glyph Bitmap Distribution Format (BDF) Specification, version 2.2]
}}
 
{{Short description|File format for storing bitmap fonts}}
==Overview==
The '''Glyph Bitmap Distribution Format''' (BDF) by [[Adobe Systems|Adobe]] is a file format for storing [[bitmap font]]s. The content takes the form of a text file intended to be human- and computer-readable. BDF is typically used in [[Unix]] [[X Window]] environments. It has largely been replaced by the [[Portable Compiled Format|PCF]] font format which is somewhat more efficient, and by scalable fonts such as [[OpenType]] and [[TrueType]] fonts.
The current version of BDF is 2.2. No future revisions are anticipated. Earlier versions were referred to as the Character Bitmap Distribution Format. Current semantics, for example in the Unicode 5.0 Standard,<ref>{{cite
|title=The Unicode 5.0 Standard
|date=2007
|author=The Unicode Consortium
|publisher=Addison Wesley
}}</ref>
defines a character as composed of one or more glyphs. Therefore the glyph is a more basic typographic element than the character.
 
==Overview==
The [[X-Windows]] Consortium adopted BDF 2.1 as a standard for X-Windows screen fonts, but is now moving towards other standards.
In 1988, the [[X Window System#The MIT X Consortium and the X Consortium, Inc.|X Consortium]] adopted BDF 2.1 as a standard for X Window screen fonts,<ref>{{cite web|title=X Window System, Version 11, Release 3|url=http://www.x.org/wiki/X11R3/|website=X.Org Foundation|access-date=19 January 2016|date=October 1988}}</ref> but X Windows has largely moved to other font standards such as [[Portable Compiled Format|PCF]], [[OpenType|Opentype]], and [[TrueType|Truetype]].
 
Version 2.2 added support for non-Western writing. For example, glyphs[[glyph]]s in a BDF 2.2 font definition can specify rendering from top-to-bottom rather than simply left-to-right.
 
A BDF font file contains three sections: 1)
#a global section that applies to all glyphs inain a font; 2)
#a section with a separate entry for each glyph; and 3)
#the {{code|ENDFONT}} statement.
 
==Example==
This is an example font containing one glyph, for ASCII capital 'A'“A”. This glyph is taken from the [[GNU Unifont]].
 
{|
<pre><nowiki>
|-
STARTFONT 2.1
|
<nowiki>STARTFONT 2.1
FONT -gnu-unifont-medium-r-normal--16-160-75-75-c-80-iso10646-1
SIZE 16 75 75
Line 34 ⟶ 45:
DWIDTH 8 0
BBX 8 16 0 -2
BITMAP
00
00
Line 52 ⟶ 63:
00
ENDCHAR
ENDFONT</nowiki>
|
</nowiki></pre>
<br /><br /><br /><br /><br />
{{Col-begin|class=mw-collapsible mw-collapsed}}
|+'''Decoded hexdraw representation of the example'''
|-
{{Col-2}}
{{sxhl|2=hexdump|
 
In the above example, the global declarations begin with the "STARTFONT" line and end with the "CHARS" line.
 
00 00000000 --------
"STARTFONT 2.1" defines the version of this BDF file as version 2.1.
00 00000000 --------
00 00000000 --------
00 00000000 --------
18 00011000 ---██---
24 00100100 --█--█--
24 00100100 --█--█--
42 01000010 -█----█-
42 01000010 -█----█-
7E 01111110 -██████-
42 01000010 -█----█-
42 01000010 -█----█-
42 01000010 -█----█-
42 01000010 -█----█-
00 00000000 --------
00 00000000 --------
.. ........ .248124.
}}
{{Col-end}}
 
|}
"FONT -gnu-unifont-medium-r-normal--16-160-75-75-c-80-iso10646-1" defines the font family and face names.
 
In the above example, the global declarations begin with the {{code|STARTFONT}} line and end with the {{code|CHARS}} line.
"SIZE 16 75 75" defines this to be a 16 point font, with an X-axis resolution of 75 dots per inch (dpi) and a Y-axis resolution of 75 dpi. This is the norm under X-Windows.
 
{{code|STARTFONT 2.1}} defines the version of this BDF file as version 2.1.
"FONTBOUNDINGBOX 16 16 0 -2" defines a bounding box for the font of 16 pixels wide by 16 pixels high, with the lower left-hand corner starting at x=0, y=-2. Note that although the bounding box is defined to be a 16 by 16 cell, this can be overridden for individual glyphs. The "A" glyph, for example, is only 8 pixels wide.
 
{{code|FONT -gnu-unifont-medium-r-normal--16-160-75-75-c-80-iso10646-1}} defines the font family and face names as an [[X logical font description]].
"STARTPROPERTIES 2" declares that two special properties will follow. "STARTPROPERTIES" is optional in the BDF specification. X-Windows allos the properties FONT_ASCENT and FONT_DESCENT to show the height above and below the baseline, respectively, for all glyphs. "FONT_ASCENT 14" declares that 14 of the 16 pixels in height are above the baseline. "FONT_DESCENT 2" declares that 2 of the 16 pixels in height are below the baseline. "ENDPROPERTIES" appears at the end of the "STARTPROPERTIES" section.
 
{{code|SIZE 16 75 75}} defines this to be a 16 point font, with an X-axis resolution of 75 dots per inch (dpi) and a Y-axis resolution of 75 dpi. This is the norm under X Window.
"CHARS 1" declares that one character will follow. Although Adobe now refers to this file format as the Glyph BDF, they have retained the keyword "CHARS" in the final version of the specification.
 
{{code|FONTBOUNDINGBOX 16 16 0 -2}} defines a bounding box for the font of 16 pixels wide by 16 pixels high, with the lower left-hand corner starting at {{math|''x'' {{=}} 0}} and {{math|''y'' {{=}} -2}}. Note that although the bounding box is defined to be a 16 by 16 cell, this can be overridden for individual glyphs. The “A” glyph, for example, is only 8 pixels wide.
Lines beginning with the word "COMMENT" can be inserted within a BDF file. Anything following the "COMMENT" keyword on a line is ignored.
 
{{code|STARTPROPERTIES 2}} declares that two special properties will follow. {{code|STARTPROPERTIES}} is optional in the BDF specification. X Window allows the properties {{code|FONT_ASCENT}} and {{code|FONT_DESCENT}} to show the height above and below the baseline, respectively, for all glyphs. {{code|FONT_ASCENT 14}} declares that 14 of the 16 pixels in height are above the baseline. {{code|FONT_DESCENT 2}} declares that 2 of the 16 pixels in height are below the baseline. {{code|ENDPROPERTIES}} appears at the end of the {{code|STARTPROPERTIES}} section.
Following the above global declarations, the following entries are repeated for each glyph.
 
{{code|CHARS 1}} declares that one character will follow. Although Adobe now refers to this file format as the Glyph BDF, they have retained the keyword {{code|CHARS}} in the final version of the specification.
"STARTCHAR U+0041" specifies the start of a character in version 2.1 and earlier, or of a glyph in version 2.2. The string name of this particular character is "U+0041", which is the Unicode convention for the code point hexadecimal 41 (decimal 65, the ASCII character "A"). In version 2.1 and earlier, the character name string was limited to 14 characters. In version 2.2, the glyph name string can contain up to 65,535 characters.
 
Lines beginning with the word {{code|COMMENT}} can be inserted within a BDF file. Anything following the {{code|COMMENT}} keyword on a line is ignored.
"ENCODING 65" declares the decimal code point for this glyph in the font.
 
Following the above global declarations, the following entries may repeat for each glyph.
"SWIDTH 500 0" declares the Scalable Width of 500 on the X-axis and 0 (default) on the Y-axis. This will result in an X-axis offset to the next glyph, but no Y-axis offset to the next glyph (i.e., the glyphs appear straight across in a line). The scalable width is 1000 times the actual point size of the character -- the same unit used in an Adobe Font Metric (AFM) file. The number of pixels calculated as
 
{{code|STARTCHAR U+0041}} specifies the start of a character in version 2.1 and earlier, or of a glyph in version 2.2. The string name of this particular character is {{code|U+0041}}, expressing in the [[Unicode]] convention the code point hexadecimal 41 (decimal 65, the ASCII character “A”). In version 2.1 and earlier, the character name string was limited to 14 characters. In version 2.2, the glyph name string can contain up to 65,535 characters.
pixels = (scalable_width / 1000) * (resolution / 72),
 
{{code|ENCODING 65}} declares the decimal code point for this glyph in the font.
where scalable_width is 500 in this example, and resolution is 75 dpi for this font. Because 75 is approximately equal to 72, the number of pixels is the full width of a glyph (defined globally as 16 pixels) times 500 / 1000, or in other words the width of this glyph is 8 pixels.
 
{{code|SWIDTH 500 0}} declares the scalable width of 500 on the X-axis and 0 (by default) on the Y-axis. This will result in an X-axis offset to the next glyph, but no Y-axis offset to the next glyph (i.e., the glyphs appear straight across in a line). The scalable width is 1000 times the actual point size of the character—the same unit used in an [[Adobe Font Metrics|Adobe Font Metric]] (AFM) file. The number of pixels calculated as {{math|''Pixels'' {{=}} {{sfrac|''Scalable Width''|1000}} * {{sfrac|''Resolution''|72}}}}, where {{math|''Scalable Width''}} is 500 in this example, and resolution is 75 dpi for this font. Because 75 is approximately equal to 72, the number of pixels is the full width of a glyph (defined globally as 16 pixels) times {{math|{{sfrac|500|1000}}}}, or in other words the width of this glyph is 8 pixels.
"DWIDTH 8 0" declares the Device Width of a glyph. In this case, after the glyph is rendered, the start of the next glyph is offset 8 pixels on the X-axis and 0 pixels on the Y-axis from the current glyph origin. Note that the Device Width is not necessarily equal to the width of the glyph. It is simply the offset on the X-axis to move the current point to the start of the next glyph.
 
{{code|DWIDTH 8 0}} declares the device width of a glyph. In this case, after the glyph is rendered, the start of the next glyph is offset 8 pixels on the X-axis and 0 pixels on the Y-axis from the current glyph origin. Note that the device width is not necessarily equal to the width of the glyph. It is simply the offset on the X-axis to move the current point to the start of the next glyph.
The Scalable Width is used to calculate the width of a high-resolution glyph on a printer, whereas the Device Width is used to calculate the width of a glyph on a display device. Thus Scalable Width is specified to greater precision than Device Width.
 
The scalable width is used to calculate the width of a high-resolution glyph on a printer, whereas the device width is used to calculate the width of a glyph on a display device. Thus the scalable width is specified to greater precision than the device width.
"BBX 8 16 0 -2" declares a bounding box that is 8 pixels wide and 16 pixels tall. The lower left-hand corner of the character is offset by 0 pixels on the X-axis and -2 pixels on the Y-axis.
 
{{code|BBX 8 16 0 -2}} declares a bounding box that is 8 pixels wide and 16 pixels tall. The lower left-hand corner of the character is offset by 0 pixels on the X-axis and -2 pixels on the Y-axis.
"BITMAP" begins the bitmap for the current glyph. This line must be followed by one line per pixel on the Y-axis. In this example the glyph is 16 pixels tall, so 16 lines follow. Each line contains the hexadecimal representation of pixels in a row. A "1" bit indicates a rendered pixel. Each line is rounded to an 8 bit (one byte) boundary, padded with zeroes on the right. In this example, the glyph is exactly 8 pixels wide, and so occupies exactly bits (one byte) per line so that there is no padding.
 
{{code|BITMAP}} begins the bitmap for the current glyph. This line must be followed by one line per pixel on the Y-axis. In this example the glyph is 16 pixels tall, so 16 lines follow. Each line contains the hexadecimal representation of pixels in a row. A “1” bit indicates a rendered pixel. Each line is rounded to an 8 bit (one byte) boundary, padded with zeroes on the right. In this example, the glyph is exactly 8 pixels wide, and so occupies exactly 8 bits (one byte) per line so that there is no padding. The most significant bit of a line of raster data represents the leftmost pixel.
"ENDCHAR" ends the current glyph.
 
{{code|ENDCHAR}} ends the current glyph.
The declaractions "STARTCHAR" through "ENDCHAR" are repeated for each glyph in a font.
 
The declarations {{code|STARTCHAR}} through {{code|ENDCHAR}} are repeated for each glyph in a font.
"ENDFONT" appears as the last line in the file, after all glyphs in the font have been enumerated.
 
{{code|ENDFONT}} appears as the last line in the file, after all glyphs in the font have been enumerated.
==Version 2.2 Extensions==
Version 2.2 of the BDF specification adds support for non-Western fonts. These additions allow moving the origin by a positive or negative movement on the X and Y axes. This not only accomodates right-to-left writing direction, but even top-to-bottom (for exmaple, for Chinese). The following values provide multinational font support:
 
==Version 2.2 extensions==
METRICSET: set to 0 for writing direction 0, 1 for writing direction 1, or 2 (in the initial global area) for both writing directions within the same font. Traditional Western left-to-right scripts use "METRICSET 0".
Version 2.2 of the BDF specification adds support for non-Western fonts. These additions allow moving the origin by a positive or negative movement on the X and Y axes. This not only accommodates right-to-left writing direction, but even top-to-bottom (for example, for Chinese). The following values provide multinational-font support:
 
{{code|METRICSET}} is set to 0 for writing direction 0, 1 for writing direction 1, or 2 (in the initial global area) for both writing directions within the same font. Traditional Western left-to-right scripts use {{code|METRICSET 0}}.
SWIDTH1, DWIDTH1: these have the same parameters as SWIDTH and DWIDTH, respectively. DWIDTH1 must be present for a METRICSET 1 glyph. Its offsets can be positive or negative.
 
{{code|SWIDTH1}} and {{code|DWIDTH1}} have the same parameters as {{code|SWIDTH}} and {{code|DWIDTH}}, respectively. {{code|DWIDTH1}} must be present for a {{code|METRICSET 1}} glyph. Its offsets can be positive or negative.
VVECTOR defines an X-axis offset and a Y-axis offset to transition from a mode 0 glyph to a mode 1 glyph. An opposite offset is applied during a mode 1 to mode 0 glyph transition.
 
{{code|VVECTOR}} defines an X-axis offset and a Y-axis offset to transition from a mode 0 glyph to a mode 1 glyph. An opposite offset is applied during a mode 1 to mode 0 glyph transition.
This scheme easily accomodates two writing directions. Historically, fonts had 128 or 256 code points. Today, Unicode allows for over one million code points. Fonts can conceivably contain thousands of glyphs, some of which should be written left-to-right, some right-to-left, and some top-to-bottom. Such many-direction writing requires creative use of DWIDTH1 and SWIDTH1 for each glyph.
 
This scheme easily accommodates two writing directions. Historically, fonts had 128 or 256 code points. Today, Unicode allows for over one million code points. Fonts can conceivably contain thousands of glyphs, some of which should be written left-to-right, some right-to-left, and some top-to-bottom. Such multi-directional writing requires creative use of {{code|DWIDTH1}} and {{code|SWIDTH1}} for each glyph.
In addition to keywords added for international support, version 2.2 adds the "CONTENTVERSION" declaration. This keyword is followed by an integer to indicate the version number of the font.
 
In addition to keywords added for international support, version 2.2 adds the {{code|CONTENTVERSION}} declaration. This keyword is followed by an integer to indicate the version number of the font.
 
For more detailed information, consult the version 2.2 specification.
 
==X Window properties==
==X-Windows Properties==
 
X-Windows font utilities (for example, the xlfd command under Linux) support several properties that can be specified in the STARTPROPERTIES section of a BDF file. A generic BDF file is in ASCII encoding. X-Windows properties are specified using ISO 8859-1 encoding, which is an extension of ASCII. These properties include:
X Window font utilities support several properties that can be specified in the {{code|STARTPROPERTIES}} section of a BDF file.<ref>{{cite book|last=Flowers |first=Jim |title=X Logical Font Description Conventions |orig-year=1988 |url=http://ftp.xfree86.org/pub/XFree86/4.5.0/doc/xlfd.txt |access-date= 2009-01-08 |edition= Version 1.5 |year= 1994 |publisher=X Consortium, Inc. |pages=13 |chapter=3.2 Font Properties |archive-url=https://web.archive.org/web/20130331010913/http://ftp.xfree86.org/pub/XFree86/4.5.0/doc/xlfd.txt |archive-date=2013-03-31}}</ref> A generic BDF file is in [[ASCII]] encoding. X Window properties are specified using [[ISO/IEC 8859-1|ISO 8859-1]] encoding, which is an extension of ASCII. These properties include:
* CAP_HEIGHT int32 -- the height above the baseline of a capital letter.
* {{code|CAP_HEIGHT}} (integer) The height above the baseline of a capital letter (See [[Cap height]]).
* COPYRIGHT string -- a copyright statement.
* {{code|COPYRIGHT}} (string)<ref name="strings">A ISO 8859-1 [[String (computer science)|character string]].</ref> A copyright statement.
* DEFAULT_CHAR card32 -- the default character (glyph) to display for an undefined glyph.
* {{code|DEFAULT_CHAR}} (unsigned integer) The default character (glyph) to display for an undefined glyph.
* FACE_NAME string -- the name of the face for this font.
* FONT{{code|FACE_NAME}} (string<ref --name="strings" the/>) X-WindowsThe name of the face for this font.
* {{code|FONT}} (string)<ref name="strings" /> The X Window name of the font.
* FONT_ASCENT int32 -- the height above the baseline, for line spacing calculation.
* FONT_DESCENT{{code|FONT_ASCENT}} int32(integer) --The theheight descentabove belowthe the[[Baseline (typography)|baseline]], for line spacing calculation.
* {{code|FONT_DESCENT}} (integer) The [[descender]] below the baseline, for line spacing calculation.
* FONT_VERSION string -- the version of the font.
* {{code|FONT_VERSION}} (string)<ref name="strings" /> The version of the font.
* FOUNDRY string
* FAMILY_NAME{{code|FOUNDRY}} (string)<ref --name="strings" the/> font familyThe name of the foundry.
* {{code|FAMILY_NAME}} (string)<ref name="strings" /> The font family name.
* NOTICE string -- a general comment.
* {{code|NOTICE}} (string)<ref name="strings" /> A general comment.
* POINT_SIZE int32 -- if not separately specified, EMspace = round(POINT_SIZE/10), ENspace = round(POINT_SIZE/20), and THINspace = round(POINT_SIZE/30).
* {{code|POINT_SIZE}} (integer) See [[Point (typography)]]. If it is not separately specified, [[Em (typography)|EMspace]] = round(POINT_SIZE/10), [[En (typography)|ENspace]] = round(POINT_SIZE/20), and THINspace = round(POINT_SIZE/30).
* RESOLUTION_X card32
* {{code|RESOLUTION_X}} (unsigned integer)
* RESOLUTION_Y card32
* {{code|RESOLUTION_Y}} (unsigned integer)
* SLANT string -- "R" is Roman.
* {{code|SLANT}} (string)<ref name="strings" /> “R” is roman, “I” is italic, “O” is oblique, “RI” is reverse italic, “RO” is reverse oblique, “OT” is other, and a number indicates polymorphic slant capability.
* WEIGHT_NAME string -- the weight of this font.
* {{code|WEIGHT_NAME}} (string)<ref name="strings" /> The weight of this font (“Bold” and “Normal” are typical, though there is no set enumeration).
* X_HEIGHT int32 -- the height above the baseline of a lower-case 'x'.
* {{code|X_HEIGHT}} (integer) The height above the baseline of a lower-case “x” (See [[x-height]]).
where "int32" is a 32 bit integer, "card32" is a 32 bit integer with value 1 or higher, and "string" is an ISO 8859-1 character string.
 
==Notes==
Line 138 ⟶ 175:
==References==
{{refbegin}}
* {{cite book|others= The [[Unicode Consortium:]] |title= ''The Unicode Standard, Version 5.0 Standard''.|edition= 5th, Addison|date=October Wesley2006 2007;|publisher= ISBN[[Addison-Wesley]] |isbn= 978-0-321-48091-0. }}
{{refend}}
 
==External links==
* [httphttps://www.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5005.BDF_Spec.pdf Adobe Glyph Bitmap Distribution Format (BDF) Specification, version 2.2]<!-- application/pdf, 101 kbytes -->
 
[[Category:Font formats]]
[[Category:X Window System]]
 
[[fr:Bitmap Distribution Format]]