1 /***************************************************************************/
5 /* Mac FOND support. Written by just@letterror.com. */
6 /* Heavily modified by mpsuzuki, George Williams, and Sean McBride. */
8 /* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */
9 /* classic platforms built by MPW. */
11 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
12 /* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */
14 /* This file is part of the FreeType project, and may only be used, */
15 /* modified, and distributed under the terms of the FreeType project */
16 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
17 /* this file you indicate that you have read the license and */
18 /* understand and accept it fully. */
20 /***************************************************************************/
26 Mac suitcase files can (and often do!) contain multiple fonts. To
27 support this I use the face_index argument of FT_(Open|New)_Face()
28 functions, and pretend the suitcase file is a collection.
30 Warning: fbit and NFNT bitmap resources are not supported yet. In old
31 sfnt fonts, bitmap glyph data for each size is stored in each `NFNT'
32 resources instead of the `bdat' table in the sfnt resource. Therefore,
33 face->num_fixed_sizes is set to 0, because bitmap data in `NFNT'
34 resource is unavailable at present.
36 The Mac FOND support works roughly like this:
38 - Check whether the offered stream points to a Mac suitcase file. This
39 is done by checking the file type: it has to be 'FFIL' or 'tfil'. The
40 stream that gets passed to our init_face() routine is a stdio stream,
41 which isn't usable for us, since the FOND resources live in the
42 resource fork. So we just grab the stream->pathname field.
44 - Read the FOND resource into memory, then check whether there is a
45 TrueType font and/or(!) a Type 1 font available.
47 - If there is a Type 1 font available (as a separate `LWFN' file), read
48 its data into memory, massage it slightly so it becomes PFB data, wrap
49 it into a memory stream, load the Type 1 driver and delegate the rest
50 of the work to it by calling FT_Open_Face(). (XXX TODO: after this
51 has been done, the kerning data from the FOND resource should be
52 appended to the face: On the Mac there are usually no AFM files
53 available. However, this is tricky since we need to map Mac char
54 codes to ps glyph names to glyph ID's...)
56 - If there is a TrueType font (an `sfnt' resource), read it into memory,
57 wrap it into a memory stream, load the TrueType driver and delegate
58 the rest of the work to it, by calling FT_Open_Face().
60 - Some suitcase fonts (notably Onyx) might point the `LWFN' file to
61 itself, even though it doesn't contains `POST' resources. To handle
62 this special case without opening the file an extra time, we just
63 ignore errors from the `LWFN' and fallback to the `sfnt' if both are
69 #include FT_FREETYPE_H
70 #include FT_INTERNAL_STREAM_H
72 /* This is for Mac OS X. Without redefinition, OS_INLINE */
73 /* expands to `static inline' which doesn't survive the */
74 /* -ansi compilation flag of GCC. */
76 #define OS_INLINE static __inline__
77 #include <Carbon/Carbon.h>
79 #ifndef HFS_MAXPATHLEN
80 #define HFS_MAXPATHLEN 1024
86 /* undefine blocking-macros in ftmac.h */
87 #undef FT_GetFile_From_Mac_Name( a, b, c )
88 #undef FT_GetFile_From_Mac_ATS_Name( a, b, c )
89 #undef FT_New_Face_From_FSSpec( a, b, c, d )
92 /* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
93 TrueType in case *both* are available (this is not common,
94 but it *is* possible). */
100 FT_EXPORT_DEF( FT_Error
)
101 FT_GetFile_From_Mac_Name( const char* fontName
,
103 FT_Long
* face_index
)
105 return FT_Err_Unimplemented_Feature
;
109 FT_EXPORT_DEF( FT_Error
)
110 FT_GetFile_From_Mac_ATS_Name( const char* fontName
,
112 FT_Long
* face_index
)
114 CFStringRef cf_fontName
;
115 ATSFontRef ats_font_id
;
120 cf_fontName
= CFStringCreateWithCString( NULL
, fontName
,
121 kCFStringEncodingMacRoman
);
122 ats_font_id
= ATSFontFindFromName( cf_fontName
,
123 kATSOptionFlagsUnRestrictedScope
);
125 if ( ats_font_id
== 0 || ats_font_id
== 0xFFFFFFFFUL
)
126 return FT_Err_Unknown_File_Format
;
128 if ( 0 != ATSFontGetFileSpecification( ats_font_id
, pathSpec
) )
129 return FT_Err_Unknown_File_Format
;
131 /* face_index calculation by searching preceding fontIDs */
132 /* with same FSRef */
138 for ( i
= 1; i
< ats_font_id
; i
++ )
140 if ( 0 != ATSFontGetFileSpecification( ats_font_id
- i
,
142 f
.vRefNum
!= pathSpec
->vRefNum
||
143 f
.parID
!= pathSpec
->parID
||
144 f
.name
[0] != pathSpec
->name
[0] ||
145 0 != ft_strncmp( (char *)f
.name
+ 1,
146 (char *)pathSpec
->name
+ 1,
150 *face_index
= ( i
- 1 );
157 FT_FSPathMakeRes( const UInt8
* pathname
,
164 if ( noErr
!= FSPathMakeRef( pathname
, &ref
, FALSE
) )
165 return FT_Err_Cannot_Open_Resource
;
167 /* at present, no support for dfont format */
168 err
= FSOpenResourceFile( &ref
, 0, NULL
, fsRdPerm
, res
);
172 /* fallback to original resource-fork font */
173 *res
= FSOpenResFile( &ref
, fsRdPerm
);
180 /* Return the file type for given pathname */
182 get_file_type_from_path( const UInt8
* pathname
)
188 if ( noErr
!= FSPathMakeRef( pathname
, &ref
, FALSE
) )
191 if ( noErr
!= FSGetCatalogInfo( &ref
, kFSCatInfoFinderInfo
, &info
,
195 return ((FInfo
*)(info
.finderInfo
))->fdType
;
199 /* Given a PostScript font name, create the Macintosh LWFN file name. */
201 create_lwfn_name( char* ps_name
,
202 Str255 lwfn_file_name
)
204 int max
= 5, count
= 0;
205 FT_Byte
* p
= lwfn_file_name
;
206 FT_Byte
* q
= (FT_Byte
*)ps_name
;
209 lwfn_file_name
[0] = 0;
213 if ( ft_isupper( *q
) )
219 if ( count
< max
&& ( ft_isalnum( *q
) || *q
== '_' ) )
231 count_faces_sfnt( char* fond_data
)
233 /* The count is 1 greater than the value in the FOND. */
234 /* Isn't that cute? :-) */
236 return EndianS16_BtoN( *( (short*)( fond_data
+
237 sizeof ( FamRec
) ) ) ) + 1;
242 count_faces_scalable( char* fond_data
)
246 short i
, face
, face_all
;
249 fond
= (FamRec
*)fond_data
;
250 face_all
= EndianS16_BtoN( *( (short *)( fond_data
+
251 sizeof ( FamRec
) ) ) ) + 1;
252 assoc
= (AsscEntry
*)( fond_data
+ sizeof ( FamRec
) + 2 );
255 for ( i
= 0; i
< face_all
; i
++ )
257 if ( 0 == EndianS16_BtoN( assoc
[i
].fontSize
) )
264 /* Look inside the FOND data, answer whether there should be an SFNT
265 resource, and answer the name of a possible LWFN Type 1 file.
267 Thanks to Paul Miller (paulm@profoundeffects.com) for the fix
268 to load a face OTHER than the first one in the FOND!
273 parse_fond( char* fond_data
,
276 Str255 lwfn_file_name
,
280 AsscEntry
* base_assoc
;
286 lwfn_file_name
[0] = 0;
288 fond
= (FamRec
*)fond_data
;
289 assoc
= (AsscEntry
*)( fond_data
+ sizeof ( FamRec
) + 2 );
292 /* Let's do a little range checking before we get too excited here */
293 if ( face_index
< count_faces_sfnt( fond_data
) )
295 assoc
+= face_index
; /* add on the face_index! */
297 /* if the face at this index is not scalable,
298 fall back to the first one (old behavior) */
299 if ( EndianS16_BtoN( assoc
->fontSize
) == 0 )
302 *sfnt_id
= EndianS16_BtoN( assoc
->fontID
);
304 else if ( base_assoc
->fontSize
== 0 )
307 *sfnt_id
= EndianS16_BtoN( base_assoc
->fontID
);
311 if ( EndianS32_BtoN( fond
->ffStylOff
) )
313 unsigned char* p
= (unsigned char*)fond_data
;
315 unsigned short string_count
;
317 unsigned char* names
[64];
321 p
+= EndianS32_BtoN( fond
->ffStylOff
);
322 style
= (StyleTable
*)p
;
323 p
+= sizeof ( StyleTable
);
324 string_count
= EndianS16_BtoN( *(short*)(p
) );
325 p
+= sizeof ( short );
327 for ( i
= 0; i
< string_count
&& i
< 64; i
++ )
335 size_t ps_name_len
= (size_t)names
[0][0];
338 if ( ps_name_len
!= 0 )
340 ft_memcpy(ps_name
, names
[0] + 1, ps_name_len
);
341 ps_name
[ps_name_len
] = 0;
343 if ( style
->indexes
[0] > 1 )
345 unsigned char* suffixes
= names
[style
->indexes
[0] - 1];
348 for ( i
= 1; i
<= suffixes
[0]; i
++ )
351 size_t j
= suffixes
[i
] - 1;
354 if ( j
< string_count
&& ( s
= names
[j
] ) != NULL
)
356 size_t s_len
= (size_t)s
[0];
359 if ( s_len
!= 0 && ps_name_len
+ s_len
< sizeof ( ps_name
) )
361 ft_memcpy( ps_name
+ ps_name_len
, s
+ 1, s_len
);
362 ps_name_len
+= s_len
;
363 ps_name
[ps_name_len
] = 0;
370 create_lwfn_name( ps_name
, lwfn_file_name
);
376 lookup_lwfn_by_fond( const UInt8
* path_fond
,
377 const StringPtr base_lwfn
,
385 /* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
386 /* We should not extract parent directory by string manipulation. */
388 if ( noErr
!= FSPathMakeRef( path_fond
, &ref
, FALSE
) )
389 return FT_Err_Invalid_Argument
;
391 if ( noErr
!= FSGetCatalogInfo( &ref
, kFSCatInfoNone
,
392 NULL
, NULL
, NULL
, &par_ref
) )
393 return FT_Err_Invalid_Argument
;
395 if ( noErr
!= FSRefMakePath( &par_ref
, path_lwfn
, path_size
) )
396 return FT_Err_Invalid_Argument
;
398 if ( ft_strlen( (char *)path_lwfn
) + 1 + base_lwfn
[0] > path_size
)
399 return FT_Err_Invalid_Argument
;
401 /* now we have absolute dirname in lookup_path */
402 if ( path_lwfn
[0] == '/' )
403 ft_strcat( (char *)path_lwfn
, "/" );
405 ft_strcat( (char *)path_lwfn
, ":" );
407 dirname_len
= ft_strlen( (char *)path_lwfn
);
408 ft_strcat( (char *)path_lwfn
, (char *)base_lwfn
+ 1 );
409 path_lwfn
[dirname_len
+ base_lwfn
[0]] = '\0';
411 if ( noErr
!= FSPathMakeRef( path_lwfn
, &ref
, FALSE
) )
412 return FT_Err_Cannot_Open_Resource
;
414 if ( noErr
!= FSGetCatalogInfo( &ref
, kFSCatInfoNone
,
415 NULL
, NULL
, NULL
, NULL
) )
416 return FT_Err_Cannot_Open_Resource
;
423 count_faces( Handle fond
,
424 const UInt8
* pathname
)
427 short have_sfnt
, have_lwfn
;
428 Str255 lwfn_file_name
;
429 UInt8 buff
[HFS_MAXPATHLEN
];
434 have_sfnt
= have_lwfn
= 0;
437 parse_fond( *fond
, &have_sfnt
, &sfnt_id
, lwfn_file_name
, 0 );
439 if ( lwfn_file_name
[0] )
441 err
= lookup_lwfn_by_fond( pathname
, lwfn_file_name
,
442 buff
, sizeof ( buff
) );
443 if ( FT_Err_Ok
== err
)
447 if ( have_lwfn
&& ( !have_sfnt
|| PREFER_LWFN
) )
450 num_faces
= count_faces_scalable( *fond
);
457 /* Read Type 1 data from the POST resources inside the LWFN file,
458 return a PFB buffer. This is somewhat convoluted because the FT2
459 PFB parser wants the ASCII header as one chunk, and the LWFN
460 chunks are often not organized that way, so we glue chunks
461 of the same type together. */
463 read_lwfn( FT_Memory memory
,
468 FT_Error error
= FT_Err_Ok
;
470 unsigned char *buffer
, *p
, *size_p
= NULL
;
471 FT_ULong total_size
= 0;
472 FT_ULong old_total_size
= 0;
473 FT_ULong post_size
, pfb_chunk_size
;
475 char code
, last_code
;
480 /* First pass: load all POST resources, and determine the size of */
481 /* the output buffer. */
487 post_data
= Get1Resource( 'POST', res_id
++ );
488 if ( post_data
== NULL
)
489 break; /* we are done */
491 code
= (*post_data
)[0];
493 if ( code
!= last_code
)
496 total_size
+= 2; /* just the end code */
498 total_size
+= 6; /* code + 4 bytes chunk length */
501 total_size
+= GetHandleSize( post_data
) - 2;
504 /* detect integer overflows */
505 if ( total_size
< old_total_size
)
507 error
= FT_Err_Array_Too_Large
;
511 old_total_size
= total_size
;
514 if ( FT_ALLOC( buffer
, (FT_Long
)total_size
) )
517 /* Second pass: append all POST data to the buffer, add PFB fields. */
518 /* Glue all consecutive chunks of the same type together. */
526 post_data
= Get1Resource( 'POST', res_id
++ );
527 if ( post_data
== NULL
)
528 break; /* we are done */
530 post_size
= (FT_ULong
)GetHandleSize( post_data
) - 2;
531 code
= (*post_data
)[0];
533 if ( code
!= last_code
)
535 if ( last_code
!= -1 )
537 /* we are done adding a chunk, fill in the size field */
538 if ( size_p
!= NULL
)
540 *size_p
++ = (FT_Byte
)( pfb_chunk_size
& 0xFF );
541 *size_p
++ = (FT_Byte
)( ( pfb_chunk_size
>> 8 ) & 0xFF );
542 *size_p
++ = (FT_Byte
)( ( pfb_chunk_size
>> 16 ) & 0xFF );
543 *size_p
++ = (FT_Byte
)( ( pfb_chunk_size
>> 24 ) & 0xFF );
550 *p
++ = 0x03; /* the end */
551 else if ( code
== 2 )
552 *p
++ = 0x02; /* binary segment */
554 *p
++ = 0x01; /* ASCII segment */
558 size_p
= p
; /* save for later */
559 p
+= 4; /* make space for size field */
563 ft_memcpy( p
, *post_data
+ 2, post_size
);
564 pfb_chunk_size
+= post_size
;
578 /* Finalizer for a memory stream; gets called by FT_Done_Face().
579 It frees the memory it uses. */
581 memory_stream_close( FT_Stream stream
)
583 FT_Memory memory
= stream
->memory
;
586 FT_FREE( stream
->base
);
594 /* Create a new memory stream from a buffer and a size. */
596 new_memory_stream( FT_Library library
,
599 FT_Stream_CloseFunc close
,
608 return FT_Err_Invalid_Library_Handle
;
611 return FT_Err_Invalid_Argument
;
614 memory
= library
->memory
;
615 if ( FT_NEW( stream
) )
618 FT_Stream_OpenMemory( stream
, base
, size
);
620 stream
->close
= close
;
629 /* Create a new FT_Face given a buffer and a driver name. */
631 open_face_from_buffer( FT_Library library
,
641 FT_Memory memory
= library
->memory
;
644 error
= new_memory_stream( library
,
655 args
.flags
= FT_OPEN_STREAM
;
656 args
.stream
= stream
;
659 args
.flags
= args
.flags
| FT_OPEN_DRIVER
;
660 args
.driver
= FT_Get_Module( library
, driver_name
);
663 /* At this point, face_index has served its purpose; */
664 /* whoever calls this function has already used it to */
665 /* locate the correct font data. We should not propagate */
666 /* this index to FT_Open_Face() (unless it is negative). */
668 if ( face_index
> 0 )
671 error
= FT_Open_Face( library
, &args
, face_index
, aface
);
672 if ( error
== FT_Err_Ok
)
673 (*aface
)->face_flags
&= ~FT_FACE_FLAG_EXTERNAL_STREAM
;
675 FT_Stream_Free( stream
, 0 );
681 /* Create a new FT_Face from a file spec to an LWFN file. */
683 FT_New_Face_From_LWFN( FT_Library library
,
684 const UInt8
* pathname
,
694 if ( noErr
!= FT_FSPathMakeRes( pathname
, &res
) )
695 return FT_Err_Cannot_Open_Resource
;
699 error
= read_lwfn( library
->memory
, res
, &pfb_data
, &pfb_size
);
700 CloseResFile( res
); /* PFB is already loaded, useless anymore */
704 return open_face_from_buffer( library
,
713 /* Create a new FT_Face from an SFNT resource, specified by res ID. */
715 FT_New_Face_From_SFNT( FT_Library library
,
723 FT_Error error
= FT_Err_Ok
;
724 FT_Memory memory
= library
->memory
;
728 sfnt
= GetResource( 'sfnt', sfnt_id
);
730 return FT_Err_Invalid_Handle
;
732 sfnt_size
= (FT_ULong
)GetHandleSize( sfnt
);
733 if ( FT_ALLOC( sfnt_data
, (FT_Long
)sfnt_size
) )
735 ReleaseResource( sfnt
);
740 ft_memcpy( sfnt_data
, *sfnt
, sfnt_size
);
742 ReleaseResource( sfnt
);
744 is_cff
= sfnt_size
> 4 && sfnt_data
[0] == 'O' &&
745 sfnt_data
[1] == 'T' &&
746 sfnt_data
[2] == 'T' &&
749 return open_face_from_buffer( library
,
753 is_cff
? "cff" : "truetype",
758 /* Create a new FT_Face from a file spec to a suitcase file. */
760 FT_New_Face_From_Suitcase( FT_Library library
,
761 const UInt8
* pathname
,
765 FT_Error error
= FT_Err_Cannot_Open_Resource
;
766 short res_ref
, res_index
;
768 short num_faces_in_res
, num_faces_in_fond
;
771 if ( noErr
!= FT_FSPathMakeRes( pathname
, &res_ref
) )
772 return FT_Err_Cannot_Open_Resource
;
774 UseResFile( res_ref
);
776 return FT_Err_Cannot_Open_Resource
;
778 num_faces_in_res
= 0;
779 for ( res_index
= 1; ; ++res_index
)
781 fond
= Get1IndResource( 'FOND', res_index
);
785 num_faces_in_fond
= count_faces( fond
, pathname
);
786 num_faces_in_res
+= num_faces_in_fond
;
788 if ( 0 <= face_index
&& face_index
< num_faces_in_fond
&& error
)
789 error
= FT_New_Face_From_FOND( library
, fond
, face_index
, aface
);
791 face_index
-= num_faces_in_fond
;
794 CloseResFile( res_ref
);
795 if ( FT_Err_Ok
== error
&& NULL
!= aface
)
796 (*aface
)->num_faces
= num_faces_in_res
;
801 /* documentation is in ftmac.h */
803 FT_EXPORT_DEF( FT_Error
)
804 FT_New_Face_From_FOND( FT_Library library
,
809 short sfnt_id
, have_sfnt
, have_lwfn
= 0;
813 Str255 lwfn_file_name
;
814 UInt8 path_lwfn
[HFS_MAXPATHLEN
];
816 FT_Error error
= FT_Err_Ok
;
819 GetResInfo( fond
, &fond_id
, &fond_type
, fond_name
);
820 if ( ResError() != noErr
|| fond_type
!= 'FOND' )
821 return FT_Err_Invalid_File_Format
;
824 parse_fond( *fond
, &have_sfnt
, &sfnt_id
, lwfn_file_name
, face_index
);
827 if ( lwfn_file_name
[0] )
832 res
= HomeResFile( fond
);
833 if ( noErr
!= ResError() )
834 goto found_no_lwfn_file
;
837 UInt8 path_fond
[HFS_MAXPATHLEN
];
841 err
= FSGetForkCBInfo( res
, kFSInvalidVolumeRefNum
,
842 NULL
, NULL
, NULL
, &ref
, NULL
);
844 goto found_no_lwfn_file
;
846 err
= FSRefMakePath( &ref
, path_fond
, sizeof ( path_fond
) );
848 goto found_no_lwfn_file
;
850 error
= lookup_lwfn_by_fond( path_fond
, lwfn_file_name
,
851 path_lwfn
, sizeof ( path_lwfn
) );
852 if ( FT_Err_Ok
== error
)
857 if ( have_lwfn
&& ( !have_sfnt
|| PREFER_LWFN
) )
858 error
= FT_New_Face_From_LWFN( library
,
863 error
= FT_Err_Unknown_File_Format
;
866 if ( have_sfnt
&& FT_Err_Ok
!= error
)
867 error
= FT_New_Face_From_SFNT( library
,
876 /* Common function to load a new FT_Face from a resource file. */
878 FT_New_Face_From_Resource( FT_Library library
,
879 const UInt8
* pathname
,
887 /* LWFN is a (very) specific file format, check for it explicitly */
888 file_type
= get_file_type_from_path( pathname
);
889 if ( file_type
== 'LWFN' )
890 return FT_New_Face_From_LWFN( library
, pathname
, face_index
, aface
);
892 /* Otherwise the file type doesn't matter (there are more than */
893 /* `FFIL' and `tfil'). Just try opening it as a font suitcase; */
894 /* if it works, fine. */
896 error
= FT_New_Face_From_Suitcase( library
, pathname
, face_index
, aface
);
900 /* let it fall through to normal loader (.ttf, .otf, etc.); */
901 /* we signal this by returning no error and no FT_Face */
907 /*************************************************************************/
913 /* This is the Mac-specific implementation of FT_New_Face. In */
914 /* addition to the standard FT_New_Face() functionality, it also */
915 /* accepts pathnames to Mac suitcase files. For further */
916 /* documentation see the original FT_New_Face() in freetype.h. */
918 FT_EXPORT_DEF( FT_Error
)
919 FT_New_Face( FT_Library library
,
920 const char* pathname
,
928 /* test for valid `library' and `aface' delayed to FT_Open_Face() */
930 return FT_Err_Invalid_Argument
;
935 /* try resourcefork based font: LWFN, FFIL */
936 error
= FT_New_Face_From_Resource( library
, (UInt8
*)pathname
,
938 if ( error
!= 0 || *aface
!= NULL
)
941 /* let it fall through to normal loader (.ttf, .otf, etc.) */
942 args
.flags
= FT_OPEN_PATHNAME
;
943 args
.pathname
= (char*)pathname
;
944 return FT_Open_Face( library
, &args
, face_index
, aface
);
948 /*************************************************************************/
951 /* FT_New_Face_From_FSRef */
954 /* FT_New_Face_From_FSRef is identical to FT_New_Face except it */
955 /* accepts an FSRef instead of a path. */
957 FT_EXPORT_DEF( FT_Error
)
958 FT_New_Face_From_FSRef( FT_Library library
,
966 UInt8 pathname
[HFS_MAXPATHLEN
];
970 return FT_Err_Invalid_Argument
;
972 err
= FSRefMakePath( ref
, pathname
, sizeof ( pathname
) );
974 error
= FT_Err_Cannot_Open_Resource
;
976 error
= FT_New_Face_From_Resource( library
, pathname
, face_index
, aface
);
977 if ( error
!= 0 || *aface
!= NULL
)
980 /* fallback to datafork font */
981 args
.flags
= FT_OPEN_PATHNAME
;
982 args
.pathname
= (char*)pathname
;
983 return FT_Open_Face( library
, &args
, face_index
, aface
);
987 /*************************************************************************/
990 /* FT_New_Face_From_FSSpec */
993 /* FT_New_Face_From_FSSpec is identical to FT_New_Face except it */
994 /* accepts an FSSpec instead of a path. */
996 FT_EXPORT_DEF( FT_Error
)
997 FT_New_Face_From_FSSpec( FT_Library library
,
1005 if ( !spec
|| FSpMakeFSRef( spec
, &ref
) != noErr
)
1006 return FT_Err_Invalid_Argument
;
1008 return FT_New_Face_From_FSRef( library
, &ref
, face_index
, aface
);