home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / console-tools / file-formats / cpi < prev    next >
Encoding:
Text File  |  1999-04-08  |  3.5 KB  |  150 lines

  1.             The CPI file-format
  2.  
  3.         (C) 1997 Yann Dirson <dirson@debian.org>
  4.  
  5.  
  6.  This file documents the CPI font-file-format, as understood by version 0.94
  7. and above of the Linux console utilities ('kbd').
  8.  
  9.  This file has revision number 1.0, and is dated 1997/09/02.
  10.  Any useful additionnal information on CPI files would be great.
  11.  
  12.  
  13. 0. Changes
  14.  
  15. 1998/08/20: updated author's e-mail.
  16.  
  17.  
  18. 1. Summary
  19.  
  20.  The CPI file format is used by MS-DOS to store its fonts. This description
  21. comes from reverse-ingeneering on codepage(1), so it's very incomplete. Any
  22. complement would be greatly appreciated.
  23.  
  24.  A CPI file contains fonts for several MS-DOS code-pages, each in possibly
  25. several sizes (typically 08, 14, 16). Each of these fonts is designed for a
  26. particular device, which can be either a screen or a printer device.
  27.  
  28.  There is also a DR-DOS CPI format, for which I have even less documentation.
  29.  
  30.  MS-DOS 6.22 provides the following CPI files containing screen (EGA) fonts:
  31.  
  32.     iso.cpi
  33.     ega.cpi
  34.     ega2.cpi
  35.     ega3.cpi
  36.     
  37.  The 3 latter files just contain selected codepages from the first one, in
  38. sizes 08, 14 and 16, but the first one only contains size 16.
  39.  
  40.  
  41. 2. History
  42.  
  43.  Unknown.
  44.  
  45.  
  46. 3. Known programs understanding this file-format.
  47.  
  48.  The following program in the Linux console utilities can read and/or write
  49. PSF files:
  50.  
  51.     codepage (R)
  52.  
  53.  
  54. 4. Technical data
  55.  
  56.  The file format is described here in sort-of EBNF notation. Upper-case
  57. WORDS represent terminal symbols, ie. C types; lower-case words represent
  58. non-terminal symbols, ie. symbols defined in terms of other symbols.
  59.  [sym] is an optional symbol
  60.  {sym} is a symbol that can be repeated 0 or more times
  61.  {sym}*N is a symbol that must be repeated N times
  62.  Comments are introduced with a # sign.
  63.  
  64.  
  65.  
  66. # The data (U_SHORT's) are stored in LITTLE_ENDIAN byte order.
  67.  
  68. ms_cpi_file =
  69. (off = 0)    ms_cpi_file_header
  70. (off = 23)    font_info_header
  71. (off = 25)    cp_entry_header
  72. (off = 53)    <more>                # chained data in no special order
  73.  
  74. ms_cpi_file_header =
  75. (off = 0)    ms_cpi_id
  76. (off = 8)    font_res    # ?
  77. (off = 16)    num_pointers    # ?
  78. (off = 18)    p_type        # ?
  79. (off = 19)    offset
  80.  (size = 23)
  81.             
  82. ms_cpi_id    = {CHAR}*8 = 0xFF "FONT   "    # cpi_id is a 8-bytes "magic number" string
  83.  (size = 8)
  84. font_res    = {CHAR}*8
  85.  (size = 8)
  86. num_pointers    = U_SHORT
  87.  (size = 2)
  88. p_type        = CHAR
  89.  (size = 1)
  90. offset        = U_LONG
  91.  (size = 4)
  92.  
  93. font_info_header = nb-codepages
  94.  (size = 2)
  95.  
  96. nb-codepages = U_SHORT
  97.  (size = 2)
  98.  
  99. #
  100.  
  101. # The header's normal size is 28 bytes. However, it is said there happens to
  102. # be 26-bytes headers. What happens in this case ? Is font_offset still valid ?
  103. cp_entry_header =
  104. (off = 0)    cp_header_size 
  105. (off = 2)    next_header_offset 
  106. (off = 6)    device_type
  107. (off = 8)    device_name
  108. (off = 16)    cp_number
  109. (off = 18)    cp_res            # ?
  110. (off = 24)    font_offset
  111.  (size = 28)
  112.  
  113. cp_header_size        = U_SHORT        # size of the codepage_header
  114.  (size = 2)
  115. next_header_offset    = U_LONG
  116.  (size = 4)
  117. device_type        = U_SHORT = 1 | 2    # 1 = screen ; 2 = printer
  118.  (size = 2)
  119. device_name        = {CHAR}*8        # eg. "EGA     "
  120.  (size = 8)
  121. cp_number        = U_SHORT
  122.  (size = 2)
  123. cp_res            = {CHAR}*6
  124.  (size = 6)
  125. font_offset        = U_LONG
  126.  (size = 4)
  127.  
  128. <AT FONT-OFFSET>: cp_info_header cp_fontdata
  129.  
  130. #
  131.  
  132. cp_info_header =
  133. (off = 0)    U_SHORT        # reserved
  134. (off = 2)    num_fonts
  135. (off = 4)    bitmap_size    # size of font data (all <num_fonts> sizes)
  136.  (size = 6)
  137.  
  138. num_fonts    = U_SHORT
  139.  (size = 2)
  140. bitmap_size    = U_SHORT        # eg. for width=8 :  16->4102  08,14,16->9746 (!?)
  141.  (size = 2)
  142.  
  143. cp_fontdata    = {raw_fontdata}    # font data for all <num_fonts> sizes
  144.  
  145. #
  146.  
  147. raw_fontdata =    {char_data}*256
  148.  
  149. char_data =    {BYTE}*<fontheight>
  150.