OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ftobjs.c */ | 3 /* ftobjs.c */ |
4 /* */ | 4 /* */ |
5 /* The FreeType private base classes (body). */ | 5 /* The FreeType private base classes (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 1996-2013 by */ | 7 /* Copyright 1996-2014 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 "../../include/ft2build.h" | 19 #include <ft2build.h> |
20 #include "../../include/freetype/ftlist.h" | 20 #include FT_LIST_H |
21 #include "../../include/freetype/ftoutln.h" | 21 #include FT_OUTLINE_H |
22 #include "../../include/freetype/internal/ftvalid.h" | 22 #include FT_INTERNAL_VALIDATE_H |
23 #include "../../include/freetype/internal/ftobjs.h" | 23 #include FT_INTERNAL_OBJECTS_H |
24 #include "../../include/freetype/internal/ftdebug.h" | 24 #include FT_INTERNAL_DEBUG_H |
25 #include "../../include/freetype/internal/ftrfork.h" | 25 #include FT_INTERNAL_RFORK_H |
26 #include "../../include/freetype/internal/ftstream.h" | 26 #include FT_INTERNAL_STREAM_H |
27 #include "../../include/freetype/internal/sfnt.h" /* for SFNT_Load_Table_Func
*/ | 27 #include FT_INTERNAL_SFNT_H /* for SFNT_Load_Table_Func */ |
28 #include "../../include/freetype/tttables.h" | 28 #include FT_TRUETYPE_TABLES_H |
29 #include "../../include/freetype/tttags.h" | 29 #include FT_TRUETYPE_TAGS_H |
30 #include "../../include/freetype/ttnameid.h" | 30 #include FT_TRUETYPE_IDS_H |
31 | 31 |
32 #include "../../include/freetype/internal/services/svprop.h" | 32 #include FT_SERVICE_PROPERTIES_H |
33 #include "../../include/freetype/internal/services/svsfnt.h" | 33 #include FT_SERVICE_SFNT_H |
34 #include "../../include/freetype/internal/services/svpostnm.h" | 34 #include FT_SERVICE_POSTSCRIPT_NAME_H |
35 #include "../../include/freetype/internal/services/svgldict.h" | 35 #include FT_SERVICE_GLYPH_DICT_H |
36 #include "../../include/freetype/internal/services/svttcmap.h" | 36 #include FT_SERVICE_TT_CMAP_H |
37 #include "../../include/freetype/internal/services/svkern.h" | 37 #include FT_SERVICE_KERNING_H |
38 #include "../../include/freetype/internal/services/svtteng.h" | 38 #include FT_SERVICE_TRUETYPE_ENGINE_H |
39 | 39 |
40 #ifdef FT_CONFIG_OPTION_MAC_FONTS | 40 #ifdef FT_CONFIG_OPTION_MAC_FONTS |
41 #include "ftbase.h" | 41 #include "ftbase.h" |
42 #endif | 42 #endif |
43 | 43 |
44 | 44 |
45 #ifdef FT_DEBUG_LEVEL_TRACE | 45 #ifdef FT_DEBUG_LEVEL_TRACE |
46 | 46 |
47 #include "../../include/freetype/ftbitmap.h" | 47 #include FT_BITMAP_H |
48 | 48 |
49 #if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ | 49 #if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ |
50 /* We disable the warning `conversion from XXX to YYY, */ | 50 /* We disable the warning `conversion from XXX to YYY, */ |
51 /* possible loss of data' in order to compile cleanly with */ | 51 /* possible loss of data' in order to compile cleanly with */ |
52 /* the maximum level of warnings: `md5.c' is non-FreeType */ | 52 /* the maximum level of warnings: `md5.c' is non-FreeType */ |
53 /* code, and it gets used during development builds only. */ | 53 /* code, and it gets used during development builds only. */ |
54 #pragma warning( push ) | 54 #pragma warning( push ) |
55 #pragma warning( disable : 4244 ) | 55 #pragma warning( disable : 4244 ) |
56 #endif /* _MSC_VER */ | 56 #endif /* _MSC_VER */ |
57 | 57 |
58 /* it's easiest to include `md5.c' directly */ | 58 /* it's easiest to include `md5.c' directly */ |
59 #define free md5_free /* suppress a shadow warning */ | |
60 #include "md5.c" | 59 #include "md5.c" |
61 #undef free | |
62 | 60 |
63 #if defined( _MSC_VER ) | 61 #if defined( _MSC_VER ) |
64 #pragma warning( pop ) | 62 #pragma warning( pop ) |
65 #endif | 63 #endif |
66 | 64 |
67 #endif /* FT_DEBUG_LEVEL_TRACE */ | 65 #endif /* FT_DEBUG_LEVEL_TRACE */ |
68 | 66 |
69 | 67 |
70 #define GRID_FIT_METRICS | 68 #define GRID_FIT_METRICS |
71 | 69 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 FT_New_GlyphSlot( FT_Face face, | 401 FT_New_GlyphSlot( FT_Face face, |
404 FT_GlyphSlot *aslot ) | 402 FT_GlyphSlot *aslot ) |
405 { | 403 { |
406 FT_Error error; | 404 FT_Error error; |
407 FT_Driver driver; | 405 FT_Driver driver; |
408 FT_Driver_Class clazz; | 406 FT_Driver_Class clazz; |
409 FT_Memory memory; | 407 FT_Memory memory; |
410 FT_GlyphSlot slot = NULL; | 408 FT_GlyphSlot slot = NULL; |
411 | 409 |
412 | 410 |
413 if ( !face || !face->driver ) | 411 if ( !face ) |
| 412 return FT_THROW( Invalid_Face_Handle ); |
| 413 |
| 414 if ( !face->driver ) |
414 return FT_THROW( Invalid_Argument ); | 415 return FT_THROW( Invalid_Argument ); |
415 | 416 |
416 driver = face->driver; | 417 driver = face->driver; |
417 clazz = driver->clazz; | 418 clazz = driver->clazz; |
418 memory = driver->root.memory; | 419 memory = driver->root.memory; |
419 | 420 |
420 FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" )); | 421 FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" )); |
421 if ( !FT_ALLOC( slot, clazz->slot_object_size ) ) | 422 if ( !FT_ALLOC( slot, clazz->slot_object_size ) ) |
422 { | 423 { |
423 slot->face = face; | 424 slot->face = face; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 internal = face->internal; | 504 internal = face->internal; |
504 | 505 |
505 internal->transform_flags = 0; | 506 internal->transform_flags = 0; |
506 | 507 |
507 if ( !matrix ) | 508 if ( !matrix ) |
508 { | 509 { |
509 internal->transform_matrix.xx = 0x10000L; | 510 internal->transform_matrix.xx = 0x10000L; |
510 internal->transform_matrix.xy = 0; | 511 internal->transform_matrix.xy = 0; |
511 internal->transform_matrix.yx = 0; | 512 internal->transform_matrix.yx = 0; |
512 internal->transform_matrix.yy = 0x10000L; | 513 internal->transform_matrix.yy = 0x10000L; |
| 514 |
513 matrix = &internal->transform_matrix; | 515 matrix = &internal->transform_matrix; |
514 } | 516 } |
515 else | 517 else |
516 internal->transform_matrix = *matrix; | 518 internal->transform_matrix = *matrix; |
517 | 519 |
518 /* set transform_flags bit flag 0 if `matrix' isn't the identity */ | 520 /* set transform_flags bit flag 0 if `matrix' isn't the identity */ |
519 if ( ( matrix->xy | matrix->yx ) || | 521 if ( ( matrix->xy | matrix->yx ) || |
520 matrix->xx != 0x10000L || | 522 matrix->xx != 0x10000L || |
521 matrix->yy != 0x10000L ) | 523 matrix->yy != 0x10000L ) |
522 internal->transform_flags |= 1; | 524 internal->transform_flags |= 1; |
523 | 525 |
524 if ( !delta ) | 526 if ( !delta ) |
525 { | 527 { |
526 internal->transform_delta.x = 0; | 528 internal->transform_delta.x = 0; |
527 internal->transform_delta.y = 0; | 529 internal->transform_delta.y = 0; |
| 530 |
528 delta = &internal->transform_delta; | 531 delta = &internal->transform_delta; |
529 } | 532 } |
530 else | 533 else |
531 internal->transform_delta = *delta; | 534 internal->transform_delta = *delta; |
532 | 535 |
533 /* set transform_flags bit flag 1 if `delta' isn't the null vector */ | 536 /* set transform_flags bit flag 1 if `delta' isn't the null vector */ |
534 if ( delta->x | delta->y ) | 537 if ( delta->x | delta->y ) |
535 internal->transform_flags |= 2; | 538 internal->transform_flags |= 2; |
536 } | 539 } |
537 | 540 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) || | 663 if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) || |
661 !FT_DRIVER_HAS_HINTER( driver ) ) | 664 !FT_DRIVER_HAS_HINTER( driver ) ) |
662 autohint = TRUE; | 665 autohint = TRUE; |
663 else | 666 else |
664 { | 667 { |
665 FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); | 668 FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); |
666 | 669 |
667 | 670 |
668 /* the check for `num_locations' assures that we actually */ | 671 /* the check for `num_locations' assures that we actually */ |
669 /* test for instructions in a TTF and not in a CFF-based OTF */ | 672 /* test for instructions in a TTF and not in a CFF-based OTF */ |
| 673 /* */ |
| 674 /* since `maxSizeOfInstructions' might be unreliable, we */ |
| 675 /* check the size of the `fpgm' and `prep' tables, too -- */ |
| 676 /* the assumption is that there don't exist real TTFs where */ |
| 677 /* both `fpgm' and `prep' tables are missing */ |
670 if ( mode == FT_RENDER_MODE_LIGHT || | 678 if ( mode == FT_RENDER_MODE_LIGHT || |
671 face->internal->ignore_unpatented_hinter || | 679 face->internal->ignore_unpatented_hinter || |
672 ( FT_IS_SFNT( face ) && | 680 ( FT_IS_SFNT( face ) && |
673 ttface->num_locations && | 681 ttface->num_locations && |
674 ttface->max_profile.maxSizeOfInstructions == 0 ) ) | 682 ttface->max_profile.maxSizeOfInstructions == 0 && |
| 683 ttface->font_program_size == 0 && |
| 684 ttface->cvt_program_size == 0 ) ) |
675 autohint = TRUE; | 685 autohint = TRUE; |
676 } | 686 } |
677 } | 687 } |
678 | 688 |
679 if ( autohint ) | 689 if ( autohint ) |
680 { | 690 { |
681 FT_AutoHinter_Interface hinting; | 691 FT_AutoHinter_Interface hinting; |
682 | 692 |
683 | 693 |
684 /* try to load embedded bitmaps first if available */ | 694 /* try to load embedded bitmaps first if available */ |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 { | 1038 { |
1029 if ( cur[0]->encoding == FT_ENCODING_UNICODE ) | 1039 if ( cur[0]->encoding == FT_ENCODING_UNICODE ) |
1030 { | 1040 { |
1031 /* XXX If some new encodings to represent UCS-4 are added, */ | 1041 /* XXX If some new encodings to represent UCS-4 are added, */ |
1032 /* they should be added here. */ | 1042 /* they should be added here. */ |
1033 if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT && | 1043 if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT && |
1034 cur[0]->encoding_id == TT_MS_ID_UCS_4 ) || | 1044 cur[0]->encoding_id == TT_MS_ID_UCS_4 ) || |
1035 ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && | 1045 ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && |
1036 cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) ) | 1046 cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) ) |
1037 { | 1047 { |
1038 #ifdef FT_MAX_CHARMAP_CACHEABLE | |
1039 if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) | |
1040 { | |
1041 FT_ERROR(( "find_unicode_charmap: UCS-4 cmap is found " | |
1042 "at too late position (%d)\n", cur - first )); | |
1043 continue; | |
1044 } | |
1045 #endif | |
1046 face->charmap = cur[0]; | 1048 face->charmap = cur[0]; |
1047 return FT_Err_Ok; | 1049 return FT_Err_Ok; |
1048 } | 1050 } |
1049 } | 1051 } |
1050 } | 1052 } |
1051 | 1053 |
1052 /* We do not have any UCS-4 charmap. */ | 1054 /* We do not have any UCS-4 charmap. */ |
1053 /* Do the loop again and search for UCS-2 charmaps. */ | 1055 /* Do the loop again and search for UCS-2 charmaps. */ |
1054 cur = first + face->num_charmaps; | 1056 cur = first + face->num_charmaps; |
1055 | 1057 |
1056 for ( ; --cur >= first; ) | 1058 for ( ; --cur >= first; ) |
1057 { | 1059 { |
1058 if ( cur[0]->encoding == FT_ENCODING_UNICODE ) | 1060 if ( cur[0]->encoding == FT_ENCODING_UNICODE ) |
1059 { | 1061 { |
1060 #ifdef FT_MAX_CHARMAP_CACHEABLE | |
1061 if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) | |
1062 { | |
1063 FT_ERROR(( "find_unicode_charmap: UCS-2 cmap is found " | |
1064 "at too late position (%d)\n", cur - first )); | |
1065 continue; | |
1066 } | |
1067 #endif | |
1068 face->charmap = cur[0]; | 1062 face->charmap = cur[0]; |
1069 return FT_Err_Ok; | 1063 return FT_Err_Ok; |
1070 } | 1064 } |
1071 } | 1065 } |
1072 | 1066 |
1073 return FT_THROW( Invalid_CharMap_Handle ); | 1067 return FT_THROW( Invalid_CharMap_Handle ); |
1074 } | 1068 } |
1075 | 1069 |
1076 | 1070 |
1077 /*************************************************************************/ | 1071 /*************************************************************************/ |
(...skipping 21 matching lines...) Expand all Loading... |
1099 if ( !first ) | 1093 if ( !first ) |
1100 return NULL; | 1094 return NULL; |
1101 | 1095 |
1102 end = first + face->num_charmaps; /* points after the last one */ | 1096 end = first + face->num_charmaps; /* points after the last one */ |
1103 | 1097 |
1104 for ( cur = first; cur < end; ++cur ) | 1098 for ( cur = first; cur < end; ++cur ) |
1105 { | 1099 { |
1106 if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && | 1100 if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && |
1107 cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR && | 1101 cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR && |
1108 FT_Get_CMap_Format( cur[0] ) == 14 ) | 1102 FT_Get_CMap_Format( cur[0] ) == 14 ) |
1109 { | |
1110 #ifdef FT_MAX_CHARMAP_CACHEABLE | |
1111 if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) | |
1112 { | |
1113 FT_ERROR(( "find_unicode_charmap: UVS cmap is found " | |
1114 "at too late position (%d)\n", cur - first )); | |
1115 continue; | |
1116 } | |
1117 #endif | |
1118 return cur[0]; | 1103 return cur[0]; |
1119 } | |
1120 } | 1104 } |
1121 | 1105 |
1122 return NULL; | 1106 return NULL; |
1123 } | 1107 } |
1124 | 1108 |
1125 | 1109 |
1126 /*************************************************************************/ | 1110 /*************************************************************************/ |
1127 /* */ | 1111 /* */ |
1128 /* <Function> */ | 1112 /* <Function> */ |
1129 /* open_face */ | 1113 /* open_face */ |
1130 /* */ | 1114 /* */ |
1131 /* <Description> */ | 1115 /* <Description> */ |
1132 /* This function does some work for FT_Open_Face(). */ | 1116 /* This function does some work for FT_Open_Face(). */ |
1133 /* */ | 1117 /* */ |
1134 static FT_Error | 1118 static FT_Error |
1135 open_face( FT_Driver driver, | 1119 open_face( FT_Driver driver, |
1136 FT_Stream stream, | 1120 FT_Stream *astream, |
| 1121 FT_Bool external_stream, |
1137 FT_Long face_index, | 1122 FT_Long face_index, |
1138 FT_Int num_params, | 1123 FT_Int num_params, |
1139 FT_Parameter* params, | 1124 FT_Parameter* params, |
1140 FT_Face *aface ) | 1125 FT_Face *aface ) |
1141 { | 1126 { |
1142 FT_Memory memory; | 1127 FT_Memory memory; |
1143 FT_Driver_Class clazz; | 1128 FT_Driver_Class clazz; |
1144 FT_Face face = 0; | 1129 FT_Face face = NULL; |
| 1130 FT_Face_Internal internal = NULL; |
| 1131 |
1145 FT_Error error, error2; | 1132 FT_Error error, error2; |
1146 FT_Face_Internal internal = NULL; | |
1147 | 1133 |
1148 | 1134 |
1149 clazz = driver->clazz; | 1135 clazz = driver->clazz; |
1150 memory = driver->root.memory; | 1136 memory = driver->root.memory; |
1151 | 1137 |
1152 /* allocate the face object and perform basic initialization */ | 1138 /* allocate the face object and perform basic initialization */ |
1153 if ( FT_ALLOC( face, clazz->face_object_size ) ) | 1139 if ( FT_ALLOC( face, clazz->face_object_size ) ) |
1154 goto Fail; | 1140 goto Fail; |
1155 | 1141 |
1156 face->driver = driver; | 1142 face->driver = driver; |
1157 face->memory = memory; | 1143 face->memory = memory; |
1158 face->stream = stream; | 1144 face->stream = *astream; |
| 1145 |
| 1146 /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ |
| 1147 if ( external_stream ) |
| 1148 face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; |
1159 | 1149 |
1160 if ( FT_NEW( internal ) ) | 1150 if ( FT_NEW( internal ) ) |
1161 goto Fail; | 1151 goto Fail; |
1162 | 1152 |
1163 face->internal = internal; | 1153 face->internal = internal; |
1164 | 1154 |
1165 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 1155 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
1166 { | 1156 { |
1167 int i; | 1157 int i; |
1168 | 1158 |
1169 | 1159 |
1170 face->internal->incremental_interface = 0; | 1160 face->internal->incremental_interface = 0; |
1171 for ( i = 0; i < num_params && !face->internal->incremental_interface; | 1161 for ( i = 0; i < num_params && !face->internal->incremental_interface; |
1172 i++ ) | 1162 i++ ) |
1173 if ( params[i].tag == FT_PARAM_TAG_INCREMENTAL ) | 1163 if ( params[i].tag == FT_PARAM_TAG_INCREMENTAL ) |
1174 face->internal->incremental_interface = | 1164 face->internal->incremental_interface = |
1175 (FT_Incremental_Interface)params[i].data; | 1165 (FT_Incremental_Interface)params[i].data; |
1176 } | 1166 } |
1177 #endif | 1167 #endif |
1178 | 1168 |
1179 if ( clazz->init_face ) | 1169 if ( clazz->init_face ) |
1180 error = clazz->init_face( stream, | 1170 error = clazz->init_face( *astream, |
1181 face, | 1171 face, |
1182 (FT_Int)face_index, | 1172 (FT_Int)face_index, |
1183 num_params, | 1173 num_params, |
1184 params ); | 1174 params ); |
| 1175 *astream = face->stream; /* Stream may have been changed. */ |
1185 if ( error ) | 1176 if ( error ) |
1186 goto Fail; | 1177 goto Fail; |
1187 | 1178 |
1188 /* select Unicode charmap by default */ | 1179 /* select Unicode charmap by default */ |
1189 error2 = find_unicode_charmap( face ); | 1180 error2 = find_unicode_charmap( face ); |
1190 | 1181 |
1191 /* if no Unicode charmap can be found, FT_Err_Invalid_CharMap_Handle */ | 1182 /* if no Unicode charmap can be found, FT_Err_Invalid_CharMap_Handle */ |
1192 /* is returned. */ | 1183 /* is returned. */ |
1193 | 1184 |
1194 /* no error should happen, but we want to play safe */ | 1185 /* no error should happen, but we want to play safe */ |
(...skipping 16 matching lines...) Expand all Loading... |
1211 *aface = 0; | 1202 *aface = 0; |
1212 } | 1203 } |
1213 | 1204 |
1214 return error; | 1205 return error; |
1215 } | 1206 } |
1216 | 1207 |
1217 | 1208 |
1218 /* there's a Mac-specific extended implementation of FT_New_Face() */ | 1209 /* there's a Mac-specific extended implementation of FT_New_Face() */ |
1219 /* in src/base/ftmac.c */ | 1210 /* in src/base/ftmac.c */ |
1220 | 1211 |
1221 //#ifndef FT_MACINTOSH | 1212 #ifndef FT_MACINTOSH |
1222 | 1213 |
1223 /* documentation is in freetype.h */ | 1214 /* documentation is in freetype.h */ |
1224 | 1215 |
1225 FT_EXPORT_DEF( FT_Error ) | 1216 FT_EXPORT_DEF( FT_Error ) |
1226 FT_New_Face( FT_Library library, | 1217 FT_New_Face( FT_Library library, |
1227 const char* pathname, | 1218 const char* pathname, |
1228 FT_Long face_index, | 1219 FT_Long face_index, |
1229 FT_Face *aface ) | 1220 FT_Face *aface ) |
1230 { | 1221 { |
1231 FT_Open_Args args; | 1222 FT_Open_Args args; |
1232 | 1223 |
1233 | 1224 |
1234 /* test for valid `library' and `aface' delayed to FT_Open_Face() */ | 1225 /* test for valid `library' and `aface' delayed to `FT_Open_Face' */ |
1235 if ( !pathname ) | 1226 if ( !pathname ) |
1236 return FT_THROW( Invalid_Argument ); | 1227 return FT_THROW( Invalid_Argument ); |
1237 | 1228 |
1238 args.flags = FT_OPEN_PATHNAME; | 1229 args.flags = FT_OPEN_PATHNAME; |
1239 args.pathname = (char*)pathname; | 1230 args.pathname = (char*)pathname; |
1240 args.stream = NULL; | 1231 args.stream = NULL; |
1241 | 1232 |
1242 return FT_Open_Face( library, &args, face_index, aface ); | 1233 return FT_Open_Face( library, &args, face_index, aface ); |
1243 } | 1234 } |
1244 | 1235 |
1245 //#endif | 1236 #endif |
1246 | 1237 |
1247 | 1238 |
1248 /* documentation is in freetype.h */ | 1239 /* documentation is in freetype.h */ |
1249 | 1240 |
1250 FT_EXPORT_DEF( FT_Error ) | 1241 FT_EXPORT_DEF( FT_Error ) |
1251 FT_New_Memory_Face( FT_Library library, | 1242 FT_New_Memory_Face( FT_Library library, |
1252 const FT_Byte* file_base, | 1243 const FT_Byte* file_base, |
1253 FT_Long file_size, | 1244 FT_Long file_size, |
1254 FT_Long face_index, | 1245 FT_Long face_index, |
1255 FT_Face *aface ) | 1246 FT_Face *aface ) |
1256 { | 1247 { |
1257 FT_Open_Args args; | 1248 FT_Open_Args args; |
1258 | 1249 |
1259 | 1250 |
1260 /* test for valid `library' and `face' delayed to FT_Open_Face() */ | 1251 /* test for valid `library' and `face' delayed to `FT_Open_Face' */ |
1261 if ( !file_base ) | 1252 if ( !file_base ) |
1262 return FT_THROW( Invalid_Argument ); | 1253 return FT_THROW( Invalid_Argument ); |
1263 | 1254 |
1264 args.flags = FT_OPEN_MEMORY; | 1255 args.flags = FT_OPEN_MEMORY; |
1265 args.memory_base = file_base; | 1256 args.memory_base = file_base; |
1266 args.memory_size = file_size; | 1257 args.memory_size = file_size; |
1267 args.stream = NULL; | 1258 args.stream = NULL; |
1268 | 1259 |
1269 return FT_Open_Face( library, &args, face_index, aface ); | 1260 return FT_Open_Face( library, &args, face_index, aface ); |
1270 } | 1261 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 FT_Stream stream, | 1555 FT_Stream stream, |
1565 FT_Long *offsets, | 1556 FT_Long *offsets, |
1566 FT_Long resource_cnt, | 1557 FT_Long resource_cnt, |
1567 FT_Long face_index, | 1558 FT_Long face_index, |
1568 FT_Face *aface ) | 1559 FT_Face *aface ) |
1569 { | 1560 { |
1570 FT_Error error = FT_ERR( Cannot_Open_Resource ); | 1561 FT_Error error = FT_ERR( Cannot_Open_Resource ); |
1571 FT_Memory memory = library->memory; | 1562 FT_Memory memory = library->memory; |
1572 FT_Byte* pfb_data = NULL; | 1563 FT_Byte* pfb_data = NULL; |
1573 int i, type, flags; | 1564 int i, type, flags; |
1574 FT_Long len; | 1565 FT_ULong len; |
1575 FT_Long pfb_len, pfb_pos, pfb_lenpos; | 1566 FT_ULong pfb_len, pfb_pos, pfb_lenpos; |
1576 FT_Long rlen, temp; | 1567 FT_ULong rlen, temp; |
1577 | 1568 |
1578 | 1569 |
1579 if ( face_index == -1 ) | 1570 if ( face_index == -1 ) |
1580 face_index = 0; | 1571 face_index = 0; |
1581 if ( face_index != 0 ) | 1572 if ( face_index != 0 ) |
1582 return error; | 1573 return error; |
1583 | 1574 |
1584 /* Find the length of all the POST resources, concatenated. Assume */ | 1575 /* Find the length of all the POST resources, concatenated. Assume */ |
1585 /* worst case (each resource in its own section). */ | 1576 /* worst case (each resource in its own section). */ |
1586 pfb_len = 0; | 1577 pfb_len = 0; |
1587 for ( i = 0; i < resource_cnt; ++i ) | 1578 for ( i = 0; i < resource_cnt; ++i ) |
1588 { | 1579 { |
1589 error = FT_Stream_Seek( stream, offsets[i] ); | 1580 error = FT_Stream_Seek( stream, offsets[i] ); |
1590 if ( error ) | 1581 if ( error ) |
1591 goto Exit; | 1582 goto Exit; |
1592 if ( FT_READ_LONG( temp ) ) | 1583 if ( FT_READ_ULONG( temp ) ) |
1593 goto Exit; | 1584 goto Exit; |
| 1585 |
| 1586 /* FT2 allocator takes signed long buffer length, |
| 1587 * too large value causing overflow should be checked |
| 1588 */ |
| 1589 FT_TRACE4(( " POST fragment #%d: length=0x%08x\n", |
| 1590 i, temp)); |
| 1591 if ( 0x7FFFFFFFUL < temp || pfb_len + temp + 6 < pfb_len ) |
| 1592 { |
| 1593 FT_TRACE2(( " too long fragment length makes" |
| 1594 " pfb_len confused: temp=0x%08x\n", temp )); |
| 1595 error = FT_THROW( Invalid_Offset ); |
| 1596 goto Exit; |
| 1597 } |
| 1598 |
1594 pfb_len += temp + 6; | 1599 pfb_len += temp + 6; |
1595 } | 1600 } |
1596 | 1601 |
| 1602 FT_TRACE2(( " total buffer size to concatenate %d" |
| 1603 " POST fragments: 0x%08x\n", |
| 1604 resource_cnt, pfb_len + 2)); |
| 1605 if ( pfb_len + 2 < 6 ) { |
| 1606 FT_TRACE2(( " too long fragment length makes" |
| 1607 " pfb_len confused: pfb_len=0x%08x\n", pfb_len )); |
| 1608 error = FT_THROW( Array_Too_Large ); |
| 1609 goto Exit; |
| 1610 } |
1597 if ( FT_ALLOC( pfb_data, (FT_Long)pfb_len + 2 ) ) | 1611 if ( FT_ALLOC( pfb_data, (FT_Long)pfb_len + 2 ) ) |
1598 goto Exit; | 1612 goto Exit; |
1599 | 1613 |
1600 pfb_data[0] = 0x80; | 1614 pfb_data[0] = 0x80; |
1601 pfb_data[1] = 1; /* Ascii section */ | 1615 pfb_data[1] = 1; /* Ascii section */ |
1602 pfb_data[2] = 0; /* 4-byte length, fill in later */ | 1616 pfb_data[2] = 0; /* 4-byte length, fill in later */ |
1603 pfb_data[3] = 0; | 1617 pfb_data[3] = 0; |
1604 pfb_data[4] = 0; | 1618 pfb_data[4] = 0; |
1605 pfb_data[5] = 0; | 1619 pfb_data[5] = 0; |
1606 pfb_pos = 6; | 1620 pfb_pos = 6; |
1607 pfb_lenpos = 2; | 1621 pfb_lenpos = 2; |
1608 | 1622 |
1609 len = 0; | 1623 len = 0; |
1610 type = 1; | 1624 type = 1; |
1611 for ( i = 0; i < resource_cnt; ++i ) | 1625 for ( i = 0; i < resource_cnt; ++i ) |
1612 { | 1626 { |
1613 error = FT_Stream_Seek( stream, offsets[i] ); | 1627 error = FT_Stream_Seek( stream, offsets[i] ); |
1614 if ( error ) | 1628 if ( error ) |
1615 goto Exit2; | 1629 goto Exit2; |
1616 if ( FT_READ_LONG( rlen ) ) | 1630 if ( FT_READ_ULONG( rlen ) ) |
1617 goto Exit; | 1631 goto Exit2; |
| 1632 |
| 1633 /* FT2 allocator takes signed long buffer length, |
| 1634 * too large fragment length causing overflow should be checked |
| 1635 */ |
| 1636 if ( 0x7FFFFFFFUL < rlen ) |
| 1637 { |
| 1638 error = FT_THROW( Invalid_Offset ); |
| 1639 goto Exit2; |
| 1640 } |
| 1641 |
1618 if ( FT_READ_USHORT( flags ) ) | 1642 if ( FT_READ_USHORT( flags ) ) |
1619 goto Exit; | 1643 goto Exit2; |
1620 FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\
n", | 1644 FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\
n", |
1621 i, offsets[i], rlen, flags )); | 1645 i, offsets[i], rlen, flags )); |
1622 | 1646 |
| 1647 error = FT_ERR( Array_Too_Large ); |
1623 /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ | 1648 /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ |
1624 if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ | 1649 if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ |
| 1650 { |
| 1651 FT_TRACE3(( " Skip POST fragment #%d because it is a comment\n", i ))
; |
1625 continue; | 1652 continue; |
| 1653 } |
1626 | 1654 |
1627 /* the flags are part of the resource, so rlen >= 2. */ | 1655 /* the flags are part of the resource, so rlen >= 2. */ |
1628 /* but some fonts declare rlen = 0 for empty fragment */ | 1656 /* but some fonts declare rlen = 0 for empty fragment */ |
1629 if ( rlen > 2 ) | 1657 if ( rlen > 2 ) |
1630 rlen -= 2; | 1658 rlen -= 2; |
1631 else | 1659 else |
1632 rlen = 0; | 1660 rlen = 0; |
1633 | 1661 |
1634 if ( ( flags >> 8 ) == type ) | 1662 if ( ( flags >> 8 ) == type ) |
1635 len += rlen; | 1663 len += rlen; |
1636 else | 1664 else |
1637 { | 1665 { |
| 1666 FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer" |
| 1667 " 0x%p + 0x%08x\n", i, pfb_data, pfb_lenpos )); |
1638 if ( pfb_lenpos + 3 > pfb_len + 2 ) | 1668 if ( pfb_lenpos + 3 > pfb_len + 2 ) |
1639 goto Exit2; | 1669 goto Exit2; |
1640 pfb_data[pfb_lenpos ] = (FT_Byte)( len ); | 1670 pfb_data[pfb_lenpos ] = (FT_Byte)( len ); |
1641 pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 ); | 1671 pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 ); |
1642 pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 ); | 1672 pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 ); |
1643 pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 ); | 1673 pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 ); |
1644 | 1674 |
1645 if ( ( flags >> 8 ) == 5 ) /* End of font mark */ | 1675 if ( ( flags >> 8 ) == 5 ) /* End of font mark */ |
1646 break; | 1676 break; |
1647 | 1677 |
| 1678 FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer" |
| 1679 " 0x%p + 0x%08x\n", i, pfb_data, pfb_pos )); |
1648 if ( pfb_pos + 6 > pfb_len + 2 ) | 1680 if ( pfb_pos + 6 > pfb_len + 2 ) |
1649 goto Exit2; | 1681 goto Exit2; |
1650 pfb_data[pfb_pos++] = 0x80; | 1682 pfb_data[pfb_pos++] = 0x80; |
1651 | 1683 |
1652 type = flags >> 8; | 1684 type = flags >> 8; |
1653 len = rlen; | 1685 len = rlen; |
1654 | 1686 |
1655 pfb_data[pfb_pos++] = (FT_Byte)type; | 1687 pfb_data[pfb_pos++] = (FT_Byte)type; |
1656 pfb_lenpos = pfb_pos; | 1688 pfb_lenpos = pfb_pos; |
1657 pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */ | 1689 pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */ |
1658 pfb_data[pfb_pos++] = 0; | 1690 pfb_data[pfb_pos++] = 0; |
1659 pfb_data[pfb_pos++] = 0; | 1691 pfb_data[pfb_pos++] = 0; |
1660 pfb_data[pfb_pos++] = 0; | 1692 pfb_data[pfb_pos++] = 0; |
1661 } | 1693 } |
1662 | 1694 |
1663 error = FT_ERR( Cannot_Open_Resource ); | |
1664 if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) | 1695 if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) |
1665 goto Exit2; | 1696 goto Exit2; |
1666 | 1697 |
| 1698 FT_TRACE3(( " Load POST fragment #%d (%d byte) to buffer" |
| 1699 " 0x%p + 0x%08x\n", i, rlen, pfb_data, pfb_pos )); |
1667 error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); | 1700 error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); |
1668 if ( error ) | 1701 if ( error ) |
1669 goto Exit2; | 1702 goto Exit2; |
1670 pfb_pos += rlen; | 1703 pfb_pos += rlen; |
1671 } | 1704 } |
1672 | 1705 |
| 1706 error = FT_ERR( Array_Too_Large ); |
1673 if ( pfb_pos + 2 > pfb_len + 2 ) | 1707 if ( pfb_pos + 2 > pfb_len + 2 ) |
1674 goto Exit2; | 1708 goto Exit2; |
1675 pfb_data[pfb_pos++] = 0x80; | 1709 pfb_data[pfb_pos++] = 0x80; |
1676 pfb_data[pfb_pos++] = 3; | 1710 pfb_data[pfb_pos++] = 3; |
1677 | 1711 |
1678 if ( pfb_lenpos + 3 > pfb_len + 2 ) | 1712 if ( pfb_lenpos + 3 > pfb_len + 2 ) |
1679 goto Exit2; | 1713 goto Exit2; |
1680 pfb_data[pfb_lenpos ] = (FT_Byte)( len ); | 1714 pfb_data[pfb_lenpos ] = (FT_Byte)( len ); |
1681 pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 ); | 1715 pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 ); |
1682 pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 ); | 1716 pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 ); |
1683 pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 ); | 1717 pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 ); |
1684 | 1718 |
1685 return open_face_from_buffer( library, | 1719 return open_face_from_buffer( library, |
1686 pfb_data, | 1720 pfb_data, |
1687 pfb_pos, | 1721 pfb_pos, |
1688 face_index, | 1722 face_index, |
1689 "type1", | 1723 "type1", |
1690 aface ); | 1724 aface ); |
1691 | 1725 |
1692 Exit2: | 1726 Exit2: |
| 1727 if ( error == FT_ERR( Array_Too_Large ) ) |
| 1728 FT_TRACE2(( " Abort due to too-short buffer to store" |
| 1729 " all POST fragments\n" )); |
| 1730 else if ( error == FT_ERR( Invalid_Offset ) ) |
| 1731 FT_TRACE2(( " Abort due to invalid offset in a POST fragment\n" )); |
| 1732 if ( error ) |
| 1733 error = FT_ERR( Cannot_Open_Resource ); |
1693 FT_FREE( pfb_data ); | 1734 FT_FREE( pfb_data ); |
1694 | 1735 |
1695 Exit: | 1736 Exit: |
1696 return error; | 1737 return error; |
1697 } | 1738 } |
1698 | 1739 |
1699 | 1740 |
1700 /* The resource header says we've got resource_cnt `sfnt' */ | 1741 /* The resource header says we've got resource_cnt `sfnt' */ |
1701 /* (TrueType/OpenType) resources in this file. Look through */ | 1742 /* (TrueType/OpenType) resources in this file. Look through */ |
1702 /* them for the one indicated by face_index, load it into mem, */ | 1743 /* them for the one indicated by face_index, load it into mem, */ |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 FT_Long map_offset, rdara_pos; | 1823 FT_Long map_offset, rdara_pos; |
1783 FT_Long *data_offsets; | 1824 FT_Long *data_offsets; |
1784 FT_Long count; | 1825 FT_Long count; |
1785 | 1826 |
1786 | 1827 |
1787 error = FT_Raccess_Get_HeaderInfo( library, stream, resource_offset, | 1828 error = FT_Raccess_Get_HeaderInfo( library, stream, resource_offset, |
1788 &map_offset, &rdara_pos ); | 1829 &map_offset, &rdara_pos ); |
1789 if ( error ) | 1830 if ( error ) |
1790 return error; | 1831 return error; |
1791 | 1832 |
| 1833 /* POST resources must be sorted to concatenate properly */ |
1792 error = FT_Raccess_Get_DataOffsets( library, stream, | 1834 error = FT_Raccess_Get_DataOffsets( library, stream, |
1793 map_offset, rdara_pos, | 1835 map_offset, rdara_pos, |
1794 TTAG_POST, | 1836 TTAG_POST, TRUE, |
1795 &data_offsets, &count ); | 1837 &data_offsets, &count ); |
1796 if ( !error ) | 1838 if ( !error ) |
1797 { | 1839 { |
1798 error = Mac_Read_POST_Resource( library, stream, data_offsets, count, | 1840 error = Mac_Read_POST_Resource( library, stream, data_offsets, count, |
1799 face_index, aface ); | 1841 face_index, aface ); |
1800 FT_FREE( data_offsets ); | 1842 FT_FREE( data_offsets ); |
1801 /* POST exists in an LWFN providing a single face */ | 1843 /* POST exists in an LWFN providing a single face */ |
1802 if ( !error ) | 1844 if ( !error ) |
1803 (*aface)->num_faces = 1; | 1845 (*aface)->num_faces = 1; |
1804 return error; | 1846 return error; |
1805 } | 1847 } |
1806 | 1848 |
| 1849 /* sfnt resources should not be sorted to preserve the face order by |
| 1850 QuickDraw API */ |
1807 error = FT_Raccess_Get_DataOffsets( library, stream, | 1851 error = FT_Raccess_Get_DataOffsets( library, stream, |
1808 map_offset, rdara_pos, | 1852 map_offset, rdara_pos, |
1809 TTAG_sfnt, | 1853 TTAG_sfnt, FALSE, |
1810 &data_offsets, &count ); | 1854 &data_offsets, &count ); |
1811 if ( !error ) | 1855 if ( !error ) |
1812 { | 1856 { |
1813 FT_Long face_index_internal = face_index % count; | 1857 FT_Long face_index_internal = face_index % count; |
1814 | 1858 |
1815 | 1859 |
1816 error = Mac_Read_sfnt_Resource( library, stream, data_offsets, count, | 1860 error = Mac_Read_sfnt_Resource( library, stream, data_offsets, count, |
1817 face_index_internal, aface ); | 1861 face_index_internal, aface ); |
1818 FT_FREE( data_offsets ); | 1862 FT_FREE( data_offsets ); |
1819 if ( !error ) | 1863 if ( !error ) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 FT_Driver driver = NULL; | 2071 FT_Driver driver = NULL; |
2028 FT_Memory memory = NULL; | 2072 FT_Memory memory = NULL; |
2029 FT_Stream stream = NULL; | 2073 FT_Stream stream = NULL; |
2030 FT_Face face = NULL; | 2074 FT_Face face = NULL; |
2031 FT_ListNode node = NULL; | 2075 FT_ListNode node = NULL; |
2032 FT_Bool external_stream; | 2076 FT_Bool external_stream; |
2033 FT_Module* cur; | 2077 FT_Module* cur; |
2034 FT_Module* limit; | 2078 FT_Module* limit; |
2035 | 2079 |
2036 | 2080 |
2037 /* test for valid `library' delayed to */ | 2081 /* test for valid `library' delayed to `FT_Stream_New' */ |
2038 /* FT_Stream_New() */ | |
2039 | 2082 |
2040 if ( ( !aface && face_index >= 0 ) || !args ) | 2083 if ( ( !aface && face_index >= 0 ) || !args ) |
2041 return FT_THROW( Invalid_Argument ); | 2084 return FT_THROW( Invalid_Argument ); |
2042 | 2085 |
2043 external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) && | 2086 external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) && |
2044 args->stream ); | 2087 args->stream ); |
2045 | 2088 |
2046 /* create input stream */ | 2089 /* create input stream */ |
2047 error = FT_Stream_New( library, args, &stream ); | 2090 error = FT_Stream_New( library, args, &stream ); |
2048 if ( error ) | 2091 if ( error ) |
(...skipping 13 matching lines...) Expand all Loading... |
2062 FT_Int num_params = 0; | 2105 FT_Int num_params = 0; |
2063 FT_Parameter* params = 0; | 2106 FT_Parameter* params = 0; |
2064 | 2107 |
2065 | 2108 |
2066 if ( args->flags & FT_OPEN_PARAMS ) | 2109 if ( args->flags & FT_OPEN_PARAMS ) |
2067 { | 2110 { |
2068 num_params = args->num_params; | 2111 num_params = args->num_params; |
2069 params = args->params; | 2112 params = args->params; |
2070 } | 2113 } |
2071 | 2114 |
2072 error = open_face( driver, stream, face_index, | 2115 error = open_face( driver, &stream, external_stream, face_index, |
2073 num_params, params, &face ); | 2116 num_params, params, &face ); |
2074 if ( !error ) | 2117 if ( !error ) |
2075 goto Success; | 2118 goto Success; |
2076 } | 2119 } |
2077 else | 2120 else |
2078 error = FT_THROW( Invalid_Handle ); | 2121 error = FT_THROW( Invalid_Handle ); |
2079 | 2122 |
2080 FT_Stream_Free( stream, external_stream ); | 2123 FT_Stream_Free( stream, external_stream ); |
2081 goto Fail; | 2124 goto Fail; |
2082 } | 2125 } |
(...skipping 15 matching lines...) Expand all Loading... |
2098 | 2141 |
2099 | 2142 |
2100 driver = FT_DRIVER( cur[0] ); | 2143 driver = FT_DRIVER( cur[0] ); |
2101 | 2144 |
2102 if ( args->flags & FT_OPEN_PARAMS ) | 2145 if ( args->flags & FT_OPEN_PARAMS ) |
2103 { | 2146 { |
2104 num_params = args->num_params; | 2147 num_params = args->num_params; |
2105 params = args->params; | 2148 params = args->params; |
2106 } | 2149 } |
2107 | 2150 |
2108 error = open_face( driver, stream, face_index, | 2151 error = open_face( driver, &stream, external_stream, face_index, |
2109 num_params, params, &face ); | 2152 num_params, params, &face ); |
2110 if ( !error ) | 2153 if ( !error ) |
2111 goto Success; | 2154 goto Success; |
2112 | 2155 |
2113 #ifdef FT_CONFIG_OPTION_MAC_FONTS | 2156 #ifdef FT_CONFIG_OPTION_MAC_FONTS |
2114 if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 && | 2157 if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 && |
2115 FT_ERR_EQ( error, Table_Missing ) ) | 2158 FT_ERR_EQ( error, Table_Missing ) ) |
2116 { | 2159 { |
2117 /* TrueType but essential tables are missing */ | 2160 /* TrueType but essential tables are missing */ |
2118 if ( FT_Stream_Seek( stream, 0 ) ) | 2161 if ( FT_Stream_Seek( stream, 0 ) ) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 error = FT_THROW( Unknown_File_Format ); | 2210 error = FT_THROW( Unknown_File_Format ); |
2168 | 2211 |
2169 Fail2: | 2212 Fail2: |
2170 FT_Stream_Free( stream, external_stream ); | 2213 FT_Stream_Free( stream, external_stream ); |
2171 goto Fail; | 2214 goto Fail; |
2172 } | 2215 } |
2173 | 2216 |
2174 Success: | 2217 Success: |
2175 FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" )); | 2218 FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" )); |
2176 | 2219 |
2177 /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ | |
2178 if ( external_stream ) | |
2179 face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; | |
2180 | |
2181 /* add the face object to its driver's list */ | 2220 /* add the face object to its driver's list */ |
2182 if ( FT_NEW( node ) ) | 2221 if ( FT_NEW( node ) ) |
2183 goto Fail; | 2222 goto Fail; |
2184 | 2223 |
2185 node->data = face; | 2224 node->data = face; |
2186 /* don't assume driver is the same as face->driver, so use */ | 2225 /* don't assume driver is the same as face->driver, so use */ |
2187 /* face->driver instead. */ | 2226 /* face->driver instead. */ |
2188 FT_List_Add( &face->driver->faces_list, node ); | 2227 FT_List_Add( &face->driver->faces_list, node ); |
2189 | 2228 |
2190 /* now allocate a glyph slot object for the face */ | 2229 /* now allocate a glyph slot object for the face */ |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 | 2318 |
2280 /* documentation is in freetype.h */ | 2319 /* documentation is in freetype.h */ |
2281 | 2320 |
2282 FT_EXPORT_DEF( FT_Error ) | 2321 FT_EXPORT_DEF( FT_Error ) |
2283 FT_Attach_File( FT_Face face, | 2322 FT_Attach_File( FT_Face face, |
2284 const char* filepathname ) | 2323 const char* filepathname ) |
2285 { | 2324 { |
2286 FT_Open_Args open; | 2325 FT_Open_Args open; |
2287 | 2326 |
2288 | 2327 |
2289 /* test for valid `face' delayed to FT_Attach_Stream() */ | 2328 /* test for valid `face' delayed to `FT_Attach_Stream' */ |
2290 | 2329 |
2291 if ( !filepathname ) | 2330 if ( !filepathname ) |
2292 return FT_THROW( Invalid_Argument ); | 2331 return FT_THROW( Invalid_Argument ); |
2293 | 2332 |
2294 open.stream = NULL; | 2333 open.stream = NULL; |
2295 open.flags = FT_OPEN_PATHNAME; | 2334 open.flags = FT_OPEN_PATHNAME; |
2296 open.pathname = (char*)filepathname; | 2335 open.pathname = (char*)filepathname; |
2297 | 2336 |
2298 return FT_Attach_Stream( face, &open ); | 2337 return FT_Attach_Stream( face, &open ); |
2299 } | 2338 } |
2300 | 2339 |
2301 | 2340 |
2302 /* documentation is in freetype.h */ | 2341 /* documentation is in freetype.h */ |
2303 | 2342 |
2304 FT_EXPORT_DEF( FT_Error ) | 2343 FT_EXPORT_DEF( FT_Error ) |
2305 FT_Attach_Stream( FT_Face face, | 2344 FT_Attach_Stream( FT_Face face, |
2306 FT_Open_Args* parameters ) | 2345 FT_Open_Args* parameters ) |
2307 { | 2346 { |
2308 FT_Stream stream; | 2347 FT_Stream stream; |
2309 FT_Error error; | 2348 FT_Error error; |
2310 FT_Driver driver; | 2349 FT_Driver driver; |
2311 | 2350 |
2312 FT_Driver_Class clazz; | 2351 FT_Driver_Class clazz; |
2313 | 2352 |
2314 | 2353 |
2315 /* test for valid `parameters' delayed to FT_Stream_New() */ | 2354 /* test for valid `parameters' delayed to `FT_Stream_New' */ |
2316 | 2355 |
2317 if ( !face ) | 2356 if ( !face ) |
2318 return FT_THROW( Invalid_Face_Handle ); | 2357 return FT_THROW( Invalid_Face_Handle ); |
2319 | 2358 |
2320 driver = face->driver; | 2359 driver = face->driver; |
2321 if ( !driver ) | 2360 if ( !driver ) |
2322 return FT_THROW( Invalid_Driver_Handle ); | 2361 return FT_THROW( Invalid_Driver_Handle ); |
2323 | 2362 |
2324 error = FT_Stream_New( driver->root.library, parameters, &stream ); | 2363 error = FT_Stream_New( driver->root.library, parameters, &stream ); |
2325 if ( error ) | 2364 if ( error ) |
(...skipping 15 matching lines...) Expand all Loading... |
2341 Exit: | 2380 Exit: |
2342 return error; | 2381 return error; |
2343 } | 2382 } |
2344 | 2383 |
2345 | 2384 |
2346 /* documentation is in freetype.h */ | 2385 /* documentation is in freetype.h */ |
2347 | 2386 |
2348 FT_EXPORT_DEF( FT_Error ) | 2387 FT_EXPORT_DEF( FT_Error ) |
2349 FT_Reference_Face( FT_Face face ) | 2388 FT_Reference_Face( FT_Face face ) |
2350 { | 2389 { |
| 2390 if ( !face ) |
| 2391 return FT_THROW( Invalid_Face_Handle ); |
| 2392 |
2351 face->internal->refcount++; | 2393 face->internal->refcount++; |
2352 | 2394 |
2353 return FT_Err_Ok; | 2395 return FT_Err_Ok; |
2354 } | 2396 } |
2355 | 2397 |
2356 | 2398 |
2357 /* documentation is in freetype.h */ | 2399 /* documentation is in freetype.h */ |
2358 | 2400 |
2359 FT_EXPORT_DEF( FT_Error ) | 2401 FT_EXPORT_DEF( FT_Error ) |
2360 FT_Done_Face( FT_Face face ) | 2402 FT_Done_Face( FT_Face face ) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2407 FT_Driver_Class clazz; | 2449 FT_Driver_Class clazz; |
2408 | 2450 |
2409 FT_Size size = 0; | 2451 FT_Size size = 0; |
2410 FT_ListNode node = 0; | 2452 FT_ListNode node = 0; |
2411 | 2453 |
2412 | 2454 |
2413 if ( !face ) | 2455 if ( !face ) |
2414 return FT_THROW( Invalid_Face_Handle ); | 2456 return FT_THROW( Invalid_Face_Handle ); |
2415 | 2457 |
2416 if ( !asize ) | 2458 if ( !asize ) |
2417 return FT_THROW( Invalid_Size_Handle ); | 2459 return FT_THROW( Invalid_Argument ); |
2418 | 2460 |
2419 if ( !face->driver ) | 2461 if ( !face->driver ) |
2420 return FT_THROW( Invalid_Driver_Handle ); | 2462 return FT_THROW( Invalid_Driver_Handle ); |
2421 | 2463 |
2422 *asize = 0; | 2464 *asize = 0; |
2423 | 2465 |
2424 driver = face->driver; | 2466 driver = face->driver; |
2425 clazz = driver->clazz; | 2467 clazz = driver->clazz; |
2426 memory = face->memory; | 2468 memory = face->memory; |
2427 | 2469 |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 FT_EXPORT_DEF( FT_Error ) | 2958 FT_EXPORT_DEF( FT_Error ) |
2917 FT_Set_Char_Size( FT_Face face, | 2959 FT_Set_Char_Size( FT_Face face, |
2918 FT_F26Dot6 char_width, | 2960 FT_F26Dot6 char_width, |
2919 FT_F26Dot6 char_height, | 2961 FT_F26Dot6 char_height, |
2920 FT_UInt horz_resolution, | 2962 FT_UInt horz_resolution, |
2921 FT_UInt vert_resolution ) | 2963 FT_UInt vert_resolution ) |
2922 { | 2964 { |
2923 FT_Size_RequestRec req; | 2965 FT_Size_RequestRec req; |
2924 | 2966 |
2925 | 2967 |
| 2968 /* check of `face' delayed to `FT_Request_Size' */ |
| 2969 |
2926 if ( !char_width ) | 2970 if ( !char_width ) |
2927 char_width = char_height; | 2971 char_width = char_height; |
2928 else if ( !char_height ) | 2972 else if ( !char_height ) |
2929 char_height = char_width; | 2973 char_height = char_width; |
2930 | 2974 |
2931 if ( !horz_resolution ) | 2975 if ( !horz_resolution ) |
2932 horz_resolution = vert_resolution; | 2976 horz_resolution = vert_resolution; |
2933 else if ( !vert_resolution ) | 2977 else if ( !vert_resolution ) |
2934 vert_resolution = horz_resolution; | 2978 vert_resolution = horz_resolution; |
2935 | 2979 |
(...skipping 18 matching lines...) Expand all Loading... |
2954 /* documentation is in freetype.h */ | 2998 /* documentation is in freetype.h */ |
2955 | 2999 |
2956 FT_EXPORT_DEF( FT_Error ) | 3000 FT_EXPORT_DEF( FT_Error ) |
2957 FT_Set_Pixel_Sizes( FT_Face face, | 3001 FT_Set_Pixel_Sizes( FT_Face face, |
2958 FT_UInt pixel_width, | 3002 FT_UInt pixel_width, |
2959 FT_UInt pixel_height ) | 3003 FT_UInt pixel_height ) |
2960 { | 3004 { |
2961 FT_Size_RequestRec req; | 3005 FT_Size_RequestRec req; |
2962 | 3006 |
2963 | 3007 |
| 3008 /* check of `face' delayed to `FT_Request_Size' */ |
| 3009 |
2964 if ( pixel_width == 0 ) | 3010 if ( pixel_width == 0 ) |
2965 pixel_width = pixel_height; | 3011 pixel_width = pixel_height; |
2966 else if ( pixel_height == 0 ) | 3012 else if ( pixel_height == 0 ) |
2967 pixel_height = pixel_width; | 3013 pixel_height = pixel_width; |
2968 | 3014 |
2969 if ( pixel_width < 1 ) | 3015 if ( pixel_width < 1 ) |
2970 pixel_width = 1; | 3016 pixel_width = 1; |
2971 if ( pixel_height < 1 ) | 3017 if ( pixel_height < 1 ) |
2972 pixel_height = 1; | 3018 pixel_height = 1; |
2973 | 3019 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3104 cur = face->charmaps; | 3150 cur = face->charmaps; |
3105 if ( !cur ) | 3151 if ( !cur ) |
3106 return FT_THROW( Invalid_CharMap_Handle ); | 3152 return FT_THROW( Invalid_CharMap_Handle ); |
3107 | 3153 |
3108 limit = cur + face->num_charmaps; | 3154 limit = cur + face->num_charmaps; |
3109 | 3155 |
3110 for ( ; cur < limit; cur++ ) | 3156 for ( ; cur < limit; cur++ ) |
3111 { | 3157 { |
3112 if ( cur[0]->encoding == encoding ) | 3158 if ( cur[0]->encoding == encoding ) |
3113 { | 3159 { |
3114 #ifdef FT_MAX_CHARMAP_CACHEABLE | |
3115 if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE ) | |
3116 { | |
3117 FT_ERROR(( "FT_Select_Charmap: requested charmap is found (%d), " | |
3118 "but in too late position to cache\n", | |
3119 cur - face->charmaps )); | |
3120 continue; | |
3121 } | |
3122 #endif | |
3123 face->charmap = cur[0]; | 3160 face->charmap = cur[0]; |
3124 return 0; | 3161 return 0; |
3125 } | 3162 } |
3126 } | 3163 } |
3127 | 3164 |
3128 return FT_THROW( Invalid_Argument ); | 3165 return FT_THROW( Invalid_Argument ); |
3129 } | 3166 } |
3130 | 3167 |
3131 | 3168 |
3132 /* documentation is in freetype.h */ | 3169 /* documentation is in freetype.h */ |
3133 | 3170 |
3134 FT_EXPORT_DEF( FT_Error ) | 3171 FT_EXPORT_DEF( FT_Error ) |
3135 FT_Set_Charmap( FT_Face face, | 3172 FT_Set_Charmap( FT_Face face, |
3136 FT_CharMap charmap ) | 3173 FT_CharMap charmap ) |
3137 { | 3174 { |
3138 FT_CharMap* cur; | 3175 FT_CharMap* cur; |
3139 FT_CharMap* limit; | 3176 FT_CharMap* limit; |
3140 | 3177 |
3141 | 3178 |
3142 if ( !face ) | 3179 if ( !face ) |
3143 return FT_THROW( Invalid_Face_Handle ); | 3180 return FT_THROW( Invalid_Face_Handle ); |
3144 | 3181 |
3145 cur = face->charmaps; | 3182 cur = face->charmaps; |
3146 if ( !cur ) | 3183 if ( !cur || !charmap ) |
3147 return FT_THROW( Invalid_CharMap_Handle ); | 3184 return FT_THROW( Invalid_CharMap_Handle ); |
| 3185 |
3148 if ( FT_Get_CMap_Format( charmap ) == 14 ) | 3186 if ( FT_Get_CMap_Format( charmap ) == 14 ) |
3149 return FT_THROW( Invalid_Argument ); | 3187 return FT_THROW( Invalid_Argument ); |
3150 | 3188 |
3151 limit = cur + face->num_charmaps; | 3189 limit = cur + face->num_charmaps; |
3152 | 3190 |
3153 for ( ; cur < limit; cur++ ) | 3191 for ( ; cur < limit; cur++ ) |
3154 { | 3192 { |
3155 if ( cur[0] == charmap ) | 3193 if ( cur[0] == charmap ) |
3156 { | 3194 { |
3157 #ifdef FT_MAX_CHARMAP_CACHEABLE | |
3158 if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE ) | |
3159 { | |
3160 FT_ERROR(( "FT_Set_Charmap: requested charmap is found (%d), " | |
3161 "but in too late position to cache\n", | |
3162 cur - face->charmaps )); | |
3163 continue; | |
3164 } | |
3165 #endif | |
3166 face->charmap = cur[0]; | 3195 face->charmap = cur[0]; |
3167 return 0; | 3196 return FT_Err_Ok; |
3168 } | 3197 } |
3169 } | 3198 } |
| 3199 |
3170 return FT_THROW( Invalid_Argument ); | 3200 return FT_THROW( Invalid_Argument ); |
3171 } | 3201 } |
3172 | 3202 |
3173 | 3203 |
3174 /* documentation is in freetype.h */ | 3204 /* documentation is in freetype.h */ |
3175 | 3205 |
3176 FT_EXPORT_DEF( FT_Int ) | 3206 FT_EXPORT_DEF( FT_Int ) |
3177 FT_Get_Charmap_Index( FT_CharMap charmap ) | 3207 FT_Get_Charmap_Index( FT_CharMap charmap ) |
3178 { | 3208 { |
3179 FT_Int i; | 3209 FT_Int i; |
3180 | 3210 |
3181 | 3211 |
3182 if ( !charmap || !charmap->face ) | 3212 if ( !charmap || !charmap->face ) |
3183 return -1; | 3213 return -1; |
3184 | 3214 |
3185 for ( i = 0; i < charmap->face->num_charmaps; i++ ) | 3215 for ( i = 0; i < charmap->face->num_charmaps; i++ ) |
3186 if ( charmap->face->charmaps[i] == charmap ) | 3216 if ( charmap->face->charmaps[i] == charmap ) |
3187 break; | 3217 break; |
3188 | 3218 |
3189 FT_ASSERT( i < charmap->face->num_charmaps ); | 3219 FT_ASSERT( i < charmap->face->num_charmaps ); |
3190 | 3220 |
3191 #ifdef FT_MAX_CHARMAP_CACHEABLE | |
3192 if ( i > FT_MAX_CHARMAP_CACHEABLE ) | |
3193 { | |
3194 FT_ERROR(( "FT_Get_Charmap_Index: requested charmap is found (%d), " | |
3195 "but in too late position to cache\n", | |
3196 i )); | |
3197 return -i; | |
3198 } | |
3199 #endif | |
3200 return i; | 3221 return i; |
3201 } | 3222 } |
3202 | 3223 |
3203 | 3224 |
3204 static void | 3225 static void |
3205 ft_cmap_done_internal( FT_CMap cmap ) | 3226 ft_cmap_done_internal( FT_CMap cmap ) |
3206 { | 3227 { |
3207 FT_CMap_Class clazz = cmap->clazz; | 3228 FT_CMap_Class clazz = cmap->clazz; |
3208 FT_Face face = cmap->charmap.face; | 3229 FT_Face face = cmap->charmap.face; |
3209 FT_Memory memory = FT_FACE_MEMORY( face ); | 3230 FT_Memory memory = FT_FACE_MEMORY( face ); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3342 /* documentation is in freetype.h */ | 3363 /* documentation is in freetype.h */ |
3343 | 3364 |
3344 FT_EXPORT_DEF( FT_ULong ) | 3365 FT_EXPORT_DEF( FT_ULong ) |
3345 FT_Get_First_Char( FT_Face face, | 3366 FT_Get_First_Char( FT_Face face, |
3346 FT_UInt *agindex ) | 3367 FT_UInt *agindex ) |
3347 { | 3368 { |
3348 FT_ULong result = 0; | 3369 FT_ULong result = 0; |
3349 FT_UInt gindex = 0; | 3370 FT_UInt gindex = 0; |
3350 | 3371 |
3351 | 3372 |
| 3373 /* only do something if we have a charmap, and we have glyphs at all */ |
3352 if ( face && face->charmap && face->num_glyphs ) | 3374 if ( face && face->charmap && face->num_glyphs ) |
3353 { | 3375 { |
3354 gindex = FT_Get_Char_Index( face, 0 ); | 3376 gindex = FT_Get_Char_Index( face, 0 ); |
3355 if ( gindex == 0 || gindex >= (FT_UInt)face->num_glyphs ) | 3377 if ( gindex == 0 || gindex >= (FT_UInt)face->num_glyphs ) |
3356 result = FT_Get_Next_Char( face, 0, &gindex ); | 3378 result = FT_Get_Next_Char( face, 0, &gindex ); |
3357 } | 3379 } |
3358 | 3380 |
3359 if ( agindex ) | 3381 if ( agindex ) |
3360 *agindex = gindex; | 3382 *agindex = gindex; |
3361 | 3383 |
(...skipping 11 matching lines...) Expand all Loading... |
3373 FT_ULong result = 0; | 3395 FT_ULong result = 0; |
3374 FT_UInt gindex = 0; | 3396 FT_UInt gindex = 0; |
3375 | 3397 |
3376 | 3398 |
3377 if ( face && face->charmap && face->num_glyphs ) | 3399 if ( face && face->charmap && face->num_glyphs ) |
3378 { | 3400 { |
3379 FT_UInt32 code = (FT_UInt32)charcode; | 3401 FT_UInt32 code = (FT_UInt32)charcode; |
3380 FT_CMap cmap = FT_CMAP( face->charmap ); | 3402 FT_CMap cmap = FT_CMAP( face->charmap ); |
3381 | 3403 |
3382 | 3404 |
3383 do { | 3405 do |
| 3406 { |
3384 gindex = cmap->clazz->char_next( cmap, &code ); | 3407 gindex = cmap->clazz->char_next( cmap, &code ); |
| 3408 |
3385 } while ( gindex >= (FT_UInt)face->num_glyphs ); | 3409 } while ( gindex >= (FT_UInt)face->num_glyphs ); |
3386 | 3410 |
3387 result = ( gindex == 0 ) ? 0 : code; | 3411 result = ( gindex == 0 ) ? 0 : code; |
3388 } | 3412 } |
3389 | 3413 |
3390 if ( agindex ) | 3414 if ( agindex ) |
3391 *agindex = gindex; | 3415 *agindex = gindex; |
3392 | 3416 |
3393 return result; | 3417 return result; |
3394 } | 3418 } |
3395 | 3419 |
3396 | 3420 |
3397 /* documentation is in freetype.h */ | 3421 /* documentation is in freetype.h */ |
3398 | 3422 |
3399 FT_EXPORT_DEF( FT_UInt ) | 3423 FT_EXPORT_DEF( FT_UInt ) |
3400 FT_Face_GetCharVariantIndex( FT_Face face, | 3424 FT_Face_GetCharVariantIndex( FT_Face face, |
3401 FT_ULong charcode, | 3425 FT_ULong charcode, |
3402 FT_ULong variantSelector ) | 3426 FT_ULong variantSelector ) |
3403 { | 3427 { |
3404 FT_UInt result = 0; | 3428 FT_UInt result = 0; |
3405 | 3429 |
3406 | 3430 |
3407 if ( face && face->charmap && | 3431 if ( face && |
3408 face->charmap->encoding == FT_ENCODING_UNICODE ) | 3432 face->charmap && |
| 3433 face->charmap->encoding == FT_ENCODING_UNICODE ) |
3409 { | 3434 { |
3410 FT_CharMap charmap = find_variant_selector_charmap( face ); | 3435 FT_CharMap charmap = find_variant_selector_charmap( face ); |
3411 FT_CMap ucmap = FT_CMAP( face->charmap ); | 3436 FT_CMap ucmap = FT_CMAP( face->charmap ); |
3412 | 3437 |
3413 | 3438 |
3414 if ( charmap != NULL ) | 3439 if ( charmap != NULL ) |
3415 { | 3440 { |
3416 FT_CMap vcmap = FT_CMAP( charmap ); | 3441 FT_CMap vcmap = FT_CMAP( charmap ); |
3417 | 3442 |
3418 | 3443 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3576 | 3601 |
3577 /* documentation is in freetype.h */ | 3602 /* documentation is in freetype.h */ |
3578 | 3603 |
3579 FT_EXPORT_DEF( FT_UInt ) | 3604 FT_EXPORT_DEF( FT_UInt ) |
3580 FT_Get_Name_Index( FT_Face face, | 3605 FT_Get_Name_Index( FT_Face face, |
3581 FT_String* glyph_name ) | 3606 FT_String* glyph_name ) |
3582 { | 3607 { |
3583 FT_UInt result = 0; | 3608 FT_UInt result = 0; |
3584 | 3609 |
3585 | 3610 |
3586 if ( face && FT_HAS_GLYPH_NAMES( face ) ) | 3611 if ( face && |
| 3612 FT_HAS_GLYPH_NAMES( face ) && |
| 3613 glyph_name ) |
3587 { | 3614 { |
3588 FT_Service_GlyphDict service; | 3615 FT_Service_GlyphDict service; |
3589 | 3616 |
3590 | 3617 |
3591 FT_FACE_LOOKUP_SERVICE( face, | 3618 FT_FACE_LOOKUP_SERVICE( face, |
3592 service, | 3619 service, |
3593 GLYPH_DICT ); | 3620 GLYPH_DICT ); |
3594 | 3621 |
3595 if ( service && service->name_index ) | 3622 if ( service && service->name_index ) |
3596 result = service->name_index( face, glyph_name ); | 3623 result = service->name_index( face, glyph_name ); |
3597 } | 3624 } |
3598 | 3625 |
3599 return result; | 3626 return result; |
3600 } | 3627 } |
3601 | 3628 |
3602 | 3629 |
3603 /* documentation is in freetype.h */ | 3630 /* documentation is in freetype.h */ |
3604 | 3631 |
3605 FT_EXPORT_DEF( FT_Error ) | 3632 FT_EXPORT_DEF( FT_Error ) |
3606 FT_Get_Glyph_Name( FT_Face face, | 3633 FT_Get_Glyph_Name( FT_Face face, |
3607 FT_UInt glyph_index, | 3634 FT_UInt glyph_index, |
3608 FT_Pointer buffer, | 3635 FT_Pointer buffer, |
3609 FT_UInt buffer_max ) | 3636 FT_UInt buffer_max ) |
3610 { | 3637 { |
3611 FT_Error error = FT_ERR( Invalid_Argument ); | 3638 FT_Error error; |
| 3639 FT_Service_GlyphDict service; |
3612 | 3640 |
3613 | 3641 |
| 3642 if ( !face ) |
| 3643 return FT_THROW( Invalid_Face_Handle ); |
| 3644 |
| 3645 if ( !buffer || buffer_max == 0 ) |
| 3646 return FT_THROW( Invalid_Argument ); |
| 3647 |
3614 /* clean up buffer */ | 3648 /* clean up buffer */ |
3615 if ( buffer && buffer_max > 0 ) | 3649 ((FT_Byte*)buffer)[0] = '\0'; |
3616 ((FT_Byte*)buffer)[0] = 0; | |
3617 | 3650 |
3618 if ( face && | 3651 if ( (FT_Long)glyph_index > face->num_glyphs || |
3619 (FT_Long)glyph_index < face->num_glyphs && | 3652 !FT_HAS_GLYPH_NAMES( face ) ) |
3620 FT_HAS_GLYPH_NAMES( face ) ) | 3653 return FT_THROW( Invalid_Argument ); |
3621 { | |
3622 FT_Service_GlyphDict service; | |
3623 | 3654 |
3624 | 3655 FT_FACE_LOOKUP_SERVICE( face, service, GLYPH_DICT ); |
3625 FT_FACE_LOOKUP_SERVICE( face, | 3656 if ( service && service->get_name ) |
3626 service, | 3657 error = service->get_name( face, glyph_index, buffer, buffer_max ); |
3627 GLYPH_DICT ); | 3658 else |
3628 | 3659 error = FT_THROW( Invalid_Argument ); |
3629 if ( service && service->get_name ) | |
3630 error = service->get_name( face, glyph_index, buffer, buffer_max ); | |
3631 } | |
3632 | 3660 |
3633 return error; | 3661 return error; |
3634 } | 3662 } |
3635 | 3663 |
3636 | 3664 |
3637 /* documentation is in freetype.h */ | 3665 /* documentation is in freetype.h */ |
3638 | 3666 |
3639 FT_EXPORT_DEF( const char* ) | 3667 FT_EXPORT_DEF( const char* ) |
3640 FT_Get_Postscript_Name( FT_Face face ) | 3668 FT_Get_Postscript_Name( FT_Face face ) |
3641 { | 3669 { |
(...skipping 20 matching lines...) Expand all Loading... |
3662 return result; | 3690 return result; |
3663 } | 3691 } |
3664 | 3692 |
3665 | 3693 |
3666 /* documentation is in tttables.h */ | 3694 /* documentation is in tttables.h */ |
3667 | 3695 |
3668 FT_EXPORT_DEF( void* ) | 3696 FT_EXPORT_DEF( void* ) |
3669 FT_Get_Sfnt_Table( FT_Face face, | 3697 FT_Get_Sfnt_Table( FT_Face face, |
3670 FT_Sfnt_Tag tag ) | 3698 FT_Sfnt_Tag tag ) |
3671 { | 3699 { |
3672 void* table = 0; | 3700 void* table = NULL; |
3673 FT_Service_SFNT_Table service; | 3701 FT_Service_SFNT_Table service; |
3674 | 3702 |
3675 | 3703 |
3676 if ( face && FT_IS_SFNT( face ) ) | 3704 if ( face && FT_IS_SFNT( face ) ) |
3677 { | 3705 { |
3678 FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); | 3706 FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); |
3679 if ( service != NULL ) | 3707 if ( service != NULL ) |
3680 table = service->get_table( face, tag ); | 3708 table = service->get_table( face, tag ); |
3681 } | 3709 } |
3682 | 3710 |
(...skipping 29 matching lines...) Expand all Loading... |
3712 FT_EXPORT_DEF( FT_Error ) | 3740 FT_EXPORT_DEF( FT_Error ) |
3713 FT_Sfnt_Table_Info( FT_Face face, | 3741 FT_Sfnt_Table_Info( FT_Face face, |
3714 FT_UInt table_index, | 3742 FT_UInt table_index, |
3715 FT_ULong *tag, | 3743 FT_ULong *tag, |
3716 FT_ULong *length ) | 3744 FT_ULong *length ) |
3717 { | 3745 { |
3718 FT_Service_SFNT_Table service; | 3746 FT_Service_SFNT_Table service; |
3719 FT_ULong offset; | 3747 FT_ULong offset; |
3720 | 3748 |
3721 | 3749 |
| 3750 /* test for valid `length' delayed to `service->table_info' */ |
| 3751 |
3722 if ( !face || !FT_IS_SFNT( face ) ) | 3752 if ( !face || !FT_IS_SFNT( face ) ) |
3723 return FT_THROW( Invalid_Face_Handle ); | 3753 return FT_THROW( Invalid_Face_Handle ); |
3724 | 3754 |
3725 FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); | 3755 FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); |
3726 if ( service == NULL ) | 3756 if ( service == NULL ) |
3727 return FT_THROW( Unimplemented_Feature ); | 3757 return FT_THROW( Unimplemented_Feature ); |
3728 | 3758 |
3729 return service->table_info( face, table_index, tag, &offset, length ); | 3759 return service->table_info( face, table_index, tag, &offset, length ); |
3730 } | 3760 } |
3731 | 3761 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3779 | 3809 |
3780 | 3810 |
3781 /* documentation is in ftsizes.h */ | 3811 /* documentation is in ftsizes.h */ |
3782 | 3812 |
3783 FT_EXPORT_DEF( FT_Error ) | 3813 FT_EXPORT_DEF( FT_Error ) |
3784 FT_Activate_Size( FT_Size size ) | 3814 FT_Activate_Size( FT_Size size ) |
3785 { | 3815 { |
3786 FT_Face face; | 3816 FT_Face face; |
3787 | 3817 |
3788 | 3818 |
3789 if ( size == NULL ) | 3819 if ( !size ) |
3790 return FT_THROW( Invalid_Argument ); | 3820 return FT_THROW( Invalid_Size_Handle ); |
3791 | 3821 |
3792 face = size->face; | 3822 face = size->face; |
3793 if ( face == NULL || face->driver == NULL ) | 3823 if ( !face || !face->driver ) |
3794 return FT_THROW( Invalid_Argument ); | 3824 return FT_THROW( Invalid_Face_Handle ); |
3795 | 3825 |
3796 /* we don't need anything more complex than that; all size objects */ | 3826 /* we don't need anything more complex than that; all size objects */ |
3797 /* are already listed by the face */ | 3827 /* are already listed by the face */ |
3798 face->size = size; | 3828 face->size = size; |
3799 | 3829 |
3800 return FT_Err_Ok; | 3830 return FT_Err_Ok; |
3801 } | 3831 } |
3802 | 3832 |
3803 | 3833 |
3804 /*************************************************************************/ | 3834 /*************************************************************************/ |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3926 FT_FREE( node ); | 3956 FT_FREE( node ); |
3927 | 3957 |
3928 Exit: | 3958 Exit: |
3929 return error; | 3959 return error; |
3930 } | 3960 } |
3931 | 3961 |
3932 | 3962 |
3933 static void | 3963 static void |
3934 ft_remove_renderer( FT_Module module ) | 3964 ft_remove_renderer( FT_Module module ) |
3935 { | 3965 { |
3936 FT_Library library = module->library; | 3966 FT_Library library; |
3937 FT_Memory memory = library->memory; | 3967 FT_Memory memory; |
3938 FT_ListNode node; | 3968 FT_ListNode node; |
3939 | 3969 |
3940 | 3970 |
| 3971 library = module->library; |
| 3972 if ( !library ) |
| 3973 return; |
| 3974 |
| 3975 memory = library->memory; |
| 3976 |
3941 node = FT_List_Find( &library->renderers, module ); | 3977 node = FT_List_Find( &library->renderers, module ); |
3942 if ( node ) | 3978 if ( node ) |
3943 { | 3979 { |
3944 FT_Renderer render = FT_RENDERER( module ); | 3980 FT_Renderer render = FT_RENDERER( module ); |
3945 | 3981 |
3946 | 3982 |
3947 /* release raster object, if any */ | 3983 /* release raster object, if any */ |
3948 if ( render->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE && | 3984 if ( render->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE && |
3949 render->raster ) | 3985 render->raster ) |
3950 render->clazz->raster_class->raster_done( render->raster ); | 3986 render->clazz->raster_class->raster_done( render->raster ); |
3951 | 3987 |
3952 /* remove from list */ | 3988 /* remove from list */ |
3953 FT_List_Remove( &library->renderers, node ); | 3989 FT_List_Remove( &library->renderers, node ); |
3954 FT_FREE( node ); | 3990 FT_FREE( node ); |
3955 | 3991 |
3956 ft_set_current_renderer( library ); | 3992 ft_set_current_renderer( library ); |
3957 } | 3993 } |
3958 } | 3994 } |
3959 | 3995 |
3960 | 3996 |
3961 /* documentation is in ftrender.h */ | 3997 /* documentation is in ftrender.h */ |
3962 | 3998 |
3963 FT_EXPORT_DEF( FT_Renderer ) | 3999 FT_EXPORT_DEF( FT_Renderer ) |
3964 FT_Get_Renderer( FT_Library library, | 4000 FT_Get_Renderer( FT_Library library, |
3965 FT_Glyph_Format format ) | 4001 FT_Glyph_Format format ) |
3966 { | 4002 { |
3967 /* test for valid `library' delayed to FT_Lookup_Renderer() */ | 4003 /* test for valid `library' delayed to `FT_Lookup_Renderer' */ |
3968 | 4004 |
3969 return FT_Lookup_Renderer( library, format, 0 ); | 4005 return FT_Lookup_Renderer( library, format, 0 ); |
3970 } | 4006 } |
3971 | 4007 |
3972 | 4008 |
3973 /* documentation is in ftrender.h */ | 4009 /* documentation is in ftrender.h */ |
3974 | 4010 |
3975 FT_EXPORT_DEF( FT_Error ) | 4011 FT_EXPORT_DEF( FT_Error ) |
3976 FT_Set_Renderer( FT_Library library, | 4012 FT_Set_Renderer( FT_Library library, |
3977 FT_Renderer renderer, | 4013 FT_Renderer renderer, |
3978 FT_UInt num_params, | 4014 FT_UInt num_params, |
3979 FT_Parameter* parameters ) | 4015 FT_Parameter* parameters ) |
3980 { | 4016 { |
3981 FT_ListNode node; | 4017 FT_ListNode node; |
3982 FT_Error error = FT_Err_Ok; | 4018 FT_Error error = FT_Err_Ok; |
3983 | 4019 |
| 4020 FT_Renderer_SetModeFunc set_mode; |
| 4021 |
3984 | 4022 |
3985 if ( !library ) | 4023 if ( !library ) |
3986 return FT_THROW( Invalid_Library_Handle ); | 4024 { |
| 4025 error = FT_THROW( Invalid_Library_Handle ); |
| 4026 goto Exit; |
| 4027 } |
3987 | 4028 |
3988 if ( !renderer ) | 4029 if ( !renderer ) |
3989 return FT_THROW( Invalid_Argument ); | 4030 { |
| 4031 error = FT_THROW( Invalid_Argument ); |
| 4032 goto Exit; |
| 4033 } |
| 4034 |
| 4035 if ( num_params > 0 && !parameters ) |
| 4036 { |
| 4037 error = FT_THROW( Invalid_Argument ); |
| 4038 goto Exit; |
| 4039 } |
3990 | 4040 |
3991 node = FT_List_Find( &library->renderers, renderer ); | 4041 node = FT_List_Find( &library->renderers, renderer ); |
3992 if ( !node ) | 4042 if ( !node ) |
3993 { | 4043 { |
3994 error = FT_THROW( Invalid_Argument ); | 4044 error = FT_THROW( Invalid_Argument ); |
3995 goto Exit; | 4045 goto Exit; |
3996 } | 4046 } |
3997 | 4047 |
3998 FT_List_Up( &library->renderers, node ); | 4048 FT_List_Up( &library->renderers, node ); |
3999 | 4049 |
4000 if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE ) | 4050 if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE ) |
4001 library->cur_renderer = renderer; | 4051 library->cur_renderer = renderer; |
4002 | 4052 |
4003 if ( num_params > 0 ) | 4053 set_mode = renderer->clazz->set_mode; |
| 4054 |
| 4055 for ( ; num_params > 0; num_params-- ) |
4004 { | 4056 { |
4005 FT_Renderer_SetModeFunc set_mode = renderer->clazz->set_mode; | 4057 error = set_mode( renderer, parameters->tag, parameters->data ); |
4006 | 4058 if ( error ) |
4007 | 4059 break; |
4008 for ( ; num_params > 0; num_params-- ) | 4060 parameters++; |
4009 { | |
4010 error = set_mode( renderer, parameters->tag, parameters->data ); | |
4011 if ( error ) | |
4012 break; | |
4013 parameters++; | |
4014 } | |
4015 } | 4061 } |
4016 | 4062 |
4017 Exit: | 4063 Exit: |
4018 return error; | 4064 return error; |
4019 } | 4065 } |
4020 | 4066 |
4021 | 4067 |
4022 FT_BASE_DEF( FT_Error ) | 4068 FT_BASE_DEF( FT_Error ) |
4023 FT_Render_Glyph_Internal( FT_Library library, | 4069 FT_Render_Glyph_Internal( FT_Library library, |
4024 FT_GlyphSlot slot, | 4070 FT_GlyphSlot slot, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4063 | 4109 |
4064 /* now, look for another renderer that supports the same */ | 4110 /* now, look for another renderer that supports the same */ |
4065 /* format. */ | 4111 /* format. */ |
4066 renderer = FT_Lookup_Renderer( library, slot->format, &node ); | 4112 renderer = FT_Lookup_Renderer( library, slot->format, &node ); |
4067 update = 1; | 4113 update = 1; |
4068 } | 4114 } |
4069 | 4115 |
4070 /* if we changed the current renderer for the glyph image format */ | 4116 /* if we changed the current renderer for the glyph image format */ |
4071 /* we need to select it as the next current one */ | 4117 /* we need to select it as the next current one */ |
4072 if ( !error && update && renderer ) | 4118 if ( !error && update && renderer ) |
4073 FT_Set_Renderer( library, renderer, 0, 0 ); | 4119 { |
| 4120 error = FT_Set_Renderer( library, renderer, 0, 0 ); |
| 4121 if ( error ) |
| 4122 break; |
| 4123 } |
4074 } | 4124 } |
4075 } | 4125 } |
4076 | 4126 |
4077 #ifdef FT_DEBUG_LEVEL_TRACE | 4127 #ifdef FT_DEBUG_LEVEL_TRACE |
4078 | 4128 |
4079 #undef FT_COMPONENT | 4129 #undef FT_COMPONENT |
4080 #define FT_COMPONENT trace_bitmap | 4130 #define FT_COMPONENT trace_bitmap |
4081 | 4131 |
4082 /* we convert to a single bitmap format for computing the checksum */ | 4132 /* we convert to a single bitmap format for computing the checksum */ |
| 4133 if ( !error ) |
4083 { | 4134 { |
4084 FT_Bitmap bitmap; | 4135 FT_Bitmap bitmap; |
4085 FT_Error err; | 4136 FT_Error err; |
4086 | 4137 |
4087 | 4138 |
4088 FT_Bitmap_New( &bitmap ); | 4139 FT_Bitmap_New( &bitmap ); |
4089 | 4140 |
| 4141 /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */ |
4090 err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 ); | 4142 err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 ); |
4091 if ( !err ) | 4143 if ( !err ) |
4092 { | 4144 { |
4093 MD5_CTX ctx; | 4145 MD5_CTX ctx; |
4094 unsigned char md5[16]; | 4146 unsigned char md5[16]; |
4095 int i; | 4147 int i; |
4096 | 4148 |
4097 | 4149 |
4098 MD5_Init( &ctx); | 4150 MD5_Init( &ctx); |
4099 MD5_Update( &ctx, bitmap.buffer, bitmap.rows * bitmap.pitch ); | 4151 MD5_Update( &ctx, bitmap.buffer, bitmap.rows * bitmap.pitch ); |
(...skipping 11 matching lines...) Expand all Loading... |
4111 } | 4163 } |
4112 | 4164 |
4113 #undef FT_COMPONENT | 4165 #undef FT_COMPONENT |
4114 #define FT_COMPONENT trace_objs | 4166 #define FT_COMPONENT trace_objs |
4115 | 4167 |
4116 #endif /* FT_DEBUG_LEVEL_TRACE */ | 4168 #endif /* FT_DEBUG_LEVEL_TRACE */ |
4117 | 4169 |
4118 return error; | 4170 return error; |
4119 } | 4171 } |
4120 | 4172 |
| 4173 |
4121 /* documentation is in freetype.h */ | 4174 /* documentation is in freetype.h */ |
4122 | 4175 |
4123 FT_EXPORT_DEF( FT_Error ) | 4176 FT_EXPORT_DEF( FT_Error ) |
4124 FT_Render_Glyph( FT_GlyphSlot slot, | 4177 FT_Render_Glyph( FT_GlyphSlot slot, |
4125 FT_Render_Mode render_mode ) | 4178 FT_Render_Mode render_mode ) |
4126 { | 4179 { |
4127 FT_Library library; | 4180 FT_Library library; |
4128 | 4181 |
| 4182 |
4129 if ( !slot || !slot->face ) | 4183 if ( !slot || !slot->face ) |
4130 return FT_THROW( Invalid_Argument ); | 4184 return FT_THROW( Invalid_Argument ); |
4131 | 4185 |
4132 library = FT_FACE_LIBRARY( slot->face ); | 4186 library = FT_FACE_LIBRARY( slot->face ); |
4133 | 4187 |
4134 return FT_Render_Glyph_Internal( library, slot, render_mode ); | 4188 return FT_Render_Glyph_Internal( library, slot, render_mode ); |
4135 } | 4189 } |
4136 | 4190 |
4137 | 4191 |
4138 /*************************************************************************/ | 4192 /*************************************************************************/ |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4319 goto Exit; | 4373 goto Exit; |
4320 } | 4374 } |
4321 | 4375 |
4322 | 4376 |
4323 /* documentation is in ftmodapi.h */ | 4377 /* documentation is in ftmodapi.h */ |
4324 | 4378 |
4325 FT_EXPORT_DEF( FT_Module ) | 4379 FT_EXPORT_DEF( FT_Module ) |
4326 FT_Get_Module( FT_Library library, | 4380 FT_Get_Module( FT_Library library, |
4327 const char* module_name ) | 4381 const char* module_name ) |
4328 { | 4382 { |
4329 FT_Module result = 0; | 4383 FT_Module result = NULL; |
4330 FT_Module* cur; | 4384 FT_Module* cur; |
4331 FT_Module* limit; | 4385 FT_Module* limit; |
4332 | 4386 |
4333 | 4387 |
4334 if ( !library || !module_name ) | 4388 if ( !library || !module_name ) |
4335 return result; | 4389 return result; |
4336 | 4390 |
4337 cur = library->modules; | 4391 cur = library->modules; |
4338 limit = cur + library->num_modules; | 4392 limit = cur + library->num_modules; |
4339 | 4393 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4444 Destroy_Module( module ); | 4498 Destroy_Module( module ); |
4445 | 4499 |
4446 return FT_Err_Ok; | 4500 return FT_Err_Ok; |
4447 } | 4501 } |
4448 } | 4502 } |
4449 } | 4503 } |
4450 return FT_THROW( Invalid_Driver_Handle ); | 4504 return FT_THROW( Invalid_Driver_Handle ); |
4451 } | 4505 } |
4452 | 4506 |
4453 | 4507 |
4454 FT_Error | 4508 static FT_Error |
4455 ft_property_do( FT_Library library, | 4509 ft_property_do( FT_Library library, |
4456 const FT_String* module_name, | 4510 const FT_String* module_name, |
4457 const FT_String* property_name, | 4511 const FT_String* property_name, |
4458 void* value, | 4512 void* value, |
4459 FT_Bool set ) | 4513 FT_Bool set ) |
4460 { | 4514 { |
4461 FT_Module* cur; | 4515 FT_Module* cur; |
4462 FT_Module* limit; | 4516 FT_Module* limit; |
4463 FT_Module_Interface interface1; | 4517 FT_Module_Interface interface; |
| 4518 |
4464 FT_Service_Properties service; | 4519 FT_Service_Properties service; |
4465 | 4520 |
4466 #ifdef FT_DEBUG_LEVEL_ERROR | 4521 #ifdef FT_DEBUG_LEVEL_ERROR |
4467 const FT_String* set_name = "FT_Property_Set"; | 4522 const FT_String* set_name = "FT_Property_Set"; |
4468 const FT_String* get_name = "FT_Property_Get"; | 4523 const FT_String* get_name = "FT_Property_Get"; |
4469 const FT_String* func_name = set ? set_name : get_name; | 4524 const FT_String* func_name = set ? set_name : get_name; |
4470 #endif | 4525 #endif |
4471 | 4526 |
4472 FT_Bool missing_func; | 4527 FT_Bool missing_func; |
4473 | 4528 |
(...skipping 21 matching lines...) Expand all Loading... |
4495 | 4550 |
4496 /* check whether we have a service interface */ | 4551 /* check whether we have a service interface */ |
4497 if ( !cur[0]->clazz->get_interface ) | 4552 if ( !cur[0]->clazz->get_interface ) |
4498 { | 4553 { |
4499 FT_ERROR(( "%s: module `%s' doesn't support properties\n", | 4554 FT_ERROR(( "%s: module `%s' doesn't support properties\n", |
4500 func_name, module_name )); | 4555 func_name, module_name )); |
4501 return FT_THROW( Unimplemented_Feature ); | 4556 return FT_THROW( Unimplemented_Feature ); |
4502 } | 4557 } |
4503 | 4558 |
4504 /* search property service */ | 4559 /* search property service */ |
4505 interface1 = cur[0]->clazz->get_interface( cur[0], | 4560 interface = cur[0]->clazz->get_interface( cur[0], |
4506 FT_SERVICE_ID_PROPERTIES ); | 4561 FT_SERVICE_ID_PROPERTIES ); |
4507 if ( !interface1 ) | 4562 if ( !interface ) |
4508 { | 4563 { |
4509 FT_ERROR(( "%s: module `%s' doesn't support properties\n", | 4564 FT_ERROR(( "%s: module `%s' doesn't support properties\n", |
4510 func_name, module_name )); | 4565 func_name, module_name )); |
4511 return FT_THROW( Unimplemented_Feature ); | 4566 return FT_THROW( Unimplemented_Feature ); |
4512 } | 4567 } |
4513 | 4568 |
4514 service = (FT_Service_Properties)interface1; | 4569 service = (FT_Service_Properties)interface; |
4515 | 4570 |
4516 if ( set ) | 4571 if ( set ) |
4517 missing_func = (FT_Bool)( !service->set_property ); | 4572 missing_func = (FT_Bool)( !service->set_property ); |
4518 else | 4573 else |
4519 missing_func = (FT_Bool)( !service->get_property ); | 4574 missing_func = (FT_Bool)( !service->get_property ); |
4520 | 4575 |
4521 if ( missing_func ) | 4576 if ( missing_func ) |
4522 { | 4577 { |
4523 FT_ERROR(( "%s: property service of module `%s' is broken\n", | 4578 FT_ERROR(( "%s: property service of module `%s' is broken\n", |
4524 func_name, module_name )); | 4579 func_name, module_name )); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4573 /*************************************************************************/ | 4628 /*************************************************************************/ |
4574 /*************************************************************************/ | 4629 /*************************************************************************/ |
4575 /*************************************************************************/ | 4630 /*************************************************************************/ |
4576 | 4631 |
4577 | 4632 |
4578 /* documentation is in ftmodapi.h */ | 4633 /* documentation is in ftmodapi.h */ |
4579 | 4634 |
4580 FT_EXPORT_DEF( FT_Error ) | 4635 FT_EXPORT_DEF( FT_Error ) |
4581 FT_Reference_Library( FT_Library library ) | 4636 FT_Reference_Library( FT_Library library ) |
4582 { | 4637 { |
| 4638 if ( !library ) |
| 4639 return FT_THROW( Invalid_Library_Handle ); |
| 4640 |
4583 library->refcount++; | 4641 library->refcount++; |
4584 | 4642 |
4585 return FT_Err_Ok; | 4643 return FT_Err_Ok; |
4586 } | 4644 } |
4587 | 4645 |
4588 | 4646 |
4589 /* documentation is in ftmodapi.h */ | 4647 /* documentation is in ftmodapi.h */ |
4590 | 4648 |
4591 FT_EXPORT_DEF( FT_Error ) | 4649 FT_EXPORT_DEF( FT_Error ) |
4592 FT_New_Library( FT_Memory memory, | 4650 FT_New_Library( FT_Memory memory, |
4593 FT_Library *alibrary ) | 4651 FT_Library *alibrary ) |
4594 { | 4652 { |
4595 FT_Library library = NULL; | 4653 FT_Library library = NULL; |
4596 FT_Error error; | 4654 FT_Error error; |
4597 | 4655 |
4598 | 4656 |
4599 if ( !memory ) | 4657 if ( !memory || !alibrary ) |
4600 return FT_THROW( Invalid_Argument ); | 4658 return FT_THROW( Invalid_Argument ); |
4601 | 4659 |
4602 #ifdef FT_DEBUG_LEVEL_ERROR | 4660 #ifdef FT_DEBUG_LEVEL_ERROR |
4603 /* init debugging support */ | 4661 /* init debugging support */ |
4604 ft_debug_init(); | 4662 ft_debug_init(); |
4605 #endif | 4663 #endif |
4606 | 4664 |
4607 /* first of all, allocate the library object */ | 4665 /* first of all, allocate the library object */ |
4608 if ( FT_NEW( library ) ) | 4666 if ( FT_NEW( library ) ) |
4609 return error; | 4667 return error; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4851 sub_index < glyph->num_subglyphs ) | 4909 sub_index < glyph->num_subglyphs ) |
4852 { | 4910 { |
4853 FT_SubGlyph subg = glyph->subglyphs + sub_index; | 4911 FT_SubGlyph subg = glyph->subglyphs + sub_index; |
4854 | 4912 |
4855 | 4913 |
4856 *p_index = subg->index; | 4914 *p_index = subg->index; |
4857 *p_flags = subg->flags; | 4915 *p_flags = subg->flags; |
4858 *p_arg1 = subg->arg1; | 4916 *p_arg1 = subg->arg1; |
4859 *p_arg2 = subg->arg2; | 4917 *p_arg2 = subg->arg2; |
4860 *p_transform = subg->transform; | 4918 *p_transform = subg->transform; |
| 4919 |
| 4920 error = FT_Err_Ok; |
4861 } | 4921 } |
4862 | 4922 |
4863 return error; | 4923 return error; |
4864 } | 4924 } |
4865 | 4925 |
4866 | 4926 |
4867 /* END */ | 4927 /* END */ |
OLD | NEW |