00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <ft2build.h>
00020 #include FT_INTERNAL_DEBUG_H
00021 #include FT_INTERNAL_STREAM_H
00022
00023 #include "cidgload.h"
00024 #include "cidload.h"
00025
00026 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
00027 #include FT_INTERNAL_POSTSCRIPT_AUX_H
00028 #include FT_INTERNAL_POSTSCRIPT_HINTS_H
00029
00030 #include "ciderrs.h"
00031
00032
00033
00034
00035
00036
00037
00038
00039 #undef FT_COMPONENT
00040 #define FT_COMPONENT trace_cidobjs
00041
00042
00043
00044
00045
00046
00047
00048
00049 FT_LOCAL_DEF( void )
00050 cid_slot_done( FT_GlyphSlot slot )
00051 {
00052 slot->internal->glyph_hints = 0;
00053 }
00054
00055
00056 FT_LOCAL_DEF( FT_Error )
00057 cid_slot_init( FT_GlyphSlot slot )
00058 {
00059 CID_Face face;
00060 PSHinter_Service pshinter;
00061
00062
00063 face = (CID_Face)slot->face;
00064 pshinter = (PSHinter_Service)face->pshinter;
00065
00066 if ( pshinter )
00067 {
00068 FT_Module module;
00069
00070
00071 module = FT_Get_Module( slot->face->driver->root.library,
00072 "pshinter" );
00073 if ( module )
00074 {
00075 T1_Hints_Funcs funcs;
00076
00077
00078 funcs = pshinter->get_t1_funcs( module );
00079 slot->internal->glyph_hints = (void*)funcs;
00080 }
00081 }
00082
00083 return 0;
00084 }
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 static PSH_Globals_Funcs
00095 cid_size_get_globals_funcs( CID_Size size )
00096 {
00097 CID_Face face = (CID_Face)size->root.face;
00098 PSHinter_Service pshinter = (PSHinter_Service)face->pshinter;
00099 FT_Module module;
00100
00101
00102 module = FT_Get_Module( size->root.face->driver->root.library,
00103 "pshinter" );
00104 return ( module && pshinter && pshinter->get_globals_funcs )
00105 ? pshinter->get_globals_funcs( module )
00106 : 0;
00107 }
00108
00109
00110 FT_LOCAL_DEF( void )
00111 cid_size_done( FT_Size cidsize )
00112 {
00113 CID_Size size = (CID_Size)cidsize;
00114
00115
00116 if ( cidsize->internal )
00117 {
00118 PSH_Globals_Funcs funcs;
00119
00120
00121 funcs = cid_size_get_globals_funcs( size );
00122 if ( funcs )
00123 funcs->destroy( (PSH_Globals)cidsize->internal );
00124
00125 cidsize->internal = 0;
00126 }
00127 }
00128
00129
00130 FT_LOCAL_DEF( FT_Error )
00131 cid_size_init( FT_Size cidsize )
00132 {
00133 CID_Size size = (CID_Size)cidsize;
00134 FT_Error error = 0;
00135 PSH_Globals_Funcs funcs = cid_size_get_globals_funcs( size );
00136
00137
00138 if ( funcs )
00139 {
00140 PSH_Globals globals;
00141 CID_Face face = (CID_Face)cidsize->face;
00142 CID_FaceDict dict = face->cid.font_dicts + face->root.face_index;
00143 PS_Private priv = &dict->private_dict;
00144
00145
00146 error = funcs->create( cidsize->face->memory, priv, &globals );
00147 if ( !error )
00148 cidsize->internal = (FT_Size_Internal)(void*)globals;
00149 }
00150
00151 return error;
00152 }
00153
00154
00155 FT_LOCAL( FT_Error )
00156 cid_size_request( FT_Size size,
00157 FT_Size_Request req )
00158 {
00159 PSH_Globals_Funcs funcs;
00160
00161
00162 FT_Request_Metrics( size->face, req );
00163
00164 funcs = cid_size_get_globals_funcs( (CID_Size)size );
00165
00166 if ( funcs )
00167 funcs->set_scale( (PSH_Globals)size->internal,
00168 size->metrics.x_scale,
00169 size->metrics.y_scale,
00170 0, 0 );
00171
00172 return CID_Err_Ok;
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 FT_LOCAL_DEF( void )
00194 cid_face_done( FT_Face cidface )
00195 {
00196 CID_Face face = (CID_Face)cidface;
00197 FT_Memory memory;
00198 CID_FaceInfo cid;
00199 PS_FontInfo info;
00200
00201
00202 if ( !face )
00203 return;
00204
00205 cid = &face->cid;
00206 info = &cid->font_info;
00207 memory = cidface->memory;
00208
00209
00210 if ( face->subrs )
00211 {
00212 FT_Int n;
00213
00214
00215 for ( n = 0; n < cid->num_dicts; n++ )
00216 {
00217 CID_Subrs subr = face->subrs + n;
00218
00219
00220 if ( subr->code )
00221 {
00222 FT_FREE( subr->code[0] );
00223 FT_FREE( subr->code );
00224 }
00225 }
00226
00227 FT_FREE( face->subrs );
00228 }
00229
00230
00231 FT_FREE( info->version );
00232 FT_FREE( info->notice );
00233 FT_FREE( info->full_name );
00234 FT_FREE( info->family_name );
00235 FT_FREE( info->weight );
00236
00237
00238 FT_FREE( cid->font_dicts );
00239 cid->num_dicts = 0;
00240
00241
00242 FT_FREE( cid->cid_font_name );
00243 FT_FREE( cid->registry );
00244 FT_FREE( cid->ordering );
00245
00246 cidface->family_name = 0;
00247 cidface->style_name = 0;
00248
00249 FT_FREE( face->binary_data );
00250 FT_FREE( face->cid_stream );
00251 }
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 FT_LOCAL_DEF( FT_Error )
00278 cid_face_init( FT_Stream stream,
00279 FT_Face cidface,
00280 FT_Int face_index,
00281 FT_Int num_params,
00282 FT_Parameter* params )
00283 {
00284 CID_Face face = (CID_Face)cidface;
00285 FT_Error error;
00286 PSAux_Service psaux;
00287 PSHinter_Service pshinter;
00288
00289 FT_UNUSED( num_params );
00290 FT_UNUSED( params );
00291 FT_UNUSED( stream );
00292
00293
00294 cidface->num_faces = 1;
00295
00296 psaux = (PSAux_Service)face->psaux;
00297 if ( !psaux )
00298 {
00299 psaux = (PSAux_Service)FT_Get_Module_Interface(
00300 FT_FACE_LIBRARY( face ), "psaux" );
00301
00302 face->psaux = psaux;
00303 }
00304
00305 pshinter = (PSHinter_Service)face->pshinter;
00306 if ( !pshinter )
00307 {
00308 pshinter = (PSHinter_Service)FT_Get_Module_Interface(
00309 FT_FACE_LIBRARY( face ), "pshinter" );
00310
00311 face->pshinter = pshinter;
00312 }
00313
00314
00315 if ( FT_STREAM_SEEK( 0 ) )
00316 goto Exit;
00317
00318 error = cid_face_open( face, face_index );
00319 if ( error )
00320 goto Exit;
00321
00322
00323 if ( face_index < 0 )
00324 goto Exit;
00325
00326
00327
00328 if ( face_index != 0 )
00329 {
00330 FT_ERROR(( "cid_face_init: invalid face index\n" ));
00331 error = CID_Err_Invalid_Argument;
00332 goto Exit;
00333 }
00334
00335
00336
00337
00338
00339
00340 {
00341 CID_FaceInfo cid = &face->cid;
00342 PS_FontInfo info = &cid->font_info;
00343
00344
00345 cidface->num_glyphs = cid->cid_count;
00346 cidface->num_charmaps = 0;
00347
00348 cidface->face_index = face_index;
00349 cidface->face_flags = FT_FACE_FLAG_SCALABLE |
00350 FT_FACE_FLAG_HORIZONTAL |
00351 FT_FACE_FLAG_HINTER;
00352
00353 if ( info->is_fixed_pitch )
00354 cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
00355
00356
00357
00358
00359
00360 cidface->family_name = info->family_name;
00361
00362 cidface->style_name = (char *)"Regular";
00363 if ( cidface->family_name )
00364 {
00365 char* full = info->full_name;
00366 char* family = cidface->family_name;
00367
00368
00369 if ( full )
00370 {
00371 while ( *full )
00372 {
00373 if ( *full == *family )
00374 {
00375 family++;
00376 full++;
00377 }
00378 else
00379 {
00380 if ( *full == ' ' || *full == '-' )
00381 full++;
00382 else if ( *family == ' ' || *family == '-' )
00383 family++;
00384 else
00385 {
00386 if ( !*family )
00387 cidface->style_name = full;
00388 break;
00389 }
00390 }
00391 }
00392 }
00393 }
00394 else
00395 {
00396
00397 if ( cid->cid_font_name )
00398 cidface->family_name = cid->cid_font_name;
00399 }
00400
00401
00402 cidface->style_flags = 0;
00403 if ( info->italic_angle )
00404 cidface->style_flags |= FT_STYLE_FLAG_ITALIC;
00405 if ( info->weight )
00406 {
00407 if ( !ft_strcmp( info->weight, "Bold" ) ||
00408 !ft_strcmp( info->weight, "Black" ) )
00409 cidface->style_flags |= FT_STYLE_FLAG_BOLD;
00410 }
00411
00412
00413 cidface->num_fixed_sizes = 0;
00414 cidface->available_sizes = 0;
00415
00416 cidface->bbox.xMin = cid->font_bbox.xMin >> 16;
00417 cidface->bbox.yMin = cid->font_bbox.yMin >> 16;
00418
00419 cidface->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFF ) >> 16;
00420 cidface->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFF ) >> 16;
00421
00422 if ( !cidface->units_per_EM )
00423 cidface->units_per_EM = 1000;
00424
00425 cidface->ascender = (FT_Short)( cidface->bbox.yMax );
00426 cidface->descender = (FT_Short)( cidface->bbox.yMin );
00427
00428 cidface->height = (FT_Short)( ( cidface->units_per_EM * 12 ) / 10 );
00429 if ( cidface->height < cidface->ascender - cidface->descender )
00430 cidface->height = (FT_Short)( cidface->ascender - cidface->descender );
00431
00432 cidface->underline_position = (FT_Short)info->underline_position;
00433 cidface->underline_thickness = (FT_Short)info->underline_thickness;
00434 }
00435
00436 Exit:
00437 return error;
00438 }
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455 FT_LOCAL_DEF( FT_Error )
00456 cid_driver_init( FT_Module driver )
00457 {
00458 FT_UNUSED( driver );
00459
00460 return CID_Err_Ok;
00461 }
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475 FT_LOCAL_DEF( void )
00476 cid_driver_done( FT_Module driver )
00477 {
00478 FT_UNUSED( driver );
00479 }
00480
00481
00482