Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* cidobjs.c */ |
| 4 | /* */ |
| 5 | /* CID objects manager (body). */ |
| 6 | /* */ |
Werner Lemberg | 415235d | 2001-06-28 17:49:10 +0000 | [diff] [blame] | 7 | /* Copyright 1996-2001 by */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +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 | |
| 19 | #include <ft2build.h> |
| 20 | #include FT_INTERNAL_DEBUG_H |
| 21 | #include FT_INTERNAL_STREAM_H |
David Turner | 8d3a401 | 2001-03-20 11:14:24 +0000 | [diff] [blame] | 22 | #include "cidgload.h" |
| 23 | #include "cidload.h" |
Werner Lemberg | cc069be | 2000-12-08 16:17:16 +0000 | [diff] [blame] | 24 | #include FT_INTERNAL_POSTSCRIPT_NAMES_H |
| 25 | #include FT_INTERNAL_POSTSCRIPT_AUX_H |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 26 | #include FT_INTERNAL_POSTSCRIPT_HINTS_H |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 27 | |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 28 | #include "ciderrs.h" |
| 29 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 30 | |
| 31 | /*************************************************************************/ |
| 32 | /* */ |
| 33 | /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
| 34 | /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
| 35 | /* messages during execution. */ |
| 36 | /* */ |
Werner Lemberg | 63408a1 | 2000-12-13 23:44:37 +0000 | [diff] [blame] | 37 | #undef FT_COMPONENT |
| 38 | #define FT_COMPONENT trace_cidobjs |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 39 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 40 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 41 | /*************************************************************************/ |
| 42 | /* */ |
| 43 | /* SLOT FUNCTIONS */ |
| 44 | /* */ |
| 45 | /*************************************************************************/ |
| 46 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 47 | FT_LOCAL_DEF( void ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 48 | CID_GlyphSlot_Done( CID_GlyphSlot slot ) |
| 49 | { |
| 50 | slot->root.internal->glyph_hints = 0; |
| 51 | } |
| 52 | |
| 53 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 54 | FT_LOCAL_DEF( FT_Error ) |
Werner Lemberg | 0d9165e | 2002-03-07 21:59:59 +0000 | [diff] [blame] | 55 | CID_GlyphSlot_Init( CID_GlyphSlot slot ) |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 56 | { |
Werner Lemberg | 0d9165e | 2002-03-07 21:59:59 +0000 | [diff] [blame] | 57 | CID_Face face; |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 58 | PSHinter_Service pshinter; |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 59 | |
| 60 | |
Werner Lemberg | 0d9165e | 2002-03-07 21:59:59 +0000 | [diff] [blame] | 61 | face = (CID_Face)slot->root.face; |
| 62 | pshinter = (PSHinter_Service)face->pshinter; |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 63 | |
| 64 | if ( pshinter ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 65 | { |
| 66 | FT_Module module; |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 67 | |
| 68 | |
| 69 | module = FT_Get_Module( slot->root.face->driver->root.library, |
| 70 | "pshinter" ); |
| 71 | if ( module ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 72 | { |
| 73 | T1_Hints_Funcs funcs; |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 74 | |
| 75 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 76 | funcs = pshinter->get_t1_funcs( module ); |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 77 | slot->root.internal->glyph_hints = (void*)funcs; |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 78 | } |
| 79 | } |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 80 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 81 | return 0; |
| 82 | } |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 83 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 84 | |
| 85 | /*************************************************************************/ |
| 86 | /* */ |
| 87 | /* SIZE FUNCTIONS */ |
| 88 | /* */ |
| 89 | /*************************************************************************/ |
| 90 | |
| 91 | |
| 92 | static PSH_Globals_Funcs |
| 93 | CID_Size_Get_Globals_Funcs( CID_Size size ) |
| 94 | { |
Werner Lemberg | 0d9165e | 2002-03-07 21:59:59 +0000 | [diff] [blame] | 95 | CID_Face face = (CID_Face)size->root.face; |
| 96 | PSHinter_Service pshinter = (PSHinter_Service)face->pshinter; |
| 97 | FT_Module module; |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 98 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 99 | |
| 100 | module = FT_Get_Module( size->root.face->driver->root.library, |
| 101 | "pshinter" ); |
| 102 | return ( module && pshinter && pshinter->get_globals_funcs ) |
| 103 | ? pshinter->get_globals_funcs( module ) |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 104 | : 0; |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 108 | FT_LOCAL_DEF( void ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 109 | CID_Size_Done( CID_Size size ) |
| 110 | { |
| 111 | if ( size->root.internal ) |
| 112 | { |
| 113 | PSH_Globals_Funcs funcs; |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 114 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 115 | |
| 116 | funcs = CID_Size_Get_Globals_Funcs( size ); |
| 117 | if ( funcs ) |
| 118 | funcs->destroy( (PSH_Globals)size->root.internal ); |
| 119 | |
| 120 | size->root.internal = 0; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 125 | FT_LOCAL_DEF( FT_Error ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 126 | CID_Size_Init( CID_Size size ) |
| 127 | { |
| 128 | FT_Error error = 0; |
| 129 | PSH_Globals_Funcs funcs = CID_Size_Get_Globals_Funcs( size ); |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 130 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 131 | |
| 132 | if ( funcs ) |
| 133 | { |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 134 | PSH_Globals globals; |
| 135 | CID_Face face = (CID_Face)size->root.face; |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 136 | CID_FaceDict dict = face->cid.font_dicts + face->root.face_index; |
| 137 | PS_Private priv = &dict->private_dict; |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 138 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 139 | |
| 140 | error = funcs->create( size->root.face->memory, priv, &globals ); |
| 141 | if ( !error ) |
| 142 | size->root.internal = (FT_Size_Internal)(void*)globals; |
| 143 | } |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 144 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 145 | return error; |
| 146 | } |
| 147 | |
| 148 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 149 | FT_LOCAL_DEF( FT_Error ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 150 | CID_Size_Reset( CID_Size size ) |
| 151 | { |
| 152 | PSH_Globals_Funcs funcs = CID_Size_Get_Globals_Funcs( size ); |
| 153 | FT_Error error = 0; |
| 154 | |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 155 | |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 156 | if ( funcs ) |
| 157 | error = funcs->set_scale( (PSH_Globals)size->root.internal, |
| 158 | size->root.metrics.x_scale, |
| 159 | size->root.metrics.y_scale, |
| 160 | 0, 0 ); |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 161 | return error; |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 167 | /*************************************************************************/ |
| 168 | /* */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 169 | /* FACE FUNCTIONS */ |
| 170 | /* */ |
| 171 | /*************************************************************************/ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 172 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 173 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 174 | /*************************************************************************/ |
| 175 | /* */ |
| 176 | /* <Function> */ |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 177 | /* CID_Face_Done */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 178 | /* */ |
| 179 | /* <Description> */ |
| 180 | /* Finalizes a given face object. */ |
| 181 | /* */ |
| 182 | /* <Input> */ |
| 183 | /* face :: A pointer to the face object to destroy. */ |
| 184 | /* */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 185 | FT_LOCAL_DEF( void ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 186 | CID_Face_Done( CID_Face face ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 187 | { |
| 188 | FT_Memory memory; |
| 189 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 190 | |
| 191 | if ( face ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 192 | { |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 193 | CID_FaceInfo cid = &face->cid; |
| 194 | PS_FontInfo info = &cid->font_info; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 195 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 196 | |
| 197 | memory = face->root.memory; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 198 | |
David Turner | 3a664fc | 2001-12-21 15:26:19 +0000 | [diff] [blame] | 199 | /* release subrs */ |
| 200 | if ( face->subrs ) |
| 201 | { |
| 202 | FT_Int n; |
| 203 | |
Werner Lemberg | af594e6 | 2001-12-22 14:38:40 +0000 | [diff] [blame] | 204 | |
David Turner | 3a664fc | 2001-12-21 15:26:19 +0000 | [diff] [blame] | 205 | for ( n = 0; n < cid->num_dicts; n++ ) |
| 206 | { |
David Turner | 2964417 | 2002-02-28 18:59:37 +0000 | [diff] [blame] | 207 | CID_Subrs subr = face->subrs + n; |
David Turner | 3a664fc | 2001-12-21 15:26:19 +0000 | [diff] [blame] | 208 | |
Werner Lemberg | af594e6 | 2001-12-22 14:38:40 +0000 | [diff] [blame] | 209 | |
David Turner | 3a664fc | 2001-12-21 15:26:19 +0000 | [diff] [blame] | 210 | if ( subr->code ) |
| 211 | { |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 212 | FT_FREE( subr->code[0] ); |
| 213 | FT_FREE( subr->code ); |
David Turner | 3a664fc | 2001-12-21 15:26:19 +0000 | [diff] [blame] | 214 | } |
| 215 | } |
| 216 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 217 | FT_FREE( face->subrs ); |
David Turner | 3a664fc | 2001-12-21 15:26:19 +0000 | [diff] [blame] | 218 | } |
| 219 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 220 | /* release FontInfo strings */ |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 221 | FT_FREE( info->version ); |
| 222 | FT_FREE( info->notice ); |
| 223 | FT_FREE( info->full_name ); |
| 224 | FT_FREE( info->family_name ); |
| 225 | FT_FREE( info->weight ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 226 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 227 | /* release font dictionaries */ |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 228 | FT_FREE( cid->font_dicts ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 229 | cid->num_dicts = 0; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 230 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 231 | /* release other strings */ |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 232 | FT_FREE( cid->cid_font_name ); |
| 233 | FT_FREE( cid->registry ); |
| 234 | FT_FREE( cid->ordering ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 235 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 236 | face->root.family_name = 0; |
| 237 | face->root.style_name = 0; |
| 238 | } |
| 239 | } |
| 240 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 241 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 242 | /*************************************************************************/ |
| 243 | /* */ |
| 244 | /* <Function> */ |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 245 | /* CID_Face_Init */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 246 | /* */ |
| 247 | /* <Description> */ |
| 248 | /* Initializes a given CID face object. */ |
| 249 | /* */ |
| 250 | /* <Input> */ |
| 251 | /* stream :: The source font stream. */ |
| 252 | /* */ |
| 253 | /* face_index :: The index of the font face in the resource. */ |
| 254 | /* */ |
| 255 | /* num_params :: Number of additional generic parameters. Ignored. */ |
| 256 | /* */ |
| 257 | /* params :: Additional generic parameters. Ignored. */ |
| 258 | /* */ |
| 259 | /* <InOut> */ |
| 260 | /* face :: The newly built face object. */ |
| 261 | /* */ |
| 262 | /* <Return> */ |
Werner Lemberg | a929ba9 | 2000-06-25 06:47:11 +0000 | [diff] [blame] | 263 | /* FreeType error code. 0 means success. */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 264 | /* */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 265 | FT_LOCAL_DEF( FT_Error ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 266 | CID_Face_Init( FT_Stream stream, |
Werner Lemberg | 93616ec | 2001-06-27 19:46:12 +0000 | [diff] [blame] | 267 | CID_Face face, |
| 268 | FT_Int face_index, |
| 269 | FT_Int num_params, |
| 270 | FT_Parameter* params ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 271 | { |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 272 | FT_Error error; |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 273 | PSNames_Service psnames; |
| 274 | PSAux_Service psaux; |
| 275 | PSHinter_Service pshinter; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 276 | |
David Turner | c6a9220 | 2000-07-04 18:12:13 +0000 | [diff] [blame] | 277 | FT_UNUSED( num_params ); |
| 278 | FT_UNUSED( params ); |
| 279 | FT_UNUSED( face_index ); |
| 280 | FT_UNUSED( stream ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 281 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 282 | |
| 283 | face->root.num_faces = 1; |
| 284 | |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 285 | psnames = (PSNames_Service)face->psnames; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 286 | if ( !psnames ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 287 | { |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 288 | psnames = (PSNames_Service)FT_Get_Module_Interface( |
Werner Lemberg | a929ba9 | 2000-06-25 06:47:11 +0000 | [diff] [blame] | 289 | FT_FACE_LIBRARY( face ), "psnames" ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 290 | |
David Turner | c312861 | 2000-06-23 05:02:13 +0000 | [diff] [blame] | 291 | face->psnames = psnames; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 292 | } |
| 293 | |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 294 | psaux = (PSAux_Service)face->psaux; |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 295 | if ( !psaux ) |
| 296 | { |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 297 | psaux = (PSAux_Service)FT_Get_Module_Interface( |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 298 | FT_FACE_LIBRARY( face ), "psaux" ); |
Werner Lemberg | e4b32a5 | 2000-10-31 20:42:18 +0000 | [diff] [blame] | 299 | |
David Turner | 34f1c2f | 2000-08-23 22:47:44 +0000 | [diff] [blame] | 300 | face->psaux = psaux; |
| 301 | } |
| 302 | |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 303 | pshinter = (PSHinter_Service)face->pshinter; |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 304 | if ( !pshinter ) |
| 305 | { |
David Turner | 4e7eeee | 2002-02-28 16:10:29 +0000 | [diff] [blame] | 306 | pshinter = (PSHinter_Service)FT_Get_Module_Interface( |
Werner Lemberg | f41e71a | 2001-12-20 21:22:02 +0000 | [diff] [blame] | 307 | FT_FACE_LIBRARY( face ), "pshinter" ); |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 308 | |
| 309 | face->pshinter = pshinter; |
| 310 | } |
| 311 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 312 | /* open the tokenizer; this will also check the font format */ |
David Turner | 7d3a264 | 2002-03-20 10:49:31 +0000 | [diff] [blame] | 313 | if ( FT_STREAM_SEEK( 0 ) ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 314 | goto Exit; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 315 | |
Werner Lemberg | e35cac6 | 2000-06-11 03:46:57 +0000 | [diff] [blame] | 316 | error = CID_Open_Face( face ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 317 | if ( error ) |
| 318 | goto Exit; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 319 | |
| 320 | /* if we just wanted to check the format, leave successfully now */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 321 | if ( face_index < 0 ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 322 | goto Exit; |
| 323 | |
| 324 | /* check the face index */ |
| 325 | if ( face_index != 0 ) |
| 326 | { |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 327 | FT_ERROR(( "CID_Face_Init: invalid face index\n" )); |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 328 | error = CID_Err_Invalid_Argument; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 329 | goto Exit; |
| 330 | } |
| 331 | |
| 332 | /* Now, load the font program into the face object */ |
| 333 | { |
| 334 | /* Init the face object fields */ |
| 335 | /* Now set up root face fields */ |
| 336 | { |
| 337 | FT_Face root = (FT_Face)&face->root; |
| 338 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 339 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 340 | root->num_glyphs = face->cid.cid_count; |
| 341 | root->num_charmaps = 0; |
| 342 | |
| 343 | root->face_index = face_index; |
| 344 | root->face_flags = FT_FACE_FLAG_SCALABLE; |
| 345 | |
| 346 | root->face_flags |= FT_FACE_FLAG_HORIZONTAL; |
| 347 | |
| 348 | if ( face->cid.font_info.is_fixed_pitch ) |
| 349 | root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; |
| 350 | |
Werner Lemberg | ac39ecd | 2000-06-30 22:24:36 +0000 | [diff] [blame] | 351 | /* XXX: TODO: add kerning with .afm support */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 352 | |
Werner Lemberg | ac39ecd | 2000-06-30 22:24:36 +0000 | [diff] [blame] | 353 | /* get style name -- be careful, some broken fonts only */ |
| 354 | /* have a /FontName dictionary entry! */ |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 355 | root->family_name = face->cid.font_info.family_name; |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 356 | if ( root->family_name ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 357 | { |
| 358 | char* full = face->cid.font_info.full_name; |
| 359 | char* family = root->family_name; |
| 360 | |
| 361 | while ( *family && *full == *family ) |
| 362 | { |
| 363 | family++; |
| 364 | full++; |
| 365 | } |
| 366 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 367 | root->style_name = ( *full == ' ' ) ? full + 1 |
Werner Lemberg | bd5ae40 | 2000-07-05 04:32:02 +0000 | [diff] [blame] | 368 | : (char *)"Regular"; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 369 | } |
| 370 | else |
| 371 | { |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 372 | /* do we have a `/FontName'? */ |
| 373 | if ( face->cid.cid_font_name ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 374 | { |
| 375 | root->family_name = face->cid.cid_font_name; |
Werner Lemberg | e72c9fe | 2000-07-31 18:59:02 +0000 | [diff] [blame] | 376 | root->style_name = (char *)"Regular"; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 377 | } |
| 378 | } |
| 379 | |
| 380 | /* no embedded bitmap support */ |
| 381 | root->num_fixed_sizes = 0; |
| 382 | root->available_sizes = 0; |
| 383 | |
David Turner | 7d0f0ba | 2002-03-05 15:55:28 +0000 | [diff] [blame] | 384 | root->bbox.xMin = face->cid.font_bbox.xMin >> 16; |
| 385 | root->bbox.yMin = face->cid.font_bbox.yMin >> 16; |
| 386 | root->bbox.xMax = (face->cid.font_bbox.xMax + 0xFFFFU) >> 16; |
| 387 | root->bbox.yMax = (face->cid.font_bbox.yMax + 0xFFFFU) >> 16; |
| 388 | |
| 389 | |
Tom Kacvinsky | 00169a3 | 2001-03-10 19:06:54 +0000 | [diff] [blame] | 390 | if ( !root->units_per_EM ) |
| 391 | root->units_per_EM = 1000; |
| 392 | |
David Turner | acfea4d | 2002-03-06 12:38:15 +0000 | [diff] [blame] | 393 | root->ascender = (FT_Short)( root->bbox.yMax ); |
| 394 | root->descender = (FT_Short)( root->bbox.yMin ); |
Werner Lemberg | 8eb0353 | 2001-06-19 23:03:41 +0000 | [diff] [blame] | 395 | root->height = (FT_Short)( |
| 396 | ( ( root->ascender + root->descender ) * 12 ) / 10 ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 397 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 398 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 399 | root->underline_position = face->cid.font_info.underline_position; |
| 400 | root->underline_thickness = face->cid.font_info.underline_thickness; |
| 401 | |
David Turner | 54e7574 | 2000-11-04 02:52:02 +0000 | [diff] [blame] | 402 | root->internal->max_points = 0; |
| 403 | root->internal->max_contours = 0; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 407 | Exit: |
| 408 | return error; |
| 409 | } |
| 410 | |
| 411 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 412 | /*************************************************************************/ |
| 413 | /* */ |
| 414 | /* <Function> */ |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 415 | /* CID_Driver_Init */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 416 | /* */ |
| 417 | /* <Description> */ |
| 418 | /* Initializes a given CID driver object. */ |
| 419 | /* */ |
| 420 | /* <Input> */ |
| 421 | /* driver :: A handle to the target driver object. */ |
| 422 | /* */ |
| 423 | /* <Return> */ |
Werner Lemberg | a929ba9 | 2000-06-25 06:47:11 +0000 | [diff] [blame] | 424 | /* FreeType error code. 0 means success. */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 425 | /* */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 426 | FT_LOCAL_DEF( FT_Error ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 427 | CID_Driver_Init( CID_Driver driver ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 428 | { |
David Turner | c6a9220 | 2000-07-04 18:12:13 +0000 | [diff] [blame] | 429 | FT_UNUSED( driver ); |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 430 | |
Werner Lemberg | 1f7f0e8 | 2001-06-06 17:30:41 +0000 | [diff] [blame] | 431 | return CID_Err_Ok; |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 435 | /*************************************************************************/ |
| 436 | /* */ |
| 437 | /* <Function> */ |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 438 | /* CID_Driver_Done */ |
Werner Lemberg | e3c11d7 | 2000-06-16 06:49:56 +0000 | [diff] [blame] | 439 | /* */ |
| 440 | /* <Description> */ |
| 441 | /* Finalizes a given CID driver. */ |
| 442 | /* */ |
| 443 | /* <Input> */ |
| 444 | /* driver :: A handle to the target CID driver. */ |
| 445 | /* */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 446 | FT_LOCAL_DEF( void ) |
David Turner | 85eb669 | 2001-12-20 09:36:21 +0000 | [diff] [blame] | 447 | CID_Driver_Done( CID_Driver driver ) |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 448 | { |
David Turner | c6a9220 | 2000-07-04 18:12:13 +0000 | [diff] [blame] | 449 | FT_UNUSED( driver ); |
David Turner | 04aa800 | 2000-06-01 03:27:48 +0000 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | |
| 453 | /* END */ |