1 /* Copyright (C) 2001-2012 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, 8 modified or distributed except as expressly authorized under the terms 9 of the license contained in the file LICENSE in this distribution. 10 11 Refer to licensing information at http://www.artifex.com or contact 12 Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, 13 CA 94903, U.S.A., +1(415)492-9861, for further information. 14 */ 15 16 17 /* Type 1 / Type 2 font data definition */ 18 19 #ifndef gxfont1_INCLUDED 20 # define gxfont1_INCLUDED 21 22 #include "gstype1.h" /* for charstring_interpret_proc */ 23 #include "gxfixed.h" 24 25 /* 26 * This is the type-specific information for Adobe Type 1 fonts. 27 * It also includes the information for Type 2 fonts, because 28 * there isn't very much of it and it's less trouble to include here. 29 */ 30 31 #ifndef gs_font_type1_DEFINED 32 # define gs_font_type1_DEFINED 33 typedef struct gs_font_type1_s gs_font_type1; 34 #endif 35 36 /* 37 * The zone_table values should be ints, according to the Adobe 38 * specification, but some fonts have arbitrary floats here. 39 */ 40 #define zone_table(size)\ 41 struct {\ 42 int count;\ 43 float values[(size)*2];\ 44 } 45 #define float_array(size)\ 46 struct {\ 47 int count;\ 48 float values[size];\ 49 } 50 #define stem_table(size)\ 51 float_array(size) 52 53 #ifndef gs_type1_data_DEFINED 54 #define gs_type1_data_DEFINED 55 typedef struct gs_type1_data_s gs_type1_data; 56 #endif 57 58 typedef struct gs_type1_data_procs_s { 59 60 /* Get the data for any glyph. Return >= 0 or < 0 as usual. */ 61 62 int (*glyph_data)(gs_font_type1 * pfont, gs_glyph glyph, 63 gs_glyph_data_t *pgd); 64 65 /* Get the data for a Subr. Return like glyph_data. */ 66 67 int (*subr_data)(gs_font_type1 * pfont, int subr_num, bool global, 68 gs_glyph_data_t *pgd); 69 70 /* 71 * Get the data for a seac character, including the glyph and/or the 72 * outline data. Any of the pointers for the return values may be 0, 73 * indicating that the corresponding value is not needed. 74 * Return like glyph_data. 75 */ 76 77 int (*seac_data)(gs_font_type1 * pfont, int ccode, 78 gs_glyph * pglyph, gs_const_string *gstr, gs_glyph_data_t *pgd); 79 80 /* 81 * Push (a) value(s) onto the client ('PostScript') stack during 82 * interpretation. Note that this procedure and the next one take a 83 * closure pointer, not the font pointer, as the first argument. 84 */ 85 86 int (*push_values)(void *callback_data, const fixed *values, 87 int count); 88 89 /* Pop a value from the client stack. */ 90 91 int (*pop_value)(void *callback_data, fixed *value); 92 93 } gs_type1_data_procs_t; 94 95 /* 96 * The garbage collector really doesn't want the client data pointer 97 * from a gs_type1_state to point to the gs_type1_data in the middle of 98 * a gs_font_type1, so we make the client data pointer (which is passed 99 * to the callback procedures) point to the gs_font_type1 itself. 100 */ 101 struct gs_type1_data_s { 102 /*int PaintType; *//* in gs_font_common */ 103 gs_type1_data_procs_t procs; 104 charstring_interpret_proc((*interpret)); 105 void *proc_data; /* data for procs */ 106 gs_font_base *parent; /* the type 9 font, if this font is is a type 9 descendent. */ 107 int lenIV; /* -1 means no encryption */ 108 /* (undocumented feature!) */ 109 uint subroutineNumberBias; /* added to operand of callsubr */ 110 /* (undocumented feature!) */ 111 /* Type 2 additions */ 112 uint gsubrNumberBias; /* added to operand of callgsubr */ 113 long initialRandomSeed; 114 fixed defaultWidthX; 115 fixed nominalWidthX; 116 /* End of Type 2 additions */ 117 /* For a description of the following hint information, */ 118 /* see chapter 5 of the "Adobe Type 1 Font Format" book. */ 119 int BlueFuzz; 120 float BlueScale; 121 float BlueShift; 122 #define max_BlueValues 7 123 zone_table(max_BlueValues) BlueValues; 124 float ExpansionFactor; 125 bool ForceBold; 126 #define max_FamilyBlues 7 127 zone_table(max_FamilyBlues) FamilyBlues; 128 #define max_FamilyOtherBlues 5 129 zone_table(max_FamilyOtherBlues) FamilyOtherBlues; 130 int LanguageGroup; 131 #define max_OtherBlues 5 132 zone_table(max_OtherBlues) OtherBlues; 133 bool RndStemUp; 134 stem_table(1) StdHW; 135 stem_table(1) StdVW; 136 #define max_StemSnap 12 137 stem_table(max_StemSnap) StemSnapH; 138 stem_table(max_StemSnap) StemSnapV; 139 /* Additional information for Multiple Master fonts */ 140 #define max_WeightVector 16 141 float_array(max_WeightVector) WeightVector; 142 byte hash_subrs[16]; /* Used only for checking font copying compatibility */ 143 int num_subrs; /* Used only for checking font copying compatibility */ 144 }; 145 146 #define gs_type1_data_s_DEFINED 147 148 struct gs_font_type1_s { 149 gs_font_base_common; 150 gs_type1_data data; 151 }; 152 153 extern_st(st_gs_font_type1); 154 #define public_st_gs_font_type1() /* in gstype1.c */\ 155 gs_public_st_suffix_add2_final(st_gs_font_type1, gs_font_type1,\ 156 "gs_font_type1", font_type1_enum_ptrs, font_type1_reloc_ptrs,\ 157 gs_font_finalize, st_gs_font_base, data.parent, data.proc_data) 158 159 /* Export font procedures so they can be called from the interpreter. */ 160 font_proc_glyph_info(gs_type1_glyph_info); 161 162 /* 163 * If a Type 1 character is defined with 'seac', store the character codes 164 * in chars[0] and chars[1] and return 1; otherwise, return 0 or <0. 165 * This is exported only for the benefit of font copying. 166 */ 167 int gs_type1_piece_codes(/*const*/ gs_font_type1 *pfont, 168 const gs_glyph_data_t *pgd, gs_char *chars); 169 170 #endif /* gxfont1_INCLUDED */ 171