home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / graphics / text / suits8.asm < prev    next >
Encoding:
Assembly Source File  |  1980-02-04  |  10.0 KB  |  222 lines

  1. * A sparse (but complete) sample font.
  2. *
  3. * Copyright (c) 1990 Commodore-Amiga, Inc.
  4. *
  5. * This example is provided in electronic form by Commodore-Amiga, Inc. for
  6. * use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  7. * The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  8. * information on the correct usage of the techniques and operating system
  9. * functions presented in this example.  The source and executable code of
  10. * this example may only be distributed in free electronic form, via bulletin
  11. * board or as part of a fully non-commercial and freely redistributable
  12. * diskette.  Both the source and executable code (including comments) must
  13. * be included, without modification, in any copy.  This example may not be
  14. * published in printed form or distributed with any commercial product.
  15. * However, the programming techniques and support routines set forth in
  16. * this example may be used in the development of original executable
  17. * software products for Commodore Amiga computers.
  18. * All other rights reserved.
  19. * This example is provided "as-is" and is subject to change; no warranties
  20. * are made.  All use is at your own risk.  No liability or responsibility
  21. * is assumed.
  22. *
  23. * To use this font, do the following:
  24. *
  25. * 1.  Assemble this file (assumed to have been saved as "suits8.asm").
  26. *     For example, if you have the CAPE 680x0 assembler, and you have
  27. *     assigned "include:" to the directory containing your include files,
  28. *     use:
  29. *        CAsm -a "suits8.asm" -o "suits8.o" -i "include:"
  30. *
  31. *     Link "suits8.o".  For example, if you have Lattice, use:
  32. *        BLink from "suits8.o" to "suits8"
  33. *
  34. * 2.  Create the subdirectory "Fonts:suits".
  35. *     Copy the file "suits8" (created in step 1.) to "Fonts:suits/8".
  36. *
  37. * 3.  Create a font contents file for the font.  You can do this
  38. *     by three methods:
  39. *   a. Run the program "Workbench1.3:System/FixFonts" which
  40. *      will create the file "Fonts:suits.font" automatically.
  41. *   b. Use the NewFontContents() call in the diskfont library to
  42. *      create a FontContentsHeader structure, which can be saved
  43. *      in the Fonts: directory as "suits.font".   This is essentially
  44. *      what FixFonts does.
  45. *   c. Create the file manually by following these directions:
  46. *
  47. * Create a file in the Fonts: directory named "suits.font" the
  48. * contents of which are as follows:
  49. * The first word (two bytes) must contain the font header identifier, FCH_ID
  50. * FCH_ID is defined in "libraries/diskfont.i" and is currently 0x0f00.
  51. *
  52. * The next word contains the number of FontContents entries.  There will
  53. * be only one font descriptor file in this sample font's directory, so the
  54. * value 0x0001 should be used.
  55. *
  56. * Follow this information with the hex values for the string "suits/8";
  57. * the path AmigaDOS should follow to reach this font size.  The path is
  58. * relative to "Fonts:"; "suits" is the directory in which AmigaDOS will find
  59. * this font's font descriptor files and "8" is a font descriptor file.
  60. * This should be followed by enough null characters (0x00) to pad the
  61. * pathname to MAXFONTPATH bytes in length.  MAXFONTPATH is defined in
  62. * "libraries/diskfont.i" and is currently 256 bytes.  The string in this
  63. * example is 7 bytes long, therefore 249 bytes of padding are needed.
  64. * Note that the font pathname must have at least one null character after
  65. * it, making the maximum pathname length MAXFONTPATH-1.
  66. *
  67. * The next word contains the font YSize; in this case, 0x0008.  
  68. *
  69. * The next byte contains the font Flags, in this case 0x00.
  70. *
  71. * The last byte contains the font characteristics, in this case 0x60.
  72. * This says it is a disk-based font (bit 1 set) and the font has been
  73. * removed (bit 7 set), saying that the font is not currently resident.
  74. *
  75. * Summary of suits.font file:
  76. *
  77. * Name: fch_FileID fch_NumEntries fc_FileName     fc_YSize fc_Flags fc_Style
  78. * Size: word       word         MAXFONTPATH bytes word     byte     byte
  79. * Hex:  0f00       0001         73756974732F3800  0008     00       60
  80. * ASCII:                        s u i t s / 8 \0
  81. *
  82. * The correct length of a font file may be calculated with this formula:
  83. * length := ((number of font contents entries) * (MAXFONTPATH+4)) + 4.
  84. * In this case (one entry), this becomes (MAXFONTPATH + 8) or 264.
  85. *
  86. * To try out this example font, do the following.
  87. * Start up the Notepad program or any other program which allows the
  88. * user to select fonts.  Choose the "suits" font in size 8 and type "abcd".
  89. * This example font defines ASCII characters 'a' 'b' 'c' and 'd' only.
  90. * All other characters map to a rectangle, meaning "character unknown".
  91.  
  92.         INCLUDE        "exec/types.i"
  93.         INCLUDE        "exec/nodes.i"
  94.         INCLUDE        "libraries/diskfont.i"
  95.  
  96. * Provide an easy exit in case this file is "Run" instead of merely loaded.
  97.  
  98.         MOVEQ        #-1,D0
  99.         RTS
  100.  
  101. * The following five entries comprise a Node structure, used by the system
  102. * to link disk fonts into a list.  See the definition of the "DiskFontHeader"
  103. * structure in the "libraries/diskfont.i" include file for more information.
  104.  
  105.         DC.L        0               ; ln_Succ
  106.         DC.L        0               ; ln_Pred
  107.         DC.B        NT_FONT         ; ln_Type
  108.         DC.B        0               ; ln_Pri
  109.         DC.L        fontName        ; ln_Name
  110.  
  111.         DC.W        DFH_ID          ; FileID
  112.         DC.W        1               ; Revision
  113.         DC.L        0               ; Segment
  114.  
  115. * The next MAXFONTNAME bytes are a placeholder.  The name of the
  116. * font contents file (e.g. "suits.font") will be copied here after this
  117. * font descriptor is LoadSeg-ed into memory.  The Name field could have
  118. * been left blank, but inserting the font name and size (or style) allows
  119. * one to tell something about the font by using "Type OPT H" on the file.
  120.  
  121. fontName:
  122.         DC.B        "suits8"        ; Name
  123.  
  124. * If your assembler needs an absolute value in place of the "length"
  125. * variable, simply count the number of characters in Name and use that.
  126.  
  127. length  EQU         *-fontName      ; Assembler calculates Name's length.
  128.         DCB.B       MAXFONTNAME-length,0 ; Padding of null characters.
  129.  
  130. * The rest of the information is a TextFont structure.
  131. * See the "graphics/text.i" include file for more information.
  132.  
  133. font:
  134.         DC.L        0               ; ln_Succ
  135.         DC.L        0               ; ln_Pred
  136.         DC.B        NT_FONT         ; ln_Type
  137.         DC.B        0               ; ln_Pri
  138.         DC.L        fontName        ; ln_Name
  139.         DC.L        0               ; mn_ReplyPort
  140.         DC.W        0               ; (Reserved for 1.4 system use.)
  141.         DC.W        8               ; tf_YSize
  142.         DC.B        0               ; tf_Style
  143.         DC.B        FPF_DESIGNED!FPF_PROPORTIONAL!FPF_DISKFONT ; tf_Flags
  144.         DC.W        14              ; tf_XSize
  145.         DC.W        6               ; tf_Baseline
  146.  
  147. * tf_Baseline must be no greater than tf_YSize-1, otherwise algorithmically-
  148. * generated styles (italic in particular) can corrupt system memory. 
  149.  
  150.         DC.W        1               ; tf_BoldSmear
  151.         DC.W        0               ; tf_Accessors
  152.         DC.B        97              ; tf_LoChar
  153.         DC.B        100             ; tf_HiChar
  154.         DC.L        fontData        ; tf_CharData
  155.         DC.W        8               ; tf_Modulo, no. of bytes to add to the
  156.                                     ; data pointer to go from one row of
  157.                                     ; a character to the next row of it.
  158.         DC.L        fontLoc         ; tf_CharLoc, bit position in the font
  159.                                     ; data at which the character begins.
  160.         DC.L        fontSpace       ; tf_CharSpace
  161.         DC.L        fontKern        ; tf_CharKern
  162.  
  163. * The four characters of this font define the four playing-card suit symbols.
  164. * The heart, club, diamond, and spade map to the lower-case ASCII characters
  165. * 'a', 'b', 'c', and 'd' respectively.  The fifth entry in the table is the
  166. * character to be output when there is no entry defined in the character set
  167. * for the requested ASCII value.
  168. *
  169. *
  170. *   97 (a)       98 (b)       99 (c)   100 (d)      255
  171. * <            X            X        X            X            >
  172. *  .@@@...@@@.  .....@.....  ...@...  ....@@@....  @@@@@@@@@@@@
  173. *  @@@@@.@@@@@  ...@@@@@...  ..@@@..  ...@@@@@...  @@........@@
  174. *  .@@@@@@@@@.  .@@@@@@@@@.  .@@@@@.  .@@..@..@@.  @@........@@
  175. *  ..@@@@@@@..  @@@@@@@@@@@  @@@@@@@  @@@@@@@@@@@  @@........@@
  176. *  ...@@@@@...  .@@@.@.@@@.  .@@@@@.  .@@..@..@@.  @@........@@
  177. *  ....@@@....  .....@.....  ..@@@..  .....@.....  @@........@@
  178. *  .....@.....  ...@@@@@...  ...@...  ...@@@@@...  @@@@@@@@@@@@
  179. *  ...........  ...........  .......  ...........  ............
  180.  
  181. * Font data is bit-packed edge to edge to save space.
  182.  
  183. fontData:
  184.         DC.W        $071C0,$08040,$070FF,$0F000
  185.         DC.W        $0FBE3,$0E0E0,$0F8C0,$03000
  186.         DC.W        $07FCF,$0F9F3,$026C0,$03000
  187.         DC.W        $03F9F,$0FFFF,$0FFC0,$03000
  188.         DC.W        $01F0E,$0B9F3,$026C0,$03000
  189.         DC.W        $00E00,$080E0,$020C0,$03000
  190.         DC.W        $00403,$0E040,$0F8FF,$0F000
  191.         DC.W        $00000,$00000,$00000,$00000
  192.         DC.W        $00000,$00000,$00000,$00000
  193.  
  194. * The fontLoc information is used to "unpack" the fontData.
  195. * Each pair of words specifies how the characters are bit-packed.  For
  196. * example, the first character starts at bit position 0x0000, and is 0x000B
  197. * (11) bits wide.  The second character starts at bit position 0x000B and
  198. * is 0x000B bits wide, and so on.  This tells the font handler how to unpack
  199. * the bits from the array.
  200.  
  201. fontLoc:         
  202.         DC.L        $00000000B,$0000B000B,$000160007,$0001D000B,$00028000C
  203.  
  204. * fontSpace array:  Use a space this wide to contain this character when it
  205. * is printed.  For reverse-path fonts these values would be small or negative.
  206.  
  207. fontSpace:
  208.         DC.W        000012,000012,000008,000012,000013
  209.  
  210. * fontKern array:  Place a space this wide after the corresponding character
  211. * to separate it from the following character.  For reverse-path fonts these
  212. * values would be large negative numbers, approximately the width of the
  213. * characters.
  214.  
  215. fontKern:
  216.         DC.W        000001,000001,000001,000001,000001
  217.  
  218. fontEnd:
  219.         END
  220.  
  221.