1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 09:37:44 +00:00

Documentation: Better file formats documentation

This commit is contained in:
sfdd 2022-07-11 02:58:10 +03:00 committed by Linus Groh
parent b8cfec7b1f
commit d1671d4f86
5 changed files with 184 additions and 16 deletions

View file

@ -1,17 +1,39 @@
## Name
font - Bitmap Font File format
font - Bitmap Font File format (.font)
## Synopsis
The .font file format stores bitmap fonts in SerenityOS's own binary format.
Font files contain bitmap definitions of fonts (`Gfx::BitmapFont`).
## Description
These files contain bitmap definitions of fonts, either varying-width or fixed-width.
Bitmap fonts can be either varying-width or fixed-width.
The first four bytes of font files contain the filemagic: `!Fnt` (0x21466e74).
The first four bytes contain the filemagic: `!Fnt` (0x21466e74).
In addition, `Gfx::BitmapFont` supports reading from and writing to font files (as well as reading directly from memory)
and the question mark '?' used as a fallback for unknown glyphs or emojis.
## Structure
The order is big-endian.
| Size | Member name |
|------------|---------------------|
| 4 bytes | Filemagic |
| 1 byte | Glyph width |
| 1 byte | Glyph height |
| 2 bytes | Range mask size |
| 1 byte | Variable width flag |
| 1 byte | Glyph spacing |
| 1 byte | Baseline |
| 1 byte | Mean line |
| 1 byte | Presentation size |
| 2 bytes | Weight |
| 1 byte | Slope |
| 32 bytes | Name |
| 32 bytes | Family |
## See also
- Format header definition in `Gfx::FontFileHeader` in [`Userland/Libraries/LibGfx/Font/BitmapFont.cpp`](../../../../../Userland/Libraries/LibGfx/Font/BitmapFont.cpp).
- Format header definition in `Gfx::FontFileHeader` in [`Userland/Libraries/LibGfx/Font/BitmapFont.cpp`](../../../../../Userland/Libraries/LibGfx/Font/BitmapFont.cpp)