home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / Development / RKM_Companion_v2.04 / Graphics_Libraries / Text / Suits8.asm < prev   
Encoding:
Assembly Source File  |  1996-03-20  |  7.4 KB  |  136 lines

  1. * A sparse (but complete) sample font.
  2. *
  3. * 1.  Assemble this file (assumed to have been saved as "suits8.asm"). For example, if you have the
  4. * CAPE 680x0 assembler, and you have assigned "include:" to the directory containing your include
  5. * files, use:
  6. *          CAsm -a "suits8.asm" -o "suits8.o" -i "include:"
  7. *
  8. *     Link "suits8.o".  For example, if you have Lattice, use:
  9. *          BLink from "suits8.o" to "suits8"
  10. *
  11. * 2.  Create the subdirectory "Fonts:suits".  Copy the file "suits8" (created in step 1)
  12. *     to "Fonts:suits/8".
  13. *
  14. * 3.  Create a font contents file for the font.  You can do this by two methods:
  15. *
  16. *   a. Run the program "System/FixFonts" which will create the file "Fonts:suits.font"
  17. *      automatically.
  18. *   b. Use the NewFontContents() call in the diskfont library to create a FontContentsHeader
  19. *      structure, which can be saved in the Fonts: directory as "suits.font".   This is essentially
  20. *      what FixFonts does.
  21. *
  22. * The next word contains the font YSize; in this case, 0x0008.
  23. *
  24. * The next byte contains the font Flags, in this case 0x00.
  25. *
  26. * The last byte contains the font characteristics, in this case 0x60.  This says it is a disk-based
  27. * font (bit 1 set) and the font has been removed (bit 7 set), saying that the font is not currently
  28. * resident.
  29. *
  30. * Summary of suits.font file:
  31. *
  32. * Name: fch_FileID fch_NumEntries fc_FileName     fc_YSize fc_Flags fc_Style
  33. * Size: word       word     MAXFONTPATH bytes word     byte     byte
  34. * Hex:  0f00       0001     73756974732F3800  0008     00       60
  35. * ASCII:            s u i t s / 8 \0
  36. *
  37. * The correct length of a font file may be calculated with this formula:
  38. * length = ((number of font contents entries) * (MAXFONTPATH+4)) + 4. In this case (one entry),
  39. * this becomes (MAXFONTPATH + 8) or 264.
  40. *
  41. * To try out this example font, do the following.  Use the Fonts Preferences editor or a
  42. * program that allows the user to select fonts.  Choose the "suits" font in size 8.
  43. * This example font defines ASCII characters 'a' 'b' 'c' and 'd' only. All other characters
  44. * map to a rectangle, meaning "character unknown".
  45.  
  46.     section  text,code
  47.  
  48.     INCLUDE  "exec/types.i"
  49.     INCLUDE  "exec/nodes.i"
  50.     INCLUDE  "libraries/diskfont.i"
  51.  
  52.     MOVEQ     #-1,D0      ; Provide an easy exit in case this file is
  53.     RTS                   ; "Run" instead of merely loaded.
  54.  
  55.     DC.L      0           ; ln_Succ     * These five entries comprise a Node structure,
  56.     DC.L      0           ; ln_Pred     * used by the system to link disk fonts into a
  57.     DC.B      NT_FONT     ; ln_Type     * list.  See the definition of the "DiskFontHeader"
  58.     DC.B      0           ; ln_Pri      * structure in the "libraries/diskfont.i" include
  59.     DC.L      fontName    ; ln_Name     * file for more information.
  60.  
  61.     DC.W      DFH_ID      ; FileID
  62.     DC.W      1           ; Revision
  63.     DC.L      0           ; Segment
  64.  
  65. * The next MAXFONTNAME bytes are a placeholder.  The name of the font contents file (e.g.
  66. * "suits.font") will be copied here after this font descriptor is LoadSeg-ed into memory.  The Name
  67. * field could have been left blank, but inserting the font name and size (or style) allows one to
  68. * tell something about the font by using "Type OPT H" on the file.
  69.  
  70. fontName:
  71.     DC.B      "suits8"    ; Name
  72.  
  73. * If your assembler needs an absolute value in place of the "length" variable, simply count the
  74. * number of characters in Name and use that.
  75.  
  76. length  EQU     *-fontName              ; Assembler calculates Name's length.
  77.         DCB.B   MAXFONTNAME-length,0    ; Padding of null characters.
  78.  
  79. font:
  80.     DC.L    0               ; ln_Succ       * The rest of the information is a TextFont
  81.     DC.L    0               ; ln_Pred       * structure.  See the "graphics/text.i" include
  82.     DC.B    NT_FONT         ; ln_Type       * file for more information.
  83.     DC.B    0               ; ln_Pri
  84.     DC.L    fontName        ; ln_Name
  85.     DC.L    0               ; mn_ReplyPort
  86.     DC.W    0               ; (Reserved for 1.4 system use.)
  87.     DC.W    8               ; tf_YSize
  88.     DC.B    0               ; tf_Style
  89.     DC.B    FPF_DESIGNED!FPF_PROPORTIONAL!FPF_DISKFONT ; tf_Flags
  90.     DC.W    14              ; tf_XSize
  91.     DC.W    6               ; tf_Baseline  <----* tf_Baseline must be no greater than
  92.     DC.W    1               ; tf_BoldSmear      * tf_YSize-1, otherwise algorithmically-
  93.     DC.W    0               ; tf_Accessors      * generated styles (italic in particular)
  94.     DC.B    97              ; tf_LoChar         * can corrupt system memory.
  95.     DC.B    100             ; tf_HiChar
  96.     DC.L    fontData        ; tf_CharData
  97.     DC.W    8               ; tf_Modulo  <- * add this to the data pointer to go from from
  98.                             ;               * one row of a character to the next row of it.
  99.     DC.L    fontLoc         ; tf_CharLoc <---------------- * bit position in the font data
  100.     DC.L    fontSpace       ; tf_CharSpace                 * at which the character begins.
  101.     DC.L    fontKern        ; tf_CharKern
  102.  
  103. * The four characters of this font define the four playing-card suit symbols.  The heart, club,
  104. * diamond, and spade map to the lower-case ASCII characters 'a', 'b', 'c', and 'd' respectively The
  105. * fifth entry in the table is the character to be output when there is no entry defined in the
  106. * character set for the requested ASCII value.  Font data is bit-packed edge to edge to save space.
  107.  
  108. fontData:                             ;   97 (a)       98 (b)       99 (c)   100 (d)      255
  109.     DC.W  $071C0,$08040,$070FF,$0F000 ; <        X        X    X        X        >
  110.     DC.W  $0FBE3,$0E0E0,$0F8C0,$03000 ;  .@@@...@@@.  .....@.....  ...@...  ....@@@....  @@@@@@@@@@@@
  111.     DC.W  $07FCF,$0F9F3,$026C0,$03000 ;  @@@@@.@@@@@  ...@@@@@...  ..@@@..  ...@@@@@...  @@........@@
  112.     DC.W  $03F9F,$0FFFF,$0FFC0,$03000 ;  .@@@@@@@@@.  .@@@@@@@@@.  .@@@@@.  .@@..@..@@.  @@........@@
  113.     DC.W  $01F0E,$0B9F3,$026C0,$03000 ;  ..@@@@@@@..  @@@@@@@@@@@  @@@@@@@  @@@@@@@@@@@  @@........@@
  114.     DC.W  $00E00,$080E0,$020C0,$03000 ;  ...@@@@@...  .@@@.@.@@@.  .@@@@@.  .@@..@..@@.  @@........@@
  115.     DC.W  $00403,$0E040,$0F8FF,$0F000 ;  ....@@@....  .....@.....  ..@@@..  .....@.....  @@........@@
  116.     DC.W  $00000,$00000,$00000,$00000 ;  .....@.....  ...@@@@@...  ...@...  ...@@@@@...  @@@@@@@@@@@@
  117.     DC.W  $00000,$00000,$00000,$00000 ;  ...........  ...........  .......  ...........  ............
  118.  
  119. fontLoc:                 ; The fontLoc information is used to "unpack" the fontData. Each
  120.     DC.L    $0000000B   ; pair of words specifies how the characters are bit-packed.  For
  121.     DC.L    $000B000B   ; example, the first character starts at bit position 0x0000, and
  122.     DC.L    $00160007   ; is 0x000B (11) bits wide.  The second character starts at bit
  123.     DC.L    $001D000B   ; position 0x000B and is 0x000B bits wide, and so on.  This tells
  124.     DC.L    $0028000C   ; the font handler how to unpack the bits from the array.
  125.  
  126. fontSpace:                        ; fontSpace array:  Use a space this wide to contain this
  127.     DC.W    000012,000012         ; character when it is printed.  For reverse-path fonts
  128.     DC.W    000008,000012,000013  ;  these values would be small or negative.
  129.  
  130. fontKern:                         ; fontKern array:  Place a space this wide after the
  131.     DC.W    000001,000001         ; corresponding character to separate it from the following
  132.     DC.W    000001,000001,000001  ; character.  For reverse-path fonts these values would be large
  133.                                   ; negative numbers, approximately the width of the characters.
  134. fontEnd:
  135.     END
  136.