1 /* Copyright (C) 2001-2006 Artifex Software, Inc. 2 All Rights Reserved. 3 4 This software is provided AS-IS with no warranty, either express or 5 implied. 6 7 This software is distributed under license and may not be copied, modified 8 or distributed except as expressly authorized under the terms of that 9 license. Refer to licensing information at http://www.artifex.com/ 10 or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, 11 San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information. 12 */ 13 14 /* $Id: gsccode.h 8022 2007-06-05 22:23:38Z giles $ */ 15 /* Types for character codes */ 16 17 #ifndef gsccode_INCLUDED 18 # define gsccode_INCLUDED 19 20 /* 21 * Define a character code. Normally this is just a single byte from a 22 * string, but because of composite fonts, character codes must be 23 * at least 32 bits. 24 */ 25 typedef ulong gs_char; 26 27 #define GS_NO_CHAR ((gs_char)~0L) 28 /* Backward compatibility */ 29 #define gs_no_char GS_NO_CHAR 30 31 /* 32 * Define a character glyph code, a.k.a. character name. The space of 33 * glyph codes is divided into five sections: 34 * 35 * - Codes >= GS_MIN_GLYPH_INDEX represent (non-negative) 36 * integers biased by GS_MIN_CID_GLYPH. They represent glyph indices 37 * of a specific font. 38 * 39 * - Codes within [GS_MIN_CID_GLYPH, GS_MIN_GLYPH_INDEX) represent (non-negative) 40 * integers biased by GS_MIN_CID_GLYPH. They represent PostScript CIDs 41 * of a specific Ordering. 42 * 43 * - Codes < GS_MIN_CID_GLYPH represent named glyphs. There are 44 * three sub-sections: 45 * 46 * - GS_NO_GLYPH, which means "no known glyph value". Note that 47 * it is not the same as /.notdef or CID 0 or GID 0: it means 48 * that the identity of the glyph is unknown, as opposed to a 49 * known glyph that is used for rendering an unknown character 50 * code. 51 * 52 * - Codes < gs_c_min_std_encoding_glyph represent names in some 53 * global space that the graphics library doesn't attempt to 54 * interpret. (When the client is the PostScript interpreter, 55 * these codes are PostScript name indices, but the graphics 56 * library doesn't know or rely on this.) The graphics library 57 * *does* assume that such codes denote the same names across 58 * all fonts, and that they can be converted to a string name 59 * by the font's glyph_name virtual procedure. 60 * 61 * - Codes >= gs_c_min_std_encoding_glyph (and < GS_MIN_CID_GLYPH) 62 * represent names in a special space used for the 11 built-in 63 * Encodings. The API is defined in gscencs.h. The only 64 * procedures that generate or recognize such codes are the ones 65 * declared in that file: clients must be careful not to mix 66 * such codes with codes in the global space. 67 * 68 * Client code may assume that GS_NO_GLYPH < GS_MIN_CID_GLYPH (i.e., it is a 69 * "name", not an integer), but should not make assumptions about whether 70 * GS_NO_GLYPH is less than or greater than gs_c_min_std_encoding_glyph. 71 */ 72 typedef ulong gs_glyph; 73 74 #define GS_NO_GLYPH ((gs_glyph)0x7fffffff) 75 #if arch_sizeof_long > 4 76 # define GS_MIN_CID_GLYPH ((gs_glyph)0x80000000L) 77 #else 78 /* Avoid compiler warnings about signed/unsigned constants. */ 79 # define GS_MIN_CID_GLYPH ((gs_glyph)~0x7fffffff) 80 #endif 81 #define GS_MIN_GLYPH_INDEX (GS_MIN_CID_GLYPH | (GS_MIN_CID_GLYPH >> 1)) 82 #define GS_GLYPH_TAG (gs_glyph)(GS_MIN_CID_GLYPH | GS_MIN_GLYPH_INDEX) 83 #define GS_MAX_GLYPH max_ulong 84 /* Backward compatibility */ 85 #define gs_no_glyph GS_NO_GLYPH 86 #define gs_min_cid_glyph GS_MIN_CID_GLYPH 87 #define gs_max_glyph GS_MAX_GLYPH 88 89 /* Define a procedure for marking a gs_glyph during garbage collection. */ 90 typedef bool (*gs_glyph_mark_proc_t)(const gs_memory_t *mem, gs_glyph glyph, void *proc_data); 91 92 /* Define the indices for known encodings. */ 93 typedef enum { 94 ENCODING_INDEX_UNKNOWN = -1, 95 /* Real encodings. These must come first. */ 96 ENCODING_INDEX_STANDARD = 0, 97 ENCODING_INDEX_ISOLATIN1, 98 ENCODING_INDEX_SYMBOL, 99 ENCODING_INDEX_DINGBATS, 100 ENCODING_INDEX_WINANSI, 101 ENCODING_INDEX_MACROMAN, 102 ENCODING_INDEX_MACEXPERT, 103 #define NUM_KNOWN_REAL_ENCODINGS 7 104 /* Pseudo-encodings (glyph sets). */ 105 ENCODING_INDEX_MACGLYPH, /* Mac glyphs */ 106 ENCODING_INDEX_ALOGLYPH, /* Adobe Latin glyph set */ 107 ENCODING_INDEX_ALXGLYPH, /* Adobe Latin Extended glyph set */ 108 ENCODING_INDEX_CFFSTRINGS /* CFF StandardStrings */ 109 #define NUM_KNOWN_ENCODINGS 11 110 } gs_encoding_index_t; 111 #define KNOWN_REAL_ENCODING_NAMES\ 112 "StandardEncoding", "ISOLatin1Encoding", "SymbolEncoding",\ 113 "DingbatsEncoding", "WinAnsiEncoding", "MacRomanEncoding",\ 114 "MacExpertEncoding" 115 116 /* 117 * For fonts that use more than one method to identify glyphs, define the 118 * glyph space for the values returned by procedures that return glyphs. 119 * Note that if a font uses only one method (such as Type 1 fonts, which 120 * only use names, or TrueType fonts, which only use indexes), the 121 * glyph_space argument is ignored. 122 */ 123 typedef enum gs_glyph_space_s { 124 GLYPH_SPACE_NAME, /* names (if available) */ 125 GLYPH_SPACE_INDEX, /* indexes (if available) */ 126 GLYPH_SPACE_NOGEN /* don't generate new names (Type 3 only) */ 127 } gs_glyph_space_t; 128 129 /* 130 * Define a procedure for mapping a glyph to its (string) name. This is 131 * currently used only for CMaps: it is *not* the same as the glyph_name 132 * procedure in fonts. 133 */ 134 typedef int (*gs_glyph_name_proc_t)(const gs_memory_t *mem, 135 gs_glyph glyph, gs_const_string *pstr, 136 void *proc_data); 137 138 #endif /* gsccode_INCLUDED */ 139