xref: /plan9/sys/src/cmd/gs/src/ifont.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: ifont.h,v 1.14 2004/08/04 19:36:12 stefan Exp $ */
18 /* Interpreter internal font representation */
19 
20 #ifndef ifont_INCLUDED
21 #  define ifont_INCLUDED
22 
23 #include "gsccode.h"		/* for gs_glyph, NUM_KNOWN_ENCODINGS */
24 #include "gsstype.h"		/* for extern_st */
25 
26 /* The external definition of fonts is given in the PostScript manual, */
27 /* pp. 91-93. */
28 
29 /* The structure given below is 'client data' from the viewpoint */
30 /* of the library.  font-type objects (t_struct/st_font, "t_fontID") */
31 /* point directly to a gs_font.  */
32 
33 typedef struct font_data_s {
34     ref dict;			/* font dictionary object */
35     ref BuildChar;
36     ref BuildGlyph;
37     ref Encoding;
38     ref CharStrings;
39     ref GlyphNames2Unicode;
40     union _fs {
41 	struct _f1 {
42 	    ref OtherSubrs;	/* from Private dictionary */
43 	    ref Subrs;		/* from Private dictionary */
44 	    ref GlobalSubrs;	/* from Private dictionary, */
45 	    /* for Type 2 charstrings */
46 	} type1;
47 	struct _f42 {
48 	    ref sfnts;
49 	    ref CIDMap;		/* for CIDFontType 2 fonts */
50 	    ref GlyphDirectory;
51 	} type42;
52 	struct _fc0 {
53 	    ref GlyphDirectory;
54 	    ref GlyphData;	/* (if preloaded) string or array of strings */
55 	    ref DataSource;	/* (if not preloaded) reusable stream */
56 	} cid0;
57     } u;
58 } font_data;
59 
60 /*
61  * Even though the interpreter's part of the font data actually
62  * consists of refs, allocating it as refs tends to create sandbars;
63  * since it is always allocated and freed as a unit, we can treat it
64  * as an ordinary structure.
65  */
66 /* st_font_data is exported for zdefault_make_font in zfont.c. */
67 extern_st(st_font_data);
68 #define public_st_font_data()	/* in zbfont.c */\
69   gs_public_st_ref_struct(st_font_data, font_data, "font_data")
70 #define pfont_data(pfont) ((font_data *)((pfont)->client_data))
71 #define pfont_dict(pfont) (&pfont_data(pfont)->dict)
72 
73 /* ================Internal procedures shared across files ================ */
74 
75 /* ---------------- Exported by zchar.c ---------------- */
76 
77 /*
78  * Get the FontBBox from a font dictionary, if any; if none, or if invalid,
79  * return 4 zeros.
80  */
81 int font_bbox_param(const gs_memory_t *mem, const ref *pfdict, double bbox[4]);
82 
83 /* ---------------- Exported by zfont.c ---------------- */
84 
85 #ifndef gs_font_DEFINED
86 #  define gs_font_DEFINED
87 typedef struct gs_font_s gs_font;
88 #endif
89 
90 /*
91  * Check a parameter that should be a valid font dictionary, and return
92  * the gs_font stored in its FID entry.
93  */
94 int font_param(const ref * pfdict, gs_font ** ppfont);
95 
96 /*
97  * Mark a glyph as a PostScript name (if it isn't a CID) for the garbage
98  * collector.  Return true if a mark was just added.  This procedure is
99  * intended to be used as the mark_glyph procedure in the character cache.
100  */
101 bool zfont_mark_glyph_name(const gs_memory_t *mem, gs_glyph glyph, void *ignore_data);
102 
103 /*
104  * Return information about a font, including information from the FontInfo
105  * dictionary.  This procedure is intended to be used as the font_info
106  * procedure in all PostScript fonts.
107  */
108 font_proc_font_info(zfont_info);
109 
110 #endif /* ifont_INCLUDED */
111