|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
<HTML>
|
|
Packit Service |
50ad14 |
<HEAD>
|
|
Packit Service |
50ad14 |
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
|
|
Packit Service |
50ad14 |
<TITLE>Font-formats recognized by the Linux kbd package: CPI fonts</TITLE>
|
|
Packit Service |
50ad14 |
<LINK HREF="font-formats-4.html" REL=next>
|
|
Packit Service |
50ad14 |
<LINK HREF="font-formats-2.html" REL=previous>
|
|
Packit Service |
50ad14 |
<LINK HREF="font-formats.html#toc3" REL=contents>
|
|
Packit Service |
50ad14 |
</HEAD>
|
|
Packit Service |
50ad14 |
<BODY>
|
|
Packit Service |
50ad14 |
Next
|
|
Packit Service |
50ad14 |
Previous
|
|
Packit Service |
50ad14 |
Contents
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
In the DOS world screen or printer fonts come in
|
|
Packit Service |
50ad14 |
Code Page Information format. There are two versions:
|
|
Packit Service |
50ad14 |
the MS-DOS/PC-DOS "FONT" format, and the DR-DOS/Novell DOS
|
|
Packit Service |
50ad14 |
"DRFONT" compressed format.
|
|
Packit Service |
50ad14 |
These *.CPI files may contain fonts for several
|
|
Packit Service |
50ad14 |
code pages, and, given a code page, for several point sizes.
|
|
Packit Service |
50ad14 |
MS-DOS files usually have 16x8, 14x8, 8x8 fonts, while
|
|
Packit Service |
50ad14 |
DR-DOS files often have 6x8, 8x8, 14x8, 16x8 fonts (in this order).
|
|
Packit Service |
50ad14 |
Printer .CPI files have only one font.
|
|
Packit Service |
50ad14 |
(One sometimes encounters entirely different .cpi files,
|
|
Packit Service |
50ad14 |
namely Unix .cpio files moved to a DOS machine with 8.3 filenames.
|
|
Packit Service |
50ad14 |
Such files are archives.)
|
|
Packit Service |
50ad14 |
The files in "FONT" format have the following layout.
|
|
Packit Service |
50ad14 |
First a 23-byte header.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
struct {
|
|
Packit Service |
50ad14 |
char id0; /* 0: 0xff */
|
|
Packit Service |
50ad14 |
char id[7]; /* 1-7: "FONT " */
|
|
Packit Service |
50ad14 |
char reserved[8]; /* 8-15: 0 */
|
|
Packit Service |
50ad14 |
short pnum; /* 16-17: number of pointers: 1 */
|
|
Packit Service |
50ad14 |
char ptyp; /* 18: type of pointers: 1 */
|
|
Packit Service |
50ad14 |
long fih_offset; /* 19-22: file offset of FontInfoHeader: 0x17 */
|
|
Packit Service |
50ad14 |
} FontFileHeader; /* 0-22 */
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
(Files in "DRFONT compressed format" have 0x7f "DRFONT " in bytes 0-7.
|
|
Packit Service |
50ad14 |
After this FontFileHeader they have an extended header
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
struct {
|
|
Packit Service |
50ad14 |
char num_fonts_per_codepage; /* 23: N=4 */
|
|
Packit Service |
50ad14 |
char font_height[N]; /* 24-27: height of each font */
|
|
Packit Service |
50ad14 |
long dfd_offset[N]; /* 28-43: file offsets of DisplayFontData */
|
|
Packit Service |
50ad14 |
} DRDOSExtendedFontFileHeader;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
and consequently fih_offset will be 44 (0x2c) instead of 23 (0x17).)
|
|
Packit Service |
50ad14 |
Next a 2-byte header that tells how many code pages this file contains.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
struct {
|
|
Packit Service |
50ad14 |
short num_codepages;
|
|
Packit Service |
50ad14 |
} FontInfoHeader; /* 23-24 */
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
Next the indicated number of code pages.
|
|
Packit Service |
50ad14 |
Each code page has a header and font data. In some files all headers
|
|
Packit Service |
50ad14 |
come first and then all font data. In other files headers and font data
|
|
Packit Service |
50ad14 |
alternate, that is, data for one code page is kept together.
|
|
Packit Service |
50ad14 |
The code page header (the offsets given are for the first occurrence):
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
struct {
|
|
Packit Service |
50ad14 |
short cpeh_size; /* 25-26: size of this header: 28 */
|
|
Packit Service |
50ad14 |
long next_cpeh_offset; /* 27-30: offset of next header; 0 or -1 for last */
|
|
Packit Service |
50ad14 |
short device_type; /* 31-32: 1: screen, 2: printer */
|
|
Packit Service |
50ad14 |
char device_name[8]; /* 33-40: e.g. "EGA " */
|
|
Packit Service |
50ad14 |
short codepage; /* 41-42: 0, 437, 737, 85[0257], 86[013569], ... */
|
|
Packit Service |
50ad14 |
char reserved[6]; /* 43-48: 0 */
|
|
Packit Service |
50ad14 |
long cpih_offset; /* 49-52: pointer to CPInfoHeader or 0 */
|
|
Packit Service |
50ad14 |
} CPEntryHeader; /* 25-52 */
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
MS-DOS and PC-DOS sometimes have 26 instead of 28 for the cpeh_size
|
|
Packit Service |
50ad14 |
field in printer font files; one even meets both 26 and 28 in the same file.
|
|
Packit Service |
50ad14 |
Probably there is confusion over whether cpih_offset
|
|
Packit Service |
50ad14 |
is short or long.
|
|
Packit Service |
50ad14 |
When headers and fonts are interspersed, next_cpeh_offset
|
|
Packit Service |
50ad14 |
will point past the font, regardless of whether more entries follow.
|
|
Packit Service |
50ad14 |
When first all headers are given, next_cpeh_offset is zero
|
|
Packit Service |
50ad14 |
in the last header.
|
|
Packit Service |
50ad14 |
It happens that next_cpeh_offset does not point to the
|
|
Packit Service |
50ad14 |
next header, but to the one after that, or that it is zero while
|
|
Packit Service |
50ad14 |
still one header follows. In such cases num_codepages
|
|
Packit Service |
50ad14 |
gives the correct number of headers. (In the cases where it is
|
|
Packit Service |
50ad14 |
zero while still one header follows, the last header is a dummy
|
|
Packit Service |
50ad14 |
one, for codepage 0 and with no associated font.)
|
|
Packit Service |
50ad14 |
Early DR-DOS printer font files have 1 instead of 2 in device_type .
|
|
Packit Service |
50ad14 |
Device names include "EGA ", "LCD " for screen, and
|
|
Packit Service |
50ad14 |
"4201 ", "4208 ", "5202 ", "1050 ", "EPS ", "PPDS "
|
|
Packit Service |
50ad14 |
for printer devices.
|
|
Packit Service |
50ad14 |
A code page font starts with a general header:
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
struct {
|
|
Packit Service |
50ad14 |
short version; /* 53-54: 1: FONT, 2: DRFONT */
|
|
Packit Service |
50ad14 |
short num_fonts; /* 55-56 */
|
|
Packit Service |
50ad14 |
short size; /* 57-58: length of font data for each font */
|
|
Packit Service |
50ad14 |
} CPInfoHeader; /* 53-58 */
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
(For printer fonts num_fonts is 1 or 2, while only a single
|
|
Packit Service |
50ad14 |
font follows. For screen fonts num_fonts is 1, 3 or 4.
|
|
Packit Service |
50ad14 |
DRFONT files have in the size field the size (24) of the
|
|
Packit Service |
50ad14 |
DRFONT header without the index table.)
|
|
Packit Service |
50ad14 |
And then for each font a header followed by the actual data.
|
|
Packit Service |
50ad14 |
For screen fonts
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
struct {
|
|
Packit Service |
50ad14 |
char height; /* 59: one of 6, 8, 14, 16 */
|
|
Packit Service |
50ad14 |
char width; /* 60: 8 */
|
|
Packit Service |
50ad14 |
short reserved; /* 61-62: 0 */
|
|
Packit Service |
50ad14 |
short num_chars; /* 63-64: 256 */
|
|
Packit Service |
50ad14 |
} ScreenFontHeader; /* 59-64 */
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
and for printer fonts
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
struct {
|
|
Packit Service |
50ad14 |
short printer_type; /* 59-60: 1=4201/1050/EPS, 2=5202/4208/PPDS */
|
|
Packit Service |
50ad14 |
short seqlength; /* 61-62: length of escape sequences */
|
|
Packit Service |
50ad14 |
} PrinterFontHeader; /* 59-62 */
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
followed by two escape sequences of the indicated length
|
|
Packit Service |
50ad14 |
to select the hardware codepage or the downloaded codepage.
|
|
Packit Service |
50ad14 |
However, in DRFONT files the CPInfoHeader is followed by
|
|
Packit Service |
50ad14 |
the DRFONT header, consisting first of 4 ScreenFontHeaders,
|
|
Packit Service |
50ad14 |
one for each point size, and then an index indicating where
|
|
Packit Service |
50ad14 |
in the font bitmap the corresponding characters can be found.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
struct {
|
|
Packit Service |
50ad14 |
struct ScreenFontHeader sfh[4];
|
|
Packit Service |
50ad14 |
short FontIndex[256];
|
|
Packit Service |
50ad14 |
} DRFONTheader;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
The font index is some integer, in the range 0-400 or so,
|
|
Packit Service |
50ad14 |
indicating where in the font this code position can be found.
|
|
Packit Service |
50ad14 |
In this way the font data is separated from the code used.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
Linux does not accept .CPI files, but the codepage
|
|
Packit Service |
50ad14 |
utility from the kbd package is willing to read .CPI files
|
|
Packit Service |
50ad14 |
of "FONT" type, and output .cp files suitable for setfont .
|
|
Packit Service |
50ad14 |
For example, the call codepage -a iso.cpi will create
|
|
Packit Service |
50ad14 |
ten font files 850.cp , 437.cp , ..., 869.cp
|
|
Packit Service |
50ad14 |
each containing a single font of pointsize 16, and
|
|
Packit Service |
50ad14 |
codepage -a ega2.cpi six font files
|
|
Packit Service |
50ad14 |
850.cp , ..., 737.cp each containing three fonts
|
|
Packit Service |
50ad14 |
of pointsizes 8, 14, 16.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
Next
|
|
Packit Service |
50ad14 |
Previous
|
|
Packit Service |
50ad14 |
Contents
|
|
Packit Service |
50ad14 |
</BODY>
|
|
Packit Service |
50ad14 |
</HTML>
|