Combined font

The more internationalizing software is required, the more Unicode support becomes crucial in operating systems for a character representation. Assuming that operating systems start supporting Unicode, it's necessary to have a way to display and print the Unicode string with a font that supports Unicode. We will have Unicode fonts some time in the future, however, we currently have a very limited number of Unicode fonts available in the current market place. Developping Unicode fonts, that must gave a huge number of characters, usually takes a large amount of time and money.

One idea to resolve this problem is to provide a solution to create logically described fonts. The font will look like other regular fonts from user's point of view and it can have the Unicode encoding. The font does not have an actual font file but is virtually created font by the system by putting some of the existing fonts together into one logically defined font. We will call the logical font the combined font since the font is created by combining existing fonts. Applications would not be aware of that the logical font is a special form of font, in the sense of that it is logically defined, and they can use the font as if other regular fonts. The combined fonts can be used for the GPI and WIN APIs as if other regular fonts, but it is not support in the VIO APIs. VIO Applications cannot use the combined fonts.

The combined font is generated from a file, called the combined font file, that includes the information how to combine existing fonts. The graphics engine will retrieved the information to defined the logical font from the combined font file such as font metrics etc. The information of the font combination will also be included in the combined font file.

The combined font format includes the following information. The logical font metric described in the Uni font metrics format. Its information will be translated into the OS/2 font metrics format by the system and will be returned to applications. This is the information to represent the combined font metrics.
 * Logical font metrics
 * Component font association information
 * Component font range information
 * Priority list of the component fonts

The component font association information describes the way to select components fonts. (The number of component fonts could be more than one. It depends upon how many component fonts to be combined to build the combined font) The system looks through the installed fonts and will find the best matching component font for each association information listed. The component font range information describes what range of the component font will be used to build the combined font. Specifying ranges are allowed for each componet font. This will allow users to customize the combined font character set as they like.

The priority list of the component fonts will allow users to specify priority among the component fonts that build a combined font. for example, this information is used to decide whcih component font is used a glyph index of a combined font in case of that the component font range information that build the combined font overlaps between two (or more) component fonts.

Alias font
Font aliasing is another requirement that customers require. (as Windows has the capability) Font aliasing can rename an installed font facename and provide it as anotehr font. For example, If we want to provide a font that has the facename of 'Arial' using the 'Helvetica' font, we can defined the font alias definition so that the 'Arial' font is pointed to the 'Helvetica' font. Both 'Arial' and 'Helvetica' facename will be shown to applications. The alias font is alos a logically defined font. We can support the font aliasing using the combined font support. In a way, we can think about font aliasing is the same as creating a combiend font that combined only only font. We can support font asliasing as a subset function of the combined font support. Therefore, an alias font definition file will have the same format as the combined font file format, while the number of component fonts is restriced to only one for alias fiont definition files.

Combined font file format
The section describes the combined font file format. The pre combine file consists of a set of self defining records like the form that is used for the OS/2 font-file format. The notation of bit order defined in this document is that bit 0 is LSB. The elements in the structures defined in this document must be aligned in 1 byte boundaries. The layout of the structure in the combine font file is as follows.


 * Combined font signature (COMBFONTSIGNATURE)
 * Combined font metrics (COMBFONTMETRICS)
 * Component font header and 1-st component font (COMPFONTHEADER)
 * 2-nd to (N-1)-th component font (COMPFONT)
 * N-th component font (COMPFONT)
 * Combined font end signature (COMBFONTEND)

The combined font file starts with a signature record. This structure is used to identify an unknown type of file whether a combined font file or not.

typedef struct _COMBFONTSIGNATURE {  /* cmbfs */ ULONG   Identity; ULONG   ulSize; ULONG   flEndian; ULONG   ulReserved; ULONG   ulVersion; UCHAR   szSignature[32]; } COMBFONTSIGNATURE; typedef COMBFONTSIGNATURE *PCOMBFONTSIGNATURE; Identity 4 byte unsigned integer. Must be 0x53464243 ('C'+('B'<<8)+('F'<<16)+('S'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMBFONTSIGNATURE structure. 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. ulReserved 4 byte unsigned integer. Must be ZERO. ulVersion 4 byte unsigned integer. Must be ZERO. szSignature[32] A NULL terminated string. Must be "COMBINED FONT". The future enhancement of the pre combine rule file may have a different signature in this field. The combine font metrics follows after the combined font signature structure.

typedef struct _COMBFONTMETRICS { /* cmbfm */ ULONG         Identity; ULONG         ulSize; UNIFONTMETRICS unifm; } COMBFONTMETRICS; typedef COMBFONTMETRICS *PCOMBFONTMETRICS; Identity 4 byte unsigned integer. Must be 0x4D464243 ('C'+('B'<<8)+('F'<<16)+('M'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMBFONTMETRICS structure. unifm The UNIFONTMETRICS structure that represents the combined font metrics. Refer to the Uni font format specification for the structure of UNIFONTMETRICS. The combined font metrics is followed by the component font header structure.

typedef struct _COMPFONTHEADER { /* cmpfh */ ULONG   Identity; ULONG   ulSize; ULONG   ulCmpFonts; COMPFONT CompFont[1]; } COMPFONTHEADER; Identity 4 byte unsigned integer. Must be 0x4D464243 ('C'+('P'<<8)+('F'<<16)+('H'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMPFONTHEADER structure. CompFont [1] The first entry of the component font array. (See below for the format of the COMPFONT structure) The COMPFONT structure is defined in the following format.

typedef struct _COMPFONT { /* cmpft */ ULONG			Identity; ULONG			ulSize; FONTASSOCIATION	CompFontAssoc; } COMPFONT; typedef COMPFONT *PCOMPFONT; Identity 4 byte unsigned integer. Must be 0x54464243 ('C'+('P'<<8)+('F'<<16)+('T'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMPFONT structure. CompFontAssoc The FONTASSOCIATION structure. (See the FONTASSOCIATION structure described below) The FONTASSOCIATION structure is defined in the following format.

typedef struct _FONTASSOCIATION {  /* fa */ ULONG               Identity; ULONG               ulSize; UNIFONTMETRICSMEMBER unimbr; UNIFONTMETRICS      unifm; ULONG               ulGlyphRanges; ULONG               flFlags; FONTASSOCGLYPHRANGE GlyphRange[1]; } FONTASSOCIATION; typedef FONTASSOCIATION *PFONTASSOCIATION; Identity 4 byte unsigned integer. Must be 0x53415446 ('F'+('T'<<8)+('A'<<16)+('S'<<24)). ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the FONTASSOCIATION structure.

unimbr The UNIFONTMETRICSMEMBER structure that have flags for all the UNIFONTMETRICS fields. Each byte field represents whether the field is concerns for the association. ASSOC_EXACT_MATCT	This field must match. ASSOC_DONT_CARE		This field is not concerned. ASSOC_USE_PARENT		Use the information of the parent association

typedef struct _IFIMETRICS32MEMBER { /* ifi32mbr */ BYTE    fbFamilyname; BYTE    fbFacename; BYTE    fbGlyphlistname; BYTE    fbRegistry; BYTE    fbCapEmHeight; BYTE    fbXHeight; BYTE    fbMaxAscender; BYTE    fbMaxDescender; BYTE    fbLowerCaseAscent; BYTE    fbLowerCaseDescent; BYTE    fbInternalLeading; BYTE    fbExternalLeading; BYTE    fbAveCharWidth; BYTE    fbMaxCharInc; BYTE    fbEmInc; BYTE    fbMaxBaselineExt; BYTE    fbCharSlope; BYTE    fbInlineDir; BYTE    fbCharRot; BYTE    fbWeightClass; BYTE    fbWidthClass; BYTE    fbEmSquareSizeX; BYTE    fbEmSquareSizeY; BYTE    fbFirstChar; BYTE    fbLastChar; BYTE    fbDefaultChar; BYTE    fbBreakChar; BYTE    fbNominalPointSize; BYTE    fbMinimumPointSize; BYTE    fbMaximumPointSize; BYTE    fbType; BYTE    fbDefn; BYTE    fbSelection; BYTE    fbCapabilities; BYTE    fbSubscriptXSize; BYTE    fbSubscriptYSize; BYTE    fbSubscriptXOffset; BYTE    fbSubscriptYOffset; BYTE    fbSuperscriptXSize; BYTE    fbSuperscriptYSize; BYTE    fbSuperscriptXOffset; BYTE    fbSuperscriptYOffset; BYTE    fbUnderscoreSize; BYTE    fbUnderscorePosition; BYTE    fbStrikeoutSize; BYTE    fbStrikeoutPosition; BYTE    fbKerningPairs; BYTE    fbFontClass; } IFIMETRICS32MEMBER;

typedef struct _UNIFONTMETRICSMEMBER { /* unimbr */ ULONG   Identity; ULONG   ulSize; IFIMETRICS32MEMBER ifi32mbr; ULONG   ulReserved; BYTE    fbPanose; BYTE    fbFullFamilyname; BYTE    fbFullFacename; UCHAR   ucReserved[5]; } UNIFONTMETRICSMEMBER;

typedef UNIFONTMETRICSMEMBER *PUNIFONTMETRICSMEMBER;

#define ASSOC_EXACT_MATCH       0x00000001 #define ASSOC_DONT_CARE         0x00000002 #define ASSOC_USE_PARENT        0x00000004 unifm The UNIFONTMETRICS structure that represents the combined font metrics. Refer to the Uni font format specification for the structure of UNIFONTMETRICS. ulGlyphRanges The number of glyph ranges to associate. GlyphRange The array of glyph ranges to associate. For combined fonts, the range will decide what component font glyphs to be used as a part of the combined font. For pre combine rule fule, the range will decide what target font glyphs to be used to associate with the source font. The number of arrays depends on the value of ulGlyphRanges. The following is the FONTASSOCGLYPHRANGE structure format. /* Font association glyph range */

typedef struct _FONTASSOCGLYPHRANGE { /* fagr */ GLYPH   giStart;             /* Start glyph index */ GLYPH   giEnd;               /* End glyph index */ GLYPH   giTarget;            /* Target glyph index mapped to */ ULONG   ulReserved1; ULONG   ulReserved2; } FONTASSOCGLYPHRANGE; typedef FONTASSOCGLYPHRANGE *PFONTASSOCGLYPHRANGE;

/* Font association */

#define FONTASSOC_H_SCALING	0x00000001 /* Horizontal scaling */ #define FONTASSOC_V_SCALING     0x00000002  /* Vertical scaling */ #define FONTASSOC_NO_XLATION	0x00000004	/* No xlation */ The combined font file ends with an end signature typedef struct _COMBFONTEND { /* cmbfe */ ULONG   Identity; ULONG   ulSize; } COMBFONTEND; typedef COMBFONTEND *PCOMBFONTEND; Identity 4 byte unsigned integer. Must be 0x45464243 ('C'+('B'<<8)+('F'<<16)+('S'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMBFONTSEND structure. Pre combine rule The pre combining means that a font is associated with another font of which association is decided by pre combine rule files and hidden from applications. The associated font is called a pre combined font as it is pre combined by another font. The associating font is called a pre combining font as it is a pre combining font. The idea of the pre combined font emerged during our seeking for general solutions for the user defined character support. We also found that the pre combined font can be used for a solution for the font association requirement. (The font association function is supported by Windows 95 in order to display/print DBCS fonts with a SBCS font. If we created a pre combine rule file to combine a DBCS font to SBCS fonts and install it into the system, we should be able to provide the same font association function as Windows 95). There are some different concept between a pre combined font and a combined font as follows. Pre combine rule file does not represent a logical font like a combined font but it describes a rule to combine physical fonts. Pre combine rule file determines like between a physical font and another physical font. Installing pre combine rule files does not change the number of available fonts, while installing combine font files increase the number of fonts by creating logical fonts. A font can be pre combined with one font at one time. Multiple pre combining, that a font is precombined with multiple fonts, is not supported. Grpahics Engine support This section describes how the graphics engine, that is a main player for the pre combine rule support, supports the pre combined files. The following pictures depints A pre combined rule file will be loaded into the graphisce engine through the GreLoadFonts API. Graphics Engine will create a link list for the loaded pre combine rule files. During the system initializtion, Graphics Engine will constructs the links betweek Pre Combine Rule (PCR) entries and Physival Font Entries (PFE). Each time one of the two conditions, a new pre combine rule file is loaded or a new engine font is loaded, should happen, the links netween PCR entries PFE entries will be refreshed. If one pre combine rule file or more than one are loaded into Graphics Engine, the combine font prologue function will be activated. Followed Gre text functions will be pre process, in order to handle the pre combining before jumping to the dispatch table. The following Gre text functions have the prologue functions. - GreCharString - GreCharStringPos - GreQueryCharStringPositions - GreQueryTextBox - GreQueryWidthTable - (GreRealizeString) - (GreQueryCharOutline) - (GreQueryCharMetricsTable) - (GreRealizeString) - (GreQueryTabbedTextExtension) - (GreTabbedCharStringAt) Pre combine rule file format This section describes the format of the pre combine rule file. The pre combine rule file consists of a set of self defining records like the form that is used for the OS/2 font-file format. The notation of bit order defined in this document is that bit 0 is LSB. The elements in the structures defined in this document must be aligned in 1 byte boundaries. The layout of the structure in the pre combine rule file is as follows. Pre combine rule signature structure (PRECOMBRULESIGNATURE) Source font association structure (FONTASSOCIATION) Target font association structure header (TARGETFONTASSOCHEADER) 1-st target font association structure (FONTASSOCIATION) 2-nd to (N-1)-th target font association structure (FONTASSOCIATION) N-th target font association structure (FONTASSOCIATION) Pre combine rule file end signature structure (PRECOMBRULEEND) Pre combine rule file starts with a signature record. This structure is used to identify an unknown type of file whether a pre combine rule file or not.

typedef struct _PRECOMBRULESIGNATURE { /* pcrs */ ULONG   Identity; ULONG   ulSize; ULONG   flEndian; ULONG   ulReserved; ULONG   ulVersion; UCHAR   szSignature[32]; } PRECOMBRULESIGNATURE; typedef PRECOMBRULESIGNATURE *PPRECOMBRULESIGNATURE; where Identity 4 byte unsigned integer. Must be 0x53524350 ('P'+('C'<<8)+('R'<<16)+('S'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the PRECOMBRULESIGNATURE structure. 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. ulReserved 4 byte unsigned integer. Must be ZERO. ulVersion 4 byte unsigned integer. Must be ZERO. szSignature[32] A NULL terminated string. Must be "PRE COMBINE RULE". The future enhancement of the pre combine rule file may have a different signature in this field. The PRECOMB	RULESIGNATURE is followed by the font association structure for the source font determination that is to be used for a combining font (associating font) for this rule. The font association structure is the same format as FONTASSOCIATION described in the combined font file format.

Please refer to the FONTASSOCIATION structure in the combined font file format described in the above section. The source font association structure is following by the target association header.

typedef struct _TARGETFONTASSOCHEADER { /* tfah */ ULONG   Identity; ULONG   ulSize; ULONG   ulTargetAssoc; ULONG   ulReserved; } TARGETFONTASSOCHEADER; typedef TARGETFONTASSOCHEADER *PTARGETFONTASSOCHEADER; where Identity 4 byte unsigned integer. Must be 0x48414654 ('T'+('F'<<8)+('A'<<16)+('H'<<24)). ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the TARGETFONTASSOCHEADER structure. ulTargetAssoc 4 byte unsigned integer. The number of the target font association structures that are following after this structure. ulReserved 4 byte unsigned integer. Must be ZERO. The TARGETFONTASSOHEADER is followed by the array of FONTASSOCIATION that represent the target fonts to associate with the source font. For example, if a pre combine rule file includes N target font association structures, sizeof(FONTASSOCIATION) * N bytes will be following after the target font association header. The pre combine rule end structure will be placed after the last target font association structure.

typedef struct _PRECOMBRULEEND { /* pcre */ ULONG   Identity; ULONG   ulSize; } PRECOMBRULEEND; typedef PRECOMBRULEEND *PPRECOMBRULEEND; where Identity 4 byte unsigned integer. Must be 0x45524350 ('P'+('C'<<8)+('R'<<16)+('E'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of PRECOMBRULEEND. Font Association Requirement The font association is required by the following background. Windows 95 has a font association function. OS/2 is required to have a equivalent function to the Windows 95 font association. If a user creates a document using the Times New Roman font, that usually does not include DBCS, with font association, the use can actually display and print DBCS on Windows 95 with the document. However, the user will neither be able to display nor print DBCS for the document if the user bring it from Windows 95 to OS/2. If we have an equivalent function to the Windows 95 font association in OS/2, the user will be able to show DBCS with the document. Users would like to display or print DBCS documents even if a SBCS font is selected. There are quite a lot of SBCS applications that use hard coded SBCS font names. Those applications usually have problems to display or print DBCS. If we have the font association function in OS/2, we could have those applications display and print DBCS. Currently users have to wait for those applications be dbcs-enabled and distributed in DBCS countries. The font association function might give the users opportunity to use those application before dbcs-enabled. How it works There is a new key defined in the OS2.INI profile file. If this key and its data are properly specified, the font association function will be activated during the system initialization.

App Name, Key Name, App Data "PM_SystemFonts", "PM_AssociateFont", "XXXXX;YY" where, XXXXX is a facename of the associate font and YY is a logical point size of the associate font. Note that the associate font must be a DBCS font. There is no U/I setting panel be provided for the Merlin release. (Future design might include the U/I setting panel) The current design is to have one associate font per device driver installed in the system. Each associate font will be selected during the device driver initialization time. The graphics engine will search the nearest font match the facename and point size in the OS2.INI profile file. the point size will be converted to the pixel size using the device resolution when searching the nearest font match. The following to the priority to select the associate font match. In all the following cases, the facename must match, otherwise, the associate font matching will fail and the font association will not be activated. Facename match of outline font Facename and exact size match of bitmap font Facename and nearest size match of bitmap font It is recommended that an outline font be used for the associate font so that it can be displayed or printed with balance to the original font after scaled to a proper size. All outline and bitmap SBCS fonts are associated to the system associate font by default. This includes support of .FON bitmap fonts and IFI outline fonts. The association is hidden from applications. Font metrics will stay the same as the original SBCS fonts but the behavior of the Gpi/Gre APIs APIs that have a parameter of string (listed below) will be a little different if the string includes a DBCS code point(s). Before font association, the graphics engine was using the default character of the SBCS font if a DBCS code point is found in the string. The default character is usually defined as a space character. For example, if you display a DBCS document file, you will see nothing on the screen since all DBCS characters are displayed in the default (space) character. The font association function can solve this problem. It will detect DBCS code points in the string and use the system associate font (usually, it isa DBCS font). If the currently selected code page is DBCS and the passed string includes a DBCS code point(s), the graphics engine switch the current font to the system associate font only for the DBCS code points in the string. For example:

12 34 56 7 SDDSDDSDDS Font switching will occur 7 times and restoring to the original font will occur once after the string is handled.

1   2 3 SSSSSDDSSS Font switching will occur 3 times and restoring to the original font will occur once after the string is handled. The overhead of the font switching should be implemented to be minimum. Font association will be executed for the following Gpi functions. GpiCharString GpiCharStringAt GpiCharStringPos GpiCharStringPosAt GpiQueryCharStringPos GpiQueryCharStringPosAt GpiQueryTextBox GpiQueryWidthTable Font Association will be executed for the following Gre functions. GreCharString GreCharStringPos GreQueryCharStringPositions GreQueryTextBox GreQueryWidthTable (GreRealizeString) (GreQueryCharOutline) (GreQueryCharMetricsTable) (GreRealizeString) (GreQueryTabbedTextExtension) (GreTabbedCharStringAt) Restriction Font association does not work for device fonts. Since the graphics engine does not have much control over the device fonts. Device fonts are excluded from the font association support. Users might see the clipped characters of the associate font The font metrics values might sometimes be smaller than the associate font's. If an application is using a value like MaxbaselineExt or MaxCharInc in the font metrics in order to position characters, users might see a problem of the associate font be mis-aligned or clipped out. This is because the original font metrics values are always not true for the associate font. Performance will become a little slower. Font association requires an additional handling than the normal text process, although we will try to be minimum overhead as possible as we can. If the font association support is not installed (in the OS2.INI profile file), there is no performance penalty. Unloading the associate font If the associate font should be unloaded by the user publically (from the font palette), the font association function will be deactivated after the unloading. The user is responsible for either reloading the associate font or using a different font for the associate font by updating the associate font entry in the OS2.INI profile file. Design Concerns Combined font To be written. Code mapping Install/Delete Restrictions (Only generic engine font, metrics difference) Font association Updated->1.Place the associate font pointer per physical device or device Updated->2.Change the matching logic to select the first one to be an outline font. 3.Make sure the font association function works with the default font that replaced the device default. 4.Make sure the font association fucntion works with a fixed pitch font.

Combined Font / Pre Combine Rule / FontAssocation Combined font The more internationalizing software is required, the more Unicode support becomes crucial in operating systems for a character representation. Assuming that operating systems start supporting Unicode, it's necessary to have a way to display and print the Unicode string with a font that supports Unicode. We will have Unicode fonts some time in the future, however, we currently have a very limited number of Unicode fonts available in the current market place. Developping Unicode fonts, that must gave a huge number of characters, usually takes a large amount of time and money. One idea to resolve this problem is to provide a solution to create logically described fonts. The font will look like other regular fonts from user's point of view and it can have the Unicode encoding. The font does not have an actual font file but is virtually created font by the system by putting some of the existing fonts together into one logically defined font. We will call the logical font the combined font since the font is created by combining existing fonts. Applications would not be aware of that the logical font is a special form of font, in the sense of that it is logically defined, and they can use the font as if other regular fonts. The combined fonts can be used for the GPI and WIN APIs as if other regular fonts, but it is not support in the VIO APIs. VIO Applications cannot use the combined fonts. The combined font is generated from a file, called the combined font file, that includes the information how to combine existing fonts. The graphics engine will retrieved the information to defined the logical font from the combined font file such as font metrics etc. The information of the font combination will also be included in the combined font file. The combined font format includes the following information. Logical font metrics Component font association information Component font range information Priority list of the component fonts The logical font metric described in the Uni font metrics format. Its information will be translated into the OS/2 font metrics format by the system and will be returned to applications. This is the information to represent the combined font metrics. The component font association information describes the way to select components fonts. (The number of component fonts could be more than one. It depends upon how many component fonts to be combined to build the combined font) The system looks through the installed fonts and will find the best matching component font for each association information listed. The component font range information describes what range of the component font will be used to build the combined font. Specifying ranges are allowed for each componet font. This will allow users to customize the combined font character set as they like. The priority list of the component fonts will allow users to specify priority among the component fonts that build a combined font. for example, this information is used to decide whcih component font is used a glyph index of a combined font in case of that the component font range information that build the combined font overlaps between two (or more) component fonts. Alias font Font aliasing is another requirement that customers require. (as Windows has the capability) Font aliasing can rename an installed font facename and provide it as anotehr font. For example, If we want to provide a font that has the facename of 'Arial' using the 'Helvetica' font, we can defined the font alias definition so that the 'Arial' font is pointed to the 'Helvetica' font. Both 'Arial' and 'Helvetica' facename will be shown to applications. The alias font is alos a logically defined font. We can support the font aliasing using the combined font support. In a way, we can think about font aliasing is the same as creating a combiend font that combined only only font. We can support font asliasing as a subset function of the combined font support. Therefore, an alias font definition file will have the same format as the combined font file format, while the number of component fonts is restriced to only one for alias fiont definition files. Combined font file format The section describes the combined font file format. The pre combine file consists of a set of self defining records like the form that is used for the OS/2 font-file format. The notation of bit order defined in this document is that bit 0 is LSB. The elements in the structures defined in this document must be aligned in 1 byte boundaries. The layout of the structure in the combine font file is as follows.

Combined font signature (COMBFONTSIGNATURE) Combined font metrics (COMBFONTMETRICS) Component font header and 1-st component font (COMPFONTHEADER) 2-nd to (N-1)-th component font (COMPFONT) N-th component font (COMPFONT) Combined font end signature (COMBFONTEND)

The combined font file starts with a signature record. This structure is used to identify an unknown type of file whether a combined font file or not.

typedef struct _COMBFONTSIGNATURE {  /* cmbfs */ ULONG   Identity; ULONG   ulSize; ULONG   flEndian; ULONG   ulReserved; ULONG   ulVersion; UCHAR   szSignature[32]; } COMBFONTSIGNATURE; typedef COMBFONTSIGNATURE *PCOMBFONTSIGNATURE; Identity 4 byte unsigned integer. Must be 0x53464243 ('C'+('B'<<8)+('F'<<16)+('S'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMBFONTSIGNATURE structure. 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. ulReserved 4 byte unsigned integer. Must be ZERO. ulVersion 4 byte unsigned integer. Must be ZERO. szSignature[32] A NULL terminated string. Must be "COMBINED FONT". The future enhancement of the pre combine rule file may have a different signature in this field. The combine font metrics follows after the combined font signature structure.

typedef struct _COMBFONTMETRICS { /* cmbfm */ ULONG         Identity; ULONG         ulSize; UNIFONTMETRICS unifm; } COMBFONTMETRICS; typedef COMBFONTMETRICS *PCOMBFONTMETRICS; Identity 4 byte unsigned integer. Must be 0x4D464243 ('C'+('B'<<8)+('F'<<16)+('M'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMBFONTMETRICS structure. unifm The UNIFONTMETRICS structure that represents the combined font metrics. Refer to the Uni font format specification for the structure of UNIFONTMETRICS. The combined font metrics is followed by the component font header structure.

typedef struct _COMPFONTHEADER { /* cmpfh */ ULONG   Identity; ULONG   ulSize; ULONG   ulCmpFonts; COMPFONT CompFont[1]; } COMPFONTHEADER; Identity 4 byte unsigned integer. Must be 0x4D464243 ('C'+('P'<<8)+('F'<<16)+('H'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMPFONTHEADER structure. CompFont [1] The first entry of the component font array. (See below for the format of the COMPFONT structure) The COMPFONT structure is defined in the following format.

typedef struct _COMPFONT { /* cmpft */ ULONG			Identity; ULONG			ulSize; FONTASSOCIATION	CompFontAssoc; } COMPFONT; typedef COMPFONT *PCOMPFONT; Identity 4 byte unsigned integer. Must be 0x54464243 ('C'+('P'<<8)+('F'<<16)+('T'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMPFONT structure. CompFontAssoc The FONTASSOCIATION structure. (See the FONTASSOCIATION structure described below) The FONTASSOCIATION structure is defined in the following format.

typedef struct _FONTASSOCIATION {  /* fa */ ULONG               Identity; ULONG               ulSize; UNIFONTMETRICSMEMBER unimbr; UNIFONTMETRICS      unifm; ULONG               ulGlyphRanges; ULONG               flFlags; FONTASSOCGLYPHRANGE GlyphRange[1]; } FONTASSOCIATION; typedef FONTASSOCIATION *PFONTASSOCIATION; Identity 4 byte unsigned integer. Must be 0x53415446 ('F'+('T'<<8)+('A'<<16)+('S'<<24)). ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the FONTASSOCIATION structure.

unimbr The UNIFONTMETRICSMEMBER structure that have flags for all the UNIFONTMETRICS fields. Each byte field represents whether the field is concerns for the association. ASSOC_EXACT_MATCT	This field must match. ASSOC_DONT_CARE		This field is not concerned. ASSOC_USE_PARENT		Use the information of the parent association

typedef struct _IFIMETRICS32MEMBER { /* ifi32mbr */ BYTE    fbFamilyname; BYTE    fbFacename; BYTE    fbGlyphlistname; BYTE    fbRegistry; BYTE    fbCapEmHeight; BYTE    fbXHeight; BYTE    fbMaxAscender; BYTE    fbMaxDescender; BYTE    fbLowerCaseAscent; BYTE    fbLowerCaseDescent; BYTE    fbInternalLeading; BYTE    fbExternalLeading; BYTE    fbAveCharWidth; BYTE    fbMaxCharInc; BYTE    fbEmInc; BYTE    fbMaxBaselineExt; BYTE    fbCharSlope; BYTE    fbInlineDir; BYTE    fbCharRot; BYTE    fbWeightClass; BYTE    fbWidthClass; BYTE    fbEmSquareSizeX; BYTE    fbEmSquareSizeY; BYTE    fbFirstChar; BYTE    fbLastChar; BYTE    fbDefaultChar; BYTE    fbBreakChar; BYTE    fbNominalPointSize; BYTE    fbMinimumPointSize; BYTE    fbMaximumPointSize; BYTE    fbType; BYTE    fbDefn; BYTE    fbSelection; BYTE    fbCapabilities; BYTE    fbSubscriptXSize; BYTE    fbSubscriptYSize; BYTE    fbSubscriptXOffset; BYTE    fbSubscriptYOffset; BYTE    fbSuperscriptXSize; BYTE    fbSuperscriptYSize; BYTE    fbSuperscriptXOffset; BYTE    fbSuperscriptYOffset; BYTE    fbUnderscoreSize; BYTE    fbUnderscorePosition; BYTE    fbStrikeoutSize; BYTE    fbStrikeoutPosition; BYTE    fbKerningPairs; BYTE    fbFontClass; } IFIMETRICS32MEMBER;

typedef struct _UNIFONTMETRICSMEMBER { /* unimbr */ ULONG   Identity; ULONG   ulSize; IFIMETRICS32MEMBER ifi32mbr; ULONG   ulReserved; BYTE    fbPanose; BYTE    fbFullFamilyname; BYTE    fbFullFacename; UCHAR   ucReserved[5]; } UNIFONTMETRICSMEMBER;

typedef UNIFONTMETRICSMEMBER *PUNIFONTMETRICSMEMBER;

#define ASSOC_EXACT_MATCH       0x00000001 #define ASSOC_DONT_CARE         0x00000002 #define ASSOC_USE_PARENT        0x00000004 unifm The UNIFONTMETRICS structure that represents the combined font metrics. Refer to the Uni font format specification for the structure of UNIFONTMETRICS. ulGlyphRanges The number of glyph ranges to associate. GlyphRange The array of glyph ranges to associate. For combined fonts, the range will decide what component font glyphs to be used as a part of the combined font. For pre combine rule fule, the range will decide what target font glyphs to be used to associate with the source font. The number of arrays depends on the value of ulGlyphRanges. The following is the FONTASSOCGLYPHRANGE structure format. /* Font association glyph range */

typedef struct _FONTASSOCGLYPHRANGE { /* fagr */ GLYPH   giStart;             /* Start glyph index */ GLYPH   giEnd;               /* End glyph index */ GLYPH   giTarget;            /* Target glyph index mapped to */ ULONG   ulReserved1; ULONG   ulReserved2; } FONTASSOCGLYPHRANGE; typedef FONTASSOCGLYPHRANGE *PFONTASSOCGLYPHRANGE;

/* Font association */

#define FONTASSOC_H_SCALING	0x00000001 /* Horizontal scaling */ #define FONTASSOC_V_SCALING     0x00000002  /* Vertical scaling */ #define FONTASSOC_NO_XLATION	0x00000004	/* No xlation */ The combined font file ends with an end signature typedef struct _COMBFONTEND { /* cmbfe */ ULONG   Identity; ULONG   ulSize; } COMBFONTEND; typedef COMBFONTEND *PCOMBFONTEND; Identity 4 byte unsigned integer. Must be 0x45464243 ('C'+('B'<<8)+('F'<<16)+('S'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the COMBFONTSEND structure. Pre combine rule The pre combining means that a font is associated with another font of which association is decided by pre combine rule files and hidden from applications. The associated font is called a pre combined font as it is pre combined by another font. The associating font is called a pre combining font as it is a pre combining font. The idea of the pre combined font emerged during our seeking for general solutions for the user defined character support. We also found that the pre combined font can be used for a solution for the font association requirement. (The font association function is supported by Windows 95 in order to display/print DBCS fonts with a SBCS font. If we created a pre combine rule file to combine a DBCS font to SBCS fonts and install it into the system, we should be able to provide the same font association function as Windows 95). There are some different concept between a pre combined font and a combined font as follows. Pre combine rule file does not represent a logical font like a combined font but it describes a rule to combine physical fonts. Pre combine rule file determines like between a physical font and another physical font. Installing pre combine rule files does not change the number of available fonts, while installing combine font files increase the number of fonts by creating logical fonts. A font can be pre combined with one font at one time. Multiple pre combining, that a font is precombined with multiple fonts, is not supported. Grpahics Engine support This section describes how the graphics engine, that is a main player for the pre combine rule support, supports the pre combined files. The following pictures depints A pre combined rule file will be loaded into the graphisce engine through the GreLoadFonts API. Graphics Engine will create a link list for the loaded pre combine rule files. During the system initializtion, Graphics Engine will constructs the links betweek Pre Combine Rule (PCR) entries and Physival Font Entries (PFE). Each time one of the two conditions, a new pre combine rule file is loaded or a new engine font is loaded, should happen, the links netween PCR entries PFE entries will be refreshed. If one pre combine rule file or more than one are loaded into Graphics Engine, the combine font prologue function will be activated. Followed Gre text functions will be pre process, in order to handle the pre combining before jumping to the dispatch table. The following Gre text functions have the prologue functions. - GreCharString - GreCharStringPos - GreQueryCharStringPositions - GreQueryTextBox - GreQueryWidthTable - (GreRealizeString) - (GreQueryCharOutline) - (GreQueryCharMetricsTable) - (GreRealizeString) - (GreQueryTabbedTextExtension) - (GreTabbedCharStringAt) Pre combine rule file format This section describes the format of the pre combine rule file. The pre combine rule file consists of a set of self defining records like the form that is used for the OS/2 font-file format. The notation of bit order defined in this document is that bit 0 is LSB. The elements in the structures defined in this document must be aligned in 1 byte boundaries. The layout of the structure in the pre combine rule file is as follows. Pre combine rule signature structure (PRECOMBRULESIGNATURE) Source font association structure (FONTASSOCIATION) Target font association structure header (TARGETFONTASSOCHEADER) 1-st target font association structure (FONTASSOCIATION) 2-nd to (N-1)-th target font association structure (FONTASSOCIATION) N-th target font association structure (FONTASSOCIATION) Pre combine rule file end signature structure (PRECOMBRULEEND) Pre combine rule file starts with a signature record. This structure is used to identify an unknown type of file whether a pre combine rule file or not.

typedef struct _PRECOMBRULESIGNATURE { /* pcrs */ ULONG   Identity; ULONG   ulSize; ULONG   flEndian; ULONG   ulReserved; ULONG   ulVersion; UCHAR   szSignature[32]; } PRECOMBRULESIGNATURE; typedef PRECOMBRULESIGNATURE *PPRECOMBRULESIGNATURE; where Identity 4 byte unsigned integer. Must be 0x53524350 ('P'+('C'<<8)+('R'<<16)+('S'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the PRECOMBRULESIGNATURE structure. 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. ulReserved 4 byte unsigned integer. Must be ZERO. ulVersion 4 byte unsigned integer. Must be ZERO. szSignature[32] A NULL terminated string. Must be "PRE COMBINE RULE". The future enhancement of the pre combine rule file may have a different signature in this field. The PRECOMB	RULESIGNATURE is followed by the font association structure for the source font determination that is to be used for a combining font (associating font) for this rule. The font association structure is the same format as FONTASSOCIATION described in the combined font file format.

Please refer to the FONTASSOCIATION structure in the combined font file format described in the above section. The source font association structure is following by the target association header.

typedef struct _TARGETFONTASSOCHEADER { /* tfah */ ULONG   Identity; ULONG   ulSize; ULONG   ulTargetAssoc; ULONG   ulReserved; } TARGETFONTASSOCHEADER; typedef TARGETFONTASSOCHEADER *PTARGETFONTASSOCHEADER; where Identity 4 byte unsigned integer. Must be 0x48414654 ('T'+('F'<<8)+('A'<<16)+('H'<<24)). ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of the TARGETFONTASSOCHEADER structure. ulTargetAssoc 4 byte unsigned integer. The number of the target font association structures that are following after this structure. ulReserved 4 byte unsigned integer. Must be ZERO. The TARGETFONTASSOHEADER is followed by the array of FONTASSOCIATION that represent the target fonts to associate with the source font. For example, if a pre combine rule file includes N target font association structures, sizeof(FONTASSOCIATION) * N bytes will be following after the target font association header. The pre combine rule end structure will be placed after the last target font association structure.

typedef struct _PRECOMBRULEEND { /* pcre */ ULONG   Identity; ULONG   ulSize; } PRECOMBRULEEND; typedef PRECOMBRULEEND *PPRECOMBRULEEND; where Identity 4 byte unsigned integer. Must be 0x45524350 ('P'+('C'<<8)+('R'<<16)+('E'<<24)) ulSize 4 byte unsigned integer. The size of the structure, in bytes, which includes all entries of PRECOMBRULEEND. Font Association Requirement The font association is required by the following background. Windows 95 has a font association function. OS/2 is required to have a equivalent function to the Windows 95 font association. If a user creates a document using the Times New Roman font, that usually does not include DBCS, with font association, the use can actually display and print DBCS on Windows 95 with the document. However, the user will neither be able to display nor print DBCS for the document if the user bring it from Windows 95 to OS/2. If we have an equivalent function to the Windows 95 font association in OS/2, the user will be able to show DBCS with the document. Users would like to display or print DBCS documents even if a SBCS font is selected. There are quite a lot of SBCS applications that use hard coded SBCS font names. Those applications usually have problems to display or print DBCS. If we have the font association function in OS/2, we could have those applications display and print DBCS. Currently users have to wait for those applications be dbcs-enabled and distributed in DBCS countries. The font association function might give the users opportunity to use those application before dbcs-enabled. How it works There is a new key defined in the OS2.INI profile file. If this key and its data are properly specified, the font association function will be activated during the system initialization.

App Name, Key Name, App Data "PM_SystemFonts", "PM_AssociateFont", "XXXXX;YY" where, XXXXX is a facename of the associate font and YY is a logical point size of the associate font. Note that the associate font must be a DBCS font. There is no U/I setting panel be provided for the Merlin release. (Future design might include the U/I setting panel) The current design is to have one associate font per device driver installed in the system. Each associate font will be selected during the device driver initialization time. The graphics engine will search the nearest font match the facename and point size in the OS2.INI profile file. the point size will be converted to the pixel size using the device resolution when searching the nearest font match. The following to the priority to select the associate font match. In all the following cases, the facename must match, otherwise, the associate font matching will fail and the font association will not be activated. Facename match of outline font Facename and exact size match of bitmap font Facename and nearest size match of bitmap font It is recommended that an outline font be used for the associate font so that it can be displayed or printed with balance to the original font after scaled to a proper size. All outline and bitmap SBCS fonts are associated to the system associate font by default. This includes support of .FON bitmap fonts and IFI outline fonts. The association is hidden from applications. Font metrics will stay the same as the original SBCS fonts but the behavior of the Gpi/Gre APIs APIs that have a parameter of string (listed below) will be a little different if the string includes a DBCS code point(s). Before font association, the graphics engine was using the default character of the SBCS font if a DBCS code point is found in the string. The default character is usually defined as a space character. For example, if you display a DBCS document file, you will see nothing on the screen since all DBCS characters are displayed in the default (space) character. The font association function can solve this problem. It will detect DBCS code points in the string and use the system associate font (usually, it isa DBCS font). If the currently selected code page is DBCS and the passed string includes a DBCS code point(s), the graphics engine switch the current font to the system associate font only for the DBCS code points in the string. For example:

12 34 56 7 SDDSDDSDDS Font switching will occur 7 times and restoring to the original font will occur once after the string is handled.

1   2 3 SSSSSDDSSS Font switching will occur 3 times and restoring to the original font will occur once after the string is handled. The overhead of the font switching should be implemented to be minimum. Font association will be executed for the following Gpi functions. GpiCharString GpiCharStringAt GpiCharStringPos GpiCharStringPosAt GpiQueryCharStringPos GpiQueryCharStringPosAt GpiQueryTextBox GpiQueryWidthTable Font Association will be executed for the following Gre functions. GreCharString GreCharStringPos GreQueryCharStringPositions GreQueryTextBox GreQueryWidthTable (GreRealizeString) (GreQueryCharOutline) (GreQueryCharMetricsTable) (GreRealizeString) (GreQueryTabbedTextExtension) (GreTabbedCharStringAt) Restriction Font association does not work for device fonts. Since the graphics engine does not have much control over the device fonts. Device fonts are excluded from the font association support. Users might see the clipped characters of the associate font The font metrics values might sometimes be smaller than the associate font's. If an application is using a value like MaxbaselineExt or MaxCharInc in the font metrics in order to position characters, users might see a problem of the associate font be mis-aligned or clipped out. This is because the original font metrics values are always not true for the associate font. Performance will become a little slower. Font association requires an additional handling than the normal text process, although we will try to be minimum overhead as possible as we can. If the font association support is not installed (in the OS2.INI profile file), there is no performance penalty. Unloading the associate font If the associate font should be unloaded by the user publically (from the font palette), the font association function will be deactivated after the unloading. The user is responsible for either reloading the associate font or using a different font for the associate font by updating the associate font entry in the OS2.INI profile file. Design Concerns Combined font To be written. Code mapping Install/Delete Restrictions (Only generic engine font, metrics difference) Font association Updated->1.Place the associate font pointer per physical device or device Updated->2.Change the matching logic to select the first one to be an outline font. 3.Make sure the font association function works with the default font that replaced the device default. 4.Make sure the font association fucntion works with a fixed pitch font.