Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

PC Screen Font

From Wikipedia, the free encyclopedia

PC Screen Font (PSF) is abitmap font format currently employed by theLinux kernel forconsole fonts. Documentation of the PSF file format can be found within the source code of the Linux kbd utilities.[1] The format is described by the University Eindhoven.[2]

File format

[edit]

File header

[edit]

Every PSF file begins with a header. There are two header types: PSF1 and PSF2. All multibyte integers are in least significant byte order (little endian).

psf1 header
LengthDescriptionNotes
2Magic bytesAlways36 04
1PSF Font modeVarious font flags, seefont modes
1Glyph sizeGlyph size in bytes, 8 bit unsigned integer. For psf1, the character size always equals the glyph height
psf2 header
LengthDescriptionNotes
4Magic bytesAlways72 b5 4a 86
4Version32 bit unsigned integer, currently always 0
4Header Size32 bit unsigned integer, size of the header in bytes (usually 32)
4Flags32 bit unsigned integer, seeFont flags
4Length32 bit unsigned integer, number of glyphs
4Glyph size32 bit unsigned integer, number of bytes per glyph
4Height32 bit unsigned integer, height of each glyph
4Width32 bit unsigned integer, width of each glyph

All psf1 glyphs are 8 pixels wide.

Font modes

[edit]

The font mode in a psf1 header is an 8 bit unsigned integer containing various flags about the font

Font mode bits
Value (hex)NameMeaning
0x01PSF1_MODE512If this bit is set, the font face will have 512 glyphs. If it is unset, then the font face will have just 256 glyphs.
0x02PSF1_MODEHASTABIf this bit is set, the font face will have aunicode table.
0x04PSF1_MODESEQEquivalent to PSF1_MODEHASTAB

Font flags

[edit]

The font flags field in a psf2 header is a 32 bit unsigned integer containing various flags about the font. There is currently only one flag.

Font flag bits
Value (hex)NameMeaning
0x00000001PSF2_HAS_UNICODE_TABLEIf this bit is set, the font face will have a unicode table

File bitmaps

[edit]

The actual glyph data immediately follows the header. Each bit in each glyph represents one pixel in the font: 0 for undrawn, 1 for drawn. Each row of each glyph is padded to a whole number of bytes. For example, a 12x12 font would have 2 bytes per row. The letter 'A' in a 12x12 PSF bitmap may look like this:

           padding Font data    |+----------+ +--+000001100000 0000000011110000 0000000110011000 0000001100001100 0000011000000110 0000110000000011 0000111111111111 0000111111111111 0000110000000011 0000110000000011 0000110000000011 0000110000000011 0000

with twelve bits of actual data and padding to fill each row to the nearest byte. Rows are stored left-most column first.

The unicode table

[edit]

If a PSF file contains a unicode table, then every glyph has an entry in the unicode table, with the first glyph corresponding to the first entry in the table, the second glyph the second entry, and so on. The format of an entry in the unicode table depends on the type of the PSF header.

The PSF1 unicode table

[edit]

Entries in the unicode table of a PSF1 file are represented as a series of 16 bit little-endian unsigned integers ending in 0xffff. The first integers in the entry contain a unicode character represented by the corresponding glyph. These unicode characters continue until the integer 0xFFFE is encountered. Then, starting from the 0xfffe value, rather than representing individual unicode characters, the numbers represent series of unicode characters that correspond to the glyph, starting a new series with every 0xfffe encountered, and stopping once 0xffff is encountered. For example, the following series of 16 bit little-endian unsigned integers would be interpreted in the following way:

0xdead0xbeef0xfffe0x31410x59260xfffe0x12340x56780xffff

Whenever either U+dead, U+beef, the sequence U+3141 U+5926, or the sequence U+1234 U+5678 is seen, display the glyph corresponding to this unicode table entry.

The PSF2 unicode table

[edit]

Entries in the unicode table of a PSF2 file are the same as those in a PSF1 file, except unicode characters are represented in UTF-8, unicode sequences begin with the one byte sequence 0xfe rather than the two byte sequence 0xfffe, and unicode entries end with the one byte sequence 0xff rather than the two byte sequence 0xffff.

References

[edit]
  1. ^the Linux Kernel Organization (2007-01-28)."psf.h".
  2. ^TUE (1999)."psf format".
Stub icon

Thisdigital typography article is astub. You can help Wikipedia byexpanding it.

Retrieved from "https://en.wikipedia.org/w/index.php?title=PC_Screen_Font&oldid=1206509319"
Categories:
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp