home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / fontutils-0.6 / include / bzr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-18  |  4.5 KB  |  134 lines

  1. /* bzr.h: manipulate Bezier-format font files.  See ../bzr/README
  2.  
  3.  
  4.    for the precise definition of the file format.
  5.  
  6. Copyright (C) 1992 Free Software Foundation, Inc.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2, or (at your option)
  11. any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  21.  
  22. #ifndef BZR_H
  23. #define BZR_H
  24.  
  25. #include "bounding-box.h"
  26. #include "font.h"
  27. #include "spline.h"
  28. #include "types.h"
  29.  
  30.  
  31. /* At most one output (and one input) file can be open at a time;
  32.    calling either of these routines twice, with no intervening call to
  33.    close the file, results in a fatal error.  */
  34. extern boolean bzr_open_output_file (string filename);
  35. extern boolean bzr_open_input_file (string filename);
  36.  
  37. /* If no output (or input) file is open, a fatal error results.  */
  38. extern void bzr_close_output_file (void);
  39. extern void bzr_close_input_file (void);
  40.  
  41. /* Fontwide information at the beginning of the file.  */
  42. typedef struct
  43. {
  44.   string comment;
  45.   real design_size;
  46. } bzr_preamble_type;
  47.  
  48. /* The comment usually identifies the creator of the file, but it need
  49.    not be anything in particular.  */
  50. #define BZR_COMMENT(p) ((p).comment)
  51.  
  52. /* The design size is given in points (72.27pt=1in).  */
  53. #define BZR_DESIGN_SIZE(p) ((p).design_size)
  54.  
  55.  
  56. /* You should write the preamble before writing anything els.  */
  57. extern void bzr_put_preamble (bzr_preamble_type);
  58.  
  59. /* You should be positioned at the beginning of the file (e.g., have
  60.    just opened it) before calling this.  Furthermore, you should call
  61.    this routine before calling any of the other input routines. 
  62.    (Because this is what reads the design size of the font, and other
  63.    values in the file are scaled by that.)  */
  64. extern bzr_preamble_type bzr_get_preamble (void);
  65.  
  66. /* Character information.  */
  67.  
  68. typedef struct
  69. {
  70.   charcode_type code;
  71.   real set_width;
  72.   real_bounding_box_type bb;
  73.   spline_list_array_type shape;
  74. } bzr_char_type;
  75.  
  76.  
  77. /* The character code is always in the range 0 to 255.  You can use the
  78.    `CHARCODE' macro to access it.  */
  79.  
  80. /* The set width is given in points.  You can use the `CHAR_SET_WIDTH'
  81.    macro to access it.  */
  82.  
  83. /* The character bounding box is not guaranteed to be the tightest
  84.    possible, but it should be close.  The values are in points.  The
  85.    CHAR_HEIGHT, CHAR_DEPTH, CHAR_SET_WIDTH, CHAR_BB, and related macros
  86.    in `font.h' all work.  */
  87.  
  88. /* The shape is given as a list of lists of lines and cubic splines.
  89.    Each element of the outer list represents a closed path.  The values
  90.    are in points.  */
  91. #define BZR_SHAPE(c) ((c).shape)
  92.  
  93.  
  94. /* This routine writes the given character.  */
  95. extern void bzr_put_char (bzr_char_type);
  96.  
  97. /* This routine returns the next character in the file.  If the postamble
  98.    is next, it returns NULL.  Each spline in the `shape' element is
  99.    guaranteed to have degree `LINEAR' or `CUBIC' (see `spline.h').  */
  100. extern bzr_char_type *bzr_get_next_char (void);
  101.  
  102. /* This routine returns the character with the given CODE, or NULL.
  103.    Each spline in the `shape' element is guaranteed to have degree
  104.    `LINEAR' or `CUBIC' (see `spline.h').  */
  105. extern bzr_char_type *bzr_get_char (one_byte code);
  106.  
  107. /* More fontwide information, this at the end of the file.  */
  108.  
  109. typedef struct
  110. {
  111.   real_bounding_box_type font_bb;
  112.   one_byte nchars;
  113. } bzr_postamble_type;
  114.  
  115. /* The font bounding box is guaranteed to be the tightest possible,
  116.    given the character bounding box.  The values are in points.  */
  117. #define BZR_FONT_BB(p) ((p).font_bb)
  118.  
  119. /* The total number of characters (possibly zero) in the font.  */
  120. #define BZR_NCHARS(p) ((p).nchars)
  121.  
  122.  
  123. /* The postamble must be written last; the library itself determines the
  124.    font bounding box, based on the character bounding boxes, so you do
  125.    not supply it as an argument.  */
  126. extern void bzr_put_postamble (void);
  127.  
  128. /* And this reads the postamble back.  You should be positioned at the
  129.    postamble (e.g., `bzr_get_char' should have just returned NULL) before
  130.    calling this.  */
  131. extern bzr_postamble_type bzr_get_postamble (void);
  132.  
  133. #endif /* not BZR_H */
  134.