The ctt2rle.exe program assumes a Latin-based language. To handle Unicode - and especially non-latin, ideographic languages - a more complex format is needed. The file layout is defined by the structures located in the ntrle.h header file.
Note GDISrv allows the driver a 32-bit handle to each glyph in the font. Basically, the FD_GLYPHSET structure contains the header information that describes how to reach into the glyph handle array of data returned by the driver to GDISrv. The driver is free to set the value within these 32 bits.
RasDD can use five different formats as follows:
#define RLE_DIRECT 10 /* Index + 1 or 2 data bytes */ #define RLE_PAIRED 11 /* Index plus 2 bytes, overstruck */ #define RLE_L_OFFSET 12 /* Length + 3 byte offset to data */ #define RLE_LI_OFFSET 13 /* Length + Index + 2 byte Offset */ #define RLE_OFFSET 14 /* Offset to (length; data) */
These values specify the different methods used to pack data into the glyph handles and are taken from the ntrle.h header file.
The glyph handles contain two or three pieces of data depending upon the particular format. Each glyph handle contains a width table index and at least one byte of data to send to the printer. If only one or two bytes are to be sent to the printer, the RLE_DIRECT or RLE_PAIRED format is used. This format has a 2-byte index and one or two bytes of data. RLE_DIRECT contains one or two bytes of data to send. If there are two bytes of data, and the second one is not zero, the second one is sent immediately following the first. One use for this format is SHift JIS, where many of the glyphs require two bytes to print. This format is defined by the RD structure in the ntrle.h header file. The RLE_PAIRED format also contains one or two bytes. If RLE_PAIRED contains two bytes RasDD is forced to backup after the first byte and print the second one. This corresponds to the overprinting mode of Windows 3.1.
If any of the glyphs require more than two bytes, one of the offset modes is required. There are three offset modes that are designed to reduce the size of the output file: RLE_L_OFFSET, RLE_LI_OFFSET and RLE_OFFSET.
The most compact of these offsets is the RLE_LI_OFFSET mode. The data format is defined by the RLIC structure in the ntrle.h header file. In this format, there is a one-byte length field, a one-byte width table index, and two bytes used either as an offset OR as one or two bytes to send to the printer. If the length field is <= 2, the data is contained in the least significant one or two bytes. Otherwise, the least significant two bytes (considered a WORD) contains an offset to the data to send. This offset is relative to NTRLE structure located at the beginning of the file/resource. There is one obvious limitation to this mode: There can be no more than 256 glyphs in the font (due to the width table index size).
The RLE_L_OFFSET format is used when the above limitations rule out use of RLE_LI_OFFSET. This format consists of a length byte and a three-byte offset field. The offset is in the least significant three bytes of the handle, while the length field occupies the most significant byte. The offset is relative to the NTRLE structure at the start of the file/resource. The data at the offset must be WORD aligned (the least significant bit of the offset must be zero). The offset points to a WORD that is the width table index for this particular glyph, followed by the bytes to send to the printer. The number of bytes is contained in the most significant byte of the glyph handle.
The RLE_OFFSET format is the largest of the offsets. RLE_OFFSET simply consists of an offset into the file. This offset is relative to the NTRLE structure at the start of the file/resource. The offset must be WORD aligned and point at two words, followed by the bytes to send to the printer. The first word contains the length of the data string to send, the second WORD is the width table index.