home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / developmen / oplexamp / FONTFORM.TXT < prev    next >
Text File  |  1993-10-09  |  3KB  |  83 lines

  1. The physical structure of font files
  2. ====================================
  3. Font files start with a P_FSIG header:
  4.     typedef struct
  5.         {
  6.         TEXT app_id[3]; /* application id */
  7.         UBYTE chk_sum; /* application id checksum */
  8.         UBYTE file_vn; /* file version number */
  9.         UBYTE app_vn; /* application version number */
  10.         } P_FSIG;
  11.  
  12. For a normal font file, appropriate values for the P_FSIG header are:
  13.     P_FSIG sig = {"FON",'F'+'O'+'N',0x30,0x30};
  14. For a fast font file, the appropriate values are:
  15.     P_FSIG sig = {"FN1",'F'+'N'+'1',0x10,0x10};
  16. The window server automatically recognises the difference
  17. between normal and fast fonts.
  18.  
  19. The P_FSIG header is followed by the data which makes up
  20. the WS_FONT_FILE_HEADER
  21.     typedef struct
  22.         {
  23.         P_FSIG sig;
  24.         UWORD checksum;
  25.         UWORD size;
  26.         G_FONT_INFO info;
  27.         } WS_FONT_FILE_HEADER;
  28.  
  29. The checksum is calculated by applying p_crc (see below) to the data
  30. that follows the WS_FONT_FILE_HEADER header (the character width
  31. array and the font bitmap).
  32.  
  33. The size is the byte size remaining in the file after the size field.
  34. The G_FONT_INFO struct is as returned by gFontInfo:
  35.     typedef struct
  36.         {
  37.         UWORD low_ch;  /* lowest code in font */
  38.         UWORD high_ch; /* highest code in font */
  39.         UWORD height;  /* height of font */
  40.         UWORD descent;   /* height of bottom part of character */
  41.         UWORD ascent; /* height of top part of character */
  42.         UWORD numeric_width; /* Width of numeric character */
  43.         UWORD max_width; /* The width of the widest character in the font */
  44.         UWORD flags;
  45.         TEXT name[FONT_NAME_LEN];
  46.         } G_FONT_INFO;
  47.  
  48. In a normal font, the WS_FONT_FILE_HEADER is followed by:
  49.   *  an array of (high_ch-low_ch+2) WORD offsets into the font bitmap
  50.   *  the font bitmap.
  51.  
  52. The font bitmap contains the characters in the font as one long
  53. string in code order.  The window server literally bit copies the
  54. characters from this font bitmap to the drawable (the screen or a
  55. bitmap).
  56.  
  57. Each word in the array of offsets contains the doubled pixel offset
  58. within the font bitmap with the least significant bit of the word set
  59. to 1 if the character is missing from the font and left as 0
  60. otherwise.  The offset corresponding to a missing character must be
  61. that of the next existing character.  An extra offset is stored at
  62. the end of the array containing what would have been the offset of
  63. the next character so that the width of a character may be calculated
  64. by subtracting its offset from the offset of the next character.
  65.  
  66. Fast fonts are stored in an expanded form that uses more memory but
  67. can be drawn faster. In a fast font, the WS_FONT_FILE_HEADER is
  68. followed by:
  69.   *  an array of 256 BYTE character pixel widths (each set to between
  70. zero and 8, inclusive)
  71.   *  the font bitmap for all 256 characters (which is 256*height
  72. bytes long).
  73.  
  74. All characters in a fast font must be less than or equal to 8 pixels
  75. wide.  The font bitmap contains all 256 characters, stored left
  76. aligned in their 8 pixel slot.  Unused bits are, by convention, set
  77. to zero.
  78.  
  79. The CRC checksum
  80. ----------------
  81. The polynomial used is (X power 16 + X power 12 + X power 5 + 1), as
  82. recommended by CCITT.
  83.