25#ifndef T1_CONFIG_OPTION_NO_AFM
52#define FT_COMPONENT t1driver
59 FT_CALLBACK_DEF( FT_Error )
60 t1_get_glyph_name( FT_Face face,
65 T1_Face t1face = (T1_Face)face;
68 FT_STRCPYN( buffer, t1face->type1.glyph_names[glyph_index], buffer_max );
74 FT_CALLBACK_DEF( FT_UInt )
75 t1_get_name_index( FT_Face face,
76 const FT_String* glyph_name )
78 T1_Face t1face = (T1_Face)face;
82 for ( i = 0; i < t1face->type1.num_glyphs; i++ )
84 FT_String* gname = t1face->type1.glyph_names[i];
87 if ( !ft_strcmp( glyph_name, gname ) )
95 static const FT_Service_GlyphDictRec t1_service_glyph_dict =
108 t1_get_ps_name( FT_Face face )
110 T1_Face t1face = (T1_Face)face;
113 return (
const char*) t1face->type1.font_name;
117 static const FT_Service_PsFontNameRec t1_service_ps_name =
119 (FT_PsName_GetFunc)t1_get_ps_name
128#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
129 static const FT_Service_MultiMastersRec t1_service_multi_masters =
140 T1_Set_MM_WeightVector,
142 T1_Get_MM_WeightVector,
163 t1_ps_get_font_info( FT_Face face,
164 PS_FontInfoRec* afont_info )
166 *afont_info = ((T1_Face)face)->type1.font_info;
173 t1_ps_get_font_extra( FT_Face face,
174 PS_FontExtraRec* afont_extra )
176 *afont_extra = ((T1_Face)face)->type1.font_extra;
183 t1_ps_has_glyph_names( FT_Face face )
192 t1_ps_get_font_private( FT_Face face,
193 PS_PrivateRec* afont_private )
195 *afont_private = ((T1_Face)face)->type1.private_dict;
202 t1_ps_get_font_value( FT_Face face,
209 FT_ULong value_len = value_len_ < 0 ? 0 : (FT_ULong)value_len_;
211 T1_Face t1face = (T1_Face)face;
212 T1_Font type1 = &t1face->type1;
217 case PS_DICT_FONT_TYPE:
218 retval =
sizeof ( type1->font_type );
219 if ( value && value_len >= retval )
220 *((FT_Byte *)value) = type1->font_type;
223 case PS_DICT_FONT_MATRIX:
224 if ( idx <
sizeof ( type1->font_matrix ) /
225 sizeof ( type1->font_matrix.xx ) )
230 retval =
sizeof ( val );
231 if ( value && value_len >= retval )
236 val = type1->font_matrix.xx;
239 val = type1->font_matrix.xy;
242 val = type1->font_matrix.yx;
245 val = type1->font_matrix.yy;
248 *((FT_Fixed *)value) = val;
253 case PS_DICT_FONT_BBOX:
254 if ( idx <
sizeof ( type1->font_bbox ) /
255 sizeof ( type1->font_bbox.xMin ) )
260 retval =
sizeof ( val );
261 if ( value && value_len >= retval )
266 val = type1->font_bbox.xMin;
269 val = type1->font_bbox.yMin;
272 val = type1->font_bbox.xMax;
275 val = type1->font_bbox.yMax;
278 *((FT_Fixed *)value) = val;
283 case PS_DICT_PAINT_TYPE:
284 retval =
sizeof ( type1->paint_type );
285 if ( value && value_len >= retval )
286 *((FT_Byte *)value) = type1->paint_type;
289 case PS_DICT_FONT_NAME:
290 if ( type1->font_name )
292 retval = ft_strlen( type1->font_name ) + 1;
293 if ( value && value_len >= retval )
294 ft_memcpy( value, (
void *)( type1->font_name ), retval );
298 case PS_DICT_UNIQUE_ID:
299 retval =
sizeof ( type1->private_dict.unique_id );
300 if ( value && value_len >= retval )
301 *((FT_Int *)value) = type1->private_dict.unique_id;
304 case PS_DICT_NUM_CHAR_STRINGS:
305 retval =
sizeof ( type1->num_glyphs );
306 if ( value && value_len >= retval )
307 *((FT_Int *)value) = type1->num_glyphs;
310 case PS_DICT_CHAR_STRING_KEY:
311 if ( idx < (FT_UInt)type1->num_glyphs )
313 retval = ft_strlen( type1->glyph_names[idx] ) + 1;
314 if ( value && value_len >= retval )
315 ft_memcpy( value, (
void *)( type1->glyph_names[idx] ), retval );
319 case PS_DICT_CHAR_STRING:
320 if ( idx < (FT_UInt)type1->num_glyphs )
322 retval = type1->charstrings_len[idx] + 1;
323 if ( value && value_len >= retval )
325 ft_memcpy( value, (
void *)( type1->charstrings[idx] ),
327 ((FT_Char *)value)[retval - 1] = (FT_Char)
'\0';
332 case PS_DICT_ENCODING_TYPE:
333 retval =
sizeof ( type1->encoding_type );
334 if ( value && value_len >= retval )
335 *((T1_EncodingType *)value) = type1->encoding_type;
338 case PS_DICT_ENCODING_ENTRY:
339 if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY &&
340 idx < (FT_UInt)type1->encoding.num_chars )
342 retval = ft_strlen( type1->encoding.char_name[idx] ) + 1;
343 if ( value && value_len >= retval )
344 ft_memcpy( value, (
void *)( type1->encoding.char_name[idx] ),
349 case PS_DICT_NUM_SUBRS:
350 retval =
sizeof ( type1->num_subrs );
351 if ( value && value_len >= retval )
352 *((FT_Int *)value) = type1->num_subrs;
360 if ( type1->subrs_hash )
363 size_t* val = ft_hash_num_lookup( (FT_Int)idx,
375 if ( idx < (FT_UInt)type1->num_subrs )
379 if ( ok && type1->subrs )
381 retval = type1->subrs_len[idx] + 1;
382 if ( value && value_len >= retval )
384 ft_memcpy( value, (
void *)( type1->subrs[idx] ), retval - 1 );
385 ((FT_Char *)value)[retval - 1] = (FT_Char)
'\0';
392 retval =
sizeof ( type1->private_dict.standard_width[0] );
393 if ( value && value_len >= retval )
394 *((FT_UShort *)value) = type1->private_dict.standard_width[0];
398 retval =
sizeof ( type1->private_dict.standard_height[0] );
399 if ( value && value_len >= retval )
400 *((FT_UShort *)value) = type1->private_dict.standard_height[0];
403 case PS_DICT_NUM_BLUE_VALUES:
404 retval =
sizeof ( type1->private_dict.num_blue_values );
405 if ( value && value_len >= retval )
406 *((FT_Byte *)value) = type1->private_dict.num_blue_values;
409 case PS_DICT_BLUE_VALUE:
410 if ( idx < type1->private_dict.num_blue_values )
412 retval =
sizeof ( type1->private_dict.blue_values[idx] );
413 if ( value && value_len >= retval )
414 *((FT_Short *)value) = type1->private_dict.blue_values[idx];
418 case PS_DICT_BLUE_SCALE:
419 retval =
sizeof ( type1->private_dict.blue_scale );
420 if ( value && value_len >= retval )
421 *((FT_Fixed *)value) = type1->private_dict.blue_scale;
424 case PS_DICT_BLUE_FUZZ:
425 retval =
sizeof ( type1->private_dict.blue_fuzz );
426 if ( value && value_len >= retval )
427 *((FT_Int *)value) = type1->private_dict.blue_fuzz;
430 case PS_DICT_BLUE_SHIFT:
431 retval =
sizeof ( type1->private_dict.blue_shift );
432 if ( value && value_len >= retval )
433 *((FT_Int *)value) = type1->private_dict.blue_shift;
436 case PS_DICT_NUM_OTHER_BLUES:
437 retval =
sizeof ( type1->private_dict.num_other_blues );
438 if ( value && value_len >= retval )
439 *((FT_Byte *)value) = type1->private_dict.num_other_blues;
442 case PS_DICT_OTHER_BLUE:
443 if ( idx < type1->private_dict.num_other_blues )
445 retval =
sizeof ( type1->private_dict.other_blues[idx] );
446 if ( value && value_len >= retval )
447 *((FT_Short *)value) = type1->private_dict.other_blues[idx];
451 case PS_DICT_NUM_FAMILY_BLUES:
452 retval =
sizeof ( type1->private_dict.num_family_blues );
453 if ( value && value_len >= retval )
454 *((FT_Byte *)value) = type1->private_dict.num_family_blues;
457 case PS_DICT_FAMILY_BLUE:
458 if ( idx < type1->private_dict.num_family_blues )
460 retval =
sizeof ( type1->private_dict.family_blues[idx] );
461 if ( value && value_len >= retval )
462 *((FT_Short *)value) = type1->private_dict.family_blues[idx];
466 case PS_DICT_NUM_FAMILY_OTHER_BLUES:
467 retval =
sizeof ( type1->private_dict.num_family_other_blues );
468 if ( value && value_len >= retval )
469 *((FT_Byte *)value) = type1->private_dict.num_family_other_blues;
472 case PS_DICT_FAMILY_OTHER_BLUE:
473 if ( idx < type1->private_dict.num_family_other_blues )
475 retval =
sizeof ( type1->private_dict.family_other_blues[idx] );
476 if ( value && value_len >= retval )
477 *((FT_Short *)value) = type1->private_dict.family_other_blues[idx];
481 case PS_DICT_NUM_STEM_SNAP_H:
482 retval =
sizeof ( type1->private_dict.num_snap_widths );
483 if ( value && value_len >= retval )
484 *((FT_Byte *)value) = type1->private_dict.num_snap_widths;
487 case PS_DICT_STEM_SNAP_H:
488 if ( idx < type1->private_dict.num_snap_widths )
490 retval =
sizeof ( type1->private_dict.snap_widths[idx] );
491 if ( value && value_len >= retval )
492 *((FT_Short *)value) = type1->private_dict.snap_widths[idx];
496 case PS_DICT_NUM_STEM_SNAP_V:
497 retval =
sizeof ( type1->private_dict.num_snap_heights );
498 if ( value && value_len >= retval )
499 *((FT_Byte *)value) = type1->private_dict.num_snap_heights;
502 case PS_DICT_STEM_SNAP_V:
503 if ( idx < type1->private_dict.num_snap_heights )
505 retval =
sizeof ( type1->private_dict.snap_heights[idx] );
506 if ( value && value_len >= retval )
507 *((FT_Short *)value) = type1->private_dict.snap_heights[idx];
511 case PS_DICT_RND_STEM_UP:
512 retval =
sizeof ( type1->private_dict.round_stem_up );
513 if ( value && value_len >= retval )
514 *((FT_Bool *)value) = type1->private_dict.round_stem_up;
517 case PS_DICT_FORCE_BOLD:
518 retval =
sizeof ( type1->private_dict.force_bold );
519 if ( value && value_len >= retval )
520 *((FT_Bool *)value) = type1->private_dict.force_bold;
523 case PS_DICT_MIN_FEATURE:
524 if ( idx <
sizeof ( type1->private_dict.min_feature ) /
525 sizeof ( type1->private_dict.min_feature[0] ) )
527 retval =
sizeof ( type1->private_dict.min_feature[idx] );
528 if ( value && value_len >= retval )
529 *((FT_Short *)value) = type1->private_dict.min_feature[idx];
534 retval =
sizeof ( type1->private_dict.lenIV );
535 if ( value && value_len >= retval )
536 *((FT_Int *)value) = type1->private_dict.lenIV;
539 case PS_DICT_PASSWORD:
540 retval =
sizeof ( type1->private_dict.password );
541 if ( value && value_len >= retval )
542 *((FT_Long *)value) = type1->private_dict.password;
545 case PS_DICT_LANGUAGE_GROUP:
546 retval =
sizeof ( type1->private_dict.language_group );
547 if ( value && value_len >= retval )
548 *((FT_Long *)value) = type1->private_dict.language_group;
551 case PS_DICT_IS_FIXED_PITCH:
552 retval =
sizeof ( type1->font_info.is_fixed_pitch );
553 if ( value && value_len >= retval )
554 *((FT_Bool *)value) = type1->font_info.is_fixed_pitch;
557 case PS_DICT_UNDERLINE_POSITION:
558 retval =
sizeof ( type1->font_info.underline_position );
559 if ( value && value_len >= retval )
560 *((FT_Short *)value) = type1->font_info.underline_position;
563 case PS_DICT_UNDERLINE_THICKNESS:
564 retval =
sizeof ( type1->font_info.underline_thickness );
565 if ( value && value_len >= retval )
566 *((FT_UShort *)value) = type1->font_info.underline_thickness;
569 case PS_DICT_FS_TYPE:
570 retval =
sizeof ( type1->font_extra.fs_type );
571 if ( value && value_len >= retval )
572 *((FT_UShort *)value) = type1->font_extra.fs_type;
575 case PS_DICT_VERSION:
576 if ( type1->font_info.version )
578 retval = ft_strlen( type1->font_info.version ) + 1;
579 if ( value && value_len >= retval )
580 ft_memcpy( value, (
void *)( type1->font_info.version ), retval );
585 if ( type1->font_info.notice )
587 retval = ft_strlen( type1->font_info.notice ) + 1;
588 if ( value && value_len >= retval )
589 ft_memcpy( value, (
void *)( type1->font_info.notice ), retval );
593 case PS_DICT_FULL_NAME:
594 if ( type1->font_info.full_name )
596 retval = ft_strlen( type1->font_info.full_name ) + 1;
597 if ( value && value_len >= retval )
598 ft_memcpy( value, (
void *)( type1->font_info.full_name ), retval );
602 case PS_DICT_FAMILY_NAME:
603 if ( type1->font_info.family_name )
605 retval = ft_strlen( type1->font_info.family_name ) + 1;
606 if ( value && value_len >= retval )
607 ft_memcpy( value, (
void *)( type1->font_info.family_name ),
613 if ( type1->font_info.weight )
615 retval = ft_strlen( type1->font_info.weight ) + 1;
616 if ( value && value_len >= retval )
617 ft_memcpy( value, (
void *)( type1->font_info.weight ), retval );
621 case PS_DICT_ITALIC_ANGLE:
622 retval =
sizeof ( type1->font_info.italic_angle );
623 if ( value && value_len >= retval )
624 *((FT_Long *)value) = type1->font_info.italic_angle;
628 return retval == 0 ? -1 : (FT_Long)retval;
632 static const FT_Service_PsInfoRec t1_service_ps_info =
635 t1_ps_get_font_extra,
636 t1_ps_has_glyph_names,
637 t1_ps_get_font_private,
638 t1_ps_get_font_value,
642#ifndef T1_CONFIG_OPTION_NO_AFM
643 static const FT_Service_KerningRec t1_service_kerning =
645 T1_Get_Track_Kerning,
655 FT_DEFINE_SERVICE_PROPERTIESREC(
656 t1_service_properties,
667 static const FT_ServiceDescRec t1_services[] =
669 { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t1_service_ps_name },
670 { FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict },
671 { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TYPE_1 },
672 { FT_SERVICE_ID_POSTSCRIPT_INFO, &t1_service_ps_info },
673 { FT_SERVICE_ID_PROPERTIES, &t1_service_properties },
675#ifndef T1_CONFIG_OPTION_NO_AFM
676 { FT_SERVICE_ID_KERNING, &t1_service_kerning },
679#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
680 { FT_SERVICE_ID_MULTI_MASTERS, &t1_service_multi_masters },
686 FT_CALLBACK_DEF( FT_Module_Interface )
687 Get_Interface( FT_Module module,
688 const FT_String* t1_interface )
692 return ft_service_list_lookup( t1_services, t1_interface );
696#ifndef T1_CONFIG_OPTION_NO_AFM
735 Get_Kerning( FT_Face t1face,
740 T1_Face face = (T1_Face)t1face;
746 if ( face->afm_data )
747 T1_Get_Kerning( (AFM_FontInfo)face->afm_data,
759 FT_CALLBACK_TABLE_DEF
760 const FT_Driver_ClassRec t1_driver_class =
763 FT_MODULE_FONT_DRIVER |
764 FT_MODULE_DRIVER_SCALABLE |
765 FT_MODULE_DRIVER_HAS_HINTER,
767 sizeof ( PS_DriverRec ),
780 sizeof ( T1_FaceRec ),
781 sizeof ( T1_SizeRec ),
782 sizeof ( T1_GlyphSlotRec ),
793#ifdef T1_CONFIG_OPTION_NO_AFM