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-2012 by */ | 7 /* Copyright 1996-2013 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 #include FT_LIST_H | 20 #include FT_LIST_H |
21 #include FT_OUTLINE_H | 21 #include FT_OUTLINE_H |
22 #include FT_INTERNAL_VALIDATE_H | 22 #include FT_INTERNAL_VALIDATE_H |
23 #include FT_INTERNAL_OBJECTS_H | 23 #include FT_INTERNAL_OBJECTS_H |
24 #include FT_INTERNAL_DEBUG_H | 24 #include FT_INTERNAL_DEBUG_H |
25 #include FT_INTERNAL_RFORK_H | 25 #include FT_INTERNAL_RFORK_H |
26 #include FT_INTERNAL_STREAM_H | 26 #include FT_INTERNAL_STREAM_H |
27 #include FT_INTERNAL_SFNT_H /* for SFNT_Load_Table_Func */ | 27 #include FT_INTERNAL_SFNT_H /* for SFNT_Load_Table_Func */ |
28 #include FT_TRUETYPE_TABLES_H | 28 #include FT_TRUETYPE_TABLES_H |
29 #include FT_TRUETYPE_TAGS_H | 29 #include FT_TRUETYPE_TAGS_H |
30 #include FT_TRUETYPE_IDS_H | 30 #include FT_TRUETYPE_IDS_H |
31 | 31 |
| 32 #include FT_SERVICE_PROPERTIES_H |
32 #include FT_SERVICE_SFNT_H | 33 #include FT_SERVICE_SFNT_H |
33 #include FT_SERVICE_POSTSCRIPT_NAME_H | 34 #include FT_SERVICE_POSTSCRIPT_NAME_H |
34 #include FT_SERVICE_GLYPH_DICT_H | 35 #include FT_SERVICE_GLYPH_DICT_H |
35 #include FT_SERVICE_TT_CMAP_H | 36 #include FT_SERVICE_TT_CMAP_H |
36 #include FT_SERVICE_KERNING_H | 37 #include FT_SERVICE_KERNING_H |
37 #include FT_SERVICE_TRUETYPE_ENGINE_H | 38 #include FT_SERVICE_TRUETYPE_ENGINE_H |
38 | 39 |
39 #ifdef FT_CONFIG_OPTION_MAC_FONTS | 40 #ifdef FT_CONFIG_OPTION_MAC_FONTS |
40 #include "ftbase.h" | 41 #include "ftbase.h" |
41 #endif | 42 #endif |
42 | 43 |
| 44 |
| 45 #ifdef FT_DEBUG_LEVEL_TRACE |
| 46 |
| 47 #include FT_BITMAP_H |
| 48 |
| 49 #if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ |
| 50 /* We disable the warning `conversion from XXX to YYY, */ |
| 51 /* possible loss of data' in order to compile cleanly with */ |
| 52 /* the maximum level of warnings: `md5.c' is non-FreeType */ |
| 53 /* code, and it gets used during development builds only. */ |
| 54 #pragma warning( push ) |
| 55 #pragma warning( disable : 4244 ) |
| 56 #endif /* _MSC_VER */ |
| 57 |
| 58 /* it's easiest to include `md5.c' directly */ |
| 59 #define free md5_free /* suppress a shadow warning */ |
| 60 #include "md5.c" |
| 61 #undef free |
| 62 |
| 63 #if defined( _MSC_VER ) |
| 64 #pragma warning( pop ) |
| 65 #endif |
| 66 |
| 67 #endif /* FT_DEBUG_LEVEL_TRACE */ |
| 68 |
| 69 |
43 #define GRID_FIT_METRICS | 70 #define GRID_FIT_METRICS |
44 | 71 |
45 | 72 |
46 FT_BASE_DEF( FT_Pointer ) | 73 FT_BASE_DEF( FT_Pointer ) |
47 ft_service_list_lookup( FT_ServiceDesc service_descriptors, | 74 ft_service_list_lookup( FT_ServiceDesc service_descriptors, |
48 const char* service_id ) | 75 const char* service_id ) |
49 { | 76 { |
50 FT_Pointer result = NULL; | 77 FT_Pointer result = NULL; |
51 FT_ServiceDesc desc = service_descriptors; | 78 FT_ServiceDesc desc = service_descriptors; |
52 | 79 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 FT_Stream *astream ) | 156 FT_Stream *astream ) |
130 { | 157 { |
131 FT_Error error; | 158 FT_Error error; |
132 FT_Memory memory; | 159 FT_Memory memory; |
133 FT_Stream stream = NULL; | 160 FT_Stream stream = NULL; |
134 | 161 |
135 | 162 |
136 *astream = 0; | 163 *astream = 0; |
137 | 164 |
138 if ( !library ) | 165 if ( !library ) |
139 return FT_Err_Invalid_Library_Handle; | 166 return FT_THROW( Invalid_Library_Handle ); |
140 | 167 |
141 if ( !args ) | 168 if ( !args ) |
142 return FT_Err_Invalid_Argument; | 169 return FT_THROW( Invalid_Argument ); |
143 | 170 |
144 memory = library->memory; | 171 memory = library->memory; |
145 | 172 |
146 if ( FT_NEW( stream ) ) | 173 if ( FT_NEW( stream ) ) |
147 goto Exit; | 174 goto Exit; |
148 | 175 |
149 stream->memory = memory; | 176 stream->memory = memory; |
150 | 177 |
151 if ( args->flags & FT_OPEN_MEMORY ) | 178 if ( args->flags & FT_OPEN_MEMORY ) |
152 { | 179 { |
(...skipping 17 matching lines...) Expand all Loading... |
170 | 197 |
171 /* in this case, we do not need to allocate a new stream object */ | 198 /* in this case, we do not need to allocate a new stream object */ |
172 /* since the caller is responsible for closing it himself */ | 199 /* since the caller is responsible for closing it himself */ |
173 FT_FREE( stream ); | 200 FT_FREE( stream ); |
174 stream = args->stream; | 201 stream = args->stream; |
175 } | 202 } |
176 | 203 |
177 #endif | 204 #endif |
178 | 205 |
179 else | 206 else |
180 error = FT_Err_Invalid_Argument; | 207 error = FT_THROW( Invalid_Argument ); |
181 | 208 |
182 if ( error ) | 209 if ( error ) |
183 FT_FREE( stream ); | 210 FT_FREE( stream ); |
184 else | 211 else |
185 stream->memory = memory; /* just to be certain */ | 212 stream->memory = memory; /* just to be certain */ |
186 | 213 |
187 *astream = stream; | 214 *astream = stream; |
188 | 215 |
189 Exit: | 216 Exit: |
190 return error; | 217 return error; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 FT_GlyphSlot *aslot ) | 404 FT_GlyphSlot *aslot ) |
378 { | 405 { |
379 FT_Error error; | 406 FT_Error error; |
380 FT_Driver driver; | 407 FT_Driver driver; |
381 FT_Driver_Class clazz; | 408 FT_Driver_Class clazz; |
382 FT_Memory memory; | 409 FT_Memory memory; |
383 FT_GlyphSlot slot = NULL; | 410 FT_GlyphSlot slot = NULL; |
384 | 411 |
385 | 412 |
386 if ( !face || !face->driver ) | 413 if ( !face || !face->driver ) |
387 return FT_Err_Invalid_Argument; | 414 return FT_THROW( Invalid_Argument ); |
388 | 415 |
389 driver = face->driver; | 416 driver = face->driver; |
390 clazz = driver->clazz; | 417 clazz = driver->clazz; |
391 memory = driver->root.memory; | 418 memory = driver->root.memory; |
392 | 419 |
393 FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" )); | 420 FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" )); |
394 if ( !FT_ALLOC( slot, clazz->slot_object_size ) ) | 421 if ( !FT_ALLOC( slot, clazz->slot_object_size ) ) |
395 { | 422 { |
396 slot->face = face; | 423 slot->face = face; |
397 | 424 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 FT_Error error; | 594 FT_Error error; |
568 FT_Driver driver; | 595 FT_Driver driver; |
569 FT_GlyphSlot slot; | 596 FT_GlyphSlot slot; |
570 FT_Library library; | 597 FT_Library library; |
571 FT_Bool autohint = FALSE; | 598 FT_Bool autohint = FALSE; |
572 FT_Module hinter; | 599 FT_Module hinter; |
573 TT_Face ttface = (TT_Face)face; | 600 TT_Face ttface = (TT_Face)face; |
574 | 601 |
575 | 602 |
576 if ( !face || !face->size || !face->glyph ) | 603 if ( !face || !face->size || !face->glyph ) |
577 return FT_Err_Invalid_Face_Handle; | 604 return FT_THROW( Invalid_Face_Handle ); |
578 | 605 |
579 /* The validity test for `glyph_index' is performed by the */ | 606 /* The validity test for `glyph_index' is performed by the */ |
580 /* font drivers. */ | 607 /* font drivers. */ |
581 | 608 |
582 slot = face->glyph; | 609 slot = face->glyph; |
583 ft_glyphslot_clear( slot ); | 610 ft_glyphslot_clear( slot ); |
584 | 611 |
585 driver = face->driver; | 612 driver = face->driver; |
586 library = driver->root.library; | 613 library = driver->root.library; |
587 hinter = library->auto_hinter; | 614 hinter = library->auto_hinter; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 face->internal->ignore_unpatented_hinter || | 671 face->internal->ignore_unpatented_hinter || |
645 ( FT_IS_SFNT( face ) && | 672 ( FT_IS_SFNT( face ) && |
646 ttface->num_locations && | 673 ttface->num_locations && |
647 ttface->max_profile.maxSizeOfInstructions == 0 ) ) | 674 ttface->max_profile.maxSizeOfInstructions == 0 ) ) |
648 autohint = TRUE; | 675 autohint = TRUE; |
649 } | 676 } |
650 } | 677 } |
651 | 678 |
652 if ( autohint ) | 679 if ( autohint ) |
653 { | 680 { |
654 FT_AutoHinter_Service hinting; | 681 FT_AutoHinter_Interface hinting; |
655 | 682 |
656 | 683 |
657 /* try to load embedded bitmaps first if available */ | 684 /* try to load embedded bitmaps first if available */ |
658 /* */ | 685 /* */ |
659 /* XXX: This is really a temporary hack that should disappear */ | 686 /* XXX: This is really a temporary hack that should disappear */ |
660 /* promptly with FreeType 2.1! */ | 687 /* promptly with FreeType 2.1! */ |
661 /* */ | 688 /* */ |
662 if ( FT_HAS_FIXED_SIZES( face ) && | 689 if ( FT_HAS_FIXED_SIZES( face ) && |
663 ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) | 690 ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) |
664 { | 691 { |
665 error = driver->clazz->load_glyph( slot, face->size, | 692 error = driver->clazz->load_glyph( slot, face->size, |
666 glyph_index, | 693 glyph_index, |
667 load_flags | FT_LOAD_SBITS_ONLY ); | 694 load_flags | FT_LOAD_SBITS_ONLY ); |
668 | 695 |
669 if ( !error && slot->format == FT_GLYPH_FORMAT_BITMAP ) | 696 if ( !error && slot->format == FT_GLYPH_FORMAT_BITMAP ) |
670 goto Load_Ok; | 697 goto Load_Ok; |
671 } | 698 } |
672 | 699 |
673 { | 700 { |
674 FT_Face_Internal internal = face->internal; | 701 FT_Face_Internal internal = face->internal; |
675 FT_Int transform_flags = internal->transform_flags; | 702 FT_Int transform_flags = internal->transform_flags; |
676 | 703 |
677 | 704 |
678 /* since the auto-hinter calls FT_Load_Glyph by itself, */ | 705 /* since the auto-hinter calls FT_Load_Glyph by itself, */ |
679 /* make sure that glyphs aren't transformed */ | 706 /* make sure that glyphs aren't transformed */ |
680 internal->transform_flags = 0; | 707 internal->transform_flags = 0; |
681 | 708 |
682 /* load auto-hinted outline */ | 709 /* load auto-hinted outline */ |
683 hinting = (FT_AutoHinter_Service)hinter->clazz->module_interface; | 710 hinting = (FT_AutoHinter_Interface)hinter->clazz->module_interface; |
684 | 711 |
685 error = hinting->load_glyph( (FT_AutoHinter)hinter, | 712 error = hinting->load_glyph( (FT_AutoHinter)hinter, |
686 slot, face->size, | 713 slot, face->size, |
687 glyph_index, load_flags ); | 714 glyph_index, load_flags ); |
688 | 715 |
689 internal->transform_flags = transform_flags; | 716 internal->transform_flags = transform_flags; |
690 } | 717 } |
691 } | 718 } |
692 else | 719 else |
693 { | 720 { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 | 834 |
808 FT_EXPORT_DEF( FT_Error ) | 835 FT_EXPORT_DEF( FT_Error ) |
809 FT_Load_Char( FT_Face face, | 836 FT_Load_Char( FT_Face face, |
810 FT_ULong char_code, | 837 FT_ULong char_code, |
811 FT_Int32 load_flags ) | 838 FT_Int32 load_flags ) |
812 { | 839 { |
813 FT_UInt glyph_index; | 840 FT_UInt glyph_index; |
814 | 841 |
815 | 842 |
816 if ( !face ) | 843 if ( !face ) |
817 return FT_Err_Invalid_Face_Handle; | 844 return FT_THROW( Invalid_Face_Handle ); |
818 | 845 |
819 glyph_index = (FT_UInt)char_code; | 846 glyph_index = (FT_UInt)char_code; |
820 if ( face->charmap ) | 847 if ( face->charmap ) |
821 glyph_index = FT_Get_Char_Index( face, char_code ); | 848 glyph_index = FT_Get_Char_Index( face, char_code ); |
822 | 849 |
823 return FT_Load_Glyph( face, glyph_index, load_flags ); | 850 return FT_Load_Glyph( face, glyph_index, load_flags ); |
824 } | 851 } |
825 | 852 |
826 | 853 |
827 /* destructor for sizes list */ | 854 /* destructor for sizes list */ |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 FT_CharMap* first; | 985 FT_CharMap* first; |
959 FT_CharMap* cur; | 986 FT_CharMap* cur; |
960 | 987 |
961 | 988 |
962 /* caller should have already checked that `face' is valid */ | 989 /* caller should have already checked that `face' is valid */ |
963 FT_ASSERT( face ); | 990 FT_ASSERT( face ); |
964 | 991 |
965 first = face->charmaps; | 992 first = face->charmaps; |
966 | 993 |
967 if ( !first ) | 994 if ( !first ) |
968 return FT_Err_Invalid_CharMap_Handle; | 995 return FT_THROW( Invalid_CharMap_Handle ); |
969 | 996 |
970 /* | 997 /* |
971 * The original TrueType specification(s) only specified charmap | 998 * The original TrueType specification(s) only specified charmap |
972 * formats that are capable of mapping 8 or 16 bit character codes to | 999 * formats that are capable of mapping 8 or 16 bit character codes to |
973 * glyph indices. | 1000 * glyph indices. |
974 * | 1001 * |
975 * However, recent updates to the Apple and OpenType specifications | 1002 * However, recent updates to the Apple and OpenType specifications |
976 * introduced new formats that are capable of mapping 32-bit character | 1003 * introduced new formats that are capable of mapping 32-bit character |
977 * codes as well. And these are already used on some fonts, mainly to | 1004 * codes as well. And these are already used on some fonts, mainly to |
978 * map non-BMP Asian ideographs as defined in Unicode. | 1005 * map non-BMP Asian ideographs as defined in Unicode. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 FT_ERROR(( "find_unicode_charmap: UCS-2 cmap is found " | 1063 FT_ERROR(( "find_unicode_charmap: UCS-2 cmap is found " |
1037 "at too late position (%d)\n", cur - first )); | 1064 "at too late position (%d)\n", cur - first )); |
1038 continue; | 1065 continue; |
1039 } | 1066 } |
1040 #endif | 1067 #endif |
1041 face->charmap = cur[0]; | 1068 face->charmap = cur[0]; |
1042 return FT_Err_Ok; | 1069 return FT_Err_Ok; |
1043 } | 1070 } |
1044 } | 1071 } |
1045 | 1072 |
1046 return FT_Err_Invalid_CharMap_Handle; | 1073 return FT_THROW( Invalid_CharMap_Handle ); |
1047 } | 1074 } |
1048 | 1075 |
1049 | 1076 |
1050 /*************************************************************************/ | 1077 /*************************************************************************/ |
1051 /* */ | 1078 /* */ |
1052 /* <Function> */ | 1079 /* <Function> */ |
1053 /* find_variant_selector_charmap */ | 1080 /* find_variant_selector_charmap */ |
1054 /* */ | 1081 /* */ |
1055 /* <Description> */ | 1082 /* <Description> */ |
1056 /* This function finds the variant selector charmap, if there is one. */ | 1083 /* This function finds the variant selector charmap, if there is one. */ |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 if ( error ) | 1185 if ( error ) |
1159 goto Fail; | 1186 goto Fail; |
1160 | 1187 |
1161 /* select Unicode charmap by default */ | 1188 /* select Unicode charmap by default */ |
1162 error2 = find_unicode_charmap( face ); | 1189 error2 = find_unicode_charmap( face ); |
1163 | 1190 |
1164 /* if no Unicode charmap can be found, FT_Err_Invalid_CharMap_Handle */ | 1191 /* if no Unicode charmap can be found, FT_Err_Invalid_CharMap_Handle */ |
1165 /* is returned. */ | 1192 /* is returned. */ |
1166 | 1193 |
1167 /* no error should happen, but we want to play safe */ | 1194 /* no error should happen, but we want to play safe */ |
1168 if ( error2 && error2 != FT_Err_Invalid_CharMap_Handle ) | 1195 if ( error2 && FT_ERR_NEQ( error2, Invalid_CharMap_Handle ) ) |
1169 { | 1196 { |
1170 error = error2; | 1197 error = error2; |
1171 goto Fail; | 1198 goto Fail; |
1172 } | 1199 } |
1173 | 1200 |
1174 *aface = face; | 1201 *aface = face; |
1175 | 1202 |
1176 Fail: | 1203 Fail: |
1177 if ( error ) | 1204 if ( error ) |
1178 { | 1205 { |
(...skipping 20 matching lines...) Expand all Loading... |
1199 FT_New_Face( FT_Library library, | 1226 FT_New_Face( FT_Library library, |
1200 const char* pathname, | 1227 const char* pathname, |
1201 FT_Long face_index, | 1228 FT_Long face_index, |
1202 FT_Face *aface ) | 1229 FT_Face *aface ) |
1203 { | 1230 { |
1204 FT_Open_Args args; | 1231 FT_Open_Args args; |
1205 | 1232 |
1206 | 1233 |
1207 /* test for valid `library' and `aface' delayed to FT_Open_Face() */ | 1234 /* test for valid `library' and `aface' delayed to FT_Open_Face() */ |
1208 if ( !pathname ) | 1235 if ( !pathname ) |
1209 return FT_Err_Invalid_Argument; | 1236 return FT_THROW( Invalid_Argument ); |
1210 | 1237 |
1211 args.flags = FT_OPEN_PATHNAME; | 1238 args.flags = FT_OPEN_PATHNAME; |
1212 args.pathname = (char*)pathname; | 1239 args.pathname = (char*)pathname; |
1213 args.stream = NULL; | 1240 args.stream = NULL; |
1214 | 1241 |
1215 return FT_Open_Face( library, &args, face_index, aface ); | 1242 return FT_Open_Face( library, &args, face_index, aface ); |
1216 } | 1243 } |
1217 | 1244 |
1218 #endif | 1245 #endif |
1219 | 1246 |
1220 | 1247 |
1221 /* documentation is in freetype.h */ | 1248 /* documentation is in freetype.h */ |
1222 | 1249 |
1223 FT_EXPORT_DEF( FT_Error ) | 1250 FT_EXPORT_DEF( FT_Error ) |
1224 FT_New_Memory_Face( FT_Library library, | 1251 FT_New_Memory_Face( FT_Library library, |
1225 const FT_Byte* file_base, | 1252 const FT_Byte* file_base, |
1226 FT_Long file_size, | 1253 FT_Long file_size, |
1227 FT_Long face_index, | 1254 FT_Long face_index, |
1228 FT_Face *aface ) | 1255 FT_Face *aface ) |
1229 { | 1256 { |
1230 FT_Open_Args args; | 1257 FT_Open_Args args; |
1231 | 1258 |
1232 | 1259 |
1233 /* test for valid `library' and `face' delayed to FT_Open_Face() */ | 1260 /* test for valid `library' and `face' delayed to FT_Open_Face() */ |
1234 if ( !file_base ) | 1261 if ( !file_base ) |
1235 return FT_Err_Invalid_Argument; | 1262 return FT_THROW( Invalid_Argument ); |
1236 | 1263 |
1237 args.flags = FT_OPEN_MEMORY; | 1264 args.flags = FT_OPEN_MEMORY; |
1238 args.memory_base = file_base; | 1265 args.memory_base = file_base; |
1239 args.memory_size = file_size; | 1266 args.memory_size = file_size; |
1240 args.stream = NULL; | 1267 args.stream = NULL; |
1241 | 1268 |
1242 return FT_Open_Face( library, &args, face_index, aface ); | 1269 return FT_Open_Face( library, &args, face_index, aface ); |
1243 } | 1270 } |
1244 | 1271 |
1245 | 1272 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 FT_ULong size, | 1324 FT_ULong size, |
1298 FT_Stream_CloseFunc close, | 1325 FT_Stream_CloseFunc close, |
1299 FT_Stream *astream ) | 1326 FT_Stream *astream ) |
1300 { | 1327 { |
1301 FT_Error error; | 1328 FT_Error error; |
1302 FT_Memory memory; | 1329 FT_Memory memory; |
1303 FT_Stream stream = NULL; | 1330 FT_Stream stream = NULL; |
1304 | 1331 |
1305 | 1332 |
1306 if ( !library ) | 1333 if ( !library ) |
1307 return FT_Err_Invalid_Library_Handle; | 1334 return FT_THROW( Invalid_Library_Handle ); |
1308 | 1335 |
1309 if ( !base ) | 1336 if ( !base ) |
1310 return FT_Err_Invalid_Argument; | 1337 return FT_THROW( Invalid_Argument ); |
1311 | 1338 |
1312 *astream = 0; | 1339 *astream = 0; |
1313 memory = library->memory; | 1340 memory = library->memory; |
1314 if ( FT_NEW( stream ) ) | 1341 if ( FT_NEW( stream ) ) |
1315 goto Exit; | 1342 goto Exit; |
1316 | 1343 |
1317 FT_Stream_OpenMemory( stream, base, size ); | 1344 FT_Stream_OpenMemory( stream, base, size ); |
1318 | 1345 |
1319 stream->close = close; | 1346 stream->close = close; |
1320 | 1347 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 *offset = 0; | 1441 *offset = 0; |
1415 *length = 0; | 1442 *length = 0; |
1416 *is_sfnt_cid = FALSE; | 1443 *is_sfnt_cid = FALSE; |
1417 | 1444 |
1418 /* TODO: support for sfnt-wrapped PS/CID in TTC format */ | 1445 /* TODO: support for sfnt-wrapped PS/CID in TTC format */ |
1419 | 1446 |
1420 /* version check for 'typ1' (should be ignored?) */ | 1447 /* version check for 'typ1' (should be ignored?) */ |
1421 if ( FT_READ_ULONG( tag ) ) | 1448 if ( FT_READ_ULONG( tag ) ) |
1422 return error; | 1449 return error; |
1423 if ( tag != TTAG_typ1 ) | 1450 if ( tag != TTAG_typ1 ) |
1424 return FT_Err_Unknown_File_Format; | 1451 return FT_THROW( Unknown_File_Format ); |
1425 | 1452 |
1426 if ( FT_READ_USHORT( numTables ) ) | 1453 if ( FT_READ_USHORT( numTables ) ) |
1427 return error; | 1454 return error; |
1428 if ( FT_STREAM_SKIP( 2 * 3 ) ) /* skip binary search header */ | 1455 if ( FT_STREAM_SKIP( 2 * 3 ) ) /* skip binary search header */ |
1429 return error; | 1456 return error; |
1430 | 1457 |
1431 pstable_index = -1; | 1458 pstable_index = -1; |
1432 *is_sfnt_cid = FALSE; | 1459 *is_sfnt_cid = FALSE; |
1433 | 1460 |
1434 for ( i = 0; i < numTables; i++ ) | 1461 for ( i = 0; i < numTables; i++ ) |
(...skipping 16 matching lines...) Expand all Loading... |
1451 pstable_index++; | 1478 pstable_index++; |
1452 *offset += 24; | 1479 *offset += 24; |
1453 *length -= 24; | 1480 *length -= 24; |
1454 *is_sfnt_cid = FALSE; | 1481 *is_sfnt_cid = FALSE; |
1455 if ( face_index < 0 ) | 1482 if ( face_index < 0 ) |
1456 return FT_Err_Ok; | 1483 return FT_Err_Ok; |
1457 } | 1484 } |
1458 if ( face_index >= 0 && pstable_index == face_index ) | 1485 if ( face_index >= 0 && pstable_index == face_index ) |
1459 return FT_Err_Ok; | 1486 return FT_Err_Ok; |
1460 } | 1487 } |
1461 return FT_Err_Table_Missing; | 1488 return FT_THROW( Table_Missing ); |
1462 } | 1489 } |
1463 | 1490 |
1464 | 1491 |
1465 FT_LOCAL_DEF( FT_Error ) | 1492 FT_LOCAL_DEF( FT_Error ) |
1466 open_face_PS_from_sfnt_stream( FT_Library library, | 1493 open_face_PS_from_sfnt_stream( FT_Library library, |
1467 FT_Stream stream, | 1494 FT_Stream stream, |
1468 FT_Long face_index, | 1495 FT_Long face_index, |
1469 FT_Int num_params, | 1496 FT_Int num_params, |
1470 FT_Parameter *params, | 1497 FT_Parameter *params, |
1471 FT_Face *aface ) | 1498 FT_Face *aface ) |
(...skipping 25 matching lines...) Expand all Loading... |
1497 if ( FT_ALLOC( sfnt_ps, (FT_Long)length ) ) | 1524 if ( FT_ALLOC( sfnt_ps, (FT_Long)length ) ) |
1498 goto Exit; | 1525 goto Exit; |
1499 | 1526 |
1500 error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length ); | 1527 error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length ); |
1501 if ( error ) | 1528 if ( error ) |
1502 goto Exit; | 1529 goto Exit; |
1503 | 1530 |
1504 error = open_face_from_buffer( library, | 1531 error = open_face_from_buffer( library, |
1505 sfnt_ps, | 1532 sfnt_ps, |
1506 length, | 1533 length, |
1507 face_index < 0 ? face_index : 0, | 1534 FT_MIN( face_index, 0 ), |
1508 is_sfnt_cid ? "cid" : "type1", | 1535 is_sfnt_cid ? "cid" : "type1", |
1509 aface ); | 1536 aface ); |
1510 Exit: | 1537 Exit: |
1511 { | 1538 { |
1512 FT_Error error1; | 1539 FT_Error error1; |
1513 | 1540 |
1514 | 1541 |
1515 if ( error == FT_Err_Unknown_File_Format ) | 1542 if ( FT_ERR_EQ( error, Unknown_File_Format ) ) |
1516 { | 1543 { |
1517 error1 = FT_Stream_Seek( stream, pos ); | 1544 error1 = FT_Stream_Seek( stream, pos ); |
1518 if ( error1 ) | 1545 if ( error1 ) |
1519 return error1; | 1546 return error1; |
1520 } | 1547 } |
1521 | 1548 |
1522 return error; | 1549 return error; |
1523 } | 1550 } |
1524 } | 1551 } |
1525 | 1552 |
1526 | 1553 |
1527 #ifndef FT_MACINTOSH | 1554 #ifndef FT_MACINTOSH |
1528 | 1555 |
1529 /* The resource header says we've got resource_cnt `POST' (type1) */ | 1556 /* The resource header says we've got resource_cnt `POST' (type1) */ |
1530 /* resources in this file. They all need to be coalesced into */ | 1557 /* resources in this file. They all need to be coalesced into */ |
1531 /* one lump which gets passed on to the type1 driver. */ | 1558 /* one lump which gets passed on to the type1 driver. */ |
1532 /* Here can be only one PostScript font in a file so face_index */ | 1559 /* Here can be only one PostScript font in a file so face_index */ |
1533 /* must be 0 (or -1). */ | 1560 /* must be 0 (or -1). */ |
1534 /* */ | 1561 /* */ |
1535 static FT_Error | 1562 static FT_Error |
1536 Mac_Read_POST_Resource( FT_Library library, | 1563 Mac_Read_POST_Resource( FT_Library library, |
1537 FT_Stream stream, | 1564 FT_Stream stream, |
1538 FT_Long *offsets, | 1565 FT_Long *offsets, |
1539 FT_Long resource_cnt, | 1566 FT_Long resource_cnt, |
1540 FT_Long face_index, | 1567 FT_Long face_index, |
1541 FT_Face *aface ) | 1568 FT_Face *aface ) |
1542 { | 1569 { |
1543 FT_Error error = FT_Err_Cannot_Open_Resource; | 1570 FT_Error error = FT_ERR( Cannot_Open_Resource ); |
1544 FT_Memory memory = library->memory; | 1571 FT_Memory memory = library->memory; |
1545 FT_Byte* pfb_data = NULL; | 1572 FT_Byte* pfb_data = NULL; |
1546 int i, type, flags; | 1573 int i, type, flags; |
1547 FT_Long len; | 1574 FT_Long len; |
1548 FT_Long pfb_len, pfb_pos, pfb_lenpos; | 1575 FT_Long pfb_len, pfb_pos, pfb_lenpos; |
1549 FT_Long rlen, temp; | 1576 FT_Long rlen, temp; |
1550 | 1577 |
1551 | 1578 |
1552 if ( face_index == -1 ) | 1579 if ( face_index == -1 ) |
1553 face_index = 0; | 1580 face_index = 0; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 len = rlen; | 1653 len = rlen; |
1627 | 1654 |
1628 pfb_data[pfb_pos++] = (FT_Byte)type; | 1655 pfb_data[pfb_pos++] = (FT_Byte)type; |
1629 pfb_lenpos = pfb_pos; | 1656 pfb_lenpos = pfb_pos; |
1630 pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */ | 1657 pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */ |
1631 pfb_data[pfb_pos++] = 0; | 1658 pfb_data[pfb_pos++] = 0; |
1632 pfb_data[pfb_pos++] = 0; | 1659 pfb_data[pfb_pos++] = 0; |
1633 pfb_data[pfb_pos++] = 0; | 1660 pfb_data[pfb_pos++] = 0; |
1634 } | 1661 } |
1635 | 1662 |
1636 error = FT_Err_Cannot_Open_Resource; | 1663 error = FT_ERR( Cannot_Open_Resource ); |
1637 if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) | 1664 if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) |
1638 goto Exit2; | 1665 goto Exit2; |
1639 | 1666 |
1640 error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); | 1667 error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); |
1641 if ( error ) | 1668 if ( error ) |
1642 goto Exit2; | 1669 goto Exit2; |
1643 pfb_pos += rlen; | 1670 pfb_pos += rlen; |
1644 } | 1671 } |
1645 | 1672 |
1646 if ( pfb_pos + 2 > pfb_len + 2 ) | 1673 if ( pfb_pos + 2 > pfb_len + 2 ) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 FT_Error error; | 1715 FT_Error error; |
1689 FT_Long flag_offset; | 1716 FT_Long flag_offset; |
1690 FT_Long rlen; | 1717 FT_Long rlen; |
1691 int is_cff; | 1718 int is_cff; |
1692 FT_Long face_index_in_resource = 0; | 1719 FT_Long face_index_in_resource = 0; |
1693 | 1720 |
1694 | 1721 |
1695 if ( face_index == -1 ) | 1722 if ( face_index == -1 ) |
1696 face_index = 0; | 1723 face_index = 0; |
1697 if ( face_index >= resource_cnt ) | 1724 if ( face_index >= resource_cnt ) |
1698 return FT_Err_Cannot_Open_Resource; | 1725 return FT_THROW( Cannot_Open_Resource ); |
1699 | 1726 |
1700 flag_offset = offsets[face_index]; | 1727 flag_offset = offsets[face_index]; |
1701 error = FT_Stream_Seek( stream, flag_offset ); | 1728 error = FT_Stream_Seek( stream, flag_offset ); |
1702 if ( error ) | 1729 if ( error ) |
1703 goto Exit; | 1730 goto Exit; |
1704 | 1731 |
1705 if ( FT_READ_LONG( rlen ) ) | 1732 if ( FT_READ_LONG( rlen ) ) |
1706 goto Exit; | 1733 goto Exit; |
1707 if ( rlen == -1 ) | 1734 if ( rlen == -1 ) |
1708 return FT_Err_Cannot_Open_Resource; | 1735 return FT_THROW( Cannot_Open_Resource ); |
1709 | 1736 |
1710 error = open_face_PS_from_sfnt_stream( library, | 1737 error = open_face_PS_from_sfnt_stream( library, |
1711 stream, | 1738 stream, |
1712 face_index, | 1739 face_index, |
1713 0, NULL, | 1740 0, NULL, |
1714 aface ); | 1741 aface ); |
1715 if ( !error ) | 1742 if ( !error ) |
1716 goto Exit; | 1743 goto Exit; |
1717 | 1744 |
1718 /* rewind sfnt stream before open_face_PS_from_sfnt_stream() */ | 1745 /* rewind sfnt stream before open_face_PS_from_sfnt_stream() */ |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 FT_Stream stream, | 1832 FT_Stream stream, |
1806 FT_Long face_index, | 1833 FT_Long face_index, |
1807 FT_Face *aface ) | 1834 FT_Face *aface ) |
1808 { | 1835 { |
1809 unsigned char header[128]; | 1836 unsigned char header[128]; |
1810 FT_Error error; | 1837 FT_Error error; |
1811 FT_Long dlen, offset; | 1838 FT_Long dlen, offset; |
1812 | 1839 |
1813 | 1840 |
1814 if ( NULL == stream ) | 1841 if ( NULL == stream ) |
1815 return FT_Err_Invalid_Stream_Operation; | 1842 return FT_THROW( Invalid_Stream_Operation ); |
1816 | 1843 |
1817 error = FT_Stream_Seek( stream, 0 ); | 1844 error = FT_Stream_Seek( stream, 0 ); |
1818 if ( error ) | 1845 if ( error ) |
1819 goto Exit; | 1846 goto Exit; |
1820 | 1847 |
1821 error = FT_Stream_Read( stream, (FT_Byte*)header, 128 ); | 1848 error = FT_Stream_Read( stream, (FT_Byte*)header, 128 ); |
1822 if ( error ) | 1849 if ( error ) |
1823 goto Exit; | 1850 goto Exit; |
1824 | 1851 |
1825 if ( header[ 0] != 0 || | 1852 if ( header[ 0] != 0 || |
1826 header[74] != 0 || | 1853 header[74] != 0 || |
1827 header[82] != 0 || | 1854 header[82] != 0 || |
1828 header[ 1] == 0 || | 1855 header[ 1] == 0 || |
1829 header[ 1] > 33 || | 1856 header[ 1] > 33 || |
1830 header[63] != 0 || | 1857 header[63] != 0 || |
1831 header[2 + header[1]] != 0 ) | 1858 header[2 + header[1]] != 0 ) |
1832 return FT_Err_Unknown_File_Format; | 1859 return FT_THROW( Unknown_File_Format ); |
1833 | 1860 |
1834 dlen = ( header[0x53] << 24 ) | | 1861 dlen = ( header[0x53] << 24 ) | |
1835 ( header[0x54] << 16 ) | | 1862 ( header[0x54] << 16 ) | |
1836 ( header[0x55] << 8 ) | | 1863 ( header[0x55] << 8 ) | |
1837 header[0x56]; | 1864 header[0x56]; |
1838 #if 0 | 1865 #if 0 |
1839 rlen = ( header[0x57] << 24 ) | | 1866 rlen = ( header[0x57] << 24 ) | |
1840 ( header[0x58] << 16 ) | | 1867 ( header[0x58] << 16 ) | |
1841 ( header[0x59] << 8 ) | | 1868 ( header[0x59] << 8 ) | |
1842 header[0x5a]; | 1869 header[0x5a]; |
(...skipping 12 matching lines...) Expand all Loading... |
1855 FT_Stream stream, | 1882 FT_Stream stream, |
1856 FT_Long face_index, | 1883 FT_Long face_index, |
1857 FT_Face *aface, | 1884 FT_Face *aface, |
1858 const FT_Open_Args *args ) | 1885 const FT_Open_Args *args ) |
1859 { | 1886 { |
1860 | 1887 |
1861 #undef FT_COMPONENT | 1888 #undef FT_COMPONENT |
1862 #define FT_COMPONENT trace_raccess | 1889 #define FT_COMPONENT trace_raccess |
1863 | 1890 |
1864 FT_Memory memory = library->memory; | 1891 FT_Memory memory = library->memory; |
1865 FT_Error error = FT_Err_Unknown_File_Format; | 1892 FT_Error error = FT_ERR( Unknown_File_Format ); |
1866 int i; | 1893 int i; |
1867 | 1894 |
1868 char * file_names[FT_RACCESS_N_RULES]; | 1895 char * file_names[FT_RACCESS_N_RULES]; |
1869 FT_Long offsets[FT_RACCESS_N_RULES]; | 1896 FT_Long offsets[FT_RACCESS_N_RULES]; |
1870 FT_Error errors[FT_RACCESS_N_RULES]; | 1897 FT_Error errors[FT_RACCESS_N_RULES]; |
1871 FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */ | 1898 FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */ |
1872 | 1899 |
1873 FT_Open_Args args2; | 1900 FT_Open_Args args2; |
1874 FT_Stream stream2 = 0; | 1901 FT_Stream stream2 = 0; |
1875 | 1902 |
(...skipping 18 matching lines...) Expand all Loading... |
1894 continue; | 1921 continue; |
1895 } | 1922 } |
1896 | 1923 |
1897 args2.flags = FT_OPEN_PATHNAME; | 1924 args2.flags = FT_OPEN_PATHNAME; |
1898 args2.pathname = file_names[i] ? file_names[i] : args->pathname; | 1925 args2.pathname = file_names[i] ? file_names[i] : args->pathname; |
1899 | 1926 |
1900 FT_TRACE3(( "Try rule %d: %s (offset=%d) ...", | 1927 FT_TRACE3(( "Try rule %d: %s (offset=%d) ...", |
1901 i, args2.pathname, offsets[i] )); | 1928 i, args2.pathname, offsets[i] )); |
1902 | 1929 |
1903 error = FT_Stream_New( library, &args2, &stream2 ); | 1930 error = FT_Stream_New( library, &args2, &stream2 ); |
1904 if ( is_darwin_vfs && error == FT_Err_Cannot_Open_Stream ) | 1931 if ( is_darwin_vfs && FT_ERR_EQ( error, Cannot_Open_Stream ) ) |
1905 vfs_rfork_has_no_font = TRUE; | 1932 vfs_rfork_has_no_font = TRUE; |
1906 | 1933 |
1907 if ( error ) | 1934 if ( error ) |
1908 { | 1935 { |
1909 FT_TRACE3(( "failed\n" )); | 1936 FT_TRACE3(( "failed\n" )); |
1910 continue; | 1937 continue; |
1911 } | 1938 } |
1912 | 1939 |
1913 error = IsMacResource( library, stream2, offsets[i], | 1940 error = IsMacResource( library, stream2, offsets[i], |
1914 face_index, aface ); | 1941 face_index, aface ); |
1915 FT_Stream_Free( stream2, 0 ); | 1942 FT_Stream_Free( stream2, 0 ); |
1916 | 1943 |
1917 FT_TRACE3(( "%s\n", error ? "failed": "successful" )); | 1944 FT_TRACE3(( "%s\n", error ? "failed": "successful" )); |
1918 | 1945 |
1919 if ( !error ) | 1946 if ( !error ) |
1920 break; | 1947 break; |
1921 else if ( is_darwin_vfs ) | 1948 else if ( is_darwin_vfs ) |
1922 vfs_rfork_has_no_font = TRUE; | 1949 vfs_rfork_has_no_font = TRUE; |
1923 } | 1950 } |
1924 | 1951 |
1925 for (i = 0; i < FT_RACCESS_N_RULES; i++) | 1952 for (i = 0; i < FT_RACCESS_N_RULES; i++) |
1926 { | 1953 { |
1927 if ( file_names[i] ) | 1954 if ( file_names[i] ) |
1928 FT_FREE( file_names[i] ); | 1955 FT_FREE( file_names[i] ); |
1929 } | 1956 } |
1930 | 1957 |
1931 /* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */ | 1958 /* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */ |
1932 if ( error ) | 1959 if ( error ) |
1933 error = FT_Err_Unknown_File_Format; | 1960 error = FT_ERR( Unknown_File_Format ); |
1934 | 1961 |
1935 return error; | 1962 return error; |
1936 | 1963 |
1937 #undef FT_COMPONENT | 1964 #undef FT_COMPONENT |
1938 #define FT_COMPONENT trace_objs | 1965 #define FT_COMPONENT trace_objs |
1939 | 1966 |
1940 } | 1967 } |
1941 | 1968 |
1942 | 1969 |
1943 /* Check for some macintosh formats without Carbon framework. */ | 1970 /* Check for some macintosh formats without Carbon framework. */ |
1944 /* Is this a macbinary file? If so look at the resource fork. */ | 1971 /* Is this a macbinary file? If so look at the resource fork. */ |
1945 /* Is this a mac dfont file? */ | 1972 /* Is this a mac dfont file? */ |
1946 /* Is this an old style resource fork? (in data) */ | 1973 /* Is this an old style resource fork? (in data) */ |
1947 /* Else call load_face_in_embedded_rfork to try extra rules */ | 1974 /* Else call load_face_in_embedded_rfork to try extra rules */ |
1948 /* (defined in `ftrfork.c'). */ | 1975 /* (defined in `ftrfork.c'). */ |
1949 /* */ | 1976 /* */ |
1950 static FT_Error | 1977 static FT_Error |
1951 load_mac_face( FT_Library library, | 1978 load_mac_face( FT_Library library, |
1952 FT_Stream stream, | 1979 FT_Stream stream, |
1953 FT_Long face_index, | 1980 FT_Long face_index, |
1954 FT_Face *aface, | 1981 FT_Face *aface, |
1955 const FT_Open_Args *args ) | 1982 const FT_Open_Args *args ) |
1956 { | 1983 { |
1957 FT_Error error; | 1984 FT_Error error; |
1958 FT_UNUSED( args ); | 1985 FT_UNUSED( args ); |
1959 | 1986 |
1960 | 1987 |
1961 error = IsMacBinary( library, stream, face_index, aface ); | 1988 error = IsMacBinary( library, stream, face_index, aface ); |
1962 if ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format ) | 1989 if ( FT_ERR_EQ( error, Unknown_File_Format ) ) |
1963 { | 1990 { |
1964 | 1991 |
1965 #undef FT_COMPONENT | 1992 #undef FT_COMPONENT |
1966 #define FT_COMPONENT trace_raccess | 1993 #define FT_COMPONENT trace_raccess |
1967 | 1994 |
1968 FT_TRACE3(( "Try as dfont: %s ...", args->pathname )); | 1995 FT_TRACE3(( "Try as dfont: %s ...", args->pathname )); |
1969 | 1996 |
1970 error = IsMacResource( library, stream, 0, face_index, aface ); | 1997 error = IsMacResource( library, stream, 0, face_index, aface ); |
1971 | 1998 |
1972 FT_TRACE3(( "%s\n", error ? "failed" : "successful" )); | 1999 FT_TRACE3(( "%s\n", error ? "failed" : "successful" )); |
1973 | 2000 |
1974 #undef FT_COMPONENT | 2001 #undef FT_COMPONENT |
1975 #define FT_COMPONENT trace_objs | 2002 #define FT_COMPONENT trace_objs |
1976 | 2003 |
1977 } | 2004 } |
1978 | 2005 |
1979 if ( ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format || | 2006 if ( ( FT_ERR_EQ( error, Unknown_File_Format ) || |
1980 FT_ERROR_BASE( error ) == FT_Err_Invalid_Stream_Operation ) && | 2007 FT_ERR_EQ( error, Invalid_Stream_Operation ) ) && |
1981 ( args->flags & FT_OPEN_PATHNAME ) ) | 2008 ( args->flags & FT_OPEN_PATHNAME ) ) |
1982 error = load_face_in_embedded_rfork( library, stream, | 2009 error = load_face_in_embedded_rfork( library, stream, |
1983 face_index, aface, args ); | 2010 face_index, aface, args ); |
1984 return error; | 2011 return error; |
1985 } | 2012 } |
1986 #endif | 2013 #endif |
1987 | 2014 |
1988 #endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */ | 2015 #endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */ |
1989 | 2016 |
1990 | 2017 |
1991 /* documentation is in freetype.h */ | 2018 /* documentation is in freetype.h */ |
(...skipping 12 matching lines...) Expand all Loading... |
2004 FT_ListNode node = NULL; | 2031 FT_ListNode node = NULL; |
2005 FT_Bool external_stream; | 2032 FT_Bool external_stream; |
2006 FT_Module* cur; | 2033 FT_Module* cur; |
2007 FT_Module* limit; | 2034 FT_Module* limit; |
2008 | 2035 |
2009 | 2036 |
2010 /* test for valid `library' delayed to */ | 2037 /* test for valid `library' delayed to */ |
2011 /* FT_Stream_New() */ | 2038 /* FT_Stream_New() */ |
2012 | 2039 |
2013 if ( ( !aface && face_index >= 0 ) || !args ) | 2040 if ( ( !aface && face_index >= 0 ) || !args ) |
2014 return FT_Err_Invalid_Argument; | 2041 return FT_THROW( Invalid_Argument ); |
2015 | 2042 |
2016 external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) && | 2043 external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) && |
2017 args->stream ); | 2044 args->stream ); |
2018 | 2045 |
2019 /* create input stream */ | 2046 /* create input stream */ |
2020 error = FT_Stream_New( library, args, &stream ); | 2047 error = FT_Stream_New( library, args, &stream ); |
2021 if ( error ) | 2048 if ( error ) |
2022 goto Fail3; | 2049 goto Fail3; |
2023 | 2050 |
2024 memory = library->memory; | 2051 memory = library->memory; |
(...skipping 16 matching lines...) Expand all Loading... |
2041 num_params = args->num_params; | 2068 num_params = args->num_params; |
2042 params = args->params; | 2069 params = args->params; |
2043 } | 2070 } |
2044 | 2071 |
2045 error = open_face( driver, stream, face_index, | 2072 error = open_face( driver, stream, face_index, |
2046 num_params, params, &face ); | 2073 num_params, params, &face ); |
2047 if ( !error ) | 2074 if ( !error ) |
2048 goto Success; | 2075 goto Success; |
2049 } | 2076 } |
2050 else | 2077 else |
2051 error = FT_Err_Invalid_Handle; | 2078 error = FT_THROW( Invalid_Handle ); |
2052 | 2079 |
2053 FT_Stream_Free( stream, external_stream ); | 2080 FT_Stream_Free( stream, external_stream ); |
2054 goto Fail; | 2081 goto Fail; |
2055 } | 2082 } |
2056 else | 2083 else |
2057 { | 2084 { |
| 2085 error = FT_ERR( Missing_Module ); |
| 2086 |
2058 /* check each font driver for an appropriate format */ | 2087 /* check each font driver for an appropriate format */ |
2059 cur = library->modules; | 2088 cur = library->modules; |
2060 limit = cur + library->num_modules; | 2089 limit = cur + library->num_modules; |
2061 | 2090 |
2062 | |
2063 for ( ; cur < limit; cur++ ) | 2091 for ( ; cur < limit; cur++ ) |
2064 { | 2092 { |
2065 /* not all modules are font drivers, so check... */ | 2093 /* not all modules are font drivers, so check... */ |
2066 if ( FT_MODULE_IS_DRIVER( cur[0] ) ) | 2094 if ( FT_MODULE_IS_DRIVER( cur[0] ) ) |
2067 { | 2095 { |
2068 FT_Int num_params = 0; | 2096 FT_Int num_params = 0; |
2069 FT_Parameter* params = 0; | 2097 FT_Parameter* params = 0; |
2070 | 2098 |
2071 | 2099 |
2072 driver = FT_DRIVER( cur[0] ); | 2100 driver = FT_DRIVER( cur[0] ); |
2073 | 2101 |
2074 if ( args->flags & FT_OPEN_PARAMS ) | 2102 if ( args->flags & FT_OPEN_PARAMS ) |
2075 { | 2103 { |
2076 num_params = args->num_params; | 2104 num_params = args->num_params; |
2077 params = args->params; | 2105 params = args->params; |
2078 } | 2106 } |
2079 | 2107 |
2080 error = open_face( driver, stream, face_index, | 2108 error = open_face( driver, stream, face_index, |
2081 num_params, params, &face ); | 2109 num_params, params, &face ); |
2082 if ( !error ) | 2110 if ( !error ) |
2083 goto Success; | 2111 goto Success; |
2084 | 2112 |
2085 #ifdef FT_CONFIG_OPTION_MAC_FONTS | 2113 #ifdef FT_CONFIG_OPTION_MAC_FONTS |
2086 if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 && | 2114 if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 && |
2087 FT_ERROR_BASE( error ) == FT_Err_Table_Missing ) | 2115 FT_ERR_EQ( error, Table_Missing ) ) |
2088 { | 2116 { |
2089 /* TrueType but essential tables are missing */ | 2117 /* TrueType but essential tables are missing */ |
2090 if ( FT_Stream_Seek( stream, 0 ) ) | 2118 if ( FT_Stream_Seek( stream, 0 ) ) |
2091 break; | 2119 break; |
2092 | 2120 |
2093 error = open_face_PS_from_sfnt_stream( library, | 2121 error = open_face_PS_from_sfnt_stream( library, |
2094 stream, | 2122 stream, |
2095 face_index, | 2123 face_index, |
2096 num_params, | 2124 num_params, |
2097 params, | 2125 params, |
2098 aface ); | 2126 aface ); |
2099 if ( !error ) | 2127 if ( !error ) |
2100 { | 2128 { |
2101 FT_Stream_Free( stream, external_stream ); | 2129 FT_Stream_Free( stream, external_stream ); |
2102 return error; | 2130 return error; |
2103 } | 2131 } |
2104 } | 2132 } |
2105 #endif | 2133 #endif |
2106 | 2134 |
2107 if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format ) | 2135 if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) |
2108 goto Fail3; | 2136 goto Fail3; |
2109 } | 2137 } |
2110 } | 2138 } |
2111 | 2139 |
2112 Fail3: | 2140 Fail3: |
2113 /* If we are on the mac, and we get an FT_Err_Invalid_Stream_Operation */ | 2141 /* If we are on the mac, and we get an */ |
2114 /* it may be because we have an empty data fork, so we need to check */ | 2142 /* FT_Err_Invalid_Stream_Operation it may be because we have an */ |
2115 /* the resource fork. */ | 2143 /* empty data fork, so we need to check the resource fork. */ |
2116 if ( FT_ERROR_BASE( error ) != FT_Err_Cannot_Open_Stream && | 2144 if ( FT_ERR_NEQ( error, Cannot_Open_Stream ) && |
2117 FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format && | 2145 FT_ERR_NEQ( error, Unknown_File_Format ) && |
2118 FT_ERROR_BASE( error ) != FT_Err_Invalid_Stream_Operation ) | 2146 FT_ERR_NEQ( error, Invalid_Stream_Operation ) ) |
2119 goto Fail2; | 2147 goto Fail2; |
2120 | 2148 |
2121 #if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS ) | 2149 #if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS ) |
2122 error = load_mac_face( library, stream, face_index, aface, args ); | 2150 error = load_mac_face( library, stream, face_index, aface, args ); |
2123 if ( !error ) | 2151 if ( !error ) |
2124 { | 2152 { |
2125 /* We don't want to go to Success here. We've already done that. */ | 2153 /* We don't want to go to Success here. We've already done that. */ |
2126 /* On the other hand, if we succeeded we still need to close this */ | 2154 /* On the other hand, if we succeeded we still need to close this */ |
2127 /* stream (we opened a different stream which extracted the */ | 2155 /* stream (we opened a different stream which extracted the */ |
2128 /* interesting information out of this stream here. That stream */ | 2156 /* interesting information out of this stream here. That stream */ |
2129 /* will still be open and the face will point to it). */ | 2157 /* will still be open and the face will point to it). */ |
2130 FT_Stream_Free( stream, external_stream ); | 2158 FT_Stream_Free( stream, external_stream ); |
2131 return error; | 2159 return error; |
2132 } | 2160 } |
2133 | 2161 |
2134 if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format ) | 2162 if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) |
2135 goto Fail2; | 2163 goto Fail2; |
2136 #endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */ | 2164 #endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */ |
2137 | 2165 |
2138 /* no driver is able to handle this format */ | 2166 /* no driver is able to handle this format */ |
2139 error = FT_Err_Unknown_File_Format; | 2167 error = FT_THROW( Unknown_File_Format ); |
2140 | 2168 |
2141 Fail2: | 2169 Fail2: |
2142 FT_Stream_Free( stream, external_stream ); | 2170 FT_Stream_Free( stream, external_stream ); |
2143 goto Fail; | 2171 goto Fail; |
2144 } | 2172 } |
2145 | 2173 |
2146 Success: | 2174 Success: |
2147 FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" )); | 2175 FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" )); |
2148 | 2176 |
2149 /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ | 2177 /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2251 FT_EXPORT_DEF( FT_Error ) | 2279 FT_EXPORT_DEF( FT_Error ) |
2252 FT_Attach_File( FT_Face face, | 2280 FT_Attach_File( FT_Face face, |
2253 const char* filepathname ) | 2281 const char* filepathname ) |
2254 { | 2282 { |
2255 FT_Open_Args open; | 2283 FT_Open_Args open; |
2256 | 2284 |
2257 | 2285 |
2258 /* test for valid `face' delayed to FT_Attach_Stream() */ | 2286 /* test for valid `face' delayed to FT_Attach_Stream() */ |
2259 | 2287 |
2260 if ( !filepathname ) | 2288 if ( !filepathname ) |
2261 return FT_Err_Invalid_Argument; | 2289 return FT_THROW( Invalid_Argument ); |
2262 | 2290 |
2263 open.stream = NULL; | 2291 open.stream = NULL; |
2264 open.flags = FT_OPEN_PATHNAME; | 2292 open.flags = FT_OPEN_PATHNAME; |
2265 open.pathname = (char*)filepathname; | 2293 open.pathname = (char*)filepathname; |
2266 | 2294 |
2267 return FT_Attach_Stream( face, &open ); | 2295 return FT_Attach_Stream( face, &open ); |
2268 } | 2296 } |
2269 | 2297 |
2270 | 2298 |
2271 /* documentation is in freetype.h */ | 2299 /* documentation is in freetype.h */ |
2272 | 2300 |
2273 FT_EXPORT_DEF( FT_Error ) | 2301 FT_EXPORT_DEF( FT_Error ) |
2274 FT_Attach_Stream( FT_Face face, | 2302 FT_Attach_Stream( FT_Face face, |
2275 FT_Open_Args* parameters ) | 2303 FT_Open_Args* parameters ) |
2276 { | 2304 { |
2277 FT_Stream stream; | 2305 FT_Stream stream; |
2278 FT_Error error; | 2306 FT_Error error; |
2279 FT_Driver driver; | 2307 FT_Driver driver; |
2280 | 2308 |
2281 FT_Driver_Class clazz; | 2309 FT_Driver_Class clazz; |
2282 | 2310 |
2283 | 2311 |
2284 /* test for valid `parameters' delayed to FT_Stream_New() */ | 2312 /* test for valid `parameters' delayed to FT_Stream_New() */ |
2285 | 2313 |
2286 if ( !face ) | 2314 if ( !face ) |
2287 return FT_Err_Invalid_Face_Handle; | 2315 return FT_THROW( Invalid_Face_Handle ); |
2288 | 2316 |
2289 driver = face->driver; | 2317 driver = face->driver; |
2290 if ( !driver ) | 2318 if ( !driver ) |
2291 return FT_Err_Invalid_Driver_Handle; | 2319 return FT_THROW( Invalid_Driver_Handle ); |
2292 | 2320 |
2293 error = FT_Stream_New( driver->root.library, parameters, &stream ); | 2321 error = FT_Stream_New( driver->root.library, parameters, &stream ); |
2294 if ( error ) | 2322 if ( error ) |
2295 goto Exit; | 2323 goto Exit; |
2296 | 2324 |
2297 /* we implement FT_Attach_Stream in each driver through the */ | 2325 /* we implement FT_Attach_Stream in each driver through the */ |
2298 /* `attach_file' interface */ | 2326 /* `attach_file' interface */ |
2299 | 2327 |
2300 error = FT_Err_Unimplemented_Feature; | 2328 error = FT_ERR( Unimplemented_Feature ); |
2301 clazz = driver->clazz; | 2329 clazz = driver->clazz; |
2302 if ( clazz->attach_file ) | 2330 if ( clazz->attach_file ) |
2303 error = clazz->attach_file( face, stream ); | 2331 error = clazz->attach_file( face, stream ); |
2304 | 2332 |
2305 /* close the attached stream */ | 2333 /* close the attached stream */ |
2306 FT_Stream_Free( stream, | 2334 FT_Stream_Free( stream, |
2307 (FT_Bool)( parameters->stream && | 2335 (FT_Bool)( parameters->stream && |
2308 ( parameters->flags & FT_OPEN_STREAM ) ) ); | 2336 ( parameters->flags & FT_OPEN_STREAM ) ) ); |
2309 | 2337 |
2310 Exit: | 2338 Exit: |
(...skipping 16 matching lines...) Expand all Loading... |
2327 | 2355 |
2328 FT_EXPORT_DEF( FT_Error ) | 2356 FT_EXPORT_DEF( FT_Error ) |
2329 FT_Done_Face( FT_Face face ) | 2357 FT_Done_Face( FT_Face face ) |
2330 { | 2358 { |
2331 FT_Error error; | 2359 FT_Error error; |
2332 FT_Driver driver; | 2360 FT_Driver driver; |
2333 FT_Memory memory; | 2361 FT_Memory memory; |
2334 FT_ListNode node; | 2362 FT_ListNode node; |
2335 | 2363 |
2336 | 2364 |
2337 error = FT_Err_Invalid_Face_Handle; | 2365 error = FT_ERR( Invalid_Face_Handle ); |
2338 if ( face && face->driver ) | 2366 if ( face && face->driver ) |
2339 { | 2367 { |
2340 face->internal->refcount--; | 2368 face->internal->refcount--; |
2341 if ( face->internal->refcount > 0 ) | 2369 if ( face->internal->refcount > 0 ) |
2342 error = FT_Err_Ok; | 2370 error = FT_Err_Ok; |
2343 else | 2371 else |
2344 { | 2372 { |
2345 driver = face->driver; | 2373 driver = face->driver; |
2346 memory = driver->root.memory; | 2374 memory = driver->root.memory; |
2347 | 2375 |
(...skipping 25 matching lines...) Expand all Loading... |
2373 FT_Error error; | 2401 FT_Error error; |
2374 FT_Memory memory; | 2402 FT_Memory memory; |
2375 FT_Driver driver; | 2403 FT_Driver driver; |
2376 FT_Driver_Class clazz; | 2404 FT_Driver_Class clazz; |
2377 | 2405 |
2378 FT_Size size = 0; | 2406 FT_Size size = 0; |
2379 FT_ListNode node = 0; | 2407 FT_ListNode node = 0; |
2380 | 2408 |
2381 | 2409 |
2382 if ( !face ) | 2410 if ( !face ) |
2383 return FT_Err_Invalid_Face_Handle; | 2411 return FT_THROW( Invalid_Face_Handle ); |
2384 | 2412 |
2385 if ( !asize ) | 2413 if ( !asize ) |
2386 return FT_Err_Invalid_Size_Handle; | 2414 return FT_THROW( Invalid_Size_Handle ); |
2387 | 2415 |
2388 if ( !face->driver ) | 2416 if ( !face->driver ) |
2389 return FT_Err_Invalid_Driver_Handle; | 2417 return FT_THROW( Invalid_Driver_Handle ); |
2390 | 2418 |
2391 *asize = 0; | 2419 *asize = 0; |
2392 | 2420 |
2393 driver = face->driver; | 2421 driver = face->driver; |
2394 clazz = driver->clazz; | 2422 clazz = driver->clazz; |
2395 memory = face->memory; | 2423 memory = face->memory; |
2396 | 2424 |
2397 /* Allocate new size object and perform basic initialisation */ | 2425 /* Allocate new size object and perform basic initialisation */ |
2398 if ( FT_ALLOC( size, clazz->size_object_size ) || FT_NEW( node ) ) | 2426 if ( FT_ALLOC( size, clazz->size_object_size ) || FT_NEW( node ) ) |
2399 goto Exit; | 2427 goto Exit; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 FT_Done_Size( FT_Size size ) | 2459 FT_Done_Size( FT_Size size ) |
2432 { | 2460 { |
2433 FT_Error error; | 2461 FT_Error error; |
2434 FT_Driver driver; | 2462 FT_Driver driver; |
2435 FT_Memory memory; | 2463 FT_Memory memory; |
2436 FT_Face face; | 2464 FT_Face face; |
2437 FT_ListNode node; | 2465 FT_ListNode node; |
2438 | 2466 |
2439 | 2467 |
2440 if ( !size ) | 2468 if ( !size ) |
2441 return FT_Err_Invalid_Size_Handle; | 2469 return FT_THROW( Invalid_Size_Handle ); |
2442 | 2470 |
2443 face = size->face; | 2471 face = size->face; |
2444 if ( !face ) | 2472 if ( !face ) |
2445 return FT_Err_Invalid_Face_Handle; | 2473 return FT_THROW( Invalid_Face_Handle ); |
2446 | 2474 |
2447 driver = face->driver; | 2475 driver = face->driver; |
2448 if ( !driver ) | 2476 if ( !driver ) |
2449 return FT_Err_Invalid_Driver_Handle; | 2477 return FT_THROW( Invalid_Driver_Handle ); |
2450 | 2478 |
2451 memory = driver->root.memory; | 2479 memory = driver->root.memory; |
2452 | 2480 |
2453 error = FT_Err_Ok; | 2481 error = FT_Err_Ok; |
2454 node = FT_List_Find( &face->sizes_list, size ); | 2482 node = FT_List_Find( &face->sizes_list, size ); |
2455 if ( node ) | 2483 if ( node ) |
2456 { | 2484 { |
2457 FT_List_Remove( &face->sizes_list, node ); | 2485 FT_List_Remove( &face->sizes_list, node ); |
2458 FT_FREE( node ); | 2486 FT_FREE( node ); |
2459 | 2487 |
2460 if ( face->size == size ) | 2488 if ( face->size == size ) |
2461 { | 2489 { |
2462 face->size = 0; | 2490 face->size = 0; |
2463 if ( face->sizes_list.head ) | 2491 if ( face->sizes_list.head ) |
2464 face->size = (FT_Size)(face->sizes_list.head->data); | 2492 face->size = (FT_Size)(face->sizes_list.head->data); |
2465 } | 2493 } |
2466 | 2494 |
2467 destroy_size( memory, size, driver ); | 2495 destroy_size( memory, size, driver ); |
2468 } | 2496 } |
2469 else | 2497 else |
2470 error = FT_Err_Invalid_Size_Handle; | 2498 error = FT_THROW( Invalid_Size_Handle ); |
2471 | 2499 |
2472 return error; | 2500 return error; |
2473 } | 2501 } |
2474 | 2502 |
2475 | 2503 |
2476 /* documentation is in ftobjs.h */ | 2504 /* documentation is in ftobjs.h */ |
2477 | 2505 |
2478 FT_BASE_DEF( FT_Error ) | 2506 FT_BASE_DEF( FT_Error ) |
2479 FT_Match_Size( FT_Face face, | 2507 FT_Match_Size( FT_Face face, |
2480 FT_Size_Request req, | 2508 FT_Size_Request req, |
2481 FT_Bool ignore_width, | 2509 FT_Bool ignore_width, |
2482 FT_ULong* size_index ) | 2510 FT_ULong* size_index ) |
2483 { | 2511 { |
2484 FT_Int i; | 2512 FT_Int i; |
2485 FT_Long w, h; | 2513 FT_Long w, h; |
2486 | 2514 |
2487 | 2515 |
2488 if ( !FT_HAS_FIXED_SIZES( face ) ) | 2516 if ( !FT_HAS_FIXED_SIZES( face ) ) |
2489 return FT_Err_Invalid_Face_Handle; | 2517 return FT_THROW( Invalid_Face_Handle ); |
2490 | 2518 |
2491 /* FT_Bitmap_Size doesn't provide enough info... */ | 2519 /* FT_Bitmap_Size doesn't provide enough info... */ |
2492 if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL ) | 2520 if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL ) |
2493 return FT_Err_Unimplemented_Feature; | 2521 return FT_THROW( Unimplemented_Feature ); |
2494 | 2522 |
2495 w = FT_REQUEST_WIDTH ( req ); | 2523 w = FT_REQUEST_WIDTH ( req ); |
2496 h = FT_REQUEST_HEIGHT( req ); | 2524 h = FT_REQUEST_HEIGHT( req ); |
2497 | 2525 |
2498 if ( req->width && !req->height ) | 2526 if ( req->width && !req->height ) |
2499 h = w; | 2527 h = w; |
2500 else if ( !req->width && req->height ) | 2528 else if ( !req->width && req->height ) |
2501 w = h; | 2529 w = h; |
2502 | 2530 |
2503 w = FT_PIX_ROUND( w ); | 2531 w = FT_PIX_ROUND( w ); |
2504 h = FT_PIX_ROUND( h ); | 2532 h = FT_PIX_ROUND( h ); |
2505 | 2533 |
2506 for ( i = 0; i < face->num_fixed_sizes; i++ ) | 2534 for ( i = 0; i < face->num_fixed_sizes; i++ ) |
2507 { | 2535 { |
2508 FT_Bitmap_Size* bsize = face->available_sizes + i; | 2536 FT_Bitmap_Size* bsize = face->available_sizes + i; |
2509 | 2537 |
2510 | 2538 |
2511 if ( h != FT_PIX_ROUND( bsize->y_ppem ) ) | 2539 if ( h != FT_PIX_ROUND( bsize->y_ppem ) ) |
2512 continue; | 2540 continue; |
2513 | 2541 |
2514 if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width ) | 2542 if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width ) |
2515 { | 2543 { |
| 2544 FT_TRACE3(( "FT_Match_Size: bitmap strike %d matches\n", i )); |
| 2545 |
2516 if ( size_index ) | 2546 if ( size_index ) |
2517 *size_index = (FT_ULong)i; | 2547 *size_index = (FT_ULong)i; |
2518 | 2548 |
2519 return FT_Err_Ok; | 2549 return FT_Err_Ok; |
2520 } | 2550 } |
2521 } | 2551 } |
2522 | 2552 |
2523 return FT_Err_Invalid_Pixel_Size; | 2553 return FT_THROW( Invalid_Pixel_Size ); |
2524 } | 2554 } |
2525 | 2555 |
2526 | 2556 |
2527 /* documentation is in ftobjs.h */ | 2557 /* documentation is in ftobjs.h */ |
2528 | 2558 |
2529 FT_BASE_DEF( void ) | 2559 FT_BASE_DEF( void ) |
2530 ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics, | 2560 ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics, |
2531 FT_Pos advance ) | 2561 FT_Pos advance ) |
2532 { | 2562 { |
2533 FT_Pos height = metrics->height; | 2563 FT_Pos height = metrics->height; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2756 /* documentation is in freetype.h */ | 2786 /* documentation is in freetype.h */ |
2757 | 2787 |
2758 FT_EXPORT_DEF( FT_Error ) | 2788 FT_EXPORT_DEF( FT_Error ) |
2759 FT_Select_Size( FT_Face face, | 2789 FT_Select_Size( FT_Face face, |
2760 FT_Int strike_index ) | 2790 FT_Int strike_index ) |
2761 { | 2791 { |
2762 FT_Driver_Class clazz; | 2792 FT_Driver_Class clazz; |
2763 | 2793 |
2764 | 2794 |
2765 if ( !face || !FT_HAS_FIXED_SIZES( face ) ) | 2795 if ( !face || !FT_HAS_FIXED_SIZES( face ) ) |
2766 return FT_Err_Invalid_Face_Handle; | 2796 return FT_THROW( Invalid_Face_Handle ); |
2767 | 2797 |
2768 if ( strike_index < 0 || strike_index >= face->num_fixed_sizes ) | 2798 if ( strike_index < 0 || strike_index >= face->num_fixed_sizes ) |
2769 return FT_Err_Invalid_Argument; | 2799 return FT_THROW( Invalid_Argument ); |
2770 | 2800 |
2771 clazz = face->driver->clazz; | 2801 clazz = face->driver->clazz; |
2772 | 2802 |
2773 if ( clazz->select_size ) | 2803 if ( clazz->select_size ) |
2774 { | 2804 { |
2775 FT_Error error; | 2805 FT_Error error; |
2776 | 2806 |
2777 | 2807 |
2778 error = clazz->select_size( face->size, (FT_ULong)strike_index ); | 2808 error = clazz->select_size( face->size, (FT_ULong)strike_index ); |
2779 | 2809 |
(...skipping 29 matching lines...) Expand all Loading... |
2809 | 2839 |
2810 FT_EXPORT_DEF( FT_Error ) | 2840 FT_EXPORT_DEF( FT_Error ) |
2811 FT_Request_Size( FT_Face face, | 2841 FT_Request_Size( FT_Face face, |
2812 FT_Size_Request req ) | 2842 FT_Size_Request req ) |
2813 { | 2843 { |
2814 FT_Driver_Class clazz; | 2844 FT_Driver_Class clazz; |
2815 FT_ULong strike_index; | 2845 FT_ULong strike_index; |
2816 | 2846 |
2817 | 2847 |
2818 if ( !face ) | 2848 if ( !face ) |
2819 return FT_Err_Invalid_Face_Handle; | 2849 return FT_THROW( Invalid_Face_Handle ); |
2820 | 2850 |
2821 if ( !req || req->width < 0 || req->height < 0 || | 2851 if ( !req || req->width < 0 || req->height < 0 || |
2822 req->type >= FT_SIZE_REQUEST_TYPE_MAX ) | 2852 req->type >= FT_SIZE_REQUEST_TYPE_MAX ) |
2823 return FT_Err_Invalid_Argument; | 2853 return FT_THROW( Invalid_Argument ); |
2824 | 2854 |
2825 clazz = face->driver->clazz; | 2855 clazz = face->driver->clazz; |
2826 | 2856 |
2827 if ( clazz->request_size ) | 2857 if ( clazz->request_size ) |
2828 { | 2858 { |
2829 FT_Error error; | 2859 FT_Error error; |
2830 | 2860 |
2831 | 2861 |
2832 error = clazz->request_size( face->size, req ); | 2862 error = clazz->request_size( face->size, req ); |
2833 | 2863 |
(...skipping 28 matching lines...) Expand all Loading... |
2862 */ | 2892 */ |
2863 if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) ) | 2893 if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) ) |
2864 { | 2894 { |
2865 FT_Error error; | 2895 FT_Error error; |
2866 | 2896 |
2867 | 2897 |
2868 error = FT_Match_Size( face, req, 0, &strike_index ); | 2898 error = FT_Match_Size( face, req, 0, &strike_index ); |
2869 if ( error ) | 2899 if ( error ) |
2870 return error; | 2900 return error; |
2871 | 2901 |
2872 FT_TRACE3(( "FT_Request_Size: bitmap strike %lu matched\n", | |
2873 strike_index )); | |
2874 | |
2875 return FT_Select_Size( face, (FT_Int)strike_index ); | 2902 return FT_Select_Size( face, (FT_Int)strike_index ); |
2876 } | 2903 } |
2877 | 2904 |
2878 FT_Request_Metrics( face, req ); | 2905 FT_Request_Metrics( face, req ); |
2879 | 2906 |
2880 return FT_Err_Ok; | 2907 return FT_Err_Ok; |
2881 } | 2908 } |
2882 | 2909 |
2883 | 2910 |
2884 /* documentation is in freetype.h */ | 2911 /* documentation is in freetype.h */ |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2964 FT_UInt left_glyph, | 2991 FT_UInt left_glyph, |
2965 FT_UInt right_glyph, | 2992 FT_UInt right_glyph, |
2966 FT_UInt kern_mode, | 2993 FT_UInt kern_mode, |
2967 FT_Vector *akerning ) | 2994 FT_Vector *akerning ) |
2968 { | 2995 { |
2969 FT_Error error = FT_Err_Ok; | 2996 FT_Error error = FT_Err_Ok; |
2970 FT_Driver driver; | 2997 FT_Driver driver; |
2971 | 2998 |
2972 | 2999 |
2973 if ( !face ) | 3000 if ( !face ) |
2974 return FT_Err_Invalid_Face_Handle; | 3001 return FT_THROW( Invalid_Face_Handle ); |
2975 | 3002 |
2976 if ( !akerning ) | 3003 if ( !akerning ) |
2977 return FT_Err_Invalid_Argument; | 3004 return FT_THROW( Invalid_Argument ); |
2978 | 3005 |
2979 driver = face->driver; | 3006 driver = face->driver; |
2980 | 3007 |
2981 akerning->x = 0; | 3008 akerning->x = 0; |
2982 akerning->y = 0; | 3009 akerning->y = 0; |
2983 | 3010 |
2984 if ( driver->clazz->get_kerning ) | 3011 if ( driver->clazz->get_kerning ) |
2985 { | 3012 { |
2986 error = driver->clazz->get_kerning( face, | 3013 error = driver->clazz->get_kerning( face, |
2987 left_glyph, | 3014 left_glyph, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3023 FT_Get_Track_Kerning( FT_Face face, | 3050 FT_Get_Track_Kerning( FT_Face face, |
3024 FT_Fixed point_size, | 3051 FT_Fixed point_size, |
3025 FT_Int degree, | 3052 FT_Int degree, |
3026 FT_Fixed* akerning ) | 3053 FT_Fixed* akerning ) |
3027 { | 3054 { |
3028 FT_Service_Kerning service; | 3055 FT_Service_Kerning service; |
3029 FT_Error error = FT_Err_Ok; | 3056 FT_Error error = FT_Err_Ok; |
3030 | 3057 |
3031 | 3058 |
3032 if ( !face ) | 3059 if ( !face ) |
3033 return FT_Err_Invalid_Face_Handle; | 3060 return FT_THROW( Invalid_Face_Handle ); |
3034 | 3061 |
3035 if ( !akerning ) | 3062 if ( !akerning ) |
3036 return FT_Err_Invalid_Argument; | 3063 return FT_THROW( Invalid_Argument ); |
3037 | 3064 |
3038 FT_FACE_FIND_SERVICE( face, service, KERNING ); | 3065 FT_FACE_FIND_SERVICE( face, service, KERNING ); |
3039 if ( !service ) | 3066 if ( !service ) |
3040 return FT_Err_Unimplemented_Feature; | 3067 return FT_THROW( Unimplemented_Feature ); |
3041 | 3068 |
3042 error = service->get_track( face, | 3069 error = service->get_track( face, |
3043 point_size, | 3070 point_size, |
3044 degree, | 3071 degree, |
3045 akerning ); | 3072 akerning ); |
3046 | 3073 |
3047 return error; | 3074 return error; |
3048 } | 3075 } |
3049 | 3076 |
3050 | 3077 |
3051 /* documentation is in freetype.h */ | 3078 /* documentation is in freetype.h */ |
3052 | 3079 |
3053 FT_EXPORT_DEF( FT_Error ) | 3080 FT_EXPORT_DEF( FT_Error ) |
3054 FT_Select_Charmap( FT_Face face, | 3081 FT_Select_Charmap( FT_Face face, |
3055 FT_Encoding encoding ) | 3082 FT_Encoding encoding ) |
3056 { | 3083 { |
3057 FT_CharMap* cur; | 3084 FT_CharMap* cur; |
3058 FT_CharMap* limit; | 3085 FT_CharMap* limit; |
3059 | 3086 |
3060 | 3087 |
3061 if ( !face ) | 3088 if ( !face ) |
3062 return FT_Err_Invalid_Face_Handle; | 3089 return FT_THROW( Invalid_Face_Handle ); |
3063 | 3090 |
3064 if ( encoding == FT_ENCODING_NONE ) | 3091 if ( encoding == FT_ENCODING_NONE ) |
3065 return FT_Err_Invalid_Argument; | 3092 return FT_THROW( Invalid_Argument ); |
3066 | 3093 |
3067 /* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */ | 3094 /* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */ |
3068 /* charmap available, i.e., one with UCS-4 characters, if possible. */ | 3095 /* charmap available, i.e., one with UCS-4 characters, if possible. */ |
3069 /* */ | 3096 /* */ |
3070 /* This is done by find_unicode_charmap() above, to share code. */ | 3097 /* This is done by find_unicode_charmap() above, to share code. */ |
3071 if ( encoding == FT_ENCODING_UNICODE ) | 3098 if ( encoding == FT_ENCODING_UNICODE ) |
3072 return find_unicode_charmap( face ); | 3099 return find_unicode_charmap( face ); |
3073 | 3100 |
3074 cur = face->charmaps; | 3101 cur = face->charmaps; |
3075 if ( !cur ) | 3102 if ( !cur ) |
3076 return FT_Err_Invalid_CharMap_Handle; | 3103 return FT_THROW( Invalid_CharMap_Handle ); |
3077 | 3104 |
3078 limit = cur + face->num_charmaps; | 3105 limit = cur + face->num_charmaps; |
3079 | 3106 |
3080 for ( ; cur < limit; cur++ ) | 3107 for ( ; cur < limit; cur++ ) |
3081 { | 3108 { |
3082 if ( cur[0]->encoding == encoding ) | 3109 if ( cur[0]->encoding == encoding ) |
3083 { | 3110 { |
3084 #ifdef FT_MAX_CHARMAP_CACHEABLE | 3111 #ifdef FT_MAX_CHARMAP_CACHEABLE |
3085 if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE ) | 3112 if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE ) |
3086 { | 3113 { |
3087 FT_ERROR(( "FT_Select_Charmap: requested charmap is found (%d), " | 3114 FT_ERROR(( "FT_Select_Charmap: requested charmap is found (%d), " |
3088 "but in too late position to cache\n", | 3115 "but in too late position to cache\n", |
3089 cur - face->charmaps )); | 3116 cur - face->charmaps )); |
3090 continue; | 3117 continue; |
3091 } | 3118 } |
3092 #endif | 3119 #endif |
3093 face->charmap = cur[0]; | 3120 face->charmap = cur[0]; |
3094 return 0; | 3121 return 0; |
3095 } | 3122 } |
3096 } | 3123 } |
3097 | 3124 |
3098 return FT_Err_Invalid_Argument; | 3125 return FT_THROW( Invalid_Argument ); |
3099 } | 3126 } |
3100 | 3127 |
3101 | 3128 |
3102 /* documentation is in freetype.h */ | 3129 /* documentation is in freetype.h */ |
3103 | 3130 |
3104 FT_EXPORT_DEF( FT_Error ) | 3131 FT_EXPORT_DEF( FT_Error ) |
3105 FT_Set_Charmap( FT_Face face, | 3132 FT_Set_Charmap( FT_Face face, |
3106 FT_CharMap charmap ) | 3133 FT_CharMap charmap ) |
3107 { | 3134 { |
3108 FT_CharMap* cur; | 3135 FT_CharMap* cur; |
3109 FT_CharMap* limit; | 3136 FT_CharMap* limit; |
3110 | 3137 |
3111 | 3138 |
3112 if ( !face ) | 3139 if ( !face ) |
3113 return FT_Err_Invalid_Face_Handle; | 3140 return FT_THROW( Invalid_Face_Handle ); |
3114 | 3141 |
3115 cur = face->charmaps; | 3142 cur = face->charmaps; |
3116 if ( !cur ) | 3143 if ( !cur ) |
3117 return FT_Err_Invalid_CharMap_Handle; | 3144 return FT_THROW( Invalid_CharMap_Handle ); |
3118 if ( FT_Get_CMap_Format( charmap ) == 14 ) | 3145 if ( FT_Get_CMap_Format( charmap ) == 14 ) |
3119 return FT_Err_Invalid_Argument; | 3146 return FT_THROW( Invalid_Argument ); |
3120 | 3147 |
3121 limit = cur + face->num_charmaps; | 3148 limit = cur + face->num_charmaps; |
3122 | 3149 |
3123 for ( ; cur < limit; cur++ ) | 3150 for ( ; cur < limit; cur++ ) |
3124 { | 3151 { |
3125 if ( cur[0] == charmap ) | 3152 if ( cur[0] == charmap ) |
3126 { | 3153 { |
3127 #ifdef FT_MAX_CHARMAP_CACHEABLE | 3154 #ifdef FT_MAX_CHARMAP_CACHEABLE |
3128 if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE ) | 3155 if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE ) |
3129 { | 3156 { |
3130 FT_ERROR(( "FT_Set_Charmap: requested charmap is found (%d), " | 3157 FT_ERROR(( "FT_Set_Charmap: requested charmap is found (%d), " |
3131 "but in too late position to cache\n", | 3158 "but in too late position to cache\n", |
3132 cur - face->charmaps )); | 3159 cur - face->charmaps )); |
3133 continue; | 3160 continue; |
3134 } | 3161 } |
3135 #endif | 3162 #endif |
3136 face->charmap = cur[0]; | 3163 face->charmap = cur[0]; |
3137 return 0; | 3164 return 0; |
3138 } | 3165 } |
3139 } | 3166 } |
3140 return FT_Err_Invalid_Argument; | 3167 return FT_THROW( Invalid_Argument ); |
3141 } | 3168 } |
3142 | 3169 |
3143 | 3170 |
3144 /* documentation is in freetype.h */ | 3171 /* documentation is in freetype.h */ |
3145 | 3172 |
3146 FT_EXPORT_DEF( FT_Int ) | 3173 FT_EXPORT_DEF( FT_Int ) |
3147 FT_Get_Charmap_Index( FT_CharMap charmap ) | 3174 FT_Get_Charmap_Index( FT_CharMap charmap ) |
3148 { | 3175 { |
3149 FT_Int i; | 3176 FT_Int i; |
3150 | 3177 |
(...skipping 18 matching lines...) Expand all Loading... |
3169 #endif | 3196 #endif |
3170 return i; | 3197 return i; |
3171 } | 3198 } |
3172 | 3199 |
3173 | 3200 |
3174 static void | 3201 static void |
3175 ft_cmap_done_internal( FT_CMap cmap ) | 3202 ft_cmap_done_internal( FT_CMap cmap ) |
3176 { | 3203 { |
3177 FT_CMap_Class clazz = cmap->clazz; | 3204 FT_CMap_Class clazz = cmap->clazz; |
3178 FT_Face face = cmap->charmap.face; | 3205 FT_Face face = cmap->charmap.face; |
3179 FT_Memory memory = FT_FACE_MEMORY(face); | 3206 FT_Memory memory = FT_FACE_MEMORY( face ); |
3180 | 3207 |
3181 | 3208 |
3182 if ( clazz->done ) | 3209 if ( clazz->done ) |
3183 clazz->done( cmap ); | 3210 clazz->done( cmap ); |
3184 | 3211 |
3185 FT_FREE( cmap ); | 3212 FT_FREE( cmap ); |
3186 } | 3213 } |
3187 | 3214 |
3188 | 3215 |
3189 FT_BASE_DEF( void ) | 3216 FT_BASE_DEF( void ) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3238 FT_CharMap charmap, | 3265 FT_CharMap charmap, |
3239 FT_CMap *acmap ) | 3266 FT_CMap *acmap ) |
3240 { | 3267 { |
3241 FT_Error error = FT_Err_Ok; | 3268 FT_Error error = FT_Err_Ok; |
3242 FT_Face face; | 3269 FT_Face face; |
3243 FT_Memory memory; | 3270 FT_Memory memory; |
3244 FT_CMap cmap = NULL; | 3271 FT_CMap cmap = NULL; |
3245 | 3272 |
3246 | 3273 |
3247 if ( clazz == NULL || charmap == NULL || charmap->face == NULL ) | 3274 if ( clazz == NULL || charmap == NULL || charmap->face == NULL ) |
3248 return FT_Err_Invalid_Argument; | 3275 return FT_THROW( Invalid_Argument ); |
3249 | 3276 |
3250 face = charmap->face; | 3277 face = charmap->face; |
3251 memory = FT_FACE_MEMORY( face ); | 3278 memory = FT_FACE_MEMORY( face ); |
3252 | 3279 |
3253 if ( !FT_ALLOC( cmap, clazz->size ) ) | 3280 if ( !FT_ALLOC( cmap, clazz->size ) ) |
3254 { | 3281 { |
3255 cmap->charmap = *charmap; | 3282 cmap->charmap = *charmap; |
3256 cmap->clazz = clazz; | 3283 cmap->clazz = clazz; |
3257 | 3284 |
3258 if ( clazz->init ) | 3285 if ( clazz->init ) |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3571 | 3598 |
3572 | 3599 |
3573 /* documentation is in freetype.h */ | 3600 /* documentation is in freetype.h */ |
3574 | 3601 |
3575 FT_EXPORT_DEF( FT_Error ) | 3602 FT_EXPORT_DEF( FT_Error ) |
3576 FT_Get_Glyph_Name( FT_Face face, | 3603 FT_Get_Glyph_Name( FT_Face face, |
3577 FT_UInt glyph_index, | 3604 FT_UInt glyph_index, |
3578 FT_Pointer buffer, | 3605 FT_Pointer buffer, |
3579 FT_UInt buffer_max ) | 3606 FT_UInt buffer_max ) |
3580 { | 3607 { |
3581 FT_Error error = FT_Err_Invalid_Argument; | 3608 FT_Error error = FT_ERR( Invalid_Argument ); |
3582 | 3609 |
3583 | 3610 |
3584 /* clean up buffer */ | 3611 /* clean up buffer */ |
3585 if ( buffer && buffer_max > 0 ) | 3612 if ( buffer && buffer_max > 0 ) |
3586 ((FT_Byte*)buffer)[0] = 0; | 3613 ((FT_Byte*)buffer)[0] = 0; |
3587 | 3614 |
3588 if ( face && | 3615 if ( face && |
3589 (FT_Long)glyph_index <= face->num_glyphs && | 3616 (FT_Long)glyph_index <= face->num_glyphs && |
3590 FT_HAS_GLYPH_NAMES( face ) ) | 3617 FT_HAS_GLYPH_NAMES( face ) ) |
3591 { | 3618 { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3660 FT_Load_Sfnt_Table( FT_Face face, | 3687 FT_Load_Sfnt_Table( FT_Face face, |
3661 FT_ULong tag, | 3688 FT_ULong tag, |
3662 FT_Long offset, | 3689 FT_Long offset, |
3663 FT_Byte* buffer, | 3690 FT_Byte* buffer, |
3664 FT_ULong* length ) | 3691 FT_ULong* length ) |
3665 { | 3692 { |
3666 FT_Service_SFNT_Table service; | 3693 FT_Service_SFNT_Table service; |
3667 | 3694 |
3668 | 3695 |
3669 if ( !face || !FT_IS_SFNT( face ) ) | 3696 if ( !face || !FT_IS_SFNT( face ) ) |
3670 return FT_Err_Invalid_Face_Handle; | 3697 return FT_THROW( Invalid_Face_Handle ); |
3671 | 3698 |
3672 FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); | 3699 FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); |
3673 if ( service == NULL ) | 3700 if ( service == NULL ) |
3674 return FT_Err_Unimplemented_Feature; | 3701 return FT_THROW( Unimplemented_Feature ); |
3675 | 3702 |
3676 return service->load_table( face, tag, offset, buffer, length ); | 3703 return service->load_table( face, tag, offset, buffer, length ); |
3677 } | 3704 } |
3678 | 3705 |
3679 | 3706 |
3680 /* documentation is in tttables.h */ | 3707 /* documentation is in tttables.h */ |
3681 | 3708 |
3682 FT_EXPORT_DEF( FT_Error ) | 3709 FT_EXPORT_DEF( FT_Error ) |
3683 FT_Sfnt_Table_Info( FT_Face face, | 3710 FT_Sfnt_Table_Info( FT_Face face, |
3684 FT_UInt table_index, | 3711 FT_UInt table_index, |
3685 FT_ULong *tag, | 3712 FT_ULong *tag, |
3686 FT_ULong *length ) | 3713 FT_ULong *length ) |
3687 { | 3714 { |
3688 FT_Service_SFNT_Table service; | 3715 FT_Service_SFNT_Table service; |
3689 FT_ULong offset; | 3716 FT_ULong offset; |
3690 | 3717 |
3691 | 3718 |
3692 if ( !face || !FT_IS_SFNT( face ) ) | 3719 if ( !face || !FT_IS_SFNT( face ) ) |
3693 return FT_Err_Invalid_Face_Handle; | 3720 return FT_THROW( Invalid_Face_Handle ); |
3694 | 3721 |
3695 FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); | 3722 FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); |
3696 if ( service == NULL ) | 3723 if ( service == NULL ) |
3697 return FT_Err_Unimplemented_Feature; | 3724 return FT_THROW( Unimplemented_Feature ); |
3698 | 3725 |
3699 return service->table_info( face, table_index, tag, &offset, length ); | 3726 return service->table_info( face, table_index, tag, &offset, length ); |
3700 } | 3727 } |
3701 | 3728 |
3702 | 3729 |
3703 /* documentation is in tttables.h */ | 3730 /* documentation is in tttables.h */ |
3704 | 3731 |
3705 FT_EXPORT_DEF( FT_ULong ) | 3732 FT_EXPORT_DEF( FT_ULong ) |
3706 FT_Get_CMap_Language_ID( FT_CharMap charmap ) | 3733 FT_Get_CMap_Language_ID( FT_CharMap charmap ) |
3707 { | 3734 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3750 | 3777 |
3751 /* documentation is in ftsizes.h */ | 3778 /* documentation is in ftsizes.h */ |
3752 | 3779 |
3753 FT_EXPORT_DEF( FT_Error ) | 3780 FT_EXPORT_DEF( FT_Error ) |
3754 FT_Activate_Size( FT_Size size ) | 3781 FT_Activate_Size( FT_Size size ) |
3755 { | 3782 { |
3756 FT_Face face; | 3783 FT_Face face; |
3757 | 3784 |
3758 | 3785 |
3759 if ( size == NULL ) | 3786 if ( size == NULL ) |
3760 return FT_Err_Invalid_Argument; | 3787 return FT_THROW( Invalid_Argument ); |
3761 | 3788 |
3762 face = size->face; | 3789 face = size->face; |
3763 if ( face == NULL || face->driver == NULL ) | 3790 if ( face == NULL || face->driver == NULL ) |
3764 return FT_Err_Invalid_Argument; | 3791 return FT_THROW( Invalid_Argument ); |
3765 | 3792 |
3766 /* we don't need anything more complex than that; all size objects */ | 3793 /* we don't need anything more complex than that; all size objects */ |
3767 /* are already listed by the face */ | 3794 /* are already listed by the face */ |
3768 face->size = size; | 3795 face->size = size; |
3769 | 3796 |
3770 return FT_Err_Ok; | 3797 return FT_Err_Ok; |
3771 } | 3798 } |
3772 | 3799 |
3773 | 3800 |
3774 /*************************************************************************/ | 3801 /*************************************************************************/ |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3946 FT_Set_Renderer( FT_Library library, | 3973 FT_Set_Renderer( FT_Library library, |
3947 FT_Renderer renderer, | 3974 FT_Renderer renderer, |
3948 FT_UInt num_params, | 3975 FT_UInt num_params, |
3949 FT_Parameter* parameters ) | 3976 FT_Parameter* parameters ) |
3950 { | 3977 { |
3951 FT_ListNode node; | 3978 FT_ListNode node; |
3952 FT_Error error = FT_Err_Ok; | 3979 FT_Error error = FT_Err_Ok; |
3953 | 3980 |
3954 | 3981 |
3955 if ( !library ) | 3982 if ( !library ) |
3956 return FT_Err_Invalid_Library_Handle; | 3983 return FT_THROW( Invalid_Library_Handle ); |
3957 | 3984 |
3958 if ( !renderer ) | 3985 if ( !renderer ) |
3959 return FT_Err_Invalid_Argument; | 3986 return FT_THROW( Invalid_Argument ); |
3960 | 3987 |
3961 node = FT_List_Find( &library->renderers, renderer ); | 3988 node = FT_List_Find( &library->renderers, renderer ); |
3962 if ( !node ) | 3989 if ( !node ) |
3963 { | 3990 { |
3964 error = FT_Err_Invalid_Argument; | 3991 error = FT_THROW( Invalid_Argument ); |
3965 goto Exit; | 3992 goto Exit; |
3966 } | 3993 } |
3967 | 3994 |
3968 FT_List_Up( &library->renderers, node ); | 3995 FT_List_Up( &library->renderers, node ); |
3969 | 3996 |
3970 if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE ) | 3997 if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE ) |
3971 library->cur_renderer = renderer; | 3998 library->cur_renderer = renderer; |
3972 | 3999 |
3973 if ( num_params > 0 ) | 4000 if ( num_params > 0 ) |
3974 { | 4001 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4012 | 4039 |
4013 /* small shortcut for the very common case */ | 4040 /* small shortcut for the very common case */ |
4014 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) | 4041 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) |
4015 { | 4042 { |
4016 renderer = library->cur_renderer; | 4043 renderer = library->cur_renderer; |
4017 node = library->renderers.head; | 4044 node = library->renderers.head; |
4018 } | 4045 } |
4019 else | 4046 else |
4020 renderer = FT_Lookup_Renderer( library, slot->format, &node ); | 4047 renderer = FT_Lookup_Renderer( library, slot->format, &node ); |
4021 | 4048 |
4022 error = FT_Err_Unimplemented_Feature; | 4049 error = FT_ERR( Unimplemented_Feature ); |
4023 while ( renderer ) | 4050 while ( renderer ) |
4024 { | 4051 { |
4025 error = renderer->render( renderer, slot, render_mode, NULL ); | 4052 error = renderer->render( renderer, slot, render_mode, NULL ); |
4026 if ( !error || | 4053 if ( !error || |
4027 FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph ) | 4054 FT_ERR_NEQ( error, Cannot_Render_Glyph ) ) |
4028 break; | 4055 break; |
4029 | 4056 |
4030 /* FT_Err_Cannot_Render_Glyph is returned if the render mode */ | 4057 /* FT_Err_Cannot_Render_Glyph is returned if the render mode */ |
4031 /* is unsupported by the current renderer for this glyph image */ | 4058 /* is unsupported by the current renderer for this glyph image */ |
4032 /* format. */ | 4059 /* format. */ |
4033 | 4060 |
4034 /* now, look for another renderer that supports the same */ | 4061 /* now, look for another renderer that supports the same */ |
4035 /* format. */ | 4062 /* format. */ |
4036 renderer = FT_Lookup_Renderer( library, slot->format, &node ); | 4063 renderer = FT_Lookup_Renderer( library, slot->format, &node ); |
4037 update = 1; | 4064 update = 1; |
4038 } | 4065 } |
4039 | 4066 |
4040 /* if we changed the current renderer for the glyph image format */ | 4067 /* if we changed the current renderer for the glyph image format */ |
4041 /* we need to select it as the next current one */ | 4068 /* we need to select it as the next current one */ |
4042 if ( !error && update && renderer ) | 4069 if ( !error && update && renderer ) |
4043 FT_Set_Renderer( library, renderer, 0, 0 ); | 4070 FT_Set_Renderer( library, renderer, 0, 0 ); |
4044 } | 4071 } |
4045 } | 4072 } |
4046 | 4073 |
| 4074 #ifdef FT_DEBUG_LEVEL_TRACE |
| 4075 |
| 4076 #undef FT_COMPONENT |
| 4077 #define FT_COMPONENT trace_bitmap |
| 4078 |
| 4079 /* we convert to a single bitmap format for computing the checksum */ |
| 4080 { |
| 4081 FT_Bitmap bitmap; |
| 4082 FT_Error err; |
| 4083 |
| 4084 |
| 4085 FT_Bitmap_New( &bitmap ); |
| 4086 |
| 4087 err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 ); |
| 4088 if ( !err ) |
| 4089 { |
| 4090 MD5_CTX ctx; |
| 4091 unsigned char md5[16]; |
| 4092 int i; |
| 4093 |
| 4094 |
| 4095 MD5_Init( &ctx); |
| 4096 MD5_Update( &ctx, bitmap.buffer, bitmap.rows * bitmap.pitch ); |
| 4097 MD5_Final( md5, &ctx ); |
| 4098 |
| 4099 FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n" |
| 4100 " ", |
| 4101 bitmap.rows, bitmap.pitch )); |
| 4102 for ( i = 0; i < 16; i++ ) |
| 4103 FT_TRACE3(( "%02X", md5[i] )); |
| 4104 FT_TRACE3(( "\n" )); |
| 4105 } |
| 4106 |
| 4107 FT_Bitmap_Done( library, &bitmap ); |
| 4108 } |
| 4109 |
| 4110 #undef FT_COMPONENT |
| 4111 #define FT_COMPONENT trace_objs |
| 4112 |
| 4113 #endif /* FT_DEBUG_LEVEL_TRACE */ |
| 4114 |
4047 return error; | 4115 return error; |
4048 } | 4116 } |
4049 | 4117 |
4050 | 4118 |
4051 /* documentation is in freetype.h */ | 4119 /* documentation is in freetype.h */ |
4052 | 4120 |
4053 FT_EXPORT_DEF( FT_Error ) | 4121 FT_EXPORT_DEF( FT_Error ) |
4054 FT_Render_Glyph( FT_GlyphSlot slot, | 4122 FT_Render_Glyph( FT_GlyphSlot slot, |
4055 FT_Render_Mode render_mode ) | 4123 FT_Render_Mode render_mode ) |
4056 { | 4124 { |
4057 FT_Library library; | 4125 FT_Library library; |
4058 | 4126 |
4059 | 4127 |
4060 if ( !slot || !slot->face ) | 4128 if ( !slot || !slot->face ) |
4061 return FT_Err_Invalid_Argument; | 4129 return FT_THROW( Invalid_Argument ); |
4062 | 4130 |
4063 library = FT_FACE_LIBRARY( slot->face ); | 4131 library = FT_FACE_LIBRARY( slot->face ); |
4064 | 4132 |
4065 return FT_Render_Glyph_Internal( library, slot, render_mode ); | 4133 return FT_Render_Glyph_Internal( library, slot, render_mode ); |
4066 } | 4134 } |
4067 | 4135 |
4068 | 4136 |
4069 /*************************************************************************/ | 4137 /*************************************************************************/ |
4070 /*************************************************************************/ | 4138 /*************************************************************************/ |
4071 /*************************************************************************/ | 4139 /*************************************************************************/ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4131 FT_Error error; | 4199 FT_Error error; |
4132 FT_Memory memory; | 4200 FT_Memory memory; |
4133 FT_Module module; | 4201 FT_Module module; |
4134 FT_UInt nn; | 4202 FT_UInt nn; |
4135 | 4203 |
4136 | 4204 |
4137 #define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \ | 4205 #define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \ |
4138 FREETYPE_MINOR ) | 4206 FREETYPE_MINOR ) |
4139 | 4207 |
4140 if ( !library ) | 4208 if ( !library ) |
4141 return FT_Err_Invalid_Library_Handle; | 4209 return FT_THROW( Invalid_Library_Handle ); |
4142 | 4210 |
4143 if ( !clazz ) | 4211 if ( !clazz ) |
4144 return FT_Err_Invalid_Argument; | 4212 return FT_THROW( Invalid_Argument ); |
4145 | 4213 |
4146 /* check freetype version */ | 4214 /* check freetype version */ |
4147 if ( clazz->module_requires > FREETYPE_VER_FIXED ) | 4215 if ( clazz->module_requires > FREETYPE_VER_FIXED ) |
4148 return FT_Err_Invalid_Version; | 4216 return FT_THROW( Invalid_Version ); |
4149 | 4217 |
4150 /* look for a module with the same name in the library's table */ | 4218 /* look for a module with the same name in the library's table */ |
4151 for ( nn = 0; nn < library->num_modules; nn++ ) | 4219 for ( nn = 0; nn < library->num_modules; nn++ ) |
4152 { | 4220 { |
4153 module = library->modules[nn]; | 4221 module = library->modules[nn]; |
4154 if ( ft_strcmp( module->clazz->module_name, clazz->module_name ) == 0 ) | 4222 if ( ft_strcmp( module->clazz->module_name, clazz->module_name ) == 0 ) |
4155 { | 4223 { |
4156 /* this installed module has the same name, compare their versions */ | 4224 /* this installed module has the same name, compare their versions */ |
4157 if ( clazz->module_version <= module->clazz->module_version ) | 4225 if ( clazz->module_version <= module->clazz->module_version ) |
4158 return FT_Err_Lower_Module_Version; | 4226 return FT_THROW( Lower_Module_Version ); |
4159 | 4227 |
4160 /* remove the module from our list, then exit the loop to replace */ | 4228 /* remove the module from our list, then exit the loop to replace */ |
4161 /* it by our new version.. */ | 4229 /* it by our new version.. */ |
4162 FT_Remove_Module( library, module ); | 4230 FT_Remove_Module( library, module ); |
4163 break; | 4231 break; |
4164 } | 4232 } |
4165 } | 4233 } |
4166 | 4234 |
4167 memory = library->memory; | 4235 memory = library->memory; |
4168 error = FT_Err_Ok; | 4236 error = FT_Err_Ok; |
4169 | 4237 |
4170 if ( library->num_modules >= FT_MAX_MODULES ) | 4238 if ( library->num_modules >= FT_MAX_MODULES ) |
4171 { | 4239 { |
4172 error = FT_Err_Too_Many_Drivers; | 4240 error = FT_THROW( Too_Many_Drivers ); |
4173 goto Exit; | 4241 goto Exit; |
4174 } | 4242 } |
4175 | 4243 |
4176 /* allocate module object */ | 4244 /* allocate module object */ |
4177 if ( FT_ALLOC( module, clazz->module_size ) ) | 4245 if ( FT_ALLOC( module, clazz->module_size ) ) |
4178 goto Exit; | 4246 goto Exit; |
4179 | 4247 |
4180 /* base initialization */ | 4248 /* base initialization */ |
4181 module->library = library; | 4249 module->library = library; |
4182 module->memory = memory; | 4250 module->memory = memory; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4294 return module ? module->clazz->module_interface : 0; | 4362 return module ? module->clazz->module_interface : 0; |
4295 } | 4363 } |
4296 | 4364 |
4297 | 4365 |
4298 FT_BASE_DEF( FT_Pointer ) | 4366 FT_BASE_DEF( FT_Pointer ) |
4299 ft_module_get_service( FT_Module module, | 4367 ft_module_get_service( FT_Module module, |
4300 const char* service_id ) | 4368 const char* service_id ) |
4301 { | 4369 { |
4302 FT_Pointer result = NULL; | 4370 FT_Pointer result = NULL; |
4303 | 4371 |
| 4372 |
4304 if ( module ) | 4373 if ( module ) |
4305 { | 4374 { |
4306 FT_ASSERT( module->clazz && module->clazz->get_interface ); | 4375 FT_ASSERT( module->clazz && module->clazz->get_interface ); |
4307 | 4376 |
4308 /* first, look for the service in the module | 4377 /* first, look for the service in the module */ |
4309 */ | |
4310 if ( module->clazz->get_interface ) | 4378 if ( module->clazz->get_interface ) |
4311 result = module->clazz->get_interface( module, service_id ); | 4379 result = module->clazz->get_interface( module, service_id ); |
4312 | 4380 |
4313 if ( result == NULL ) | 4381 if ( result == NULL ) |
4314 { | 4382 { |
4315 /* we didn't find it, look in all other modules then | 4383 /* we didn't find it, look in all other modules then */ |
4316 */ | |
4317 FT_Library library = module->library; | 4384 FT_Library library = module->library; |
4318 FT_Module* cur = library->modules; | 4385 FT_Module* cur = library->modules; |
4319 FT_Module* limit = cur + library->num_modules; | 4386 FT_Module* limit = cur + library->num_modules; |
4320 | 4387 |
4321 | 4388 |
4322 for ( ; cur < limit; cur++ ) | 4389 for ( ; cur < limit; cur++ ) |
4323 { | 4390 { |
4324 if ( cur[0] != module ) | 4391 if ( cur[0] != module ) |
4325 { | 4392 { |
4326 FT_ASSERT( cur[0]->clazz ); | 4393 FT_ASSERT( cur[0]->clazz ); |
(...skipping 15 matching lines...) Expand all Loading... |
4342 | 4409 |
4343 /* documentation is in ftmodapi.h */ | 4410 /* documentation is in ftmodapi.h */ |
4344 | 4411 |
4345 FT_EXPORT_DEF( FT_Error ) | 4412 FT_EXPORT_DEF( FT_Error ) |
4346 FT_Remove_Module( FT_Library library, | 4413 FT_Remove_Module( FT_Library library, |
4347 FT_Module module ) | 4414 FT_Module module ) |
4348 { | 4415 { |
4349 /* try to find the module from the table, then remove it from there */ | 4416 /* try to find the module from the table, then remove it from there */ |
4350 | 4417 |
4351 if ( !library ) | 4418 if ( !library ) |
4352 return FT_Err_Invalid_Library_Handle; | 4419 return FT_THROW( Invalid_Library_Handle ); |
4353 | 4420 |
4354 if ( module ) | 4421 if ( module ) |
4355 { | 4422 { |
4356 FT_Module* cur = library->modules; | 4423 FT_Module* cur = library->modules; |
4357 FT_Module* limit = cur + library->num_modules; | 4424 FT_Module* limit = cur + library->num_modules; |
4358 | 4425 |
4359 | 4426 |
4360 for ( ; cur < limit; cur++ ) | 4427 for ( ; cur < limit; cur++ ) |
4361 { | 4428 { |
4362 if ( cur[0] == module ) | 4429 if ( cur[0] == module ) |
4363 { | 4430 { |
4364 /* remove it from the table */ | 4431 /* remove it from the table */ |
4365 library->num_modules--; | 4432 library->num_modules--; |
4366 limit--; | 4433 limit--; |
4367 while ( cur < limit ) | 4434 while ( cur < limit ) |
4368 { | 4435 { |
4369 cur[0] = cur[1]; | 4436 cur[0] = cur[1]; |
4370 cur++; | 4437 cur++; |
4371 } | 4438 } |
4372 limit[0] = 0; | 4439 limit[0] = 0; |
4373 | 4440 |
4374 /* destroy the module */ | 4441 /* destroy the module */ |
4375 Destroy_Module( module ); | 4442 Destroy_Module( module ); |
4376 | 4443 |
4377 return FT_Err_Ok; | 4444 return FT_Err_Ok; |
4378 } | 4445 } |
4379 } | 4446 } |
4380 } | 4447 } |
4381 return FT_Err_Invalid_Driver_Handle; | 4448 return FT_THROW( Invalid_Driver_Handle ); |
4382 } | 4449 } |
4383 | 4450 |
4384 | 4451 |
| 4452 FT_Error |
| 4453 ft_property_do( FT_Library library, |
| 4454 const FT_String* module_name, |
| 4455 const FT_String* property_name, |
| 4456 void* value, |
| 4457 FT_Bool set ) |
| 4458 { |
| 4459 FT_Module* cur; |
| 4460 FT_Module* limit; |
| 4461 FT_Module_Interface interface; |
| 4462 |
| 4463 FT_Service_Properties service; |
| 4464 |
| 4465 #ifdef FT_DEBUG_LEVEL_ERROR |
| 4466 const FT_String* set_name = "FT_Property_Set"; |
| 4467 const FT_String* get_name = "FT_Property_Get"; |
| 4468 const FT_String* func_name = set ? set_name : get_name; |
| 4469 #endif |
| 4470 |
| 4471 FT_Bool missing_func; |
| 4472 |
| 4473 |
| 4474 if ( !library ) |
| 4475 return FT_THROW( Invalid_Library_Handle ); |
| 4476 |
| 4477 if ( !module_name || !property_name || !value ) |
| 4478 return FT_THROW( Invalid_Argument ); |
| 4479 |
| 4480 cur = library->modules; |
| 4481 limit = cur + library->num_modules; |
| 4482 |
| 4483 /* search module */ |
| 4484 for ( ; cur < limit; cur++ ) |
| 4485 if ( !ft_strcmp( cur[0]->clazz->module_name, module_name ) ) |
| 4486 break; |
| 4487 |
| 4488 if ( cur == limit ) |
| 4489 { |
| 4490 FT_ERROR(( "%s: can't find module `%s'\n", |
| 4491 func_name, module_name )); |
| 4492 return FT_THROW( Missing_Module ); |
| 4493 } |
| 4494 |
| 4495 /* check whether we have a service interface */ |
| 4496 if ( !cur[0]->clazz->get_interface ) |
| 4497 { |
| 4498 FT_ERROR(( "%s: module `%s' doesn't support properties\n", |
| 4499 func_name, module_name )); |
| 4500 return FT_THROW( Unimplemented_Feature ); |
| 4501 } |
| 4502 |
| 4503 /* search property service */ |
| 4504 interface = cur[0]->clazz->get_interface( cur[0], |
| 4505 FT_SERVICE_ID_PROPERTIES ); |
| 4506 if ( !interface ) |
| 4507 { |
| 4508 FT_ERROR(( "%s: module `%s' doesn't support properties\n", |
| 4509 func_name, module_name )); |
| 4510 return FT_THROW( Unimplemented_Feature ); |
| 4511 } |
| 4512 |
| 4513 service = (FT_Service_Properties)interface; |
| 4514 |
| 4515 if ( set ) |
| 4516 missing_func = !service->set_property; |
| 4517 else |
| 4518 missing_func = !service->get_property; |
| 4519 |
| 4520 if ( missing_func ) |
| 4521 { |
| 4522 FT_ERROR(( "%s: property service of module `%s' is broken\n", |
| 4523 func_name, module_name )); |
| 4524 return FT_THROW( Unimplemented_Feature ); |
| 4525 } |
| 4526 |
| 4527 return set ? service->set_property( cur[0], property_name, value ) |
| 4528 : service->get_property( cur[0], property_name, value ); |
| 4529 } |
| 4530 |
| 4531 |
| 4532 /* documentation is in ftmodapi.h */ |
| 4533 |
| 4534 FT_EXPORT_DEF( FT_Error ) |
| 4535 FT_Property_Set( FT_Library library, |
| 4536 const FT_String* module_name, |
| 4537 const FT_String* property_name, |
| 4538 const void* value ) |
| 4539 { |
| 4540 return ft_property_do( library, |
| 4541 module_name, |
| 4542 property_name, |
| 4543 (void*)value, |
| 4544 TRUE ); |
| 4545 } |
| 4546 |
| 4547 |
| 4548 /* documentation is in ftmodapi.h */ |
| 4549 |
| 4550 FT_EXPORT_DEF( FT_Error ) |
| 4551 FT_Property_Get( FT_Library library, |
| 4552 const FT_String* module_name, |
| 4553 const FT_String* property_name, |
| 4554 void* value ) |
| 4555 { |
| 4556 return ft_property_do( library, |
| 4557 module_name, |
| 4558 property_name, |
| 4559 value, |
| 4560 FALSE ); |
| 4561 } |
| 4562 |
| 4563 |
4385 /*************************************************************************/ | 4564 /*************************************************************************/ |
4386 /*************************************************************************/ | 4565 /*************************************************************************/ |
4387 /*************************************************************************/ | 4566 /*************************************************************************/ |
4388 /**** ****/ | 4567 /**** ****/ |
4389 /**** ****/ | 4568 /**** ****/ |
4390 /**** L I B R A R Y ****/ | 4569 /**** L I B R A R Y ****/ |
4391 /**** ****/ | 4570 /**** ****/ |
4392 /**** ****/ | 4571 /**** ****/ |
4393 /*************************************************************************/ | 4572 /*************************************************************************/ |
4394 /*************************************************************************/ | 4573 /*************************************************************************/ |
(...skipping 15 matching lines...) Expand all Loading... |
4410 | 4589 |
4411 FT_EXPORT_DEF( FT_Error ) | 4590 FT_EXPORT_DEF( FT_Error ) |
4412 FT_New_Library( FT_Memory memory, | 4591 FT_New_Library( FT_Memory memory, |
4413 FT_Library *alibrary ) | 4592 FT_Library *alibrary ) |
4414 { | 4593 { |
4415 FT_Library library = NULL; | 4594 FT_Library library = NULL; |
4416 FT_Error error; | 4595 FT_Error error; |
4417 | 4596 |
4418 | 4597 |
4419 if ( !memory ) | 4598 if ( !memory ) |
4420 return FT_Err_Invalid_Argument; | 4599 return FT_THROW( Invalid_Argument ); |
4421 | 4600 |
4422 #ifdef FT_DEBUG_LEVEL_ERROR | 4601 #ifdef FT_DEBUG_LEVEL_ERROR |
4423 /* init debugging support */ | 4602 /* init debugging support */ |
4424 ft_debug_init(); | 4603 ft_debug_init(); |
4425 #endif | 4604 #endif |
4426 | 4605 |
4427 /* first of all, allocate the library object */ | 4606 /* first of all, allocate the library object */ |
4428 if ( FT_NEW( library ) ) | 4607 if ( FT_NEW( library ) ) |
4429 return error; | 4608 return error; |
4430 | 4609 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4497 | 4676 |
4498 /* documentation is in ftmodapi.h */ | 4677 /* documentation is in ftmodapi.h */ |
4499 | 4678 |
4500 FT_EXPORT_DEF( FT_Error ) | 4679 FT_EXPORT_DEF( FT_Error ) |
4501 FT_Done_Library( FT_Library library ) | 4680 FT_Done_Library( FT_Library library ) |
4502 { | 4681 { |
4503 FT_Memory memory; | 4682 FT_Memory memory; |
4504 | 4683 |
4505 | 4684 |
4506 if ( !library ) | 4685 if ( !library ) |
4507 return FT_Err_Invalid_Library_Handle; | 4686 return FT_THROW( Invalid_Library_Handle ); |
4508 | 4687 |
4509 library->refcount--; | 4688 library->refcount--; |
4510 if ( library->refcount > 0 ) | 4689 if ( library->refcount > 0 ) |
4511 goto Exit; | 4690 goto Exit; |
4512 | 4691 |
4513 memory = library->memory; | 4692 memory = library->memory; |
4514 | 4693 |
4515 /* | 4694 /* |
4516 * Close all faces in the library. If we don't do this, we can have | 4695 * Close all faces in the library. If we don't do this, we can have |
4517 * some subtle memory leaks. | 4696 * some subtle memory leaks. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4644 FT_SERVICE_ID_TRUETYPE_ENGINE ); | 4823 FT_SERVICE_ID_TRUETYPE_ENGINE ); |
4645 if ( service ) | 4824 if ( service ) |
4646 result = service->engine_type; | 4825 result = service->engine_type; |
4647 } | 4826 } |
4648 } | 4827 } |
4649 | 4828 |
4650 return result; | 4829 return result; |
4651 } | 4830 } |
4652 | 4831 |
4653 | 4832 |
4654 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS | |
4655 | |
4656 FT_BASE_DEF( FT_Error ) | |
4657 ft_stub_set_char_sizes( FT_Size size, | |
4658 FT_F26Dot6 width, | |
4659 FT_F26Dot6 height, | |
4660 FT_UInt horz_res, | |
4661 FT_UInt vert_res ) | |
4662 { | |
4663 FT_Size_RequestRec req; | |
4664 FT_Driver driver = size->face->driver; | |
4665 | |
4666 | |
4667 if ( driver->clazz->request_size ) | |
4668 { | |
4669 req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; | |
4670 req.width = width; | |
4671 req.height = height; | |
4672 | |
4673 if ( horz_res == 0 ) | |
4674 horz_res = vert_res; | |
4675 | |
4676 if ( vert_res == 0 ) | |
4677 vert_res = horz_res; | |
4678 | |
4679 if ( horz_res == 0 ) | |
4680 horz_res = vert_res = 72; | |
4681 | |
4682 req.horiResolution = horz_res; | |
4683 req.vertResolution = vert_res; | |
4684 | |
4685 return driver->clazz->request_size( size, &req ); | |
4686 } | |
4687 | |
4688 return 0; | |
4689 } | |
4690 | |
4691 | |
4692 FT_BASE_DEF( FT_Error ) | |
4693 ft_stub_set_pixel_sizes( FT_Size size, | |
4694 FT_UInt width, | |
4695 FT_UInt height ) | |
4696 { | |
4697 FT_Size_RequestRec req; | |
4698 FT_Driver driver = size->face->driver; | |
4699 | |
4700 | |
4701 if ( driver->clazz->request_size ) | |
4702 { | |
4703 req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; | |
4704 req.width = width << 6; | |
4705 req.height = height << 6; | |
4706 req.horiResolution = 0; | |
4707 req.vertResolution = 0; | |
4708 | |
4709 return driver->clazz->request_size( size, &req ); | |
4710 } | |
4711 | |
4712 return 0; | |
4713 } | |
4714 | |
4715 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
4716 | |
4717 | |
4718 /* documentation is in freetype.h */ | 4833 /* documentation is in freetype.h */ |
4719 | 4834 |
4720 FT_EXPORT_DEF( FT_Error ) | 4835 FT_EXPORT_DEF( FT_Error ) |
4721 FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, | 4836 FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, |
4722 FT_UInt sub_index, | 4837 FT_UInt sub_index, |
4723 FT_Int *p_index, | 4838 FT_Int *p_index, |
4724 FT_UInt *p_flags, | 4839 FT_UInt *p_flags, |
4725 FT_Int *p_arg1, | 4840 FT_Int *p_arg1, |
4726 FT_Int *p_arg2, | 4841 FT_Int *p_arg2, |
4727 FT_Matrix *p_transform ) | 4842 FT_Matrix *p_transform ) |
4728 { | 4843 { |
4729 FT_Error error = FT_Err_Invalid_Argument; | 4844 FT_Error error = FT_ERR( Invalid_Argument ); |
4730 | 4845 |
4731 | 4846 |
4732 if ( glyph && | 4847 if ( glyph && |
4733 glyph->subglyphs && | 4848 glyph->subglyphs && |
4734 glyph->format == FT_GLYPH_FORMAT_COMPOSITE && | 4849 glyph->format == FT_GLYPH_FORMAT_COMPOSITE && |
4735 sub_index < glyph->num_subglyphs ) | 4850 sub_index < glyph->num_subglyphs ) |
4736 { | 4851 { |
4737 FT_SubGlyph subg = glyph->subglyphs + sub_index; | 4852 FT_SubGlyph subg = glyph->subglyphs + sub_index; |
4738 | 4853 |
4739 | 4854 |
4740 *p_index = subg->index; | 4855 *p_index = subg->index; |
4741 *p_flags = subg->flags; | 4856 *p_flags = subg->flags; |
4742 *p_arg1 = subg->arg1; | 4857 *p_arg1 = subg->arg1; |
4743 *p_arg2 = subg->arg2; | 4858 *p_arg2 = subg->arg2; |
4744 *p_transform = subg->transform; | 4859 *p_transform = subg->transform; |
4745 } | 4860 } |
4746 | 4861 |
4747 return error; | 4862 return error; |
4748 } | 4863 } |
4749 | 4864 |
4750 | 4865 |
4751 /* END */ | 4866 /* END */ |
OLD | NEW |