Fileformat for Smoothed MipMap Font

Fileformat for Smoothed MipMap Font

Post by Erik Unge » Wed, 09 Sep 1998 04:00:00



Hi,

What do you think about defining a new file-format for fonts,
that alow us to render text with 3D-hardware ?

Have a look on my suggested SMF-format,
attached to this e-mail, and tell me your thoughts.

Erik.

http://www.bigfoot.com/~ungerik/

[ SMF.htm 7K ]

Description of the MIP and SMF fileformat:

MIP stands for MipMap and
SMF stands fro Smooth MipMap Font.

You can use the MIP format to store any bitmap or texture data.
The SMF format is based on MIP, but was extended to hold data for a font, that uses the texture-data as bitmap for its characters.

For every character of the font, 4 vertices are defined.
These 4 vertices describe the polygon (doesn't have to be a rectangle) on the mip-map surface, which encloses the shape of one character.
This can be used to draw text with 3D-Hardware, using a smoothed, mip-maped texture-font.

ElementTypeOffsetRemarks
IdStringArray 4 Chars 8 Bit0'M'+'I'+'P'+Zero or 'S'+'M'+'F'+Zero
Base header for MIP and SMF format:
TexelFormat32 Bit integer4Texel-format; see table below
RedShift32 Bit integer8Offset in bits from Bit 0
GreenShift32 Bit integer12Offset in bits from Bit 0
BlueShift32 Bit integer16Offset in bits from Bit 0
AlphaShift32 Bit integer20Offset in bits from Bit 0
PaletteOffset32 Bit pointer24Offset of the Palette; see Table below
Translucent32 Bit boolean28Use alpha-bits or color-key
ColorKey32 Bit texelformat32Color-key with the current texel-format
Width32 Bit integer36Width in texels of the largest mip-map
Hight32 Bit integer40Hight in texels of the largest mip-map
MipMapCount32 Bit integer44Number of mip-map levels
MipMapListOffset32 Bit pointer48Offset of an offset-array to texel-data
Extended header for SMF format:
CharacterCount32 Bit integer52Number of Characters
CharacterListOffset32 Bit pointer56Offset of the Character-List
StrikeY32 Bit float60Y of the Strikeline in % of font-hight / 100
StrikeThickness32 Bit float64Thickness of the Strikeline in % of font-hight / 100
UnderlineY32 Bit float68Y of the Underline in % of font-hight / 100
UnderlineThickness32 Bit float72Thickness of the Underline in % of font-hight / 100
LineTopLeftX32 Bit float76Top-left corner of the texture for lines
LineTopLeftY32 Bit float80Top-left corner of the texture for lines
LineBottomRightX32 Bit float84Bottom-right corner of the texture for lines
LineBottomRightY32 Bit float88Bottom-right corner of the texture for lines

All offset values are relative to the beginning of the file.
So you can read a file from the disk to a buffer on the heap, and add the address of the buffer to all offset-values to get pointers.

PointerOffset
MIP and SMF format:
PaletteOffset24
MipMapListOffset48
MipMapList[MipMapCount]MipMapListOffset+(i*4)
SMF format:
CharacterListOffset56

LineTopLeft and LineBottomRight describe a rectangle, which is used as texture for the underlines and strikelines.
The texture will be repeated without mirroring.


All float values are in the range of 0.0 - 1.0 .
The top-left corner of the texture is at (0.0,0.0), and the bottom-right corner is at (1.0,1.0).

Format of one entry of the character-list:

ElementTypeOffsetRemarks
Unicode16 Bit Unicode Char0The unicode of the described Character
ANSI8 Bit ANSI Char16Unused at the moment; must be zero
ASCII8 Bit ASCII Char24Unused at the moment; must be zero
Length32 Bit float32= Width / height of the Character
TopLeftX32 Bit float36Top-left corner of the texture for character
TopLeftY32 Bit float36Top-left corner of the texture for character
TopRightX32 Bit float40Top-right corner of the texture for character
TopRightY32 Bit float40Top-right corner of the texture for character
BottomLeftX32 Bit float44Bottom-left corner of the texture for character
BottomLeftY32 Bit float44Bottom-left corner of the texture for character
BottomRightX32 Bit float48Bottom-right corner of the texture for character
BottomRightY32 Bit float48Bottom-right corner of the texture for character

Format of one entry of the Palette:

ElementTypeOffsetRemarks
Red8 Bit unsigned0Red color component
Green8 Bit unsigned1Green color component
Blue8 Bit unsigned2Blue color component
Unused8 Bit unsigned3Must be zero

Values for TexelFormat:

Value
(PA or RGBA)
ColorAlpha
(Used if Translucent=true)
01no color1 Bit
04no color4 Bit
08no color8 Bit
101 Bit PaletteColorKey
404 Bit PaletteColorKey
808 Bit PaletteColorKey
888 Bit Palette8 Bit
33208 Bit RGBColorKey
33288 Bit RGB8 Bit
444412 Bit RGB4 Bit
555115 Bit RGB1 Bit
565016 Bit RGBColorKey
888024 Bit RGBColorKey
888824 Bit RGB8 Bit