1 /***************************************************************************/ |
1 /**************************************************************************** |
2 /* */ |
2 * |
3 /* cffobjs.c */ |
3 * cffobjs.c |
4 /* */ |
4 * |
5 /* OpenType objects manager (body). */ |
5 * OpenType objects manager (body). |
6 /* */ |
6 * |
7 /* Copyright 1996-2018 by */ |
7 * Copyright (C) 1996-2019 by |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
8 * David Turner, Robert Wilhelm, and Werner Lemberg. |
9 /* */ |
9 * |
10 /* This file is part of the FreeType project, and may only be used, */ |
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 */ |
11 * modified, and distributed under the terms of the FreeType project |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute |
13 /* this file you indicate that you have read the license and */ |
13 * this file you indicate that you have read the license and |
14 /* understand and accept it fully. */ |
14 * understand and accept it fully. |
15 /* */ |
15 * |
16 /***************************************************************************/ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <ft2build.h> |
19 #include <ft2build.h> |
20 |
20 |
21 #include FT_INTERNAL_DEBUG_H |
21 #include FT_INTERNAL_DEBUG_H |
35 |
35 |
36 #include FT_INTERNAL_CFF_OBJECTS_TYPES_H |
36 #include FT_INTERNAL_CFF_OBJECTS_TYPES_H |
37 #include "cffobjs.h" |
37 #include "cffobjs.h" |
38 #include "cffload.h" |
38 #include "cffload.h" |
39 #include "cffcmap.h" |
39 #include "cffcmap.h" |
40 #include "cffpic.h" |
|
41 |
40 |
42 #include "cfferrs.h" |
41 #include "cfferrs.h" |
43 |
42 |
44 #include FT_INTERNAL_POSTSCRIPT_AUX_H |
43 #include FT_INTERNAL_POSTSCRIPT_AUX_H |
45 #include FT_SERVICE_CFF_TABLE_LOAD_H |
44 #include FT_SERVICE_CFF_TABLE_LOAD_H |
46 |
45 |
47 |
46 |
48 /*************************************************************************/ |
47 /************************************************************************** |
49 /* */ |
48 * |
50 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
49 * The macro FT_COMPONENT is used in trace mode. It is an implicit |
51 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
50 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log |
52 /* messages during execution. */ |
51 * messages during execution. |
53 /* */ |
52 */ |
54 #undef FT_COMPONENT |
53 #undef FT_COMPONENT |
55 #define FT_COMPONENT trace_cffobjs |
54 #define FT_COMPONENT cffobjs |
56 |
55 |
57 |
56 |
58 /*************************************************************************/ |
57 /************************************************************************** |
59 /* */ |
58 * |
60 /* SIZE FUNCTIONS */ |
59 * SIZE FUNCTIONS |
61 /* */ |
60 * |
62 /*************************************************************************/ |
61 */ |
63 |
62 |
64 |
63 |
65 static PSH_Globals_Funcs |
64 static PSH_Globals_Funcs |
66 cff_size_get_globals_funcs( CFF_Size size ) |
65 cff_size_get_globals_funcs( CFF_Size size ) |
67 { |
66 { |
643 |
642 |
644 cffface->num_glyphs = (FT_Long)cff->num_glyphs; |
643 cffface->num_glyphs = (FT_Long)cff->num_glyphs; |
645 |
644 |
646 dict = &cff->top_font.font_dict; |
645 dict = &cff->top_font.font_dict; |
647 |
646 |
648 /* we need the `PSNames' module for CFF and CEF formats */ |
647 /* we need the `psnames' module for CFF and CEF formats */ |
649 /* which aren't CID-keyed */ |
648 /* which aren't CID-keyed */ |
650 if ( dict->cid_registry == 0xFFFFU && !psnames ) |
649 if ( dict->cid_registry == 0xFFFFU && !psnames ) |
651 { |
650 { |
652 FT_ERROR(( "cff_face_init:" |
651 FT_ERROR(( "cff_face_init:" |
653 " cannot open CFF & CEF fonts\n" |
652 " cannot open CFF & CEF fonts\n" |
654 " " |
653 " " |
655 " without the `PSNames' module\n" )); |
654 " without the `psnames' module\n" )); |
656 error = FT_THROW( Missing_Module ); |
655 error = FT_THROW( Missing_Module ); |
657 goto Exit; |
656 goto Exit; |
658 } |
657 } |
659 |
658 |
660 #ifdef FT_DEBUG_LEVEL_TRACE |
659 #ifdef FT_DEBUG_LEVEL_TRACE |
963 cffface->style_name = style_name; |
962 cffface->style_name = style_name; |
964 else |
963 else |
965 /* assume "Regular" style if we don't know better */ |
964 /* assume "Regular" style if we don't know better */ |
966 cffface->style_name = cff_strcpy( memory, (char *)"Regular" ); |
965 cffface->style_name = cff_strcpy( memory, (char *)"Regular" ); |
967 |
966 |
968 /*******************************************************************/ |
967 /******************************************************************** |
969 /* */ |
968 * |
970 /* Compute face flags. */ |
969 * Compute face flags. |
971 /* */ |
970 */ |
972 flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ |
971 flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ |
973 FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ |
972 FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ |
974 FT_FACE_FLAG_HINTER; /* has native hinter */ |
973 FT_FACE_FLAG_HINTER; /* has native hinter */ |
975 |
974 |
976 if ( sfnt_format ) |
975 if ( sfnt_format ) |
987 flags |= FT_FACE_FLAG_KERNING; |
986 flags |= FT_FACE_FLAG_KERNING; |
988 #endif |
987 #endif |
989 |
988 |
990 cffface->face_flags |= flags; |
989 cffface->face_flags |= flags; |
991 |
990 |
992 /*******************************************************************/ |
991 /******************************************************************** |
993 /* */ |
992 * |
994 /* Compute style flags. */ |
993 * Compute style flags. |
995 /* */ |
994 */ |
996 flags = 0; |
995 flags = 0; |
997 |
996 |
998 if ( dict->italic_angle ) |
997 if ( dict->italic_angle ) |
999 flags |= FT_STYLE_FLAG_ITALIC; |
998 flags |= FT_STYLE_FLAG_ITALIC; |
1000 |
999 |
1026 #endif |
1025 #endif |
1027 |
1026 |
1028 if ( dict->cid_registry != 0xFFFFU && pure_cff ) |
1027 if ( dict->cid_registry != 0xFFFFU && pure_cff ) |
1029 cffface->face_flags |= FT_FACE_FLAG_CID_KEYED; |
1028 cffface->face_flags |= FT_FACE_FLAG_CID_KEYED; |
1030 |
1029 |
1031 /*******************************************************************/ |
1030 /******************************************************************** |
1032 /* */ |
1031 * |
1033 /* Compute char maps. */ |
1032 * Compute char maps. |
1034 /* */ |
1033 */ |
1035 |
1034 |
1036 /* Try to synthesize a Unicode charmap if there is none available */ |
1035 /* Try to synthesize a Unicode charmap if there is none available */ |
1037 /* already. If an OpenType font contains a Unicode "cmap", we */ |
1036 /* already. If an OpenType font contains a Unicode "cmap", we */ |
1038 /* will use it, whatever be in the CFF part of the file. */ |
1037 /* will use it, whatever be in the CFF part of the file. */ |
1039 { |
1038 { |
1068 cmaprec.encoding_id = TT_MS_ID_UNICODE_CS; |
1067 cmaprec.encoding_id = TT_MS_ID_UNICODE_CS; |
1069 cmaprec.encoding = FT_ENCODING_UNICODE; |
1068 cmaprec.encoding = FT_ENCODING_UNICODE; |
1070 |
1069 |
1071 nn = (FT_UInt)cffface->num_charmaps; |
1070 nn = (FT_UInt)cffface->num_charmaps; |
1072 |
1071 |
1073 error = FT_CMap_New( &CFF_CMAP_UNICODE_CLASS_REC_GET, NULL, |
1072 error = FT_CMap_New( &cff_cmap_unicode_class_rec, NULL, |
1074 &cmaprec, NULL ); |
1073 &cmaprec, NULL ); |
1075 if ( error && |
1074 if ( error && |
1076 FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) |
1075 FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) && |
|
1076 FT_ERR_NEQ( error, Unimplemented_Feature ) ) |
1077 goto Exit; |
1077 goto Exit; |
1078 error = FT_Err_Ok; |
1078 error = FT_Err_Ok; |
1079 |
1079 |
1080 /* if no Unicode charmap was previously selected, select this one */ |
1080 /* if no Unicode charmap was previously selected, select this one */ |
1081 if ( !cffface->charmap && nn != (FT_UInt)cffface->num_charmaps ) |
1081 if ( !cffface->charmap && nn != (FT_UInt)cffface->num_charmaps ) |
1092 |
1092 |
1093 if ( encoding->offset == 0 ) |
1093 if ( encoding->offset == 0 ) |
1094 { |
1094 { |
1095 cmaprec.encoding_id = TT_ADOBE_ID_STANDARD; |
1095 cmaprec.encoding_id = TT_ADOBE_ID_STANDARD; |
1096 cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD; |
1096 cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD; |
1097 clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET; |
1097 clazz = &cff_cmap_encoding_class_rec; |
1098 } |
1098 } |
1099 else if ( encoding->offset == 1 ) |
1099 else if ( encoding->offset == 1 ) |
1100 { |
1100 { |
1101 cmaprec.encoding_id = TT_ADOBE_ID_EXPERT; |
1101 cmaprec.encoding_id = TT_ADOBE_ID_EXPERT; |
1102 cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT; |
1102 cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT; |
1103 clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET; |
1103 clazz = &cff_cmap_encoding_class_rec; |
1104 } |
1104 } |
1105 else |
1105 else |
1106 { |
1106 { |
1107 cmaprec.encoding_id = TT_ADOBE_ID_CUSTOM; |
1107 cmaprec.encoding_id = TT_ADOBE_ID_CUSTOM; |
1108 cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM; |
1108 cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM; |
1109 clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET; |
1109 clazz = &cff_cmap_encoding_class_rec; |
1110 } |
1110 } |
1111 |
1111 |
1112 error = FT_CMap_New( clazz, NULL, &cmaprec, NULL ); |
1112 error = FT_CMap_New( clazz, NULL, &cmaprec, NULL ); |
1113 } |
1113 } |
1114 } |
1114 } |