Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
Werner Lemberg | b5084e1 | 2000-10-28 17:10:06 +0000 | [diff] [blame] | 3 | /* t1objs.c */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 4 | /* */ |
Werner Lemberg | b5084e1 | 2000-10-28 17:10:06 +0000 | [diff] [blame] | 5 | /* Type 1 objects manager (body). */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 6 | /* */ |
Werner Lemberg | 415235d | 2001-06-28 17:49:10 +0000 | [diff] [blame] | 7 | /* Copyright 1996-2001 by */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 9 | /* */ |
| 10 | /* This file is part of the FreeType project, and may only be used, */ |
| 11 | /* modified, and distributed under the terms of the FreeType project */ |
| 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 13 | /* this file you indicate that you have read the license and */ |
| 14 | /* understand and accept it fully. */ |
| 15 | /* */ |
| 16 | /***************************************************************************/ |
| 17 | |
Werner Lemberg | cc069be | 2000-12-08 16:17:16 +0000 | [diff] [blame] | 18 | |
David Turner | 19ed8af | 2000-12-08 02:42:29 +0000 | [diff] [blame] | 19 | #include <ft2build.h> |
| 20 | #include FT_INTERNAL_DEBUG_H |
| 21 | #include FT_INTERNAL_STREAM_H |
Werner Lemberg | cc069be | 2000-12-08 16:17:16 +0000 | [diff] [blame] | 22 | |
Werner Lemberg | 6dd303d | 2000-11-26 21:25:53 +0000 | [diff] [blame] | 23 | #include <string.h> /* strcmp() */ |
| 24 | |
David Turner | 8d3a401 | 2001-03-20 11:14:24 +0000 | [diff] [blame] | 25 | #include "t1gload.h" |
| 26 | #include "t1load.h" |
Werner Lemberg | f1ca234 | 2000-11-29 15:18:54 +0000 | [diff] [blame] | 27 | |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 28 | #include "t1errors.h" |
| 29 | |
Werner Lemberg | f1ca234 | 2000-11-29 15:18:54 +0000 | [diff] [blame] | 30 | #ifndef T1_CONFIG_OPTION_NO_AFM |
David Turner | 8d3a401 | 2001-03-20 11:14:24 +0000 | [diff] [blame] | 31 | #include "t1afm.h" |
Werner Lemberg | f1ca234 | 2000-11-29 15:18:54 +0000 | [diff] [blame] | 32 | #endif |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 33 | |
David Turner | 19ed8af | 2000-12-08 02:42:29 +0000 | [diff] [blame] | 34 | #include FT_INTERNAL_POSTSCRIPT_NAMES_H |
| 35 | #include FT_INTERNAL_POSTSCRIPT_AUX_H |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 36 | |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 37 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 38 | /*************************************************************************/ |
| 39 | /* */ |
| 40 | /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
| 41 | /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
| 42 | /* messages during execution. */ |
| 43 | /* */ |
| 44 | #undef FT_COMPONENT |
Werner Lemberg | b5084e1 | 2000-10-28 17:10:06 +0000 | [diff] [blame] | 45 | #define FT_COMPONENT trace_t1objs |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 46 | |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 47 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 48 | /*************************************************************************/ |
| 49 | /* */ |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 50 | /* SIZE FUNCTIONS */ |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 51 | /* */ |
| 52 | /* note that we store the global hints in the size's "internal" root */ |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 53 | /* field */ |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 54 | /* */ |
| 55 | /*************************************************************************/ |
| 56 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 57 | |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 58 | static PSH_Globals_Funcs |
| 59 | T1_Size_Get_Globals_Funcs( T1_Size size ) |
| 60 | { |
Werner Lemberg | 0d9165e | 2002-03-07 21:59:59 +0000 | [diff] [blame] | 61 | T1_Face face = (T1_Face)size->root.face; |
| 62 | PSHinter_Service pshinter = (PSHinter_Service)face->pshinter; |
| 63 | FT_Module module; |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 64 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 65 | |
| 66 | module = FT_Get_Module( size->root.face->driver->root.library, |
| 67 | "pshinter" ); |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 68 | return ( module && pshinter && pshinter->get_globals_funcs ) |
| 69 | ? pshinter->get_globals_funcs( module ) |
| 70 | : 0 ; |
| 71 | } |
| 72 | |
| 73 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 74 | FT_LOCAL_DEF( void ) |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 75 | T1_Size_Done( T1_Size size ) |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 76 | { |
| 77 | if ( size->root.internal ) |
| 78 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 79 | PSH_Globals_Funcs funcs; |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 80 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 81 | |
| 82 | funcs = T1_Size_Get_Globals_Funcs( size ); |
| 83 | if ( funcs ) |
| 84 | funcs->destroy( (PSH_Globals)size->root.internal ); |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 85 | |
| 86 | size->root.internal = 0; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 91 | FT_LOCAL_DEF( FT_Error ) |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 92 | T1_Size_Init( T1_Size size ) |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 93 | { |
| 94 | FT_Error error = 0; |
| 95 | PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size ); |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 96 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 97 | |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 98 | if ( funcs ) |
| 99 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 100 | PSH_Globals globals; |
| 101 | T1_Face face = (T1_Face)size->root.face; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 102 | |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 103 | |
| 104 | error = funcs->create( size->root.face->memory, |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 105 | &face->type1.private_dict, &globals ); |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 106 | if ( !error ) |
| 107 | size->root.internal = (FT_Size_Internal)(void*)globals; |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 108 | } |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 109 | |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 110 | return error; |
| 111 | } |
| 112 | |
| 113 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 114 | FT_LOCAL_DEF( FT_Error ) |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 115 | T1_Size_Reset( T1_Size size ) |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 116 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 117 | PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size ); |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 118 | FT_Error error = 0; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 119 | |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 120 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 121 | if ( funcs ) |
| 122 | error = funcs->set_scale( (PSH_Globals)size->root.internal, |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 123 | size->root.metrics.x_scale, |
| 124 | size->root.metrics.y_scale, |
| 125 | 0, 0 ); |
David Turner | 3a664fc | 2001-12-21 15:26:19 +0000 | [diff] [blame] | 126 | return error; |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | |
| 130 | /*************************************************************************/ |
| 131 | /* */ |
| 132 | /* SLOT FUNCTIONS */ |
| 133 | /* */ |
| 134 | /*************************************************************************/ |
| 135 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 136 | FT_LOCAL_DEF( void ) |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 137 | T1_GlyphSlot_Done( T1_GlyphSlot slot ) |
| 138 | { |
| 139 | slot->root.internal->glyph_hints = 0; |
| 140 | } |
| 141 | |
| 142 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 143 | FT_LOCAL_DEF( FT_Error ) |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 144 | T1_GlyphSlot_Init( T1_GlyphSlot slot ) |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 145 | { |
Werner Lemberg | 0d9165e | 2002-03-07 21:59:59 +0000 | [diff] [blame] | 146 | T1_Face face; |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 147 | PSHinter_Service pshinter; |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 148 | |
Werner Lemberg | 0d9165e | 2002-03-07 21:59:59 +0000 | [diff] [blame] | 149 | |
| 150 | face = (T1_Face)slot->root.face; |
| 151 | pshinter = (PSHinter_Service)face->pshinter; |
| 152 | |
| 153 | if ( pshinter ) |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 154 | { |
| 155 | FT_Module module; |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 156 | |
Werner Lemberg | 0d9165e | 2002-03-07 21:59:59 +0000 | [diff] [blame] | 157 | |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 158 | module = FT_Get_Module( slot->root.face->driver->root.library, "pshinter" ); |
| 159 | if (module) |
| 160 | { |
| 161 | T1_Hints_Funcs funcs; |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 162 | |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 163 | funcs = pshinter->get_t1_funcs( module ); |
| 164 | slot->root.internal->glyph_hints = (void*)funcs; |
| 165 | } |
| 166 | } |
| 167 | return 0; |
| 168 | } |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 169 | |
| 170 | |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 171 | /*************************************************************************/ |
| 172 | /* */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 173 | /* FACE FUNCTIONS */ |
| 174 | /* */ |
| 175 | /*************************************************************************/ |
| 176 | |
| 177 | |
| 178 | /*************************************************************************/ |
| 179 | /* */ |
| 180 | /* <Function> */ |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 181 | /* T1_Face_Done */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 182 | /* */ |
| 183 | /* <Description> */ |
| 184 | /* The face object destructor. */ |
| 185 | /* */ |
| 186 | /* <Input> */ |
| 187 | /* face :: A typeless pointer to the face object to destroy. */ |
| 188 | /* */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 189 | FT_LOCAL_DEF( void ) |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 190 | T1_Face_Done( T1_Face face ) |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 191 | { |
| 192 | FT_Memory memory; |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 193 | T1_Font type1 = &face->type1; |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 194 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 195 | |
| 196 | if ( face ) |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 197 | { |
| 198 | memory = face->root.memory; |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 199 | |
Werner Lemberg | b5084e1 | 2000-10-28 17:10:06 +0000 | [diff] [blame] | 200 | #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT |
David Turner | 7c388ba | 2000-05-26 02:07:40 +0000 | [diff] [blame] | 201 | /* release multiple masters information */ |
Werner Lemberg | b5084e1 | 2000-10-28 17:10:06 +0000 | [diff] [blame] | 202 | T1_Done_Blend( face ); |
David Turner | 7c388ba | 2000-05-26 02:07:40 +0000 | [diff] [blame] | 203 | face->blend = 0; |
| 204 | #endif |
| 205 | |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 206 | /* release font info strings */ |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 207 | { |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 208 | PS_FontInfo info = &type1->font_info; |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 209 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 210 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 211 | FT_FREE( info->version ); |
| 212 | FT_FREE( info->notice ); |
| 213 | FT_FREE( info->full_name ); |
| 214 | FT_FREE( info->family_name ); |
| 215 | FT_FREE( info->weight ); |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 216 | } |
| 217 | |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 218 | /* release top dictionary */ |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 219 | FT_FREE( type1->charstrings_len ); |
| 220 | FT_FREE( type1->charstrings ); |
| 221 | FT_FREE( type1->glyph_names ); |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 222 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 223 | FT_FREE( type1->subrs ); |
| 224 | FT_FREE( type1->subrs_len ); |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 225 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 226 | FT_FREE( type1->subrs_block ); |
| 227 | FT_FREE( type1->charstrings_block ); |
| 228 | FT_FREE( type1->glyph_names_block ); |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 229 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 230 | FT_FREE( type1->encoding.char_index ); |
| 231 | FT_FREE( type1->encoding.char_name ); |
| 232 | FT_FREE( type1->font_name ); |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 233 | |
Werner Lemberg | b5084e1 | 2000-10-28 17:10:06 +0000 | [diff] [blame] | 234 | #ifndef T1_CONFIG_OPTION_NO_AFM |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 235 | /* release afm data if present */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 236 | if ( face->afm_data ) |
Werner Lemberg | b5084e1 | 2000-10-28 17:10:06 +0000 | [diff] [blame] | 237 | T1_Done_AFM( memory, (T1_AFM*)face->afm_data ); |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 238 | #endif |
| 239 | |
| 240 | /* release unicode map, if any */ |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 241 | FT_FREE( face->unicode_map.maps ); |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 242 | face->unicode_map.num_maps = 0; |
| 243 | |
| 244 | face->root.family_name = 0; |
| 245 | face->root.style_name = 0; |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 246 | } |
| 247 | } |
| 248 | |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 249 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 250 | /*************************************************************************/ |
| 251 | /* */ |
| 252 | /* <Function> */ |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 253 | /* T1_Face_Init */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 254 | /* */ |
| 255 | /* <Description> */ |
| 256 | /* The face object constructor. */ |
| 257 | /* */ |
| 258 | /* <Input> */ |
| 259 | /* stream :: input stream where to load font data. */ |
| 260 | /* */ |
| 261 | /* face_index :: The index of the font face in the resource. */ |
| 262 | /* */ |
| 263 | /* num_params :: Number of additional generic parameters. Ignored. */ |
| 264 | /* */ |
| 265 | /* params :: Additional generic parameters. Ignored. */ |
| 266 | /* */ |
| 267 | /* <InOut> */ |
| 268 | /* face :: The face record to build. */ |
| 269 | /* */ |
| 270 | /* <Return> */ |
| 271 | /* FreeType error code. 0 means success. */ |
| 272 | /* */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 273 | FT_LOCAL_DEF( FT_Error ) |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 274 | T1_Face_Init( FT_Stream stream, |
Werner Lemberg | 4a2305c | 2001-06-28 07:17:51 +0000 | [diff] [blame] | 275 | T1_Face face, |
| 276 | FT_Int face_index, |
| 277 | FT_Int num_params, |
| 278 | FT_Parameter* params ) |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 279 | { |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 280 | FT_Error error; |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 281 | PSNames_Service psnames; |
| 282 | PSAux_Service psaux; |
| 283 | PSHinter_Service pshinter; |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 284 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 285 | FT_UNUSED( num_params ); |
| 286 | FT_UNUSED( params ); |
| 287 | FT_UNUSED( face_index ); |
| 288 | FT_UNUSED( stream ); |
| 289 | |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 290 | |
| 291 | face->root.num_faces = 1; |
| 292 | |
David Turner | 4bd5d0a | 2002-03-20 09:42:31 +0000 | [diff] [blame] | 293 | psnames = face->psnames = (PSNames_Service) |
| 294 | FT_Get_Module_Interface( FT_FACE_LIBRARY(face), "psnames" ); |
David Turner | 95bec28 | 2000-02-15 12:55:57 +0000 | [diff] [blame] | 295 | |
David Turner | 4bd5d0a | 2002-03-20 09:42:31 +0000 | [diff] [blame] | 296 | psaux = face->psaux = (PSAux_Service) |
| 297 | FT_Get_Module_Interface( FT_FACE_LIBRARY(face), "psaux" ); |
David Turner | c312861 | 2000-06-23 05:02:13 +0000 | [diff] [blame] | 298 | |
David Turner | 4bd5d0a | 2002-03-20 09:42:31 +0000 | [diff] [blame] | 299 | pshinter = face->pshinter = (PSHinter_Service) |
| 300 | FT_Get_Module_Interface( FT_FACE_LIBRARY(face), "pshinter" ); |
David Turner | 9748807 | 2000-08-22 22:36:33 +0000 | [diff] [blame] | 301 | |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 302 | /* open the tokenizer, this will also check the font format */ |
Werner Lemberg | b5084e1 | 2000-10-28 17:10:06 +0000 | [diff] [blame] | 303 | error = T1_Open_Face( face ); |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 304 | if ( error ) |
| 305 | goto Exit; |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 306 | |
| 307 | /* if we just wanted to check the format, leave successfully now */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 308 | if ( face_index < 0 ) |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 309 | goto Exit; |
| 310 | |
| 311 | /* check the face index */ |
| 312 | if ( face_index != 0 ) |
| 313 | { |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 314 | FT_ERROR(( "T1_Face_Init: invalid face index\n" )); |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 315 | error = T1_Err_Invalid_Argument; |
| 316 | goto Exit; |
| 317 | } |
| 318 | |
| 319 | /* Now, load the font program into the face object */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 320 | |
| 321 | /* Init the face object fields */ |
| 322 | /* Now set up root face fields */ |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 323 | { |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 324 | FT_Face root = (FT_Face)&face->root; |
| 325 | |
| 326 | |
| 327 | root->num_glyphs = face->type1.num_glyphs; |
| 328 | root->num_charmaps = 1; |
| 329 | |
| 330 | root->face_index = face_index; |
| 331 | root->face_flags = FT_FACE_FLAG_SCALABLE; |
| 332 | |
| 333 | root->face_flags |= FT_FACE_FLAG_HORIZONTAL; |
| 334 | |
David Turner | 6930b45 | 2000-07-19 17:13:03 +0000 | [diff] [blame] | 335 | root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; |
| 336 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 337 | if ( face->type1.font_info.is_fixed_pitch ) |
| 338 | root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; |
| 339 | |
| 340 | if ( face->blend ) |
| 341 | root->face_flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; |
| 342 | |
| 343 | /* XXX: TODO -- add kerning with .afm support */ |
| 344 | |
| 345 | /* get style name -- be careful, some broken fonts only */ |
| 346 | /* have a `/FontName' dictionary entry! */ |
| 347 | root->family_name = face->type1.font_info.family_name; |
| 348 | if ( root->family_name ) |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 349 | { |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 350 | char* full = face->type1.font_info.full_name; |
| 351 | char* family = root->family_name; |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 352 | |
David Turner | 662b344 | 2002-01-03 16:56:59 +0000 | [diff] [blame] | 353 | if ( full ) |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 354 | { |
David Turner | 662b344 | 2002-01-03 16:56:59 +0000 | [diff] [blame] | 355 | while ( *family && *full == *family ) |
| 356 | { |
| 357 | family++; |
| 358 | full++; |
| 359 | } |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 360 | |
David Turner | 662b344 | 2002-01-03 16:56:59 +0000 | [diff] [blame] | 361 | root->style_name = ( *full == ' ' ? full + 1 |
| 362 | : (char *)"Regular" ); |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 363 | } |
David Turner | 662b344 | 2002-01-03 16:56:59 +0000 | [diff] [blame] | 364 | else |
Werner Lemberg | 1a0a979 | 2002-01-03 22:06:13 +0000 | [diff] [blame] | 365 | root->style_name = (char *)"Regular"; |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 366 | } |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 367 | else |
| 368 | { |
| 369 | /* do we have a `/FontName'? */ |
| 370 | if ( face->type1.font_name ) |
| 371 | { |
| 372 | root->family_name = face->type1.font_name; |
Werner Lemberg | e72c9fe | 2000-07-31 18:59:02 +0000 | [diff] [blame] | 373 | root->style_name = (char *)"Regular"; |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 374 | } |
| 375 | } |
| 376 | |
Werner Lemberg | 6dd303d | 2000-11-26 21:25:53 +0000 | [diff] [blame] | 377 | /* compute style flags */ |
| 378 | root->style_flags = 0; |
| 379 | if ( face->type1.font_info.italic_angle ) |
| 380 | root->style_flags |= FT_STYLE_FLAG_ITALIC; |
| 381 | if ( face->type1.font_info.weight ) |
| 382 | { |
| 383 | if ( !strcmp( face->type1.font_info.weight, "Bold" ) || |
| 384 | !strcmp( face->type1.font_info.weight, "Black" ) ) |
| 385 | root->style_flags |= FT_STYLE_FLAG_BOLD; |
| 386 | } |
| 387 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 388 | /* no embedded bitmap support */ |
| 389 | root->num_fixed_sizes = 0; |
| 390 | root->available_sizes = 0; |
| 391 | |
David Turner | 7d0f0ba | 2002-03-05 15:55:28 +0000 | [diff] [blame] | 392 | root->bbox.xMin = face->type1.font_bbox.xMin >> 16; |
| 393 | root->bbox.yMin = face->type1.font_bbox.yMin >> 16; |
| 394 | root->bbox.xMax = (face->type1.font_bbox.xMax + 0xFFFFU) >> 16; |
| 395 | root->bbox.yMax = (face->type1.font_bbox.yMax + 0xFFFFU) >> 16; |
Tom Kacvinsky | 7b91bea | 2001-02-07 01:14:53 +0000 | [diff] [blame] | 396 | |
| 397 | /* Set units_per_EM if we didn't set it in parse_font_matrix. */ |
| 398 | if ( !root->units_per_EM ) |
| 399 | root->units_per_EM = 1000; |
| 400 | |
David Turner | acfea4d | 2002-03-06 12:38:15 +0000 | [diff] [blame] | 401 | root->ascender = (FT_Short)( root->bbox.yMax ); |
| 402 | root->descender = (FT_Short)( root->bbox.yMin ); |
Werner Lemberg | 8eb0353 | 2001-06-19 23:03:41 +0000 | [diff] [blame] | 403 | root->height = (FT_Short)( |
| 404 | ( ( root->ascender - root->descender ) * 12 ) / 10 ); |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 405 | |
| 406 | /* now compute the maximum advance width */ |
Werner Lemberg | 521a2d7 | 2001-03-20 22:58:56 +0000 | [diff] [blame] | 407 | root->max_advance_width = |
David Turner | acfea4d | 2002-03-06 12:38:15 +0000 | [diff] [blame] | 408 | (FT_Short)( root->bbox.xMax ); |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 409 | { |
| 410 | FT_Int max_advance; |
| 411 | |
| 412 | |
Werner Lemberg | b5084e1 | 2000-10-28 17:10:06 +0000 | [diff] [blame] | 413 | error = T1_Compute_Max_Advance( face, &max_advance ); |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 414 | |
| 415 | /* in case of error, keep the standard width */ |
| 416 | if ( !error ) |
David Turner | 8edbcab | 2001-06-19 08:28:24 +0000 | [diff] [blame] | 417 | root->max_advance_width = (FT_Short)max_advance; |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 418 | else |
| 419 | error = 0; /* clear error */ |
| 420 | } |
| 421 | |
| 422 | root->max_advance_height = root->height; |
| 423 | |
| 424 | root->underline_position = face->type1.font_info.underline_position; |
| 425 | root->underline_thickness = face->type1.font_info.underline_thickness; |
| 426 | |
David Turner | 54e7574 | 2000-11-04 02:52:02 +0000 | [diff] [blame] | 427 | root->internal->max_points = 0; |
| 428 | root->internal->max_contours = 0; |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 429 | } |
| 430 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 431 | /* charmap support -- synthetize unicode charmap if possible */ |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 432 | { |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 433 | FT_Face root = &face->root; |
| 434 | FT_CharMap charmap = face->charmaprecs; |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 435 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 436 | |
| 437 | /* synthesize a Unicode charmap if there is support in the `PSNames' */ |
| 438 | /* module */ |
Werner Lemberg | e72c9fe | 2000-07-31 18:59:02 +0000 | [diff] [blame] | 439 | if ( psnames ) |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 440 | { |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 441 | if ( psnames->unicode_value ) |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 442 | { |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 443 | error = psnames->build_unicodes( |
| 444 | root->memory, |
| 445 | face->type1.num_glyphs, |
| 446 | (const char**)face->type1.glyph_names, |
| 447 | &face->unicode_map ); |
| 448 | if ( !error ) |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 449 | { |
| 450 | root->charmap = charmap; |
| 451 | charmap->face = (FT_Face)face; |
| 452 | charmap->encoding = ft_encoding_unicode; |
| 453 | charmap->platform_id = 3; |
| 454 | charmap->encoding_id = 1; |
| 455 | charmap++; |
| 456 | } |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 457 | |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 458 | /* simply clear the error in case of failure (which really) */ |
| 459 | /* means that out of memory or no unicode glyph names */ |
Werner Lemberg | 1429db6 | 2001-04-02 23:54:01 +0000 | [diff] [blame] | 460 | error = T1_Err_Ok; |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 461 | } |
| 462 | } |
| 463 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 464 | /* now, support either the standard, expert, or custom encoding */ |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 465 | charmap->face = (FT_Face)face; |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 466 | charmap->platform_id = 7; /* a new platform id for Adobe fonts? */ |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 467 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 468 | switch ( face->type1.encoding_type ) |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 469 | { |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 470 | case T1_ENCODING_TYPE_STANDARD: |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 471 | charmap->encoding = ft_encoding_adobe_standard; |
| 472 | charmap->encoding_id = 0; |
| 473 | break; |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 474 | |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 475 | case T1_ENCODING_TYPE_EXPORT: |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 476 | charmap->encoding = ft_encoding_adobe_expert; |
| 477 | charmap->encoding_id = 1; |
| 478 | break; |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 479 | |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 480 | case T1_ENCODING_TYPE_ARRAY: |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 481 | charmap->encoding = ft_encoding_adobe_custom; |
| 482 | charmap->encoding_id = 2; |
| 483 | break; |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 484 | |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 485 | case T1_ENCODING_TYPE_ISOLATIN1: |
Werner Lemberg | 66b3509 | 2002-02-10 12:33:14 +0000 | [diff] [blame] | 486 | charmap->encoding = ft_encoding_latin_1; |
| 487 | charmap->encoding_id = 3; |
| 488 | break; |
| 489 | |
| 490 | default: |
| 491 | FT_ERROR(( "T1_Face_Init: invalid encoding\n" )); |
| 492 | error = T1_Err_Invalid_File_Format; |
| 493 | goto Exit; |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 494 | } |
David Turner | e49ab25 | 2000-05-16 23:44:38 +0000 | [diff] [blame] | 495 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 496 | root->charmaps = face->charmaps; |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 497 | root->num_charmaps = charmap - face->charmaprecs + 1; |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 498 | face->charmaps[0] = &face->charmaprecs[0]; |
| 499 | face->charmaps[1] = &face->charmaprecs[1]; |
David Turner | 4d3e563 | 2000-05-05 12:33:23 +0000 | [diff] [blame] | 500 | } |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 501 | |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 502 | Exit: |
| 503 | return error; |
| 504 | } |
| 505 | |
| 506 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 507 | /*************************************************************************/ |
| 508 | /* */ |
| 509 | /* <Function> */ |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 510 | /* T1_Driver_Init */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 511 | /* */ |
| 512 | /* <Description> */ |
| 513 | /* Initializes a given Type 1 driver object. */ |
| 514 | /* */ |
| 515 | /* <Input> */ |
| 516 | /* driver :: A handle to the target driver object. */ |
| 517 | /* */ |
| 518 | /* <Return> */ |
| 519 | /* FreeType error code. 0 means success. */ |
| 520 | /* */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 521 | FT_LOCAL_DEF( FT_Error ) |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 522 | T1_Driver_Init( T1_Driver driver ) |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 523 | { |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 524 | FT_UNUSED( driver ); |
| 525 | |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 526 | return T1_Err_Ok; |
| 527 | } |
| 528 | |
| 529 | |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 530 | /*************************************************************************/ |
| 531 | /* */ |
| 532 | /* <Function> */ |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 533 | /* T1_Driver_Done */ |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 534 | /* */ |
| 535 | /* <Description> */ |
| 536 | /* Finalizes a given Type 1 driver. */ |
| 537 | /* */ |
| 538 | /* <Input> */ |
| 539 | /* driver :: A handle to the target Type 1 driver. */ |
| 540 | /* */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 541 | FT_LOCAL_DEF( void ) |
David Turner | 5893c1b | 2001-10-18 11:49:26 +0000 | [diff] [blame] | 542 | T1_Driver_Done( T1_Driver driver ) |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 543 | { |
Werner Lemberg | 7fa51b5 | 2000-07-08 19:51:42 +0000 | [diff] [blame] | 544 | FT_UNUSED( driver ); |
David Turner | 2dfb5ac | 2000-01-27 14:02:04 +0000 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | |
| 548 | /* END */ |