home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 21 / CD_ASCQ_21_040595.iso / dos / prg / pas / tvgr70 / fonts.doc < prev    next >
Text File  |  1994-09-24  |  7KB  |  187 lines

  1. file Fonts.Doc    September 1994
  2.  
  3. TVGraphic 2.0
  4.  
  5. Documentation on replacing TVGraphic's default bitmapped fonts.
  6.  
  7. Users wishing to replace the default 8x14 pixel bitmapped font in 
  8. TVGraphic:
  9.  
  10.   1. Replacing with your own font   (can be other than 14 pixels tall)
  11.   2. European users wishing to use European DOS code page fonts
  12.  
  13. Users wishing to replace the default 8x8 bitmapped font:
  14.  
  15.   Follow section 1 but use the font8x8 functions and procedures.
  16.   Font must be 8 pixels tall.
  17.   There is no YOffset parameter to set.
  18.  
  19.   European users also see section 2.
  20.  
  21. Users wishing to replace just a few characters in the 8x8 or 8x14 font:
  22.  
  23.   Due to restrictions of protected mode, you cannot directly change data
  24.   (like a font) which is linked to your program's code segment with
  25.   the $L command.
  26.  
  27.   For 8x14 font:
  28.     Use function PointerTo8x14Font to access current 8x14 font array.
  29.       Declare a variable MyFont of type font8x14type.
  30.       Copy the font into MyFont
  31.         MyFont := PointerTo8x14Font^;
  32.       Make your changes to MyFont and procede as in section 1 to create
  33.       a new font file.
  34.  
  35. -------------------------
  36. exported by unit MyGraph
  37.   function  PointerTo8x8Font : P8x8Type; {returns pointer to current
  38.                                           8x8 font}
  39.   procedure Set8x8FontStyle(P : Pointer);
  40.   procedure SetDefault8x8FontStyle; {restores default font8x8}
  41.   function  PointerTo8x14Font : P8x14Type; {returns pointer to current
  42.                                             8x14 font}
  43.   procedure Set8x14FontStyle(P : Pointer; YOffset : byte);
  44.   procedure SetDefault8x14FontStyle; {restores default font8x14}
  45.  
  46. type
  47.   {note: a bitmap font file consists of the font header followed
  48.         by the BitMapArray. The memory image is identical.}
  49.  
  50.   FontHdrType = record
  51.     Name : string[5];       {'BFN20' for version 2.0 fonts}
  52.     CharSpacing : byte;     {of a char, in pixels - not used yet}
  53.     CharHeight : byte;      {of a char, in pixels
  54.                              must equal number of stored bytes/char}
  55.   end;
  56.  
  57.   BitMap8x8      = array[0..7] of byte;  {contains one character}
  58.                       {0 is the top row of pixels, 7 is the bottom}
  59.                       {bit 7 of a byte is the leftmost pixel}
  60.   BitMapArray8x8 = array[0..255] of BitMap8x8; {contains bitmaps for
  61.                                                 one 8x8 font}
  62.   P8x8type = ^font8x8type;
  63.   font8x8type = record
  64.     Hdr : FontHdrType;
  65.     Map : BitMapArray8x8;
  66.   end;
  67.  
  68.   BitMap8x14      = array[0..13] of byte;
  69.   BitMapArray8x14 = array[0..255] of BitMap8x14;
  70.   P8x14type = ^font8x14type;
  71.   font8x14type = record
  72.     Hdr : FontHdrType;
  73.     Map : BitMapArray8x14;
  74.   end;
  75.  
  76.   BitMap8x16      = array[0..15] of byte;
  77. -------------------------
  78.  
  79. 1. Replacing with your own font
  80.   (TVGraphic bitmapped fonts follow the type declarations just listed.)
  81.  
  82.   For an 8x14 font:
  83.     A bitmap for a single character is stored in type BitMap8x14.
  84.     Bitmaps for the 256 characters of an 8x14 pixel font are
  85.     stored in a 256 array of BitMap8x14 called type BitMapArray8x14.
  86.  
  87.     A bitmap font file (font8x14type) consists of the font header
  88.     followed by the BitMapArray8x14.
  89.  
  90.   Declare variable MyFont of type font8x14type and load the
  91.   BitMapArray8x14 portion (MyFont.Map) with your font.
  92.     For MyFont.Hdr
  93.       Set NAME := 'BFN20'
  94.       Set CharSpacing to 8   (value not used in TVGraphic yet)
  95.       Set CharHeight to the number of bytes used to store a character
  96.       in your font.
  97.         To replace TVGraphic's default 8x8 font, CharHeight must be 8.
  98.         To replace the default 8x14 font, set Charheight to 14.
  99.           However you can replace TVGraphic's 8x14 font with a font of
  100.           a different height - 8x2 to 8x16. Set CharHeight to match
  101.           your font.
  102.         The maximum allowed value of CharHeight is 16.
  103.  
  104.   Create a disk file
  105.        Assign(Fontfile, 'NEWFONT.BIN');
  106.        Rewrite(Fontfile, 1);
  107.        store the array using
  108.          BlockWrite(Fontfile, MyFont, Sizeof(MyFont));
  109.        Close(FontFile);
  110.     This stores MyFont in a binary format file named NEWFONT.BIN.
  111.  
  112.   Convert to .OBJ file.
  113.    (TVGraphic convention is to name the font object file with .FNT, not .OBJ)
  114.      Use Borland utility BINOBJ to convert NewFont.Bin to NewFont.OBJ.
  115.      Rename the file with the .FNT extension.
  116.        BINOBJ will ask you for a name which you will use when writing
  117.        your TVGraphic program.
  118.               example of name:   MyBitMap_Font
  119.  
  120.   In your TVGraphic program
  121.     Link the file             {same as for European users}
  122.      procedure MyBitMap_Font; external;  {use the name supplied to BINOBJ}
  123.      {$L NewFont.FNT}
  124.          {causes compiler to load the object file and link it to unit}
  125.  
  126.      When you want to replace the default 8x14 font with your font:
  127.  
  128.        Set8x14FontStyle(@MyBitMap_Font, YOffset);
  129.           Set value of parameter YOffset to match your 8x14 font.
  130.           This controls the Y position of the characters in
  131.           standard TVGraphic views that use the BYOffset variable.
  132.           It is most noticable in TgInputLine.
  133.           Usual choices are 0 or 1.
  134.           {Global variable BYOffset will be set to value of YOffset
  135.            whenever the 8x14 font is selected.}
  136.  
  137.      To restore the default 8x14 font:
  138.        SetDefault8x14FontStyle;
  139.  
  140.   NOTE: if you replace font8x14 with a font of a different height,
  141.        TVGraphic's standard views may not look good. If this is a
  142.        problem, use your font only inside your .Draw method and
  143.        restore the default 8x14 font before leaving the .Draw routine.
  144.  
  145. 2. For European users wishing to use European DOS code page fonts.
  146.   {Note: In TVGraphic version 1.5, only the upper 128 chars of the font
  147.    were replaced using SetEuroFont - SetEuroFont is no longer supported.
  148.    In v2.0 the entire font is replaced and you must set the YOffset
  149.    parameter.}
  150.  
  151.   Version 2.0 of TVGraphic includes 8x14 pixel fonts matching the
  152.   DOS code pages for Nordic and MultiLingual(Latin I). In Europe the
  153.   DOS terminology may be different from US. So try this:
  154.     Nordic = Scandinavian
  155.     Multilingual = most European languages derived from Latin
  156.   8x8 pixel fonts corresponding to the Nordic and MultiLingual fonts
  157.   are also included in this version.
  158.  
  159.   Font file names:
  160.     8x14 pixel char size : NORDIC14.FNT, LATIN14.FNT
  161.     8x8  pixel char size : NORDIC8.FNT, LATIN8.FNT  (if available)
  162.            {procedure names NORDIC8x8_FONT, LATIN8x8_FONT}
  163.  
  164.   To Use:
  165.     Declare a procedure using the names as shown below.
  166.     Link the desired font file to your program with $L compiler directive.
  167.         Assign a pointer to the procedure/font using the @ operator.
  168.     Use this pointer in a call to
  169.         Set8x14FontStyle(P : Pointer; YOffset : byte);
  170.           Set parameter YOffset to 0 for European DOS code pages.
  171.     To restore the default 8x14 US font, call SetDefault8x14FontStyle;
  172.  
  173.     example
  174.       procedure Nordic8x14_Font; external; {just to hold the data, NEVER CALL}
  175.       {$L NORDIC14.FNT}
  176.       ...
  177.       begin
  178.         ...
  179.         Set8x14FontStyle(@Nordic8x14_Font, 0); {call to change fonts}
  180.  
  181.      (* OR
  182.       procedure Latin8x14_Font; external; {just to hold the data, NEVER CALL}
  183.       {$L LATIN14.FNT} *)
  184.  
  185.  
  186. Have fun.
  187.