1 /***************************************************************************/
5 /* OpenType objects manager (body). */
7 /* Copyright 1996-2011 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16 /***************************************************************************/
20 #include FT_INTERNAL_DEBUG_H
21 #include FT_INTERNAL_CALC_H
22 #include FT_INTERNAL_STREAM_H
24 #include FT_TRUETYPE_IDS_H
25 #include FT_TRUETYPE_TAGS_H
26 #include FT_INTERNAL_SFNT_H
34 /*************************************************************************/
36 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
37 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
38 /* messages during execution. */
41 #define FT_COMPONENT trace_cffobjs
44 /*************************************************************************/
48 /* Note that we store the global hints in the size's `internal' root */
51 /*************************************************************************/
54 static PSH_Globals_Funcs
55 cff_size_get_globals_funcs( CFF_Size size )
57 CFF_Face face = (CFF_Face)size->root.face;
58 CFF_Font font = (CFF_Font)face->extra.data;
59 PSHinter_Service pshinter = font->pshinter;
63 module = FT_Get_Module( size->root.face->driver->root.library,
65 return ( module && pshinter && pshinter->get_globals_funcs )
66 ? pshinter->get_globals_funcs( module )
72 cff_size_done( FT_Size cffsize ) /* CFF_Size */
74 CFF_Size size = (CFF_Size)cffsize;
75 CFF_Face face = (CFF_Face)size->root.face;
76 CFF_Font font = (CFF_Font)face->extra.data;
77 CFF_Internal internal = (CFF_Internal)cffsize->internal;
82 PSH_Globals_Funcs funcs;
85 funcs = cff_size_get_globals_funcs( size );
91 funcs->destroy( internal->topfont );
93 for ( i = font->num_subfonts; i > 0; i-- )
94 funcs->destroy( internal->subfonts[i - 1] );
97 /* `internal' is freed by destroy_size (in ftobjs.c) */
102 /* CFF and Type 1 private dictionaries have slightly different */
103 /* structures; we need to synthesize a Type 1 dictionary on the fly */
106 cff_make_private_dict( CFF_SubFont subfont,
109 CFF_Private cpriv = &subfont->private_dict;
113 FT_MEM_ZERO( priv, sizeof ( *priv ) );
115 count = priv->num_blue_values = cpriv->num_blue_values;
116 for ( n = 0; n < count; n++ )
117 priv->blue_values[n] = (FT_Short)cpriv->blue_values[n];
119 count = priv->num_other_blues = cpriv->num_other_blues;
120 for ( n = 0; n < count; n++ )
121 priv->other_blues[n] = (FT_Short)cpriv->other_blues[n];
123 count = priv->num_family_blues = cpriv->num_family_blues;
124 for ( n = 0; n < count; n++ )
125 priv->family_blues[n] = (FT_Short)cpriv->family_blues[n];
127 count = priv->num_family_other_blues = cpriv->num_family_other_blues;
128 for ( n = 0; n < count; n++ )
129 priv->family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n];
131 priv->blue_scale = cpriv->blue_scale;
132 priv->blue_shift = (FT_Int)cpriv->blue_shift;
133 priv->blue_fuzz = (FT_Int)cpriv->blue_fuzz;
135 priv->standard_width[0] = (FT_UShort)cpriv->standard_width;
136 priv->standard_height[0] = (FT_UShort)cpriv->standard_height;
138 count = priv->num_snap_widths = cpriv->num_snap_widths;
139 for ( n = 0; n < count; n++ )
140 priv->snap_widths[n] = (FT_Short)cpriv->snap_widths[n];
142 count = priv->num_snap_heights = cpriv->num_snap_heights;
143 for ( n = 0; n < count; n++ )
144 priv->snap_heights[n] = (FT_Short)cpriv->snap_heights[n];
146 priv->force_bold = cpriv->force_bold;
147 priv->language_group = cpriv->language_group;
148 priv->lenIV = cpriv->lenIV;
152 FT_LOCAL_DEF( FT_Error )
153 cff_size_init( FT_Size cffsize ) /* CFF_Size */
155 CFF_Size size = (CFF_Size)cffsize;
156 FT_Error error = CFF_Err_Ok;
157 PSH_Globals_Funcs funcs = cff_size_get_globals_funcs( size );
162 CFF_Face face = (CFF_Face)cffsize->face;
163 CFF_Font font = (CFF_Font)face->extra.data;
164 CFF_Internal internal = NULL;
167 FT_Memory memory = cffsize->face->memory;
172 if ( FT_NEW( internal ) )
175 cff_make_private_dict( &font->top_font, &priv );
176 error = funcs->create( cffsize->face->memory, &priv,
177 &internal->topfont );
181 for ( i = font->num_subfonts; i > 0; i-- )
183 CFF_SubFont sub = font->subfonts[i - 1];
186 cff_make_private_dict( sub, &priv );
187 error = funcs->create( cffsize->face->memory, &priv,
188 &internal->subfonts[i - 1] );
193 cffsize->internal = (FT_Size_Internal)(void*)internal;
196 size->strike_index = 0xFFFFFFFFUL;
203 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
205 FT_LOCAL_DEF( FT_Error )
206 cff_size_select( FT_Size size,
207 FT_ULong strike_index )
209 CFF_Size cffsize = (CFF_Size)size;
210 PSH_Globals_Funcs funcs;
213 cffsize->strike_index = strike_index;
215 FT_Select_Metrics( size->face, strike_index );
217 funcs = cff_size_get_globals_funcs( cffsize );
221 CFF_Face face = (CFF_Face)size->face;
222 CFF_Font font = (CFF_Font)face->extra.data;
223 CFF_Internal internal = (CFF_Internal)size->internal;
225 FT_ULong top_upm = font->top_font.font_dict.units_per_em;
229 funcs->set_scale( internal->topfont,
230 size->metrics.x_scale, size->metrics.y_scale,
233 for ( i = font->num_subfonts; i > 0; i-- )
235 CFF_SubFont sub = font->subfonts[i - 1];
236 FT_ULong sub_upm = sub->font_dict.units_per_em;
237 FT_Pos x_scale, y_scale;
240 if ( top_upm != sub_upm )
242 x_scale = FT_MulDiv( size->metrics.x_scale, top_upm, sub_upm );
243 y_scale = FT_MulDiv( size->metrics.y_scale, top_upm, sub_upm );
247 x_scale = size->metrics.x_scale;
248 y_scale = size->metrics.y_scale;
251 funcs->set_scale( internal->subfonts[i - 1],
252 x_scale, y_scale, 0, 0 );
259 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
262 FT_LOCAL_DEF( FT_Error )
263 cff_size_request( FT_Size size,
264 FT_Size_Request req )
266 CFF_Size cffsize = (CFF_Size)size;
267 PSH_Globals_Funcs funcs;
270 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
272 if ( FT_HAS_FIXED_SIZES( size->face ) )
274 CFF_Face cffface = (CFF_Face)size->face;
275 SFNT_Service sfnt = (SFNT_Service)cffface->sfnt;
276 FT_ULong strike_index;
279 if ( sfnt->set_sbit_strike( cffface, req, &strike_index ) )
280 cffsize->strike_index = 0xFFFFFFFFUL;
282 return cff_size_select( size, strike_index );
285 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
287 FT_Request_Metrics( size->face, req );
289 funcs = cff_size_get_globals_funcs( cffsize );
293 CFF_Face cffface = (CFF_Face)size->face;
294 CFF_Font font = (CFF_Font)cffface->extra.data;
295 CFF_Internal internal = (CFF_Internal)size->internal;
297 FT_ULong top_upm = font->top_font.font_dict.units_per_em;
301 funcs->set_scale( internal->topfont,
302 size->metrics.x_scale, size->metrics.y_scale,
305 for ( i = font->num_subfonts; i > 0; i-- )
307 CFF_SubFont sub = font->subfonts[i - 1];
308 FT_ULong sub_upm = sub->font_dict.units_per_em;
309 FT_Pos x_scale, y_scale;
312 if ( top_upm != sub_upm )
314 x_scale = FT_MulDiv( size->metrics.x_scale, top_upm, sub_upm );
315 y_scale = FT_MulDiv( size->metrics.y_scale, top_upm, sub_upm );
319 x_scale = size->metrics.x_scale;
320 y_scale = size->metrics.y_scale;
323 funcs->set_scale( internal->subfonts[i - 1],
324 x_scale, y_scale, 0, 0 );
332 /*************************************************************************/
336 /*************************************************************************/
339 cff_slot_done( FT_GlyphSlot slot )
341 slot->internal->glyph_hints = 0;
345 FT_LOCAL_DEF( FT_Error )
346 cff_slot_init( FT_GlyphSlot slot )
348 CFF_Face face = (CFF_Face)slot->face;
349 CFF_Font font = (CFF_Font)face->extra.data;
350 PSHinter_Service pshinter = font->pshinter;
358 module = FT_Get_Module( slot->face->driver->root.library,
362 T2_Hints_Funcs funcs;
365 funcs = pshinter->get_t2_funcs( module );
366 slot->internal->glyph_hints = (void*)funcs;
374 /*************************************************************************/
378 /*************************************************************************/
381 cff_strcpy( FT_Memory memory,
382 const FT_String* source )
388 (void)FT_STRDUP( result, source );
396 /* Strip all subset prefixes of the form `ABCDEF+'. Usually, there */
397 /* is only one, but font names like `APCOOG+JFABTD+FuturaBQ-Bold' */
398 /* have been seen in the wild. */
401 remove_subset_prefix( FT_String* name )
404 FT_Int32 length = strlen( name ) + 1;
405 FT_Bool continue_search = 1;
408 while ( continue_search )
410 if ( length >= 7 && name[6] == '+' )
412 for ( idx = 0; idx < 6; idx++ )
414 /* ASCII uppercase letters */
415 if ( !( 'A' <= name[idx] && name[idx] <= 'Z' ) )
419 if ( continue_search )
421 for ( idx = 7; idx < length; idx++ )
422 name[idx - 7] = name[idx];
432 /* Remove the style part from the family name (if present). */
435 remove_style( FT_String* family_name,
436 const FT_String* style_name )
438 FT_Int32 family_name_length, style_name_length;
441 family_name_length = strlen( family_name );
442 style_name_length = strlen( style_name );
444 if ( family_name_length > style_name_length )
449 for ( idx = 1; idx <= style_name_length; ++idx )
451 if ( family_name[family_name_length - idx] !=
452 style_name[style_name_length - idx] )
456 if ( idx > style_name_length )
458 /* family_name ends with style_name; remove it */
459 idx = family_name_length - style_name_length - 1;
461 /* also remove special characters */
462 /* between real family name and style */
464 ( family_name[idx] == '-' ||
465 family_name[idx] == ' ' ||
466 family_name[idx] == '_' ||
467 family_name[idx] == '+' ) )
471 family_name[idx + 1] = '\0';
477 FT_LOCAL_DEF( FT_Error )
478 cff_face_init( FT_Stream stream,
479 FT_Face cffface, /* CFF_Face */
482 FT_Parameter* params )
484 CFF_Face face = (CFF_Face)cffface;
487 FT_Service_PsCMaps psnames;
488 PSHinter_Service pshinter;
489 FT_Bool pure_cff = 1;
490 FT_Bool sfnt_format = 0;
491 FT_Library library = cffface->driver->root.library;
494 sfnt = (SFNT_Service)FT_Get_Module_Interface(
499 FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
501 pshinter = (PSHinter_Service)FT_Get_Module_Interface(
502 library, "pshinter" );
504 /* create input stream from resource */
505 if ( FT_STREAM_SEEK( 0 ) )
508 /* check whether we have a valid OpenType file */
509 error = sfnt->init_face( stream, face, face_index, num_params, params );
512 if ( face->format_tag != TTAG_OTTO ) /* `OTTO'; OpenType/CFF font */
514 FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
518 /* if we are performing a simple font format check, exit immediately */
519 if ( face_index < 0 )
522 /* UNDOCUMENTED! A CFF in an SFNT can have only a single font. */
523 if ( face_index > 0 )
525 FT_ERROR(( "cff_face_init: invalid face index\n" ));
526 error = CFF_Err_Invalid_Argument;
532 /* now, the font can be either an OpenType/CFF font, or an SVG CEF */
533 /* font; in the latter case it doesn't have a `head' table */
534 error = face->goto_table( face, TTAG_head, stream, 0 );
539 /* load font directory */
540 error = sfnt->load_face( stream, face, 0, num_params, params );
546 /* load the `cmap' table explicitly */
547 error = sfnt->load_cmap( face, stream );
551 /* XXX: we don't load the GPOS table, as OpenType Layout */
552 /* support will be added later to a layout library on top of */
556 /* now load the CFF part of the file */
557 error = face->goto_table( face, TTAG_CFF, stream, 0 );
563 /* rewind to start of file; we are going to load a pure-CFF font */
564 if ( FT_STREAM_SEEK( 0 ) )
569 /* now load and parse the CFF table in the file */
572 CFF_FontRecDict dict;
573 FT_Memory memory = cffface->memory;
581 face->extra.data = cff;
582 error = cff_font_load( library, stream, face_index, cff, pure_cff );
586 cff->pshinter = pshinter;
587 cff->psnames = psnames;
589 cffface->face_index = face_index;
591 /* Complement the root flags with some interesting information. */
592 /* Note that this is only necessary for pure CFF and CEF fonts; */
593 /* SFNT based fonts use the `name' table instead. */
595 cffface->num_glyphs = cff->num_glyphs;
597 dict = &cff->top_font.font_dict;
599 /* we need the `PSNames' module for CFF and CEF formats */
600 /* which aren't CID-keyed */
601 if ( dict->cid_registry == 0xFFFFU && !psnames )
603 FT_ERROR(( "cff_face_init:"
604 " cannot open CFF & CEF fonts\n"
606 " without the `PSNames' module\n" ));
610 #ifdef FT_DEBUG_LEVEL_TRACE
616 FT_TRACE4(( "SIDs\n" ));
618 /* dump string index, including default strings for convenience */
619 for ( idx = 0; idx < cff->num_strings + 390; idx++ )
621 s = cff_index_get_sid_string( cff, idx );
623 FT_TRACE4((" %5d %s\n", idx, s ));
626 #endif /* FT_DEBUG_LEVEL_TRACE */
628 if ( !dict->has_font_matrix )
629 dict->units_per_em = pure_cff ? 1000 : face->root.units_per_EM;
631 /* Normalize the font matrix so that `matrix->xx' is 1; the */
632 /* scaling is done with `units_per_em' then (at this point, */
633 /* it already contains the scaling factor, but without */
634 /* normalization of the matrix). */
636 /* Note that the offsets must be expressed in integer font */
640 FT_Matrix* matrix = &dict->font_matrix;
641 FT_Vector* offset = &dict->font_offset;
642 FT_ULong* upm = &dict->units_per_em;
643 FT_Fixed temp = FT_ABS( matrix->yy );
646 if ( temp != 0x10000L )
648 *upm = FT_DivFix( *upm, temp );
650 matrix->xx = FT_DivFix( matrix->xx, temp );
651 matrix->yx = FT_DivFix( matrix->yx, temp );
652 matrix->xy = FT_DivFix( matrix->xy, temp );
653 matrix->yy = FT_DivFix( matrix->yy, temp );
654 offset->x = FT_DivFix( offset->x, temp );
655 offset->y = FT_DivFix( offset->y, temp );
662 for ( i = cff->num_subfonts; i > 0; i-- )
664 CFF_FontRecDict sub = &cff->subfonts[i - 1]->font_dict;
665 CFF_FontRecDict top = &cff->top_font.font_dict;
673 if ( sub->has_font_matrix )
678 /* if we have a top-level matrix, */
679 /* concatenate the subfont matrix */
681 if ( top->has_font_matrix )
683 if ( top->units_per_em > 1 && sub->units_per_em > 1 )
684 scaling = FT_MIN( top->units_per_em, sub->units_per_em );
688 FT_Matrix_Multiply_Scaled( &top->font_matrix,
691 FT_Vector_Transform_Scaled( &sub->font_offset,
695 sub->units_per_em = FT_MulDiv( sub->units_per_em,
702 sub->font_matrix = top->font_matrix;
703 sub->font_offset = top->font_offset;
705 sub->units_per_em = top->units_per_em;
708 matrix = &sub->font_matrix;
709 offset = &sub->font_offset;
710 upm = &sub->units_per_em;
711 temp = FT_ABS( matrix->yy );
713 if ( temp != 0x10000L )
715 *upm = FT_DivFix( *upm, temp );
717 matrix->xx = FT_DivFix( matrix->xx, temp );
718 matrix->yx = FT_DivFix( matrix->yx, temp );
719 matrix->xy = FT_DivFix( matrix->xy, temp );
720 matrix->yy = FT_DivFix( matrix->yy, temp );
721 offset->x = FT_DivFix( offset->x, temp );
722 offset->y = FT_DivFix( offset->y, temp );
731 char* style_name = NULL;
734 /* set up num_faces */
735 cffface->num_faces = cff->num_faces;
737 /* compute number of glyphs */
738 if ( dict->cid_registry != 0xFFFFU )
739 cffface->num_glyphs = cff->charset.max_cid + 1;
741 cffface->num_glyphs = cff->charstrings_index.count;
743 /* set global bbox, as well as EM size */
744 cffface->bbox.xMin = dict->font_bbox.xMin >> 16;
745 cffface->bbox.yMin = dict->font_bbox.yMin >> 16;
746 /* no `U' suffix here to 0xFFFF! */
747 cffface->bbox.xMax = ( dict->font_bbox.xMax + 0xFFFF ) >> 16;
748 cffface->bbox.yMax = ( dict->font_bbox.yMax + 0xFFFF ) >> 16;
750 cffface->units_per_EM = (FT_UShort)( dict->units_per_em );
752 cffface->ascender = (FT_Short)( cffface->bbox.yMax );
753 cffface->descender = (FT_Short)( cffface->bbox.yMin );
755 cffface->height = (FT_Short)( ( cffface->units_per_EM * 12 ) / 10 );
756 if ( cffface->height < cffface->ascender - cffface->descender )
757 cffface->height = (FT_Short)( cffface->ascender - cffface->descender );
759 cffface->underline_position =
760 (FT_Short)( dict->underline_position >> 16 );
761 cffface->underline_thickness =
762 (FT_Short)( dict->underline_thickness >> 16 );
764 /* retrieve font family & style name */
765 cffface->family_name = cff_index_get_name( cff, face_index );
766 if ( cffface->family_name )
768 char* full = cff_index_get_sid_string( cff,
771 char* family = cffface->family_name;
772 char* family_name = NULL;
775 remove_subset_prefix( cffface->family_name );
777 if ( dict->family_name )
779 family_name = cff_index_get_sid_string( cff,
782 family = family_name;
785 /* We try to extract the style name from the full name. */
786 /* We need to ignore spaces and dashes during the search. */
787 if ( full && family )
791 /* skip common characters at the start of both strings */
792 if ( *fullp == *family )
799 /* ignore spaces and dashes in full name during comparison */
800 if ( *fullp == ' ' || *fullp == '-' )
806 /* ignore spaces and dashes in family name during comparison */
807 if ( *family == ' ' || *family == '-' )
813 if ( !*family && *fullp )
815 /* The full name begins with the same characters as the */
816 /* family name, with spaces and dashes removed. In this */
817 /* case, the remaining string in `fullp' will be used as */
818 /* the style name. */
819 style_name = cff_strcpy( memory, fullp );
821 /* remove the style part from the family name (if present) */
822 remove_style( cffface->family_name, style_name );
830 char *cid_font_name =
831 cff_index_get_sid_string( cff,
832 dict->cid_font_name );
835 /* do we have a `/FontName' for a CID-keyed font? */
837 cffface->family_name = cff_strcpy( memory, cid_font_name );
841 cffface->style_name = style_name;
843 /* assume "Regular" style if we don't know better */
844 cffface->style_name = cff_strcpy( memory, (char *)"Regular" );
846 /*******************************************************************/
848 /* Compute face flags. */
850 flags = (FT_UInt32)( FT_FACE_FLAG_SCALABLE | /* scalable outlines */
851 FT_FACE_FLAG_HORIZONTAL | /* horizontal data */
852 FT_FACE_FLAG_HINTER ); /* has native hinter */
855 flags |= (FT_UInt32)FT_FACE_FLAG_SFNT;
857 /* fixed width font? */
858 if ( dict->is_fixed_pitch )
859 flags |= (FT_UInt32)FT_FACE_FLAG_FIXED_WIDTH;
861 /* XXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */
863 /* kerning available? */
864 if ( face->kern_pairs )
865 flags |= (FT_UInt32)FT_FACE_FLAG_KERNING;
868 cffface->face_flags = flags;
870 /*******************************************************************/
872 /* Compute style flags. */
876 if ( dict->italic_angle )
877 flags |= FT_STYLE_FLAG_ITALIC;
880 char *weight = cff_index_get_sid_string( cff,
885 if ( !ft_strcmp( weight, "Bold" ) ||
886 !ft_strcmp( weight, "Black" ) )
887 flags |= FT_STYLE_FLAG_BOLD;
891 if ( !(flags & FT_STYLE_FLAG_BOLD) && cffface->style_name )
892 if ( !ft_strncmp( cffface->style_name, "Bold", 4 ) ||
893 !ft_strncmp( cffface->style_name, "Black", 5 ) )
894 flags |= FT_STYLE_FLAG_BOLD;
896 cffface->style_flags = flags;
900 #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
901 /* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */
902 /* has unset this flag because of the 3.0 `post' table. */
903 if ( dict->cid_registry == 0xFFFFU )
904 cffface->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
907 if ( dict->cid_registry != 0xFFFFU && pure_cff )
908 cffface->face_flags |= FT_FACE_FLAG_CID_KEYED;
911 /*******************************************************************/
913 /* Compute char maps. */
916 /* Try to synthesize a Unicode charmap if there is none available */
917 /* already. If an OpenType font contains a Unicode "cmap", we */
918 /* will use it, whatever be in the CFF part of the file. */
920 FT_CharMapRec cmaprec;
923 CFF_Encoding encoding = &cff->encoding;
926 for ( nn = 0; nn < (FT_UInt)cffface->num_charmaps; nn++ )
928 cmap = cffface->charmaps[nn];
930 /* Windows Unicode? */
931 if ( cmap->platform_id == TT_PLATFORM_MICROSOFT &&
932 cmap->encoding_id == TT_MS_ID_UNICODE_CS )
935 /* Apple Unicode platform id? */
936 if ( cmap->platform_id == TT_PLATFORM_APPLE_UNICODE )
937 goto Skip_Unicode; /* Apple Unicode */
940 /* since CID-keyed fonts don't contain glyph names, we can't */
941 /* construct a cmap */
942 if ( pure_cff && cff->top_font.font_dict.cid_registry != 0xFFFFU )
945 #ifdef FT_MAX_CHARMAP_CACHEABLE
946 if ( nn + 1 > FT_MAX_CHARMAP_CACHEABLE )
948 FT_ERROR(( "cff_face_init: no Unicode cmap is found, "
949 "and too many subtables (%d) to add synthesized cmap\n",
955 /* we didn't find a Unicode charmap -- synthesize one */
956 cmaprec.face = cffface;
957 cmaprec.platform_id = TT_PLATFORM_MICROSOFT;
958 cmaprec.encoding_id = TT_MS_ID_UNICODE_CS;
959 cmaprec.encoding = FT_ENCODING_UNICODE;
961 nn = (FT_UInt)cffface->num_charmaps;
963 error = FT_CMap_New( &FT_CFF_CMAP_UNICODE_CLASS_REC_GET, NULL,
965 if ( error && FT_Err_No_Unicode_Glyph_Name != error )
969 /* if no Unicode charmap was previously selected, select this one */
970 if ( cffface->charmap == NULL && nn != (FT_UInt)cffface->num_charmaps )
971 cffface->charmap = cffface->charmaps[nn];
974 #ifdef FT_MAX_CHARMAP_CACHEABLE
975 if ( nn > FT_MAX_CHARMAP_CACHEABLE )
977 FT_ERROR(( "cff_face_init: Unicode cmap is found, "
978 "but too many preceding subtables (%d) to access\n",
983 if ( encoding->count > 0 )
988 cmaprec.face = cffface;
989 cmaprec.platform_id = TT_PLATFORM_ADOBE; /* Adobe platform id */
991 if ( encoding->offset == 0 )
993 cmaprec.encoding_id = TT_ADOBE_ID_STANDARD;
994 cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD;
995 clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
997 else if ( encoding->offset == 1 )
999 cmaprec.encoding_id = TT_ADOBE_ID_EXPERT;
1000 cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT;
1001 clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
1005 cmaprec.encoding_id = TT_ADOBE_ID_CUSTOM;
1006 cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM;
1007 clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
1010 error = FT_CMap_New( clazz, NULL, &cmaprec, NULL );
1019 error = CFF_Err_Unknown_File_Format;
1024 FT_LOCAL_DEF( void )
1025 cff_face_done( FT_Face cffface ) /* CFF_Face */
1027 CFF_Face face = (CFF_Face)cffface;
1035 memory = cffface->memory;
1036 sfnt = (SFNT_Service)face->sfnt;
1039 sfnt->done_face( face );
1042 CFF_Font cff = (CFF_Font)face->extra.data;
1047 cff_font_done( cff );
1048 FT_FREE( face->extra.data );
1054 FT_LOCAL_DEF( FT_Error )
1055 cff_driver_init( FT_Module module )
1057 FT_UNUSED( module );
1063 FT_LOCAL_DEF( void )
1064 cff_driver_done( FT_Module module )
1066 FT_UNUSED( module );