ATE-Ansi Text Editor by Roy/SAC

.ATEF - ANSIFONT - File Format Specifications

   Back to ATE - Ansi Text Editor

Introduction

File format definitions for the ANSI/ASCII font files used by my tool ATE - Ansi Text Editor.

Table of Contents

 

.ATEF - ANSIFONT - File Format Specifications V1.0 2014-07

  Label Type Len Pos .NET Type Comment
"FORM" CHUNKID STR_FIX_LEN 4 0 STRING "FORM"
00 00 00 00 - FF FF FF FF CHUNKSIZE DWORD 4 4 INT32 00 00 00 00 - FF FF FF FF
 
"ANSIFONT" CHUNKID STR_FIX_LEN 8 8 STRING "ANSIFONT"
00 00 00 00 - FF FF FF FF CHUNKSIZE DWORD 4 16 INT32 00 00 00 00 - FF FF FF FF
 
"AFNT" CHUNKID STR_FIX_LEN 4 20 STRING "FORM"
00 00 03 80 CHUNKSIZE DWORD 4 24 INT32 00 00 00 00 - FF FF FF FF*
            *Always = 896 (or "00 00 03 80")
 
HEADER "AFNT"
Main 0
  ID STR_FIX_LEN 32 32 STRING CLSID (RAW)
  NAME STR_FIX_LEN 25 57 STRING TEXT
  CREATEDBY STR_FIX_LEN 35 92 STRING TEXT
  DATECREATED STR_FIX_LEN 15 107 Date "YYYYMMDD-HHMMSS"
  LASTCHANGED STR_FIX_LEN 15 122 Date "YYYYMMDD-HHMMSS"
  FONTTYPE BYTE 1 123 eAnsiFontTypes 01 = ANSI, 02 = ASCII
  EMPTYLINEHEIGHT BYTE 1 124 BYTE 00-FF
  LETTERSPACING BYTE 1 125 BYTE 00-FF
  LINESPACING BYTE 1 126 BYTE 00-FF
  SPACEWIDTH BYTE 1 127 BYTE 00-FF
  BASELINEHEIGHT BYTE 1 128 BYTE 00-FF
  ALLCASE BYTE 1 129 eLetterCase 00 = NotApplicable, 01 = Upper- & 02 = LowerCase
  ALLOWOVERLAP BYTE 1 130 BOOL 01 or 00
  UPPEREQLOWER BYTE 1 131 BOOL 01 or 00
  UNUSED STR_FIX_LEN 13 144 - "00 00 00 00 00 00 00 00 00 00 00 00 00"
Chars  
(ASC: 33 - 127) = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
DOSCHAR BYTE 1 1 BYTE 00-FF
DEFINED BYTE 1 2 BOOL 00 or 01
MAXWIDTH BYTE 1 3 BYTE X
MAXHEIGHT BYTE 1 4 BYTE Y
BLOCKSTART* DWORD 4 8 INT32 = -1 IF Defined = 0
  8 * 94 = 752   Offset Starting from 0 (= 920 from File Beginning)
        896   Total
"CHAR" CHUNKID STR_FIX_LEN 4 920 STRING "CHAR"
CHUNKSIZE CHUNKSIZE DWORD 4 924 INT32 00 00 00 00 - FF FF FF FF
            *Positions are for the first block
 
* CHUNKSIZE for "CHAR" can be pre-determined:
1 + CHARBLOCKLENTH = MAXHEIGHT * MAXWIDTH * 8
+ SMUSHBLOCKLENGTH = (MAXHEIGHT + MAXWIDTH) * 8
= CHUNKSIZE
 
DOSCHAR BYTE 1 1 BYTE 00-FF
CHARBLOCK Y = 0 to Y = MAXHEIGHT - 1, FOR EACH, X = 0 to X = MAXWIDTH - 1
CHARVALUE BYTE 1   BYTE 00-FF
FORECOLOR BYTE 1   BYTE 00-0F
BACKCOLOR BYTE 1   BYTE 00-07
BLINKING BYTE 1   BOOL 01 or 00
REVERSED BYTE 1   BOOL 01 or 00
UNUSED BYTE 3   - "00 00 00"
SMUSHBLOCK Y = 0 to Y = MAXHEIGHT - 1 (= MAXHEIGHT * 8 Bytes) , THEN X = 0 to X = MAXWIDTH - 1 (= MAXWIDTH * 8 Bytes)
  NEAR DWORD 4   INT32 00 00 00 00 - FF FF FF FF
  FAR DWORD 4   INT32 00 00 00 00 - FF FF FF FF

 

CHUNK Hierarchy Illustration

 
    Absolute Offset Byte Length
"FORM"   0 4
CHUNKSIZE   4 4
"ANSIFONT"   8 8
CHUNKSIZE   16 4
"AFNT"     20 4
CHUNKSIZE     24 4
    AFNT DATA       28 896
           
"CHAR" *     ? 4
CHUNKSIZE     ? 4
    CHAR DATA       ???
           
      ? 4
      ? 4
            ???
           
      ? 4
      ? 4
            ???
       
     
0-94 Times, for each Character that has a definition

 

General Notes:

All NON-Byte Values are Stored in BIG-ENDIAN Format (like on the COMMODORE AMIGA) and NOT LITTLE-ENDIAN, as you might would expect on a PC. For Example the "CHUNK Sizes", 4 Bytes, Dword; If a chunk has a Size of 4048 Bytes (0xFD0), it would be stored as "00 00 0F D0" in the file and not as "D0 0F 00 00"

 

CHUNK IDS

# MINIMUM
# occurrence(s)
MAXIMUM
# occurrence(s)
Chunk ID Level Parent
Chunk ID
1. 1 1 FORM 1 ROOT
2. 1 1 ANSIFONT 2 FORM
3. 1 1 AFNT 3 ANSIFONT
4. 0 94 CHAR 3 ANSIFONT

So a Newly Created Font would not have any "CHAR" chunks yet, because non of the characters have any definition yet.
Once all 94 characters have a definition the file will end up with having 94 chunks with ID "CHAR"

First 28 Bytes of a NEW Font File without any definitions yet.

 

Font File Structures Defintions for VB.NET

 
Public Structure ANSIFONT_CHUNK
    Public AFNT As AFNT_CHUNK
    Public CHAR_CHUNKS  As CHAR_CHUNK()
End Structure
Public Structure AFNT_CHUNK
    Public MAIN  As AFNT_MAIN
    Public CHARS  As AFNT_CHAR()
End Structure
Public Structure AFNT_MAIN
    ''' <summary>
    ''' Unique Font Identifier. GUID is being generated when a font is created and then 
    ''' kept for the entire life-time of the font.
    ''' The ID is used as KEY value in any lists/collections of fonts, file name, including
    '''	preview images etc. 
    ''' </summary>
    ''' <remarks>The GUID is stored in raw 32 characters long string format without any {} 
    ''' or dashes ("-").
    ''' </remarks> 
	<VBFixedString(32)> Public ID As String
    ''' <summary>
    ''' A Custom Name/Label for the Font
    ''' </summary>
    ''' <remarks>
    ''' This is not a key, so it is not required to be unique in a collection of fonts.
    ''' </remarks>
    <VBFixedString(25)> Public NAME As String
    ''' <summary>
    ''' Credits/Creator Name (Optional Information)
    ''' </summary>
    ''' <remarks></remarks>
    <VBFixedString(35)> Public CREATEDBY As String
    ''' <summary>
    ''' Font Created Date/Time in String Format "YYYYMMDD-HHNNSS"
    ''' </summary>
    ''' <remarks></remarks>
    <VBFixedString(15)> Public DATECREATED As String
    ''' <summary>
    ''' Last Modified Date/Time in String Format "YYYYMMDD-HHNNSS"
    ''' </summary>
    ''' <remarks></remarks>
    <VBFixedString(15)> Public LASTCHANGED As String
    ''' <summary>
    ''' FONTTYPE Value derived from <seealso>eAnsiFontTypes</seealso> Enumeration.
    ''' 01 = ANSI, 02 = ASCII
    ''' </summary>
    ''' <remarks></remarks>
    Public FONTTYPE As Byte
    Public EMPTYLINEHEIGHT As Byte
    Public LETTERSPACING As Byte
    Public LINESPACING As Byte
    Public SPACEWIDTH As Byte
    Public BASELINEHEIGHT As Byte
    ''' <summary>
    ''' ALLCASE Value derived from <seealso>eLetterCase</seealso> Enumeration.
    ''' 00 = NotApplicable, 01 = UpperCase, 02 = LowerCase
    ''' </summary>
    ''' <remarks></remarks>
    Public ALLCASE As Byte
    ''' <summary>
    '''  ALLOWOVERLAP Converted by BOOLEAN, only 00 and 01 are valid values.
    ''' </summary>
    ''' <remarks></remarks>
    Public ALLOWOVERLAP As Byte
    ''' <summary>
    ''' UPPEREQLOWER Converted by BOOLEAN, only 00 and 01 are valid values.
    ''' </summary>
    ''' <remarks></remarks>
    Public UPPEREQLOWER As Byte
    <VBFixedString(13)>  Public FILLER As String
End Structure
Public Structure AFNT_CHAR
    Public DOSCHAR  As Byte
    Public DEFINED  As Byte
    Public MAXWIDTH  As Byte
    Public MAXHEIGHT  As Byte
    Public BLOCKSTART  As System.Int32
End Structure
Public Structure CHAR_SMUSH
    Public NEAR  As System.Int32
    Public FAR  As System.Int32
End Structure
Public Structure CHAR_CHAR
    Public CHARVALUE  As Byte
    Public FORECOLOR  As Byte
    Public BACKCOLOR  As Byte
    Public BLINKING As Byte
    Public REVERSED  As Byte
    Public UNUSED1  As Byte
    Public UNUSED2  As Byte
    Public UNUSED3  As Byte
End Structure
Public Structure CHAR_CHUNK
    Public DOSCHAR As Byte
    Public CHARBLOCK  As CHAR_CHAR()
    Public SMUSHBLOCK As CHAR_SMUSH()
End Structure

 

Font File Structures Defintions for C#.NET

 
public struct ANSIFONT_CHUNK
{
	public AFNT_CHUNK AFNT;
	public CHAR_CHUNK[] CHAR_CHUNKS;
}
public struct AFNT_CHUNK
{
	public AFNT_MAIN MAIN;
	public AFNT_CHAR[] CHARS;
}
public struct AFNT_MAIN
{
	/// <summary>
	/// Unique Font Identifier. GUID is being generated when a font is created and then 
	/// kept for the entire life-time of the font.
	/// The ID is used as KEY value in any lists/collections of fonts, file name, including
	///	preview images etc. 
	/// </summary>
	/// <remarks>The GUID is stored in raw 32 characters long string format without any {} 
	/// or dashes ("-").
	/// </remarks> 
	[VBFixedString(32)]
	public string ID;
	/// <summary>
	/// A Custom Name/Label for the Font
	/// </summary>
	/// <remarks>
	/// This is not a key, so it is not required to be unique in a collection of fonts.
	/// </remarks>
	[VBFixedString(25)]
	public string NAME;
	/// <summary>
	/// Credits/Creator Name (Optional Information)
	/// </summary>
	/// <remarks></remarks>
	[VBFixedString(35)]
	public string CREATEDBY;
	/// <summary>
	/// Font Created Date/Time in String Format "YYYYMMDD-HHNNSS"
	/// </summary>
	/// <remarks></remarks>
	[VBFixedString(15)]
	public string DATECREATED;
	/// <summary>
	/// Last Modified Date/Time in String Format "YYYYMMDD-HHNNSS"
	/// </summary>
	/// <remarks></remarks>
	[VBFixedString(15)]
	public string LASTCHANGED;
	/// <summary>
	/// FONTTYPE Value derived from <seealso>eAnsiFontTypes</seealso> Enumeration.
	/// 01 = ANSI, 02 = ASCII
	/// </summary>
	/// <remarks></remarks>
	public byte FONTTYPE;
	public byte EMPTYLINEHEIGHT;
	public byte LETTERSPACING;
	public byte LINESPACING;
	public byte SPACEWIDTH;
	public byte BASELINEHEIGHT;
	/// <summary>
	/// ALLCASE Value derived from <seealso>eLetterCase</seealso> Enumeration.
	/// 00 = NotApplicable, 01 = UpperCase, 02 = LowerCase
	/// </summary>
	/// <remarks></remarks>
	public byte ALLCASE;
	/// <summary>
	///  ALLOWOVERLAP Converted by BOOLEAN, only 00 and 01 are valid values.
	/// </summary>
	/// <remarks></remarks>
	public byte ALLOWOVERLAP;
	/// <summary>
	/// UPPEREQLOWER Converted by BOOLEAN, only 00 and 01 are valid values.
	/// </summary>
	/// <remarks></remarks>
	public byte UPPEREQLOWER;
	[VBFixedString(13)]
	public string FILLER;
}
public struct AFNT_CHAR
{
	public byte DOSCHAR;
	public byte DEFINED;
	public byte MAXWIDTH;
	public byte MAXHEIGHT;
	public System.Int32 BLOCKSTART;
}
public struct CHAR_SMUSH
{
	public System.Int32 NEAR;
	public System.Int32 FAR;
}
public struct CHAR_CHAR
{
	public byte CHARVALUE;
	public byte FORECOLOR;
	public byte BACKCOLOR;
	public byte BLINKING;
	public byte REVERSED;
	public byte UNUSED1;
	public byte UNUSED2;
	public byte UNUSED3;
}
public struct CHAR_CHUNK
{
	public byte DOSCHAR;
	public CHAR_CHAR[] CHARBLOCK;
	public CHAR_SMUSH[] SMUSHBLOCK;
}