The Uni Font-file format

The Uni Font-file format is designed for image fonts which has large character set in the font file such as the DBCS (Double Byte Character Set) and the UNICODE encoding. The Uni Font-file format is a super set format of the OS/2 2.1 PM Font-file format.

The Uni Font-file consists of a Uni font directory and several Uni font resources which are included in the font file. The font directory and the font resource are a set of self-defining records of the form:  typedef struct _RECORD {	UCHAR  Identity[4];  /* structure identity code */ ULONG	 Identity;	    / * structure identity code */ ULONG  ulSize;       /* structure size in bytes */ .                    /* data */ .	. } RECORD;  The notation of bit order defined in this document is that bit 0 is LSB. The elements in the stuructures defined in this document must be aligned in 1 byte boundaries. WPOS OS/2 1.0 and OS/2 2.2 will support only image fonts for the Uni font-file format.

The Uni Font Directory
This section describes the directory section of a Uni font resource. A Uni font directory contains a directory consisting of a set of structures. Each structure contains the flags, the offset to a Uni font resource, the index to a base Uni font resource if the font is a virtual font.

Several Uni font resources can be contained in a Uni font-file by specifying them in the FontResEntry array in the UNIFONTDIRECTORY structure. All values in the UNIFONTDIRECTORY structure is stored in the little endian format. The format of the font directory is:  typedef struct _UNIFONTDIRECTORY {	UCHAR	     Identity[4]; ULONG		Identity; ULONG		ulSize; ULONG	     ulUniFontResources; ULONG		flEndian; ULONG		flFileMode; UNIFONTRESOURCEENTRY FontResEntry[1]; } UNIFONTDIRECTORY;  Where:
 * Identity
 * 4 byte unsigned integer. Must be 0x554E4644 ('UNFD') 0x44464E55 ('U'+('N'<<8)+('F'<<16)+('D'<<24)).


 * ulSize
 * 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of UNIFONTRESOURCEENTRY. (i.e. sizeof(UNIFONTDIRECTORY) + sizeof(UNIFONTRESOURCEENTRY) * (ulUniFontResources - 1))


 * ulUniFontResources
 * 4 byte unsigned integer. The number of the Uni font resources in the Uni font file.


 * flEndian
 * 4 bytes of flags to specify the byte order and the bit order of the font file.


 * UNIFONT_ENDIAN_BYTEOREDER (bit 0)	Must be ZERO.
 * UNIFONT_ENDIAN_BITORDER (bit 1)		Must be ZERO.
 * Other bits must be ZERO.


 * flFileMode
 * 4 byte of flags to specify file mode.


 * UNIFONT_WRITABLE (bit 1)
 * This flag is on if the font file is designated to be updated, such as the user defined font.


 * FontResEntry
 * ulUniFontResources size of array of the UNIFONTRESOURCEENTRY structure.

The format of the Uni font resource entry is  typedef struct _UNIFONTRESOURCEENTRY {	ULONG		flUniFont; LONG		offsetUniFont; ULONG		ulBaseUniFont; } UNIFONTRESOURCEENTRY;  where:
 * flUniFont
 * 4 bytes of flags.


 * UNIFONT_VIRTUAL_FONT (bit 0)
 * This flag is on if the font is a virtual font. The font definition header, theThe font character group definition and the font character definitions are not included in the font resource. The virtual font can consists of only the font signature, the font metrics, and the font end signature and the font definition header.


 * (UNIFONT_NAME_UNICODE (bit 1))
 * This flag is on if the naming such as typeface and familyname is specified in the Unicode string.
 * (bit1) Reserved. Must be ZERO.
 * Other bits must be ZERO.


 * offsetUniFont
 * 4 byte signed integer. The offset from the beginning of the file at which the Uni font resource begins.


 * ulBaseUniFont.
 * 4 bytes unsigned integer. The index in the FontResEntry array in UNIFONTDIRECTORY which specifies the base Uni font resource used by the virtual font. This field will be specified only when the font is defined as a virtual font.

The Uni Font Resource
The Uni font resource format consists of two sections. The first section contains the general attributes of the Uni font resource and describes features such as its typeface, style and nominal size. The second section contains the actual definitions of the characters belonging to the Uni font resource.

There are four to six records in a Uni font resource in a Uni font file between the font signature and the font end resource: A Uni font resource starts with a special font-signature structure and ends with an ending structure. The font signature has the form: typedef struct _UNIFONTSIGNATURE {	UCHAR  Identity[4]; ULONG	 Identity; ULONG  ulSize; UCHAR  szSignature [24]; UCHAR	 szTechnology[64]; LONG	 offsetCompressTable; ULONG  flFontResource; } UNIFONTSIGNATURE;
 * The font signature (UNIFONTSIGNATURE)
 * The font metrics (UNIFONTMETRICS)
 * The font definition header (UNIFONTDEFINITIONHEADER)
 * The font character group definitions (UNICHARGROUPDEFINITION)
 * The pair kerning table. (Option) (UNIKERNPAIRTABLE)
 * The font character definitions
 * The font end signature (UNIENDFONTRESOURCE)
 * The records in the Uni font resource must be in the order defined above. Former record has less number in the identity field.
 * The font character definition of the image format is only supported.
 * The above figure shows an example of a Uni font resource which has N character group definitions.
 * The Font Signature

where: Identity 4 bytes unsigned integer. Must be 0x554E4653 ('UNFS'). 0x53464E55 ('U'+('N'<<8)+('F'<<16)+('S'<<24)). ulSize 4 byte unsigned integer. The size of the structure, in bytes. szSignature A NULL terminated string. Must be "UNI FONT". The future enhancement of the Uni font-file format may have a different signature in this field. szTechnology A NULL terminated string which represents the compress technology of the character glyph images. If the charcater glyph images are not compressed, the NULL string "" must be placed. This field must be NULL string for WPOS and OS/2 2.2. This field is reserved for the future compressed font support. offsetCompressTable 4 byte signed integer. The offset from the beginning of the file at which the compress table begins. This field will be used only if the compress technology name is specifed in the szTechnology field. This field must be ZERO and reserve for the future compressed font support. flFontResource 4 Bytes of flags. UNIFONT_KERNINGPAIRS_EXIST (bit 0) 	Indicates that the font has the kerning pairs table UNIFONT_PANOSE_EXIST (bit 1)		Indicates that the font has PANOSE description Other bits must be ZERO. The Font End Signature

The font end structure has the form: typedef struct _UNIENDFONTRESOURCE {	UCHAR  Identity[4]; ULONG  Identity; ULONG  ulSize; } UNIENDFONTRESOURCE;

where:

Identity 4 bytes unsigned integer. Must be 0x554E4645 ('UNFE'). 0x45464E55 ('U'+('N'<<8)+('F'<<16)+('E'<<24)). ulSize 4 byte unsigned integer. The size of the structure, in bytes. The Font Metrics This section gives an explanation of how to set the fields of the UNIFONTMETRICS structure which contains the physical font metrics used when creating fonts.  /* #defines for fsType in IFIMETRICS */


 * 1) define IFIMETRICS32_FIXED      0x0001
 * 2) define IFIMETRICS32_LICENSED   0x0002
 * 3) define IFIMETRICS32_KERNING    0x0004
 * 4) define IFIMETRICS32_DBCS       0x0010
 * 5) define IFIMETRICS32_MBCS       0x0018
 * 6) define IFIMETRICS32_FAMTRUNC   0x2000
 * 7) define IFIMETRICS32_FACETRUNC  0x1000
 * 8) define IFIMETRICS32_UNICODE	 0x0020
 * 9) define IFIMETRICS32_NO_CACHE	 0x4000

/* #defines for fsDefn in IFIMETRICS */


 * 1) define IFIMETRICS_OUTLINE      0x0001
 * 2) define IFIMETRICS32_UDC	  0x0002
 * 3) define IFIMETRICS32_ANTI_ALIAS 0x0004

/* #defines for fsSelection in IFIMETRICS */


 * 1) define IFIMETRICS32_ITALIC     0x8000
 * 2) define IFIMETRICS32_UNDERSCORE 0x4000
 * 3) define IFIMETRICS32_OVERSTRUCK 0x2000
 * 4) define IFIMETRICS32_NEGATIVE   0x1000
 * 5) define IFIMETRICS32_HOLLOW     0x0800

typedef struct _IFIMETRICS32 {  UCHAR   szFamilyname[32]; UCHAR  szFacename[32]; UCHAR  szGlyphlistName[16]; USHORT idRegistry; ULONG  idRegistry; LONG   lCapEmHeight; LONG   lXHeight; LONG   lMaxAscender; LONG   lMaxDescender; LONG   lLowerCaseAscent; LONG   lLowerCaseDescent; LONG   lInternalLeading; LONG   lExternalLeading; LONG   lAveCharWidth; LONG   lMaxCharInc; LONG   lEmInc; LONG   lMaxBaselineExt; FIXED  fxCharSlope; FIXED  fxInlineDir; FIXED  fxCharRot; USHORT usWeightClass; USHORT usWidthClass; ULONG  ulWeightClass; ULONG  ulWidthClass; LONG   lEmSquareSizeX; LONG   lEmSquareSizeY; GLYPH  giFirstChar; GLYPH  giLastChar; GLYPH  giDefaultChar; GLYPH  giBreakChar; USHORT usNominalPointSize; USHORT usMinimumPointSize; USHORT usMaximumPointSize; USHORT fsType; USHORT fsDefn; USHORT fsSelection; USHORT fsCapabilities; ULONG  ulNominalPointSize; ULONG  ulMinimumPointSize; ULONG  ulMaximumPointSize; ULONG  flType; ULONG  flDefn; ULONG  flSelection; ULONG  flCapabilities; LONG   lSubscriptXSize; LONG   lSubscriptYSize; LONG   lSubscriptXOffset; LONG   lSubscriptYOffset; LONG   lSuperscriptXSize; LONG   lSuperscriptYSize; LONG   lSuperscriptXOffset; LONG   lSuperscriptYOffset; LONG   lUnderscoreSize; LONG   lUnderscorePosition; LONG   lStrikeoutSize; LONG   lStrikeoutPosition; SHORT  cKerningPairs; ULONG  ulKerningPairs; ULONG  ulFontClass; } IFIMETRICS32; typedef IFIMETRICS32 *PIFIMETRICS32;

typedef struct _UNIFONTMETRICS {	UCHAR	 Identity[4]; ULONG  Identity; ULONG  ulSize; IFIMETRICS32 ifiMetrics; ULONG  flOptions; PANOSE panose; ULONG  ulFullFamilynameLen; LONG   offsetFullFamilyName; ULONG	 ulFullFacenameLen; LONG   offsetFullFacename; UCHAR  szFullFamilyname[256]; UCHAR  szFullFacename[256]; } UNIFONTMETRICS; typedef UNIFONTMETRICS *PUNIFONTMETRICS; 

UNIFONTMETRICS is an extension of IFIMETRICS32 which is redefined for the 32 bit environment by assuring the 4 byte alignment. UNIFONTMETRICS has the following additional fields. Identity 4 bytes unsigned integer. This must be 0x554E464D ('UNFM'). 0x4D464E55 ('U'+('N'<<8)+('F'<<16)+('M'<<24)). ulSize 4 byte unsigned integer. The size of the UNIFONTMETRICS structure, in bytes. Note that the size includes the variable length of the FullFamilyname and the FullFacename string. flOptions 4 byte unsigned integer. Option flags. UNIFONTMETRICS_PANOSE_EXIST (bit 0) The panose structure is represented in the Uni font metrics. UNIFONTMETRICS_FULLFAMILYNAME_EXIST (bit 1) The Full familyname string is represented in the Uni font metrics. UNIFONTMETRICS_FULLFACENAME_EXIST (bit 2) The full facename string is represented in the Uni font metrics.

ulFullFamilyName 4 byte unsigned integer. This size of FullFamilyName string located by offsetFullFamilyName, in bytes. This size includes NULL terminate character. If the FullFamilyName is not specified in the font file, the field must be ZERO. offsetFullFamilyName 4 byte signed integer. The offset from the top of the UNIFONTMETRICS structure at which the FamilyName string begins. The Family name string must be NULL terminated. ulFullFaceName 4 byte unsigned integer. The size of FullFaceName string located by offsetFullFaceName, in bytes. This size includes NULL terminate character. If the FullFaceName is not specified in the font file, this field must be ZERO. offsetFullFaceName 4 byte signed integer. The offset from the top of the UNIFONTMETRICS structure at which the Face name string begins. The Face name string must be NULL terminated. szFullFamilyname[256] 256 byte unsigned character array. The full familyname string of the Uni font resource. szFullFacename[256] 256 byte unsigned character array. The full facename string of the Unifont resource. panose PANOSE structure. The ten digit PANOSE number with two bytes of padding. The PANOSE definition consists of ten digits, each of which describes one of up to sixteen variations. The current digits are:  typedef struct _PANOSE { BYTE   bFamilyType; BYTE   bSerifStyle; BYTE   bWeight; BYTE   bProportion; BYTE   bContrast; BYTE   bStrokeVariation; BYTE   bArmStyle; BYTE   bLetterform; BYTE   bMidline; BYTE   bXHeight; BYTE   fbPassedISO; BYTE   fbFailedISO; } PANOSE;  1. Family Kind (bFamilyType - 6 variations) 0   = Any 1   = No Fit 2   = Text and Display 3   = Script 4   = Decorative 5   = Pictorial

2. Serif Style (bSerifStyle - 16 variations) 0   = Any 1   = No Fit 2   = Cove 3   = Obtuse Cove 4   = Square Cove 5   = Obtuse Square Cove 6   = Square 7   = Thin 8   = Bone 9   = Exaggerated 10  = Triangle 11  = Normal Sans 12  = Obtuse Sans 13  = Perp Sans 14  = Flared 15  = Rounded

3. Weight (bWeight - 12 variations) 0   = Any 1   = No Fit 2   = Very Light 3   = Light 4   = Thin 5   = Book 6   = Medium 7   = Demi 8   = Bold 9   = Heavy 10  = Black 11  = Nord

4. Proportion (bProportion - 10 variations) 0   = Any 1   = No Fit 2   = Old Style 3   = Modern 4   = Even Width 5   = Expanded 6   = Condensed 7   = Very Expanded 8   = Very Condensed 9   = Monospaced

5. Contrast (bContrast - 10 variations) 0   = Any 1   = No Fit 2   = None 3   = Very Low 4   = Low 5   = Medium Low 6   = Medium 7   = Medium High 8   = High 9   = Very High

6. Stroke Variation (bStorokeVariation - 9 variations) 0   = Any 1   = No Fit 2   = Gradual/Diagonal 3   = Gradual/Transitional 4   = Gradual/Vertical 5   = Gradual/Horizontal 6   = Rapid/Vertical 7   = Rapid/Horizontal 8   = Instant/Vertical

7. Arm Style (bArmStyle - 12 variations) 0   = Any 1   = No Fit 2   = Straight Arms/Horizontal 3   = Straight Arms/Wedge 4   = Straight Arms/Vertical 5   = Straight Arms/Single Serif 6   = Straight Arms/Double Serif 7   = Non-Straight Arms/Horizontal 8   = Non-Straight Arms/Wedge 9   = Non-Straight Arms/Vertical 10  = Non-Straight Arms/Single Serif 11  = Non-Straight Arms/Double Serif

8. Letterform (bLetterform - 16 variations) 0   = Any 1   = No Fit 2   = Normal/Contact 3   = Normal/Weighted 4   = Normal/Boxed 5   = Normal/Flattened 6   = Normal/Rounded 7   = Normal/Off Center 8   = Normal/Square 9   = Oblique/Contact 10  = Oblique/Weighted 11  = Oblique/Boxed 12  = Oblique/Flattened 13  = Oblique/Rounded 14  = Oblique/Off Center 15  = Oblique/Square

9. Midline (bMidline - 14 variations) 0   = Any 1   = No Fit 2   = Standard/Trimmed 3   = Standard/Pointed 4   = Standard/Serifed 5   = High/Trimmed 6   = High/Pointed 7   = High/Serifed 8   = Constant/Trimmed 9   = Constant/Pointed 10  = Constant/Serifed 11  = Low/Trimmed 12  = Low/Pointed 13  = Low/Serifed

10. X-height (bXHeight - 8 variations) 0   = Any 1   = No Fit 2   = Constant/Small 3   = Constant/Standard 4   = Constant/Large 5   = Ducking/Small 6   = Ducking/Standard 7   = Ducking/Large

11. fbPassedISO T.B.D

12. fbFailedISO T.B.D

When using the PANOSE number to match fonts, the ordering of the PANOSE digit is the key to finding the closest match. The most significant digit is the first digit, and the least significant digit is number ten. To find matches, the digits need to be compared, in the order given. A font mapper may want to change the precedence of the digits, to give higher weightings to other font features.

See the definition of IFIMETRICS in the IFI specification for a detailed explanation of the IFIMETRICS fields. The Font Definition Header The font definition header contains information about the format of the character definitions, the character group definitions, data about each group, each character including width data and the offset into the definition section at which the character glyph definition begins. This structure defines the format of the character group definition records and the character definition records that follow:  typedef struct _UNIFONTDEFINITIONHEADER {	UCHAR       Identity[4]; ULONG		 Identity; ULONG       ulSize; ULONG       flFontDef; ULONG		 flGroupDef; ULONG		 flCharDef; ULONG       ulCharDefSize; SHORT       xCellWidth; SHORT       yCellHeight; SHORT       xCellIncrement; SHORT       xCellA; SHORT       xCellB; SHORT       xCellC; SHORT       yCellBaseOffset; USHORT	 usReserved; GLYPH		 giFirstChar; GLYPH		 giLastChar; ULONG		 ulCharDefNum; } UNIFONTDEFINITIONHEADER;  Identity 4 bytes unsigned integer. Must be equal to 0x554E4648 ('UNFH'). 0x48464E55 ('U'+('N'<<8)+('F'<<16)+('H'<<24)). ulSize 4 byte unsigned integer. Size of this structure in bytes. flFontDef 4 bytes of flags. Indicates which fields are present in the font definition data in the header.

Bit 0		1 = character width is defined in the font definition header (fixed pitch) 0 = character width is not defined in the font definition header

Bit 1		1 = character height is defined in the font definition header (same for all characters) 0 = character height is not defined in the font definition header

Bit 2		1 = character increment is defined in the font definition header (same for all characters) 0 = character increment is not defined in the font definition header

Bit 3		1 = a_space is defined in the font definition header (same		   for all characters) 0 = a_space is not defined in the font definition header (non abc_space font or defined for each character)

Bit 4		1 = b_space is defined in the font definition header (same		   for all characters) 0 = b_space is not defined in the font definition header (non abc_space font or defined for each character)

Bit 5		1 = c_space is defined in the font definition header (same		   for all characters) 0 = c_space is not defined in the font definition header (non abc_space font or defined for each character)

Bit 6		1 = base offset is defined in the font definition header (same for all chracters) 0 = base offset is not defined in the font definition header flGroupDef 4 bytes of flags. Indicates which fields are present on a per character group basis. Each flag is valid only when the correnponding flFontDef flag bit is on (= 1).

Bit 0		1 = character width is defined in the character group definitions (defined for each character group) 0 = character width is not defined in the character group definition (same for all characters)

Bit 1		1 = character height is defined in the character group definitions (defined for each character group) 0 = character height is not defined in the character group definitions (same for all characters)

Bit 2		1 = character increment is defined in the the character group definitions (defined for each character group) 0 = character increment is not defined in the character group definitions (same for all characters)

Bit 3		1 = a_space is defined in the character group definitions (defined for each character group) 0 = a_space is not defined in the character group definitions (same for all characters)

Bit 4		1 = b_space is defined in the character group definitions (defined for each character group) 0 = b_space is not defined in the character group definitions (same for all characters)

Bit 5		1 = c_space is defined in the character group definitions (defined for each character group) 0 = c_space is not defined in the character group definitions (same for all characters) Bit 6		1 = base offset is defined in the character group definitions (defined for each character group) 0 = base offset is not defined in the character group definitions (same for all characters)

flCharDef 4 bytes of flags. Indicates which fields are present on a per character basis.

Bit 0		1 = character width is defined in the character definitions (defined for each character definition) 0 = character width is not defined in the character definitions

Bit 1		1 = character height is defined in the character definitions (defined for each character definition) 0 = character height is not defined in the character definitions

Bit 2		1 = character increment is defined in the the character definitions (defined for each character definition) 0 = character increment is not defined in the character definitions

Bit 3		1 = a_space is defined in the character definitions (defined for each character definition) 0 = a_space is not defined in the character definitions

Bit 4		1 = b_space is defined in the character definitions (defined for each character definition) 0 = b_space is not defined in the character definitions

Bit 5		1 = c_space is defined in the character definitions (defined for each character definition) 0 = c_space is not defined in the character definitions Bit 6		1 = base offset is defined in the character definitions (defined for each character definition) 0 = base offset is not defined in the character definitions

Bit 7		1 = offset to glyph is defined 0 = offset to glyph is not defined

Bit 7 must be ON for WPOS OS/2 1.0 and OS/2 2.2. ulCharDefSize 4-byte unsigned integer. Indicates the length in bytes of each character definition record (the per character data). xCellWidth 2-byte signed integer. The width of the characters, in pels for image fonts. yCellHeight 2-byte signed integer. The height of the characters, in pels for image fonts. xCellIncrement 2-byte signed integer. The distance, in pels for image fonts, along with the character baseline required to step from one character to the next (when forming a character string). xCellA 2-byte signed integer. The width of the space before a character in the inline direction (the a_space), in pels for image fonts. xCellB 2-byte signed integer. The width of a character (inline direction), in pels for image fonts. (the b_space). xCellC 2-byte signed integer. The width of the space after a character in the inline direction, in pels for image fonts (the c_space). yCellBaseOffset 2-byte signed integer. The position of the top of a character definition relative to the baseline in the direction perpendicular to the baseline, in pels for image fonts. usReserved 2 byte unsigned integer. Must be ZERO. giFirstChar 4 byte unsigned integer. The index of the first character glyph in the font file. giLastChar 4 byte unsigned integer. The index of the last character glyph in the font file. ulCharDefNum 4 byte unsigned integer. The number of the character definitions in the font file. If all of the characters between the first and the last character are defined, the value in this field will be giLastChar - giFirstChar + 1. WPOS OS/2 1.0 and OS/2 2.2 will support only type1, type2 and type3 font as the font defintion header records are defined as follows. Type 1 - fixed pitch width and height font

ulIdentity = 0x554E4648; ulSIze = 64; flFontDef = 0x00000047;	flGroupDef = 0x00000000; flCharDef = 0x00000081; (width defined for each character for the performance even		 if the font is deifned as a fixed pitch width font) ulCharDefSize = 6; xCellWidth = Width of the characters yCellHeight = Height of the characters xCellIncrement = Width of the characters xCellA = 0 xCellB = 0 xCellC = 0 yCellBaseOffset = Baseline offset for all characters ulFirstChar = The glyph index of the first character ulLastChar = The glyph index of the last character ulCharDefNum = The number of the character definitions Type2 - Proportional width and fixed pitch height font

ulIdentity = 0x554E4648; ulSIze = 64; flFontDef = 0x00000042; flGroupDef = 0x00000000; flCharDef = 0x00000081; ulCharDefSize = 6; xCellWidth = 0 yCellHeight = Height of the characters xCellIncrement = 0 xCellA = 0 xCellB = 0 xCellC = 0 yCellBaseOffset = Baseline offset for all characters ulFirstChar = The glyph index of the first character ulLastChar = The glyph index of the last character ulCharDefNum = The number of the character definitions Type3 - ABC_space width and fixed pitch height font ulIdentity = 0x554E4648; ulSIze = 64; flFontDef = 0x00000042; flGroupDef = 0x00000000; flCharDef = 0x000000B8; ulCharDefSize = 10; xCellWidth = 0 yCellHeight = Height of the characters xCellIncrement = 0 xCellA = 0 xCellB = 0 xCellC = 0 yCellBaseOffset = Baseline offset for all characters ulFirstChar = The glyph index of the first character ulLastChar = The glyph index of the last character ulCharDefNum = The number of the character definitions The following is a explanation of a_space, b_space and c_space definition. 1. Proportional characters (a+b+c = character increment) for each character: a,b,c >= 0 2. Characters where a, b, and c are definitions for all characters: b >= 0 a, c any integer

The Font Character Group Definition
The character group definition record is defined to support the font indices of a large character set of which indices may consist of sparse ranges.

typedef struct _UNICHARGROUPDEFINITION {	UCHAR		Identity[4]; ULONG		Identity; ULONG		ulSize; ULONG		ulCharGroups; UNICHARGROUPENTRY CharGroupEntry[1]; } UNICHARGROUPDEFINITION; Identity 4 bytes unsigned integer. Must be 0x554E4748 ('UNGH'). 0x48474E55 ('U'+('N'<<8)+('G'<<16)+('H'<<24)). ulSize 4 byte unsigned integer. Size of this structure, in bytes, which includes all entries of UNICHARGROUPENTRY. (i.e. sizeof(UNICHARGROUPDEFINITION) + sizeof(UNICHARGROUPENTRY) * (ulCharGroups - 1)) ulCharGroups 4 byte unsigned integer. The number of the character groups in the record. CharGroupEntry unCharGroups size of array of the UNICHARGROUPENTRY structure. The format of the UNICHARGROUPENTRY is :

typedef struct _UNICHARGROUPENTRY {	ULONG		flCharGroupEntry; GLYPH		giFirstChar; GLYPH		giLastChar; LONG		offsetCharDef; LONG		offsetImageData; ULONG 	ulImageDataSize; SHORT		xCellWidth; SHORT		yCellHeight; SHORT		xCellIncrement; SHORT		xCellA; SHORT		xCellB; SHORT		xCellC; SHORT		yCellBaseOffset; USHORT	usReserved; } UNICHARGROUPENTRY;

where: flCharGroupEntry 4 bytes of flags. Indicates which fields are present in the character definition data in the header. If the font file is created for a single repository, UNIFONT_FREQUENT_GROUP (Bit 0) Indicate that this character gorup may be frequestly used. It is recommended that the font subsystem cache the character definitions of this group in memory for the performance when this bit is ON. giFirstChar 4 byte unsigned integer. Indicates the start font index of the character group. giLastChar 4 byte unsigned integer. Indicates the end font index of the character group. offsetCharDef 4 bytes signed integer. The offset from the beginning of the Uni font resource (the beginning of the font signature structure) at which the character definition record of this character group begins. offsetImageData 4-byte unsigned integer. The offset from the beginning of the Uni font resource (the beginning of the font signature structure) at which the character glyph definitions begins which belongs to the character group. All character glyph definitions (Image data) must be stored from the offsetImageData position continuously and must be stored in the ulImageDataSize block size of the block. ulImageDataSize 4-byte unsigned integer. The size of the character glyph definition group (image data group). The following field are defined in the UNICHARGROUPENTRY structure, however, the values may or may not be present in them according to the ulGroupDef field in UNIFONTDEFINITIONHEADER. If the values are present, they are applied for only the character group. xCellWidth 2-byte signed integer. The width of the characters in the character group definition in pels. yCellHeight 2-byte signed integer. The height of the characters in the character group definition in pels. xCellIncrement 2-byte signed integer. The length along the character baseline required to step from this character to the next in pels(when forming a character string). xCellA 2-byte signed integer. The width of the space before the character in the inline direction in pels. (a_space) xCellB 2-byte signed integer. The width of the character shape in the inline direction in pels. (b_space) xCellC 2-byte signed integer. The width of the space after the character in the inline direction in pels. (c_space) yCellBaseOffset 2-byte signed integer. The position of the top of the chraacters in the character group definition relative to the baseline in the direction perpendicular to the baseline in pels. usReserved 2-byte unsigned integer. Must be ZERO. The Kerning Pair Table This record will exist in a Uni font-file format if the UNIFONT_KERNINGPAIRS_EXIST flag in the flFontSignature field in the UNIFONTSIGNATE structure is on. The kerning pair table record is not present if the cKerningPairs field in the UNIFONTMETRICS structure is zero. This table should be sorted by the first character (usFirstChar) and the second character (usSecondChar) order to allow binary searches.

typedef struct _UNIKERNPAIRTABLE {	UCHAR  Identity[4]; ULONG	 Identity; ULONG  ulSize; ULONG  ulKernPairs; KERNINGPAIRS KernPairs[1]; } UNIKERNPAIRTABLE;

where: Identity 4bytes unsigned integer. Must be 0x554E4B54 ('UNKT'). 0x544B4E55 ('U'+('N'<<8)+('K'<<16)+('T'<<24)). ulSize 4 byte unsigned integer. The size of the stucture in bytes, which includes all entries of KERNINGPAIRS. (i.e. sizeof(UNIKERNINGPAIRTABLE) + sizeof(KERNINGPAIRS) * (ulKernPairs - 1)) ulKernPairs 4 byte unsigned integer. The number of kerning pairs in the record. KernPairs ulKernPairs size of array of the KERNINGPAIR structure.

typedef struct _KERNINGPAIRS {	ULONG  ulFirstChar; ULONG  ulSecondChar; LONG   lKerningAmount; } KERNINGPAIRS;

where:

ulFirstChar 4 byte unsigned integer. First character of the kerning pair. This value must be zero-extended when converted to the GLYPH type. ulSecondChar 4 byte unsigned integer. Second character of the kerning pair. This value must be zero-extended when converted to the GLYPH type. lKerningAmount 4 byte signed integer. Kerning value in pels for image fonts. Positive values increase the inter-character spacing while negative values bring the characters closer together. The Font Character Definition Character Definition Record The following fields may or may not be present, according to the font character definition fields flags. If a field is present, it is present for each character and the value applies to that character only. The fields in the record should be in the order of the following. There are ulCharNumber of the records for image fonts. Character Glyph Definition Offset (offsetImageData) 4 byte signed integer. The offset from the beginning of the Uni font resource at which the character glyph definition begins. This field should be set to zero if the character glyph is not defined in the font file. If the font subsystem detect the zero value in this field, it should return the character glyph image of giDefaultChar index which is specified in UNIFONTMETRICS. This field must be presented. Character Cell Width (xCellWidth) 2-byte integer. The width of the character definition in pels. Character Cell Height (xCellHeight) 2-byte integer. The height of the character definition in pels. Character Increment (xCellIncrement) 2-byte integer. The length along the character baseline required to step from this character to the next in pels (when forming a character string). Character a-space (xCellA) 2-byte signed integer. The width of the space before the character in the inline direction in pels. Character b-space (xCellB) 2-byte integer. The width of the character shape in the inline direction in pels. Character c-space (xCellC) 2-byte signed integer. The width of the space after the character in the inline direction in pels. Character Baseline Offset (xCellBaseOffset) 2-byte signed integer. The position of the top of a character definition relative to the baseline in the direction perpendicular to the baseline in pels. The xCellWidth and the xCellIncrement field in the FONTDEFINITIONHEADER structure are nonzero and that represents a fixed pitch width font for the type 1 font. However, the type 1 fonts have offset (offsetImageData) and width (xCellWidth) pairs in the character definition records and the proportional-space flag, bit 0, is set in the fsType field of the UNIFONTMETRICS structure. OS/2 2.1 PM font-file format has the same definition for the type 1 fonts. Image Data Format The bits for each character are stored separately, and start on a byte boundary. Sequential bytes represent horizontal pieces of the character image. For example, a 15-bit-wide H is stored as follows:

byte                  byte 0  00000000 0000000-   1      2   01100000 0000110-   3      	4   01100000 0000110-   5 6   01100000 0000110-   7      8   01100000 0000110-   9      10  01111111 1111110-  11      12  01111111 1111110-  13      14  01100000 0000110-  15 16  01100000 0000110-  17      18  01100000 0000110-  19      20  01100000 0000110-  21 22  00000000 0000000-  23 The format is the same as the OS/2 bitmap format of one bit per pel.

The Uni Font-file format
The Uni Font-file format is designed for image fonts which has large character set in the font file such as the DBCS (Double Byte Character Set) and the UNICODE encoding. The Uni Font-file format is a super set format of the OS/2 2.1 PM Font-file format.

The Uni Font-file consists of a Uni font directory and several Uni font resources which are included in the font file.

The font directory and the font resource are a set of self-defining records of the form:

typedef struct _RECORD {	UCHAR  Identity[4];  /* structure identity code */ ULONG	 Identity;	    / * structure identity code */ ULONG  ulSize;       /* structure size in bytes */ .                    /* data */ .	. } RECORD; The notation of bit order defined in this document is that bit 0 is LSB. The elements in the stuructures defined in this document must be aligned in 1 byte boundaries. WPOS OS/2 1.0 and OS/2 2.2 will support only image fonts for the Uni font-file format. The Uni Font Directory This section describes the directory section of a Uni font resource. A Uni font directory contains a directory consisting of a set of structures. Each structure contains the flags, the offset to a Uni font resource, the index to a base Uni font resource if the font is a virtual font. Several Uni font resources can be contained in a Uni font-file by specifying them in the FontResEntry array in the UNIFONTDIRECTORY structure. All values in the UNIFONTDIRECTORY structure is stored in the little endian format. The format of the font directory is:

typedef struct _UNIFONTDIRECTORY {	UCHAR	     Identity[4]; ULONG		Identity; ULONG		ulSize; ULONG	     ulUniFontResources; ULONG		flEndian; ULONG		flFileMode; UNIFONTRESOURCEENTRY FontResEntry[1]; } UNIFONTDIRECTORY;

Where: Identity 4 byte unsigned integer. Must be 0x554E4644 ('UNFD') 0x44464E55 ('U'+('N'<<8)+('F'<<16)+('D'<<24)). ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of UNIFONTRESOURCEENTRY. (i.e. sizeof(UNIFONTDIRECTORY) + sizeof(UNIFONTRESOURCEENTRY) * (ulUniFontResources - 1)) ulUniFontResources 4 byte unsigned integer. The number of the Uni font resources in the Uni font file. flEndian 4 bytes of flags to specify the byte order and the bit order of the font file. UNIFONT_ENDIAN_BYTEOREDER (bit 0)	Must be ZERO. UNIFONT_ENDIAN_BITORDER (bit 1)		Must be ZERO. Other bits must be ZERO. flFileMode 4 byte of flags to specify file mode. UNIFONT_WRITABLE (bit 1) This flag is on if the font file is designated to be updated, such as the user defined font. FontResEntry ulUniFontResources size of array of the UNIFONTRESOURCEENTRY structure.

The format of the Uni font resource entry is

typedef struct _UNIFONTRESOURCEENTRY {	ULONG		flUniFont; LONG		offsetUniFont; ULONG		ulBaseUniFont; } UNIFONTRESOURCEENTRY; where: flUniFont 4 bytes of flags. UNIFONT_VIRTUAL_FONT (bit 0) 	This flag is on if the font is a virtual font. The font definition header, theThe font character group definition and the font character definitions are not included in the font resource. The virtual font can consists of only the font signature, the font metrics, and the font end signature and the font definition header. (UNIFONT_NAME_UNICODE (bit 1))	This flag is on if the naming such as typeface and familyname is specified in the Unicode string. (bit1) Reserved. Must be ZERO. Other bits must be ZERO. offsetUniFont 4 byte signed integer. The offset from the beginning of the file at which the Uni font resource begins. ulBaseUniFont. 4 bytes unsigned integer. The index in the FontResEntry array in UNIFONTDIRECTORY which specifies the base Uni font resource used by the virtual font. This field will be specified only when the font is defined as a virtual font. The Uni Font Resource The Uni font resource format consists of two sections. The first section contains the general attributes of the Uni font resource and describes features such as its typeface, style and nominal size. The second section contains the actual definitions of the characters belonging to the Uni font resource. There are four to six records in a Uni font resource in a Uni font file between the font signature and the font end resource: The font signature (UNIFONTSIGNATURE) The font metrics (UNIFONTMETRICS) The font definition header (UNIFONTDEFINITIONHEADER) The font character group definitions (UNICHARGROUPDEFINITION) The pair kerning table. (Option) (UNIKERNPAIRTABLE) The font character definitions The font end signature (UNIENDFONTRESOURCE) The records in the Uni font resource must be in the order defined above. Former record has less number in the identity field. The font character definition of the image format is only supported. The above figure shows an example of a Uni font resource which has N character group definitions. The Font Signature A Uni font resource starts with a special font-signature structure and ends with an ending structure. The font signature has the form:

typedef struct _UNIFONTSIGNATURE {	UCHAR  Identity[4]; ULONG	 Identity; ULONG  ulSize; UCHAR  szSignature [24]; UCHAR	 szTechnology[64]; LONG	 offsetCompressTable; ULONG  flFontResource; } UNIFONTSIGNATURE; where: Identity 4 bytes unsigned integer. Must be 0x554E4653 ('UNFS'). 0x53464E55 ('U'+('N'<<8)+('F'<<16)+('S'<<24)). ulSize 4 byte unsigned integer. The size of the structure, in bytes. szSignature A NULL terminated string. Must be "UNI FONT". The future enhancement of the Uni font-file format may have a different signature in this field. szTechnology A NULL terminated string which represents the compress technology of the character glyph images. If the charcater glyph images are not compressed, the NULL string "" must be placed. This field must be NULL string for WPOS and OS/2 2.2. This field is reserved for the future compressed font support. offsetCompressTable 4 byte signed integer. The offset from the beginning of the file at which the compress table begins. This field will be used only if the compress technology name is specifed in the szTechnology field. This field must be ZERO and reserve for the future compressed font support. flFontResource 4 Bytes of flags. UNIFONT_KERNINGPAIRS_EXIST (bit 0) 	Indicates that the font has the kerning pairs table UNIFONT_PANOSE_EXIST (bit 1)		Indicates that the font has PANOSE description Other bits must be ZERO.

The Font End Signature
The font end structure has the form:  typedef struct _UNIENDFONTRESOURCE {	UCHAR  Identity[4]; ULONG  Identity; ULONG  ulSize; } UNIENDFONTRESOURCE; 

where:

Identity 4 bytes unsigned integer. Must be 0x554E4645 ('UNFE'). 0x45464E55 ('U'+('N'<<8)+('F'<<16)+('E'<<24)). ulSize 4 byte unsigned integer. The size of the structure, in bytes. The Font Metrics This section gives an explanation of how to set the fields of the UNIFONTMETRICS structure which contains the physical font metrics used when creating fonts.

/* #defines for fsType in IFIMETRICS */


 * 1) define IFIMETRICS32_FIXED      0x0001
 * 2) define IFIMETRICS32_LICENSED   0x0002
 * 3) define IFIMETRICS32_KERNING    0x0004
 * 4) define IFIMETRICS32_DBCS       0x0010
 * 5) define IFIMETRICS32_MBCS       0x0018
 * 6) define IFIMETRICS32_FAMTRUNC   0x2000
 * 7) define IFIMETRICS32_FACETRUNC  0x1000
 * 8) define IFIMETRICS32_UNICODE	 0x0020
 * 9) define IFIMETRICS32_NO_CACHE	 0x4000

/* #defines for fsDefn in IFIMETRICS */


 * 1) define IFIMETRICS_OUTLINE      0x0001
 * 2) define IFIMETRICS32_UDC	  0x0002
 * 3) define IFIMETRICS32_ANTI_ALIAS 0x0004

/* #defines for fsSelection in IFIMETRICS */


 * 1) define IFIMETRICS32_ITALIC     0x8000
 * 2) define IFIMETRICS32_UNDERSCORE 0x4000
 * 3) define IFIMETRICS32_OVERSTRUCK 0x2000
 * 4) define IFIMETRICS32_NEGATIVE   0x1000
 * 5) define IFIMETRICS32_HOLLOW     0x0800

typedef struct _IFIMETRICS32 {  UCHAR   szFamilyname[32]; UCHAR  szFacename[32]; UCHAR  szGlyphlistName[16]; USHORT idRegistry; ULONG  idRegistry; LONG   lCapEmHeight; LONG   lXHeight; LONG   lMaxAscender; LONG   lMaxDescender; LONG   lLowerCaseAscent; LONG   lLowerCaseDescent; LONG   lInternalLeading; LONG   lExternalLeading; LONG   lAveCharWidth; LONG   lMaxCharInc; LONG   lEmInc; LONG   lMaxBaselineExt; FIXED  fxCharSlope; FIXED  fxInlineDir; FIXED  fxCharRot; USHORT usWeightClass; USHORT usWidthClass; ULONG  ulWeightClass; ULONG  ulWidthClass; LONG   lEmSquareSizeX; LONG   lEmSquareSizeY; GLYPH  giFirstChar; GLYPH  giLastChar; GLYPH  giDefaultChar; GLYPH  giBreakChar; USHORT usNominalPointSize; USHORT usMinimumPointSize; USHORT usMaximumPointSize; USHORT fsType; USHORT fsDefn; USHORT fsSelection; USHORT fsCapabilities; ULONG  ulNominalPointSize; ULONG  ulMinimumPointSize; ULONG  ulMaximumPointSize; ULONG  flType; ULONG  flDefn; ULONG  flSelection; ULONG  flCapabilities; LONG   lSubscriptXSize; LONG   lSubscriptYSize; LONG   lSubscriptXOffset; LONG   lSubscriptYOffset; LONG   lSuperscriptXSize; LONG   lSuperscriptYSize; LONG   lSuperscriptXOffset; LONG   lSuperscriptYOffset; LONG   lUnderscoreSize; LONG   lUnderscorePosition; LONG   lStrikeoutSize; LONG   lStrikeoutPosition; SHORT  cKerningPairs; ULONG  ulKerningPairs; ULONG  ulFontClass; } IFIMETRICS32; typedef IFIMETRICS32 *PIFIMETRICS32;

typedef struct _UNIFONTMETRICS {	UCHAR	 Identity[4]; ULONG  Identity; ULONG  ulSize; IFIMETRICS32 ifiMetrics; ULONG  flOptions; PANOSE panose; ULONG  ulFullFamilynameLen; LONG   offsetFullFamilyName; ULONG	 ulFullFacenameLen; LONG   offsetFullFacename; UCHAR  szFullFamilyname[256]; UCHAR  szFullFacename[256]; } UNIFONTMETRICS; typedef UNIFONTMETRICS *PUNIFONTMETRICS; UNIFONTMETRICS is an extension of IFIMETRICS32 which is redefined for the 32 bit environment by assuring the 4 byte alignment. UNIFONTMETRICS has the following additional fields. Identity 4 bytes unsigned integer. This must be 0x554E464D ('UNFM'). 0x4D464E55 ('U'+('N'<<8)+('F'<<16)+('M'<<24)). ulSize 4 byte unsigned integer. The size of the UNIFONTMETRICS structure, in bytes. Note that the size includes the variable length of the FullFamilyname and the FullFacename string. flOptions 4 byte unsigned integer. Option flags. UNIFONTMETRICS_PANOSE_EXIST (bit 0) The panose structure is represented in the Uni font metrics. UNIFONTMETRICS_FULLFAMILYNAME_EXIST (bit 1) The Full familyname string is represented in the Uni font metrics. UNIFONTMETRICS_FULLFACENAME_EXIST (bit 2) The full facename string is represented in the Uni font metrics.

ulFullFamilyName 4 byte unsigned integer. This size of FullFamilyName string located by offsetFullFamilyName, in bytes. This size includes NULL terminate character. If the FullFamilyName is not specified in the font file, the field must be ZERO. offsetFullFamilyName 4 byte signed integer. The offset from the top of the UNIFONTMETRICS structure at which the FamilyName string begins. The Family name string must be NULL terminated. ulFullFaceName 4 byte unsigned integer. The size of FullFaceName string located by offsetFullFaceName, in bytes. This size includes NULL terminate character. If the FullFaceName is not specified in the font file, this field must be ZERO. offsetFullFaceName 4 byte signed integer. The offset from the top of the UNIFONTMETRICS structure at which the Face name string begins. The Face name string must be NULL terminated. szFullFamilyname[256] 256 byte unsigned character array. The full familyname string of the Uni font resource. szFullFacename[256] 256 byte unsigned character array. The full facename string of the Unifont resource. panose PANOSE structure. The ten digit PANOSE number with two bytes of padding. The PANOSE definition consists of ten digits, each of which describes one of up to sixteen variations. The current digits are:

typedef struct _PANOSE { BYTE   bFamilyType; BYTE   bSerifStyle; BYTE   bWeight; BYTE   bProportion; BYTE   bContrast; BYTE   bStrokeVariation; BYTE   bArmStyle; BYTE   bLetterform; BYTE   bMidline; BYTE   bXHeight; BYTE   fbPassedISO; BYTE   fbFailedISO; } PANOSE;

1. Family Kind (bFamilyType - 6 variations) 0   = Any 1   = No Fit 2   = Text and Display 3   = Script 4   = Decorative 5   = Pictorial

2. Serif Style (bSerifStyle - 16 variations) 0   = Any 1   = No Fit 2   = Cove 3   = Obtuse Cove 4   = Square Cove 5   = Obtuse Square Cove 6   = Square 7   = Thin 8   = Bone 9   = Exaggerated 10  = Triangle 11  = Normal Sans 12  = Obtuse Sans 13  = Perp Sans 14  = Flared 15  = Rounded

3. Weight (bWeight - 12 variations) 0   = Any 1   = No Fit 2   = Very Light 3   = Light 4   = Thin 5   = Book 6   = Medium 7   = Demi 8   = Bold 9   = Heavy 10  = Black 11  = Nord

4. Proportion (bProportion - 10 variations) 0   = Any 1   = No Fit 2   = Old Style 3   = Modern 4   = Even Width 5   = Expanded 6   = Condensed 7   = Very Expanded 8   = Very Condensed 9   = Monospaced

5. Contrast (bContrast - 10 variations) 0   = Any 1   = No Fit 2   = None 3   = Very Low 4   = Low 5   = Medium Low 6   = Medium 7   = Medium High 8   = High 9   = Very High

6. Stroke Variation (bStorokeVariation - 9 variations) 0   = Any 1   = No Fit 2   = Gradual/Diagonal 3   = Gradual/Transitional 4   = Gradual/Vertical 5   = Gradual/Horizontal 6   = Rapid/Vertical 7   = Rapid/Horizontal 8   = Instant/Vertical

7. Arm Style (bArmStyle - 12 variations) 0   = Any 1   = No Fit 2   = Straight Arms/Horizontal 3   = Straight Arms/Wedge 4   = Straight Arms/Vertical 5   = Straight Arms/Single Serif 6   = Straight Arms/Double Serif 7   = Non-Straight Arms/Horizontal 8   = Non-Straight Arms/Wedge 9   = Non-Straight Arms/Vertical 10  = Non-Straight Arms/Single Serif 11  = Non-Straight Arms/Double Serif

8. Letterform (bLetterform - 16 variations) 0   = Any 1   = No Fit 2   = Normal/Contact 3   = Normal/Weighted 4   = Normal/Boxed 5   = Normal/Flattened 6   = Normal/Rounded 7   = Normal/Off Center 8   = Normal/Square 9   = Oblique/Contact 10  = Oblique/Weighted 11  = Oblique/Boxed 12  = Oblique/Flattened 13  = Oblique/Rounded 14  = Oblique/Off Center 15  = Oblique/Square

9. Midline (bMidline - 14 variations) 0   = Any 1   = No Fit 2   = Standard/Trimmed 3   = Standard/Pointed 4   = Standard/Serifed 5   = High/Trimmed 6   = High/Pointed 7   = High/Serifed 8   = Constant/Trimmed 9   = Constant/Pointed 10  = Constant/Serifed 11  = Low/Trimmed 12  = Low/Pointed 13  = Low/Serifed

10. X-height (bXHeight - 8 variations) 0   = Any 1   = No Fit 2   = Constant/Small 3   = Constant/Standard 4   = Constant/Large 5   = Ducking/Small 6   = Ducking/Standard 7   = Ducking/Large

11. fbPassedISO T.B.D

12. fbFailedISO T.B.D

When using the PANOSE number to match fonts, the ordering of the PANOSE digit is the key to finding the closest match. The most significant digit is the first digit, and the least significant digit is number ten. To find matches, the digits need to be compared, in the order given. A font mapper may want to change the precedence of the digits, to give higher weightings to other font features.

See the definition of IFIMETRICS in the IFI specification for a detailed explanation of the IFIMETRICS fields. The Font Definition Header The font definition header contains information about the format of the character definitions, the character group definitions, data about each group, each character including width data and the offset into the definition section at which the character glyph definition begins. This structure defines the format of the character group definition records and the character definition records that follow:

typedef struct _UNIFONTDEFINITIONHEADER {	UCHAR       Identity[4]; ULONG		 Identity; ULONG       ulSize; ULONG       flFontDef; ULONG		 flGroupDef; ULONG		 flCharDef; ULONG       ulCharDefSize; SHORT       xCellWidth; SHORT       yCellHeight; SHORT       xCellIncrement; SHORT       xCellA; SHORT       xCellB; SHORT       xCellC; SHORT       yCellBaseOffset; USHORT	 usReserved; GLYPH		 giFirstChar; GLYPH		 giLastChar; ULONG		 ulCharDefNum; } UNIFONTDEFINITIONHEADER;

Identity 4 bytes unsigned integer. Must be equal to 0x554E4648 ('UNFH'). 0x48464E55 ('U'+('N'<<8)+('F'<<16)+('H'<<24)). ulSize 4 byte unsigned integer. Size of this structure in bytes. flFontDef 4 bytes of flags. Indicates which fields are present in the font definition data in the header.

Bit 0		1 = character width is defined in the font definition header (fixed pitch) 0 = character width is not defined in the font definition header

Bit 1		1 = character height is defined in the font definition header (same for all characters) 0 = character height is not defined in the font definition header

Bit 2		1 = character increment is defined in the font definition header (same for all characters) 0 = character increment is not defined in the font definition header

Bit 3		1 = a_space is defined in the font definition header (same		   for all characters) 0 = a_space is not defined in the font definition header (non abc_space font or defined for each character)

Bit 4		1 = b_space is defined in the font definition header (same		   for all characters) 0 = b_space is not defined in the font definition header (non abc_space font or defined for each character)

Bit 5		1 = c_space is defined in the font definition header (same		   for all characters) 0 = c_space is not defined in the font definition header (non abc_space font or defined for each character)

Bit 6		1 = base offset is defined in the font definition header (same for all chracters) 0 = base offset is not defined in the font definition header flGroupDef 4 bytes of flags. Indicates which fields are present on a per character group basis. Each flag is valid only when the correnponding flFontDef flag bit is on (= 1).

Bit 0		1 = character width is defined in the character group definitions (defined for each character group) 0 = character width is not defined in the character group definition (same for all characters)

Bit 1		1 = character height is defined in the character group definitions (defined for each character group) 0 = character height is not defined in the character group definitions (same for all characters)

Bit 2		1 = character increment is defined in the the character group definitions (defined for each character group) 0 = character increment is not defined in the character group definitions (same for all characters)

Bit 3		1 = a_space is defined in the character group definitions (defined for each character group) 0 = a_space is not defined in the character group definitions (same for all characters)

Bit 4		1 = b_space is defined in the character group definitions (defined for each character group) 0 = b_space is not defined in the character group definitions (same for all characters)

Bit 5		1 = c_space is defined in the character group definitions (defined for each character group) 0 = c_space is not defined in the character group definitions (same for all characters) Bit 6		1 = base offset is defined in the character group definitions (defined for each character group) 0 = base offset is not defined in the character group definitions (same for all characters)

flCharDef 4 bytes of flags. Indicates which fields are present on a per character basis.

Bit 0		1 = character width is defined in the character definitions (defined for each character definition) 0 = character width is not defined in the character definitions

Bit 1		1 = character height is defined in the character definitions (defined for each character definition) 0 = character height is not defined in the character definitions

Bit 2		1 = character increment is defined in the the character definitions (defined for each character definition) 0 = character increment is not defined in the character definitions

Bit 3		1 = a_space is defined in the character definitions (defined for each character definition) 0 = a_space is not defined in the character definitions

Bit 4		1 = b_space is defined in the character definitions (defined for each character definition) 0 = b_space is not defined in the character definitions

Bit 5		1 = c_space is defined in the character definitions (defined for each character definition) 0 = c_space is not defined in the character definitions Bit 6		1 = base offset is defined in the character definitions (defined for each character definition) 0 = base offset is not defined in the character definitions

Bit 7		1 = offset to glyph is defined 0 = offset to glyph is not defined

Bit 7 must be ON for WPOS OS/2 1.0 and OS/2 2.2.


 * ulCharDefSize
 * 4-byte unsigned integer. Indicates the length in bytes of each character definition record (the per character data).


 * xCellWidth
 * 2-byte signed integer. The width of the characters, in pels for image fonts.


 * yCellHeight
 * 2-byte signed integer. The height of the characters, in pels for image fonts.


 * xCellIncrement
 * 2-byte signed integer. The distance, in pels for image fonts, along with the character baseline required to step from one character to the next (when forming a character string).


 * xCellA
 * 2-byte signed integer. The width of the space before a character in the inline direction (the a_space), in pels for image fonts.


 * xCellB
 * 2-byte signed integer. The width of a character (inline direction), in pels for image fonts. (the b_space).


 * xCellC
 * 2-byte signed integer. The width of the space after a character in the inline direction, in pels for image fonts (the c_space).


 * yCellBaseOffset
 * 2-byte signed integer. The position of the top of a character definition relative to the baseline in the direction perpendicular to the baseline, in pels for image fonts.


 * usReserved
 * 2 byte unsigned integer. Must be ZERO.


 * giFirstChar
 * 4 byte unsigned integer. The index of the first character glyph in the font file.


 * giLastChar
 * 4 byte unsigned integer. The index of the last character glyph in the font file.


 * ulCharDefNum
 * 4 byte unsigned integer. The number of the character definitions in the font file. If all of the characters between the first and the last character are defined, the value in this field will be giLastChar - giFirstChar + 1.

WPOS OS/2 1.0 and OS/2 2.2 will support only type1, type2 and type3 font as the font defintion header records are defined as follows.

Type 1 - fixed pitch width and height font

ulIdentity = 0x554E4648; ulSIze = 64; flFontDef = 0x00000047;	flGroupDef = 0x00000000; flCharDef = 0x00000081; (width defined for each character for the performance even		 if the font is deifned as a fixed pitch width font) ulCharDefSize = 6; xCellWidth = Width of the characters yCellHeight = Height of the characters xCellIncrement = Width of the characters xCellA = 0 xCellB = 0 xCellC = 0 yCellBaseOffset = Baseline offset for all characters ulFirstChar = The glyph index of the first character ulLastChar = The glyph index of the last character ulCharDefNum = The number of the character definitions

Type2 - Proportional width and fixed pitch height font

ulIdentity = 0x554E4648; ulSIze = 64; flFontDef = 0x00000042; flGroupDef = 0x00000000; flCharDef = 0x00000081; ulCharDefSize = 6; xCellWidth = 0 yCellHeight = Height of the characters xCellIncrement = 0 xCellA = 0 xCellB = 0 xCellC = 0 yCellBaseOffset = Baseline offset for all characters ulFirstChar = The glyph index of the first character ulLastChar = The glyph index of the last character ulCharDefNum = The number of the character definitions

Type3 - ABC_space width and fixed pitch height font ulIdentity = 0x554E4648; ulSIze = 64; flFontDef = 0x00000042; flGroupDef = 0x00000000; flCharDef = 0x000000B8; ulCharDefSize = 10; xCellWidth = 0 yCellHeight = Height of the characters xCellIncrement = 0 xCellA = 0 xCellB = 0 xCellC = 0 yCellBaseOffset = Baseline offset for all characters ulFirstChar = The glyph index of the first character ulLastChar = The glyph index of the last character ulCharDefNum = The number of the character definitions

The following is a explanation of a_space, b_space and c_space definition.

1. Proportional characters (a+b+c = character increment) for each character: a,b,c >= 0 2. Characters where a, b, and c are definitions for all characters: b >= 0 a, c any integer

The Font Character Group Definition
The character group definition record is defined to support the font indices of a large character set of which indices may consist of sparse ranges.  typedef struct _UNICHARGROUPDEFINITION {	UCHAR		Identity[4]; ULONG		Identity; ULONG		ulSize; ULONG		ulCharGroups; UNICHARGROUPENTRY CharGroupEntry[1]; } UNICHARGROUPDEFINITION; 

Identity 4 bytes unsigned integer. Must be 0x554E4748 ('UNGH'). 0x48474E55 ('U'+('N'<<8)+('G'<<16)+('H'<<24)). ulSize 4 byte unsigned integer. Size of this structure, in bytes, which includes all entries of UNICHARGROUPENTRY. (i.e. sizeof(UNICHARGROUPDEFINITION) + sizeof(UNICHARGROUPENTRY) * (ulCharGroups - 1)) ulCharGroups 4 byte unsigned integer. The number of the character groups in the record. CharGroupEntry unCharGroups size of array of the UNICHARGROUPENTRY structure. The format of the UNICHARGROUPENTRY is :

typedef struct _UNICHARGROUPENTRY {	ULONG		flCharGroupEntry; GLYPH		giFirstChar; GLYPH		giLastChar; LONG		offsetCharDef; LONG		offsetImageData; ULONG 	ulImageDataSize; SHORT		xCellWidth; SHORT		yCellHeight; SHORT		xCellIncrement; SHORT		xCellA; SHORT		xCellB; SHORT		xCellC; SHORT		yCellBaseOffset; USHORT	usReserved; } UNICHARGROUPENTRY;

where:


 * flCharGroupEntry
 * 4 bytes of flags. Indicates which fields are present in the character definition data in the header. If the font file is created for a single repository,

UNIFONT_FREQUENT_GROUP (Bit 0) Indicate that this character gorup may be frequestly used. It is recommended that the font subsystem cache the character definitions of this group in memory for the performance when this bit is ON.
 * giFirstChar
 * 4 byte unsigned integer. Indicates the start font index of the character group.


 * giLastChar
 * 4 byte unsigned integer. Indicates the end font index of the character group.


 * offsetCharDef
 * 4 bytes signed integer. The offset from the beginning of the Uni font resource (the beginning of the font signature structure) at which the character definition record of this character group begins.


 * offsetImageData
 * 4-byte unsigned integer. The offset from the beginning of the Uni font resource (the beginning of the font signature structure) at which the character glyph definitions begins which belongs to the character group. All character glyph definitions (Image data) must be stored from the offsetImageData position continuously and must be stored in the ulImageDataSize block size of the block.


 * ulImageDataSize
 * 4-byte unsigned integer. The size of the character glyph definition group (image data group).

The following field are defined in the UNICHARGROUPENTRY structure, however, the values may or may not be present in them according to the ulGroupDef field in UNIFONTDEFINITIONHEADER. If the values are present, they are applied for only the character group.
 * xCellWidth
 * 2-byte signed integer. The width of the characters in the character group definition in pels.


 * yCellHeight
 * 2-byte signed integer. The height of the characters in the character group definition in pels.


 * xCellIncrement
 * 2-byte signed integer. The length along the character baseline required to step from this character to the next in pels(when forming a character string).


 * xCellA
 * 2-byte signed integer. The width of the space before the character in the inline direction in pels. (a_space)


 * xCellB
 * 2-byte signed integer. The width of the character shape in the inline direction in pels. (b_space)


 * xCellC
 * 2-byte signed integer. The width of the space after the character in the inline direction in pels. (c_space)


 * yCellBaseOffset
 * 2-byte signed integer. The position of the top of the chraacters in the character group definition relative to the baseline in the direction perpendicular to the baseline in pels.


 * usReserved
 * 2-byte unsigned integer. Must be ZERO.

The Kerning Pair Table
This record will exist in a Uni font-file format if the UNIFONT_KERNINGPAIRS_EXIST flag in the flFontSignature field in the UNIFONTSIGNATE structure is on.

The kerning pair table record is not present if the cKerningPairs field in the UNIFONTMETRICS structure is zero. This table should be sorted by the first character (usFirstChar) and the second character (usSecondChar) order to allow binary searches.

typedef struct _UNIKERNPAIRTABLE {	UCHAR  Identity[4]; ULONG	 Identity; ULONG  ulSize; ULONG  ulKernPairs; KERNINGPAIRS KernPairs[1]; } UNIKERNPAIRTABLE;

where:

Identity 4bytes unsigned integer. Must be 0x554E4B54 ('UNKT'). 0x544B4E55 ('U'+('N'<<8)+('K'<<16)+('T'<<24)). ulSize 4 byte unsigned integer. The size of the stucture in bytes, which includes all entries of KERNINGPAIRS. (i.e. sizeof(UNIKERNINGPAIRTABLE) + sizeof(KERNINGPAIRS) * (ulKernPairs - 1)) ulKernPairs 4 byte unsigned integer. The number of kerning pairs in the record. KernPairs ulKernPairs size of array of the KERNINGPAIR structure.

typedef struct _KERNINGPAIRS {	ULONG  ulFirstChar; ULONG  ulSecondChar; LONG   lKerningAmount; } KERNINGPAIRS;

where:

ulFirstChar 4 byte unsigned integer. First character of the kerning pair. This value must be zero-extended when converted to the GLYPH type. ulSecondChar 4 byte unsigned integer. Second character of the kerning pair. This value must be zero-extended when converted to the GLYPH type. lKerningAmount 4 byte signed integer. Kerning value in pels for image fonts. Positive values increase the inter-character spacing while negative values bring the characters closer together. The Font Character Definition Character Definition Record The following fields may or may not be present, according to the font character definition fields flags. If a field is present, it is present for each character and the value applies to that character only. The fields in the record should be in the order of the following. There are ulCharNumber of the records for image fonts. Character Glyph Definition Offset (offsetImageData) 4 byte signed integer. The offset from the beginning of the Uni font resource at which the character glyph definition begins. This field should be set to zero if the character glyph is not defined in the font file. If the font subsystem detect the zero value in this field, it should return the character glyph image of giDefaultChar index which is specified in UNIFONTMETRICS. This field must be presented. Character Cell Width (xCellWidth) 2-byte integer. The width of the character definition in pels. Character Cell Height (xCellHeight) 2-byte integer. The height of the character definition in pels. Character Increment (xCellIncrement) 2-byte integer. The length along the character baseline required to step from this character to the next in pels (when forming a character string). Character a-space (xCellA) 2-byte signed integer. The width of the space before the character in the inline direction in pels. Character b-space (xCellB) 2-byte integer. The width of the character shape in the inline direction in pels. Character c-space (xCellC) 2-byte signed integer. The width of the space after the character in the inline direction in pels. Character Baseline Offset (xCellBaseOffset) 2-byte signed integer. The position of the top of a character definition relative to the baseline in the direction perpendicular to the baseline in pels. The xCellWidth and the xCellIncrement field in the FONTDEFINITIONHEADER structure are nonzero and that represents a fixed pitch width font for the type 1 font. However, the type 1 fonts have offset (offsetImageData) and width (xCellWidth) pairs in the character definition records and the proportional-space flag, bit 0, is set in the fsType field of the UNIFONTMETRICS structure. OS/2 2.1 PM font-file format has the same definition for the type 1 fonts. Image Data Format The bits for each character are stored separately, and start on a byte boundary. Sequential bytes represent horizontal pieces of the character image. For example, a 15-bit-wide H is stored as follows:

byte                  byte 0  00000000 0000000-   1      2   01100000 0000110-   3      	4   01100000 0000110-   5 6   01100000 0000110-   7      8   01100000 0000110-   9      10  01111111 1111110-  11      12  01111111 1111110-  13      14  01100000 0000110-  15 16  01100000 0000110-  17      18  01100000 0000110-  19      20  01100000 0000110-  21 22  00000000 0000000-  23 The format is the same as the OS/2 bitmap format of one bit per pel.