The Simple Font Format (SFF)

From New Open Cosmos Alliance
Jump to: navigation, search

Envy OS Project - 2013

Introduction

Aims

The simple font format aims to provide a very simple file format for the storage of non-vector fonts that do not have to be fixed width. This specification is open source and may be used in any way you wish, please note that in order to place on our implementation list below your project/application must be compatible with a test file that will be provided shortly.

Current Implementations

The projects below have implemented a version of .sff in their projects, if you wish to be included in this list please email opencosmosalliance@gmail.com

  • Envy OS - The open source COSMOS OS

The File Format

Header

The file format contains a header as outlined below, this should be read before any data.

 Name  Lenght (In bytes)  Description
 Magic Word  3  The characters “sff” in ascii. [0x73 0x66 0x66]
 Font Name  50  The name of the font in ascii.
 Style  1  The style of the font (0 - Normal, 1 - Bold, 2 - Italic)

Glyphs/Character

Each glyph is a byte array. The glyph size cannot exceed 255 x 255 pixels. Each glyph is set out like below and is not separated, any problems with data length will render the file unusable and create weird looking results and may even end in an EoF error.

 Name  Lenght (In bytes)  Description
Glyph Character 1 The character that the glyph represents in ASCII
Width 1 The width of the glyph in pixels
Height 1 The height of the glyph in pixels
Content  Width*Height The content of the glyph
.SSF

Fonts are rendered from the top left down to the bottom right. Content is divided into lines of pixels by dividing the content by the width. Where a 0x00 is found there is no pixel, where a 0x01 is found there is a pixel. In this example the first line of the glyph ‘H’s content would be [0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00] In a file the whole of the glyph for the letter ‘H’ would look like the bytes below.

[0x48 0x08 0x08 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x01 0x01 0x01 0x01 0x01 0x01 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00]

End of File

The end of the file should be marked by a single byte of 0x03 which of course is ASCII is “End of Text” or “ETX” for short.

Other Details

Range

A .sff file is able to support glyphs for ASCII characters: 0x20 - 0x7E inclusive. Any other characters should not be found within the file.

Suggested Functionality

Fonts which have an identical name but different styles should be grouped together for use in rich text purposes (e.g changing a font called Simples into the bold version of Simples)

Appendix A

Any complaints or suggestions about the content of this specification should be placed at the following URL in the discussion board marked “Open Specifications by Envy OS” http://envyos.codeplex.com/discussions