home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / program / gs300sr1 / gs300sr1.exe / GXFONT.H < prev    next >
C/C++ Source or Header  |  1994-07-27  |  7KB  |  192 lines

  1. /* Copyright (C) 1989, 1992, 1993, 1994 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gxfont.h */
  20. /* Internal font definition for Ghostscript library */
  21. /* Requires gsccode.h, gsmatrix.h, gxdevice.h */
  22. #include "gsfont.h"
  23. #include "gsuid.h"
  24. #include "gsstruct.h"            /* for extern_st */
  25.  
  26. /* A font object as seen by clients. */
  27. /* See the PostScript Language Reference Manual for details. */
  28.  
  29. #ifndef gs_show_enum_DEFINED
  30. #  define gs_show_enum_DEFINED
  31. typedef struct gs_show_enum_s gs_show_enum;
  32. #endif
  33.  
  34. /*
  35.  * Fonts are "objects" to a limited extent, in that some of their
  36.  * behavior is provided by a record of procedures in the font.
  37.  * However, adding new types of fonts (subclasses) is not really supported.
  38.  */
  39.  
  40. typedef struct gs_font_procs_s {
  41.  
  42.     /*
  43.      * Define any needed procedure for initializing the composite
  44.      * font stack in a show enumerator.  This is a no-op for
  45.      * all but composite fonts.
  46.      */
  47.  
  48. #define font_proc_init_fstack(proc)\
  49.   int proc(P2(gs_show_enum *, gs_font *))
  50.     font_proc_init_fstack((*init_fstack));
  51.  
  52.     /*
  53.      * Define the font's algorithm for getting the next character from
  54.      * a string being shown.  This is trivial, except for composite fonts.
  55.      * Returns 0 if the current (base) font didn't change,
  56.      * 1 if it did change, 2 if there are no more characters,
  57.      * or an error code.
  58.      */
  59.  
  60. #define font_proc_next_char(proc)\
  61.   int proc(P2(gs_show_enum *, gs_char *))
  62.     font_proc_next_char((*next_char));
  63.  
  64.     /* A client-supplied character encoding procedure. */
  65.  
  66. #define font_proc_encode_char(proc)\
  67.   gs_glyph proc(P3(gs_show_enum *, gs_font *, gs_char *))
  68.     font_proc_encode_char((*encode_char));
  69.  
  70.     /*
  71.      * A client-supplied BuildChar/BuildGlyph procedure.
  72.      * The gs_char may be gs_no_char (for BuildGlyph), or the gs_glyph
  73.      * may be gs_no_glyph (for BuildChar), but not both.
  74.      */
  75.  
  76. #define font_proc_build_char(proc)\
  77.   int proc(P5(gs_show_enum *, gs_state *, gs_font *, gs_char, gs_glyph))
  78.     font_proc_build_char((*build_char));
  79.  
  80.     /* A procedure for getting the name of a gs_glyph */
  81.     /* (see gsccode.h for details.) */
  82.  
  83.     gs_proc_glyph_name((*glyph_name));
  84.  
  85.     /*
  86.      * Define any special handling of gs_definefont.
  87.      * We break this out so it can be different for composite fonts.
  88.      */
  89.  
  90. #define font_proc_define_font(proc)\
  91.   int proc(P2(gs_font_dir *, gs_font *))
  92.     font_proc_define_font((*define_font));
  93.  
  94.     /*
  95.      * Define any special handling of gs_makefont.
  96.      * We break this out so it can be different for composite fonts.
  97.      */
  98.  
  99. #define font_proc_make_font(proc)\
  100.   int proc(P4(gs_font_dir *, const gs_font *, const gs_matrix *,\
  101.     gs_font **))
  102.     font_proc_make_font((*make_font));
  103.  
  104. } gs_font_procs;
  105. /* Default font procedures */
  106. font_proc_init_fstack(gs_default_init_fstack);
  107. font_proc_next_char(gs_default_next_char);
  108. font_proc_encode_char(gs_no_encode_char);
  109. font_proc_build_char(gs_no_build_char);
  110. font_proc_define_font(gs_no_define_font);
  111. font_proc_make_font(gs_no_make_font);
  112.  
  113. /* Define the known font types. */
  114. /* These numbers must be the same as the values of FontType */
  115. /* in font dictionaries. */
  116. typedef enum {
  117.     ft_composite = 0,
  118.     ft_encrypted = 1,
  119.     ft_user_defined = 3
  120. } font_type;
  121.  
  122. /* Define the bitmap font behaviors. */
  123. /* These numbers must be the same as the values of the ExactSize, */
  124. /* InBetweenSize, and TransformedChar entries in font dictionaries. */
  125. typedef enum {
  126.     fbit_use_outlines = 0,
  127.     fbit_use_bitmaps = 1,
  128.     fbit_transform_bitmaps = 2
  129. } fbit_type;
  130.  
  131. /* The font names are only needed for xfont lookup. */
  132. typedef struct gs_font_name_s {
  133. #define gs_font_name_max 47        /* must be >= 40 */
  134.     /* The +1 is so we can null-terminate for debugging printout. */
  135.     byte chars[gs_font_name_max+1];
  136.       uint size;
  137. } gs_font_name;
  138.  
  139. /* Define a generic font. */
  140. #define gs_font_common\
  141.     gs_font *next, *prev;        /* chain for original font list or */\
  142.                     /* scaled font cache */\
  143.     gs_memory_t *memory;        /* allocator for this font */\
  144.     gs_font_dir *dir;        /* directory where registered */\
  145.     gs_font *base;            /* original (unscaled) base font */\
  146.     void *client_data;        /* additional client data */\
  147.     gs_matrix FontMatrix;\
  148.     font_type FontType;\
  149.     bool BitmapWidths;\
  150.     fbit_type ExactSize, InBetweenSize, TransformedChar;\
  151.     int WMode;            /* 0 or 1 */\
  152.     gs_font_procs procs;\
  153.     /* We store both the FontDirectory key (key_name) and, */\
  154.     /* if present, the FontName (font_name). */\
  155.     gs_font_name key_name, font_name
  156. /*typedef struct gs_font_s gs_font;*/    /* in gsfont.h and other places */
  157. struct gs_font_s {
  158.     gs_font_common;
  159. };
  160. extern_st(st_gs_font);        /* (abstract) */
  161. #define public_st_gs_font()    /* in gsfont.c */\
  162.   gs_public_st_composite(st_gs_font, gs_font, "gs_font",\
  163.     font_enum_ptrs, font_reloc_ptrs)
  164. #define st_gs_font_max_ptrs 5
  165. #define private_st_gs_font_ptr()    /* in gsfont.c */\
  166.   gs_private_st_ptr(st_gs_font_ptr, gs_font *, "gs_font *",\
  167.     font_ptr_enum_ptrs, font_ptr_reloc_ptrs)
  168. #define st_gs_font_ptr_max_ptrs 1
  169. extern_st(st_gs_font_ptr_element);
  170. #define public_st_gs_font_ptr_element()    /* in gsfont.c */\
  171.   gs_public_st_element(st_gs_font_ptr_element, gs_font *, "gs_font *[]",\
  172.     font_ptr_element_enum_ptrs, font_ptr_element_reloc_ptrs, st_gs_font_ptr)
  173.  
  174. /* Define a base (not composite) font. */
  175. #define gs_font_base_common\
  176.     gs_font_common;\
  177.     gs_rect FontBBox;\
  178.     gs_uid UID;\
  179.     int encoding_index;        /* 0=Std, 1=ISOLatin1, 2=Symbol, */\
  180.                     /* 3=Dingbats, -1=other */\
  181.     int nearest_encoding_index    /* (may be >= 0 even if */\
  182.                     /* encoding_index = -1) */
  183. typedef struct gs_font_common_s {
  184.     gs_font_base_common;
  185. } gs_font_base;
  186. extern_st(st_gs_font_base);
  187. #define public_st_gs_font_base()    /* in gsfont.c */\
  188.   gs_public_st_suffix_add1(st_gs_font_base, gs_font_base, "gs_font_base",\
  189.     font_base_enum_ptrs, font_base_reloc_ptrs,\
  190.     font_enum_ptrs, font_reloc_ptrs, UID.xvalues)
  191. #define st_gs_font_base_max_ptrs (st_gs_font_max_ptrs + 1)
  192.