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-2014 by */ | 7 /* Copyright 1996-2015 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 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 FT_BASE_DEF( FT_Error ) | 151 FT_BASE_DEF( FT_Error ) |
152 FT_Stream_New( FT_Library library, | 152 FT_Stream_New( FT_Library library, |
153 const FT_Open_Args* args, | 153 const FT_Open_Args* args, |
154 FT_Stream *astream ) | 154 FT_Stream *astream ) |
155 { | 155 { |
156 FT_Error error; | 156 FT_Error error; |
157 FT_Memory memory; | 157 FT_Memory memory; |
158 FT_Stream stream = NULL; | 158 FT_Stream stream = NULL; |
159 | 159 |
160 | 160 |
161 *astream = 0; | 161 *astream = NULL; |
162 | 162 |
163 if ( !library ) | 163 if ( !library ) |
164 return FT_THROW( Invalid_Library_Handle ); | 164 return FT_THROW( Invalid_Library_Handle ); |
165 | 165 |
166 if ( !args ) | 166 if ( !args ) |
167 return FT_THROW( Invalid_Argument ); | 167 return FT_THROW( Invalid_Argument ); |
168 | 168 |
169 memory = library->memory; | 169 memory = library->memory; |
170 | 170 |
171 if ( FT_NEW( stream ) ) | 171 if ( FT_NEW( stream ) ) |
172 goto Exit; | 172 goto Exit; |
173 | 173 |
174 stream->memory = memory; | 174 stream->memory = memory; |
175 | 175 |
176 if ( args->flags & FT_OPEN_MEMORY ) | 176 if ( args->flags & FT_OPEN_MEMORY ) |
177 { | 177 { |
178 /* create a memory-based stream */ | 178 /* create a memory-based stream */ |
179 FT_Stream_OpenMemory( stream, | 179 FT_Stream_OpenMemory( stream, |
180 (const FT_Byte*)args->memory_base, | 180 (const FT_Byte*)args->memory_base, |
181 args->memory_size ); | 181 (FT_ULong)args->memory_size ); |
182 } | 182 } |
183 | 183 |
184 #ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT | 184 #ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT |
185 | 185 |
186 else if ( args->flags & FT_OPEN_PATHNAME ) | 186 else if ( args->flags & FT_OPEN_PATHNAME ) |
187 { | 187 { |
188 /* create a normal system stream */ | 188 /* create a normal system stream */ |
189 error = FT_Stream_Open( stream, args->pathname ); | 189 error = FT_Stream_Open( stream, args->pathname ); |
190 stream->pathname.pointer = args->pathname; | 190 stream->pathname.pointer = args->pathname; |
191 } | 191 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 346 |
347 slot->bitmap.width = 0; | 347 slot->bitmap.width = 0; |
348 slot->bitmap.rows = 0; | 348 slot->bitmap.rows = 0; |
349 slot->bitmap.pitch = 0; | 349 slot->bitmap.pitch = 0; |
350 slot->bitmap.pixel_mode = 0; | 350 slot->bitmap.pixel_mode = 0; |
351 /* `slot->bitmap.buffer' has been handled by ft_glyphslot_free_bitmap */ | 351 /* `slot->bitmap.buffer' has been handled by ft_glyphslot_free_bitmap */ |
352 | 352 |
353 slot->bitmap_left = 0; | 353 slot->bitmap_left = 0; |
354 slot->bitmap_top = 0; | 354 slot->bitmap_top = 0; |
355 slot->num_subglyphs = 0; | 355 slot->num_subglyphs = 0; |
356 slot->subglyphs = 0; | 356 slot->subglyphs = NULL; |
357 slot->control_data = 0; | 357 slot->control_data = NULL; |
358 slot->control_len = 0; | 358 slot->control_len = 0; |
359 slot->other = 0; | 359 slot->other = NULL; |
360 slot->format = FT_GLYPH_FORMAT_NONE; | 360 slot->format = FT_GLYPH_FORMAT_NONE; |
361 | 361 |
362 slot->linearHoriAdvance = 0; | 362 slot->linearHoriAdvance = 0; |
363 slot->linearVertAdvance = 0; | 363 slot->linearVertAdvance = 0; |
364 slot->lsb_delta = 0; | 364 slot->lsb_delta = 0; |
365 slot->rsb_delta = 0; | 365 slot->rsb_delta = 0; |
366 } | 366 } |
367 | 367 |
368 | 368 |
369 static void | 369 static void |
(...skipping 10 matching lines...) Expand all Loading... |
380 /* free bitmap buffer if needed */ | 380 /* free bitmap buffer if needed */ |
381 ft_glyphslot_free_bitmap( slot ); | 381 ft_glyphslot_free_bitmap( slot ); |
382 | 382 |
383 /* slot->internal might be NULL in out-of-memory situations */ | 383 /* slot->internal might be NULL in out-of-memory situations */ |
384 if ( slot->internal ) | 384 if ( slot->internal ) |
385 { | 385 { |
386 /* free glyph loader */ | 386 /* free glyph loader */ |
387 if ( FT_DRIVER_USES_OUTLINES( driver ) ) | 387 if ( FT_DRIVER_USES_OUTLINES( driver ) ) |
388 { | 388 { |
389 FT_GlyphLoader_Done( slot->internal->loader ); | 389 FT_GlyphLoader_Done( slot->internal->loader ); |
390 slot->internal->loader = 0; | 390 slot->internal->loader = NULL; |
391 } | 391 } |
392 | 392 |
393 FT_FREE( slot->internal ); | 393 FT_FREE( slot->internal ); |
394 } | 394 } |
395 } | 395 } |
396 | 396 |
397 | 397 |
398 /* documentation is in ftobjs.h */ | 398 /* documentation is in ftobjs.h */ |
399 | 399 |
400 FT_BASE_DEF( FT_Error ) | 400 FT_BASE_DEF( FT_Error ) |
(...skipping 30 matching lines...) Expand all Loading... |
431 goto Exit; | 431 goto Exit; |
432 } | 432 } |
433 | 433 |
434 slot->next = face->glyph; | 434 slot->next = face->glyph; |
435 face->glyph = slot; | 435 face->glyph = slot; |
436 | 436 |
437 if ( aslot ) | 437 if ( aslot ) |
438 *aslot = slot; | 438 *aslot = slot; |
439 } | 439 } |
440 else if ( aslot ) | 440 else if ( aslot ) |
441 *aslot = 0; | 441 *aslot = NULL; |
442 | 442 |
443 | 443 |
444 Exit: | 444 Exit: |
445 FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error )); | 445 FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error )); |
446 return error; | 446 return error; |
447 } | 447 } |
448 | 448 |
449 | 449 |
450 /* documentation is in ftobjs.h */ | 450 /* documentation is in ftobjs.h */ |
451 | 451 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 /* Discard glyph slots for this face. */ | 925 /* Discard glyph slots for this face. */ |
926 /* Beware! FT_Done_GlyphSlot() changes the field `face->glyph' */ | 926 /* Beware! FT_Done_GlyphSlot() changes the field `face->glyph' */ |
927 while ( face->glyph ) | 927 while ( face->glyph ) |
928 FT_Done_GlyphSlot( face->glyph ); | 928 FT_Done_GlyphSlot( face->glyph ); |
929 | 929 |
930 /* discard all sizes for this face */ | 930 /* discard all sizes for this face */ |
931 FT_List_Finalize( &face->sizes_list, | 931 FT_List_Finalize( &face->sizes_list, |
932 (FT_List_Destructor)destroy_size, | 932 (FT_List_Destructor)destroy_size, |
933 memory, | 933 memory, |
934 driver ); | 934 driver ); |
935 face->size = 0; | 935 face->size = NULL; |
936 | 936 |
937 /* now discard client data */ | 937 /* now discard client data */ |
938 if ( face->generic.finalizer ) | 938 if ( face->generic.finalizer ) |
939 face->generic.finalizer( face ); | 939 face->generic.finalizer( face ); |
940 | 940 |
941 /* discard charmaps */ | 941 /* discard charmaps */ |
942 destroy_charmaps( face, memory ); | 942 destroy_charmaps( face, memory ); |
943 | 943 |
944 /* finalize format-specific stuff */ | 944 /* finalize format-specific stuff */ |
945 if ( clazz->done_face ) | 945 if ( clazz->done_face ) |
946 clazz->done_face( face ); | 946 clazz->done_face( face ); |
947 | 947 |
948 /* close the stream for this face if needed */ | 948 /* close the stream for this face if needed */ |
949 FT_Stream_Free( | 949 FT_Stream_Free( |
950 face->stream, | 950 face->stream, |
951 ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 ); | 951 ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 ); |
952 | 952 |
953 face->stream = 0; | 953 face->stream = NULL; |
954 | 954 |
955 /* get rid of it */ | 955 /* get rid of it */ |
956 if ( face->internal ) | 956 if ( face->internal ) |
957 { | 957 { |
958 FT_FREE( face->internal ); | 958 FT_FREE( face->internal ); |
959 } | 959 } |
960 FT_FREE( face ); | 960 FT_FREE( face ); |
961 } | 961 } |
962 | 962 |
963 | 963 |
964 static void | 964 static void |
965 Destroy_Driver( FT_Driver driver ) | 965 Destroy_Driver( FT_Driver driver ) |
966 { | 966 { |
967 FT_List_Finalize( &driver->faces_list, | 967 FT_List_Finalize( &driver->faces_list, |
968 (FT_List_Destructor)destroy_face, | 968 (FT_List_Destructor)destroy_face, |
969 driver->root.memory, | 969 driver->root.memory, |
970 driver ); | 970 driver ); |
971 | |
972 /* check whether we need to drop the driver's glyph loader */ | |
973 if ( FT_DRIVER_USES_OUTLINES( driver ) ) | |
974 FT_GlyphLoader_Done( driver->glyph_loader ); | |
975 } | 971 } |
976 | 972 |
977 | 973 |
978 /*************************************************************************/ | 974 /*************************************************************************/ |
979 /* */ | 975 /* */ |
980 /* <Function> */ | 976 /* <Function> */ |
981 /* find_unicode_charmap */ | 977 /* find_unicode_charmap */ |
982 /* */ | 978 /* */ |
983 /* <Description> */ | 979 /* <Description> */ |
984 /* This function finds a Unicode charmap, if there is one. */ | 980 /* This function finds a Unicode charmap, if there is one. */ |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 if ( FT_NEW( internal ) ) | 1146 if ( FT_NEW( internal ) ) |
1151 goto Fail; | 1147 goto Fail; |
1152 | 1148 |
1153 face->internal = internal; | 1149 face->internal = internal; |
1154 | 1150 |
1155 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 1151 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
1156 { | 1152 { |
1157 int i; | 1153 int i; |
1158 | 1154 |
1159 | 1155 |
1160 face->internal->incremental_interface = 0; | 1156 face->internal->incremental_interface = NULL; |
1161 for ( i = 0; i < num_params && !face->internal->incremental_interface; | 1157 for ( i = 0; i < num_params && !face->internal->incremental_interface; |
1162 i++ ) | 1158 i++ ) |
1163 if ( params[i].tag == FT_PARAM_TAG_INCREMENTAL ) | 1159 if ( params[i].tag == FT_PARAM_TAG_INCREMENTAL ) |
1164 face->internal->incremental_interface = | 1160 face->internal->incremental_interface = |
1165 (FT_Incremental_Interface)params[i].data; | 1161 (FT_Incremental_Interface)params[i].data; |
1166 } | 1162 } |
1167 #endif | 1163 #endif |
1168 | 1164 |
1169 if ( clazz->init_face ) | 1165 if ( clazz->init_face ) |
1170 error = clazz->init_face( *astream, | 1166 error = clazz->init_face( *astream, |
(...skipping 21 matching lines...) Expand all Loading... |
1192 *aface = face; | 1188 *aface = face; |
1193 | 1189 |
1194 Fail: | 1190 Fail: |
1195 if ( error ) | 1191 if ( error ) |
1196 { | 1192 { |
1197 destroy_charmaps( face, memory ); | 1193 destroy_charmaps( face, memory ); |
1198 if ( clazz->done_face ) | 1194 if ( clazz->done_face ) |
1199 clazz->done_face( face ); | 1195 clazz->done_face( face ); |
1200 FT_FREE( internal ); | 1196 FT_FREE( internal ); |
1201 FT_FREE( face ); | 1197 FT_FREE( face ); |
1202 *aface = 0; | 1198 *aface = NULL; |
1203 } | 1199 } |
1204 | 1200 |
1205 return error; | 1201 return error; |
1206 } | 1202 } |
1207 | 1203 |
1208 | 1204 |
1209 /* there's a Mac-specific extended implementation of FT_New_Face() */ | 1205 /* there's a Mac-specific extended implementation of FT_New_Face() */ |
1210 /* in src/base/ftmac.c */ | 1206 /* in src/base/ftmac.c */ |
1211 | 1207 |
1212 #ifndef FT_MACINTOSH | 1208 #ifndef FT_MACINTOSH |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 /* From ftmac.c. */ | 1291 /* From ftmac.c. */ |
1296 static void | 1292 static void |
1297 memory_stream_close( FT_Stream stream ) | 1293 memory_stream_close( FT_Stream stream ) |
1298 { | 1294 { |
1299 FT_Memory memory = stream->memory; | 1295 FT_Memory memory = stream->memory; |
1300 | 1296 |
1301 | 1297 |
1302 FT_FREE( stream->base ); | 1298 FT_FREE( stream->base ); |
1303 | 1299 |
1304 stream->size = 0; | 1300 stream->size = 0; |
1305 stream->base = 0; | 1301 stream->base = NULL; |
1306 stream->close = 0; | 1302 stream->close = NULL; |
1307 } | 1303 } |
1308 | 1304 |
1309 | 1305 |
1310 /* Create a new memory stream from a buffer and a size. */ | 1306 /* Create a new memory stream from a buffer and a size. */ |
1311 /* From ftmac.c. */ | 1307 /* From ftmac.c. */ |
1312 static FT_Error | 1308 static FT_Error |
1313 new_memory_stream( FT_Library library, | 1309 new_memory_stream( FT_Library library, |
1314 FT_Byte* base, | 1310 FT_Byte* base, |
1315 FT_ULong size, | 1311 FT_ULong size, |
1316 FT_Stream_CloseFunc close, | 1312 FT_Stream_CloseFunc close, |
1317 FT_Stream *astream ) | 1313 FT_Stream *astream ) |
1318 { | 1314 { |
1319 FT_Error error; | 1315 FT_Error error; |
1320 FT_Memory memory; | 1316 FT_Memory memory; |
1321 FT_Stream stream = NULL; | 1317 FT_Stream stream = NULL; |
1322 | 1318 |
1323 | 1319 |
1324 if ( !library ) | 1320 if ( !library ) |
1325 return FT_THROW( Invalid_Library_Handle ); | 1321 return FT_THROW( Invalid_Library_Handle ); |
1326 | 1322 |
1327 if ( !base ) | 1323 if ( !base ) |
1328 return FT_THROW( Invalid_Argument ); | 1324 return FT_THROW( Invalid_Argument ); |
1329 | 1325 |
1330 *astream = 0; | 1326 *astream = NULL; |
1331 memory = library->memory; | 1327 memory = library->memory; |
1332 if ( FT_NEW( stream ) ) | 1328 if ( FT_NEW( stream ) ) |
1333 goto Exit; | 1329 goto Exit; |
1334 | 1330 |
1335 FT_Stream_OpenMemory( stream, base, size ); | 1331 FT_Stream_OpenMemory( stream, base, size ); |
1336 | 1332 |
1337 stream->close = close; | 1333 stream->close = close; |
1338 | 1334 |
1339 *astream = stream; | 1335 *astream = stream; |
1340 | 1336 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 | 1368 |
1373 args.flags = FT_OPEN_STREAM; | 1369 args.flags = FT_OPEN_STREAM; |
1374 args.stream = stream; | 1370 args.stream = stream; |
1375 if ( driver_name ) | 1371 if ( driver_name ) |
1376 { | 1372 { |
1377 args.flags = args.flags | FT_OPEN_DRIVER; | 1373 args.flags = args.flags | FT_OPEN_DRIVER; |
1378 args.driver = FT_Get_Module( library, driver_name ); | 1374 args.driver = FT_Get_Module( library, driver_name ); |
1379 } | 1375 } |
1380 | 1376 |
1381 #ifdef FT_MACINTOSH | 1377 #ifdef FT_MACINTOSH |
1382 /* At this point, face_index has served its purpose; */ | 1378 /* At this point, the face index has served its purpose; */ |
1383 /* whoever calls this function has already used it to */ | 1379 /* whoever calls this function has already used it to */ |
1384 /* locate the correct font data. We should not propagate */ | 1380 /* locate the correct font data. We should not propagate */ |
1385 /* this index to FT_Open_Face() (unless it is negative). */ | 1381 /* this index to FT_Open_Face() (unless it is negative). */ |
1386 | 1382 |
1387 if ( face_index > 0 ) | 1383 if ( face_index > 0 ) |
1388 face_index = 0; | 1384 face_index &= 0x7FFF0000L; /* retain GX data */ |
1389 #endif | 1385 #endif |
1390 | 1386 |
1391 error = FT_Open_Face( library, &args, face_index, aface ); | 1387 error = FT_Open_Face( library, &args, face_index, aface ); |
1392 | 1388 |
1393 if ( error == FT_Err_Ok ) | 1389 if ( error == FT_Err_Ok ) |
1394 (*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM; | 1390 (*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM; |
1395 else | 1391 else |
1396 #ifdef FT_MACINTOSH | 1392 #ifdef FT_MACINTOSH |
1397 FT_Stream_Free( stream, 0 ); | 1393 FT_Stream_Free( stream, 0 ); |
1398 #else | 1394 #else |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 open_face_PS_from_sfnt_stream( FT_Library library, | 1480 open_face_PS_from_sfnt_stream( FT_Library library, |
1485 FT_Stream stream, | 1481 FT_Stream stream, |
1486 FT_Long face_index, | 1482 FT_Long face_index, |
1487 FT_Int num_params, | 1483 FT_Int num_params, |
1488 FT_Parameter *params, | 1484 FT_Parameter *params, |
1489 FT_Face *aface ) | 1485 FT_Face *aface ) |
1490 { | 1486 { |
1491 FT_Error error; | 1487 FT_Error error; |
1492 FT_Memory memory = library->memory; | 1488 FT_Memory memory = library->memory; |
1493 FT_ULong offset, length; | 1489 FT_ULong offset, length; |
1494 FT_Long pos; | 1490 FT_ULong pos; |
1495 FT_Bool is_sfnt_cid; | 1491 FT_Bool is_sfnt_cid; |
1496 FT_Byte* sfnt_ps = NULL; | 1492 FT_Byte* sfnt_ps = NULL; |
1497 | 1493 |
1498 FT_UNUSED( num_params ); | 1494 FT_UNUSED( num_params ); |
1499 FT_UNUSED( params ); | 1495 FT_UNUSED( params ); |
1500 | 1496 |
1501 | 1497 |
1502 pos = FT_Stream_Pos( stream ); | 1498 /* ignore GX stuff */ |
| 1499 if ( face_index > 0 ) |
| 1500 face_index &= 0xFFFFL; |
| 1501 |
| 1502 pos = FT_STREAM_POS(); |
1503 | 1503 |
1504 error = ft_lookup_PS_in_sfnt_stream( stream, | 1504 error = ft_lookup_PS_in_sfnt_stream( stream, |
1505 face_index, | 1505 face_index, |
1506 &offset, | 1506 &offset, |
1507 &length, | 1507 &length, |
1508 &is_sfnt_cid ); | 1508 &is_sfnt_cid ); |
1509 if ( error ) | 1509 if ( error ) |
1510 goto Exit; | 1510 goto Exit; |
1511 | 1511 |
1512 if ( FT_Stream_Seek( stream, pos + offset ) ) | 1512 if ( FT_Stream_Seek( stream, pos + offset ) ) |
1513 goto Exit; | 1513 goto Exit; |
1514 | 1514 |
1515 if ( FT_ALLOC( sfnt_ps, (FT_Long)length ) ) | 1515 if ( FT_ALLOC( sfnt_ps, (FT_Long)length ) ) |
1516 goto Exit; | 1516 goto Exit; |
1517 | 1517 |
1518 error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length ); | 1518 error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length ); |
1519 if ( error ) | 1519 if ( error ) { |
| 1520 FT_FREE( sfnt_ps ); |
1520 goto Exit; | 1521 goto Exit; |
| 1522 } |
1521 | 1523 |
1522 error = open_face_from_buffer( library, | 1524 error = open_face_from_buffer( library, |
1523 sfnt_ps, | 1525 sfnt_ps, |
1524 length, | 1526 length, |
1525 FT_MIN( face_index, 0 ), | 1527 FT_MIN( face_index, 0 ), |
1526 is_sfnt_cid ? "cid" : "type1", | 1528 is_sfnt_cid ? "cid" : "type1", |
1527 aface ); | 1529 aface ); |
1528 Exit: | 1530 Exit: |
1529 { | 1531 { |
1530 FT_Error error1; | 1532 FT_Error error1; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 if ( face_index == -1 ) | 1572 if ( face_index == -1 ) |
1571 face_index = 0; | 1573 face_index = 0; |
1572 if ( face_index != 0 ) | 1574 if ( face_index != 0 ) |
1573 return error; | 1575 return error; |
1574 | 1576 |
1575 /* Find the length of all the POST resources, concatenated. Assume */ | 1577 /* Find the length of all the POST resources, concatenated. Assume */ |
1576 /* worst case (each resource in its own section). */ | 1578 /* worst case (each resource in its own section). */ |
1577 pfb_len = 0; | 1579 pfb_len = 0; |
1578 for ( i = 0; i < resource_cnt; ++i ) | 1580 for ( i = 0; i < resource_cnt; ++i ) |
1579 { | 1581 { |
1580 error = FT_Stream_Seek( stream, offsets[i] ); | 1582 error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] ); |
1581 if ( error ) | 1583 if ( error ) |
1582 goto Exit; | 1584 goto Exit; |
1583 if ( FT_READ_ULONG( temp ) ) | 1585 if ( FT_READ_ULONG( temp ) ) |
1584 goto Exit; | 1586 goto Exit; |
1585 | 1587 |
1586 /* FT2 allocator takes signed long buffer length, | 1588 /* FT2 allocator takes signed long buffer length, |
1587 * too large value causing overflow should be checked | 1589 * too large value causing overflow should be checked |
1588 */ | 1590 */ |
1589 FT_TRACE4(( " POST fragment #%d: length=0x%08x\n", | 1591 FT_TRACE4(( " POST fragment #%d: length=0x%08x" |
1590 i, temp)); | 1592 " total pfb_len=0x%08x\n", |
1591 if ( 0x7FFFFFFFUL < temp || pfb_len + temp + 6 < pfb_len ) | 1593 i, temp, pfb_len + temp + 6)); |
| 1594 if ( FT_MAC_RFORK_MAX_LEN < temp || |
| 1595 FT_MAC_RFORK_MAX_LEN - temp < pfb_len + 6 ) |
1592 { | 1596 { |
1593 FT_TRACE2(( " too long fragment length makes" | 1597 FT_TRACE2(( " MacOS resource length cannot exceed" |
1594 " pfb_len confused: temp=0x%08x\n", temp )); | 1598 " 0x%08x\n", FT_MAC_RFORK_MAX_LEN )); |
1595 error = FT_THROW( Invalid_Offset ); | 1599 error = FT_THROW( Invalid_Offset ); |
1596 goto Exit; | 1600 goto Exit; |
1597 } | 1601 } |
1598 | 1602 |
1599 pfb_len += temp + 6; | 1603 pfb_len += temp + 6; |
1600 } | 1604 } |
1601 | 1605 |
1602 FT_TRACE2(( " total buffer size to concatenate %d" | 1606 FT_TRACE2(( " total buffer size to concatenate %d" |
1603 " POST fragments: 0x%08x\n", | 1607 " POST fragments: 0x%08x\n", |
1604 resource_cnt, pfb_len + 2)); | 1608 resource_cnt, pfb_len + 2)); |
(...skipping 12 matching lines...) Expand all Loading... |
1617 pfb_data[3] = 0; | 1621 pfb_data[3] = 0; |
1618 pfb_data[4] = 0; | 1622 pfb_data[4] = 0; |
1619 pfb_data[5] = 0; | 1623 pfb_data[5] = 0; |
1620 pfb_pos = 6; | 1624 pfb_pos = 6; |
1621 pfb_lenpos = 2; | 1625 pfb_lenpos = 2; |
1622 | 1626 |
1623 len = 0; | 1627 len = 0; |
1624 type = 1; | 1628 type = 1; |
1625 for ( i = 0; i < resource_cnt; ++i ) | 1629 for ( i = 0; i < resource_cnt; ++i ) |
1626 { | 1630 { |
1627 error = FT_Stream_Seek( stream, offsets[i] ); | 1631 error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] ); |
1628 if ( error ) | 1632 if ( error ) |
1629 goto Exit2; | 1633 goto Exit2; |
1630 if ( FT_READ_ULONG( rlen ) ) | 1634 if ( FT_READ_ULONG( rlen ) ) |
1631 goto Exit2; | 1635 goto Exit2; |
1632 | 1636 |
1633 /* FT2 allocator takes signed long buffer length, | 1637 /* FT2 allocator takes signed long buffer length, |
1634 * too large fragment length causing overflow should be checked | 1638 * too large fragment length causing overflow should be checked |
1635 */ | 1639 */ |
1636 if ( 0x7FFFFFFFUL < rlen ) | 1640 if ( 0x7FFFFFFFUL < rlen ) |
1637 { | 1641 { |
(...skipping 19 matching lines...) Expand all Loading... |
1657 if ( rlen > 2 ) | 1661 if ( rlen > 2 ) |
1658 rlen -= 2; | 1662 rlen -= 2; |
1659 else | 1663 else |
1660 rlen = 0; | 1664 rlen = 0; |
1661 | 1665 |
1662 if ( ( flags >> 8 ) == type ) | 1666 if ( ( flags >> 8 ) == type ) |
1663 len += rlen; | 1667 len += rlen; |
1664 else | 1668 else |
1665 { | 1669 { |
1666 FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer" | 1670 FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer" |
1667 " 0x%p + 0x%08x\n", i, pfb_data, pfb_lenpos )); | 1671 " %p + 0x%08x\n", i, pfb_data, pfb_lenpos )); |
1668 if ( pfb_lenpos + 3 > pfb_len + 2 ) | 1672 if ( pfb_lenpos + 3 > pfb_len + 2 ) |
1669 goto Exit2; | 1673 goto Exit2; |
1670 pfb_data[pfb_lenpos ] = (FT_Byte)( len ); | 1674 pfb_data[pfb_lenpos ] = (FT_Byte)( len ); |
1671 pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 ); | 1675 pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 ); |
1672 pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 ); | 1676 pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 ); |
1673 pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 ); | 1677 pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 ); |
1674 | 1678 |
1675 if ( ( flags >> 8 ) == 5 ) /* End of font mark */ | 1679 if ( ( flags >> 8 ) == 5 ) /* End of font mark */ |
1676 break; | 1680 break; |
1677 | 1681 |
1678 FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer" | 1682 FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer" |
1679 " 0x%p + 0x%08x\n", i, pfb_data, pfb_pos )); | 1683 " %p + 0x%08x\n", i, pfb_data, pfb_pos )); |
1680 if ( pfb_pos + 6 > pfb_len + 2 ) | 1684 if ( pfb_pos + 6 > pfb_len + 2 ) |
1681 goto Exit2; | 1685 goto Exit2; |
1682 pfb_data[pfb_pos++] = 0x80; | 1686 pfb_data[pfb_pos++] = 0x80; |
1683 | 1687 |
1684 type = flags >> 8; | 1688 type = flags >> 8; |
1685 len = rlen; | 1689 len = rlen; |
1686 | 1690 |
1687 pfb_data[pfb_pos++] = (FT_Byte)type; | 1691 pfb_data[pfb_pos++] = (FT_Byte)type; |
1688 pfb_lenpos = pfb_pos; | 1692 pfb_lenpos = pfb_pos; |
1689 pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */ | 1693 pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */ |
1690 pfb_data[pfb_pos++] = 0; | 1694 pfb_data[pfb_pos++] = 0; |
1691 pfb_data[pfb_pos++] = 0; | 1695 pfb_data[pfb_pos++] = 0; |
1692 pfb_data[pfb_pos++] = 0; | 1696 pfb_data[pfb_pos++] = 0; |
1693 } | 1697 } |
1694 | 1698 |
1695 if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) | 1699 if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) |
1696 goto Exit2; | 1700 goto Exit2; |
1697 | 1701 |
1698 FT_TRACE3(( " Load POST fragment #%d (%d byte) to buffer" | 1702 FT_TRACE3(( " Load POST fragment #%d (%d byte) to buffer" |
1699 " 0x%p + 0x%08x\n", i, rlen, pfb_data, pfb_pos )); | 1703 " %p + 0x%08x\n", i, rlen, pfb_data, pfb_pos )); |
1700 error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); | 1704 error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); |
1701 if ( error ) | 1705 if ( error ) |
1702 goto Exit2; | 1706 goto Exit2; |
1703 pfb_pos += rlen; | 1707 pfb_pos += rlen; |
1704 } | 1708 } |
1705 | 1709 |
1706 error = FT_ERR( Array_Too_Large ); | 1710 error = FT_ERR( Array_Too_Large ); |
1707 if ( pfb_pos + 2 > pfb_len + 2 ) | 1711 if ( pfb_pos + 2 > pfb_len + 2 ) |
1708 goto Exit2; | 1712 goto Exit2; |
1709 pfb_data[pfb_pos++] = 0x80; | 1713 pfb_data[pfb_pos++] = 0x80; |
(...skipping 24 matching lines...) Expand all Loading... |
1734 FT_FREE( pfb_data ); | 1738 FT_FREE( pfb_data ); |
1735 | 1739 |
1736 Exit: | 1740 Exit: |
1737 return error; | 1741 return error; |
1738 } | 1742 } |
1739 | 1743 |
1740 | 1744 |
1741 /* The resource header says we've got resource_cnt `sfnt' */ | 1745 /* The resource header says we've got resource_cnt `sfnt' */ |
1742 /* (TrueType/OpenType) resources in this file. Look through */ | 1746 /* (TrueType/OpenType) resources in this file. Look through */ |
1743 /* them for the one indicated by face_index, load it into mem, */ | 1747 /* them for the one indicated by face_index, load it into mem, */ |
1744 /* pass it on the the truetype driver and return it. */ | 1748 /* pass it on to the truetype driver, and return it. */ |
1745 /* */ | 1749 /* */ |
1746 static FT_Error | 1750 static FT_Error |
1747 Mac_Read_sfnt_Resource( FT_Library library, | 1751 Mac_Read_sfnt_Resource( FT_Library library, |
1748 FT_Stream stream, | 1752 FT_Stream stream, |
1749 FT_Long *offsets, | 1753 FT_Long *offsets, |
1750 FT_Long resource_cnt, | 1754 FT_Long resource_cnt, |
1751 FT_Long face_index, | 1755 FT_Long face_index, |
1752 FT_Face *aface ) | 1756 FT_Face *aface ) |
1753 { | 1757 { |
1754 FT_Memory memory = library->memory; | 1758 FT_Memory memory = library->memory; |
1755 FT_Byte* sfnt_data = NULL; | 1759 FT_Byte* sfnt_data = NULL; |
1756 FT_Error error; | 1760 FT_Error error; |
1757 FT_Long flag_offset; | 1761 FT_ULong flag_offset; |
1758 FT_Long rlen; | 1762 FT_Long rlen; |
1759 int is_cff; | 1763 int is_cff; |
1760 FT_Long face_index_in_resource = 0; | 1764 FT_Long face_index_in_resource = 0; |
1761 | 1765 |
1762 | 1766 |
1763 if ( face_index == -1 ) | 1767 if ( face_index == -1 ) |
1764 face_index = 0; | 1768 face_index = 0; |
1765 if ( face_index >= resource_cnt ) | 1769 if ( face_index >= resource_cnt ) |
1766 return FT_THROW( Cannot_Open_Resource ); | 1770 return FT_THROW( Cannot_Open_Resource ); |
1767 | 1771 |
1768 flag_offset = offsets[face_index]; | 1772 flag_offset = (FT_ULong)offsets[face_index]; |
1769 error = FT_Stream_Seek( stream, flag_offset ); | 1773 error = FT_Stream_Seek( stream, flag_offset ); |
1770 if ( error ) | 1774 if ( error ) |
1771 goto Exit; | 1775 goto Exit; |
1772 | 1776 |
1773 if ( FT_READ_LONG( rlen ) ) | 1777 if ( FT_READ_LONG( rlen ) ) |
1774 goto Exit; | 1778 goto Exit; |
1775 if ( rlen == -1 ) | 1779 if ( rlen == -1 ) |
1776 return FT_THROW( Cannot_Open_Resource ); | 1780 return FT_THROW( Cannot_Open_Resource ); |
| 1781 if ( (FT_ULong)rlen > FT_MAC_RFORK_MAX_LEN ) |
| 1782 return FT_THROW( Invalid_Offset ); |
1777 | 1783 |
1778 error = open_face_PS_from_sfnt_stream( library, | 1784 error = open_face_PS_from_sfnt_stream( library, |
1779 stream, | 1785 stream, |
1780 face_index, | 1786 face_index, |
1781 0, NULL, | 1787 0, NULL, |
1782 aface ); | 1788 aface ); |
1783 if ( !error ) | 1789 if ( !error ) |
1784 goto Exit; | 1790 goto Exit; |
1785 | 1791 |
1786 /* rewind sfnt stream before open_face_PS_from_sfnt_stream() */ | 1792 /* rewind sfnt stream before open_face_PS_from_sfnt_stream() */ |
1787 if ( FT_Stream_Seek( stream, flag_offset + 4 ) ) | 1793 if ( FT_Stream_Seek( stream, flag_offset + 4 ) ) |
1788 goto Exit; | 1794 goto Exit; |
1789 | 1795 |
1790 if ( FT_ALLOC( sfnt_data, (FT_Long)rlen ) ) | 1796 if ( FT_ALLOC( sfnt_data, rlen ) ) |
1791 return error; | 1797 return error; |
1792 error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, rlen ); | 1798 error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, (FT_ULong)rlen ); |
1793 if ( error ) | 1799 if ( error ) { |
| 1800 FT_FREE( sfnt_data ); |
1794 goto Exit; | 1801 goto Exit; |
| 1802 } |
1795 | 1803 |
1796 is_cff = rlen > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 ); | 1804 is_cff = rlen > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 ); |
1797 error = open_face_from_buffer( library, | 1805 error = open_face_from_buffer( library, |
1798 sfnt_data, | 1806 sfnt_data, |
1799 rlen, | 1807 (FT_ULong)rlen, |
1800 face_index_in_resource, | 1808 face_index_in_resource, |
1801 is_cff ? "cff" : "truetype", | 1809 is_cff ? "cff" : "truetype", |
1802 aface ); | 1810 aface ); |
1803 | 1811 |
1804 Exit: | 1812 Exit: |
1805 return error; | 1813 return error; |
1806 } | 1814 } |
1807 | 1815 |
1808 | 1816 |
1809 /* Check for a valid resource fork header, or a valid dfont */ | 1817 /* Check for a valid resource fork header, or a valid dfont */ |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 return FT_THROW( Invalid_Stream_Operation ); | 1894 return FT_THROW( Invalid_Stream_Operation ); |
1887 | 1895 |
1888 error = FT_Stream_Seek( stream, 0 ); | 1896 error = FT_Stream_Seek( stream, 0 ); |
1889 if ( error ) | 1897 if ( error ) |
1890 goto Exit; | 1898 goto Exit; |
1891 | 1899 |
1892 error = FT_Stream_Read( stream, (FT_Byte*)header, 128 ); | 1900 error = FT_Stream_Read( stream, (FT_Byte*)header, 128 ); |
1893 if ( error ) | 1901 if ( error ) |
1894 goto Exit; | 1902 goto Exit; |
1895 | 1903 |
1896 if ( header[ 0] != 0 || | 1904 if ( header[ 0] != 0 || |
1897 header[74] != 0 || | 1905 header[74] != 0 || |
1898 header[82] != 0 || | 1906 header[82] != 0 || |
1899 header[ 1] == 0 || | 1907 header[ 1] == 0 || |
1900 header[ 1] > 33 || | 1908 header[ 1] > 33 || |
1901 header[63] != 0 || | 1909 header[63] != 0 || |
1902 header[2 + header[1]] != 0 ) | 1910 header[2 + header[1]] != 0 || |
| 1911 header[0x53] > 0x7F ) |
1903 return FT_THROW( Unknown_File_Format ); | 1912 return FT_THROW( Unknown_File_Format ); |
1904 | 1913 |
1905 dlen = ( header[0x53] << 24 ) | | 1914 dlen = ( header[0x53] << 24 ) | |
1906 ( header[0x54] << 16 ) | | 1915 ( header[0x54] << 16 ) | |
1907 ( header[0x55] << 8 ) | | 1916 ( header[0x55] << 8 ) | |
1908 header[0x56]; | 1917 header[0x56]; |
1909 #if 0 | 1918 #if 0 |
1910 rlen = ( header[0x57] << 24 ) | | 1919 rlen = ( header[0x57] << 24 ) | |
1911 ( header[0x58] << 16 ) | | 1920 ( header[0x58] << 16 ) | |
1912 ( header[0x59] << 8 ) | | 1921 ( header[0x59] << 8 ) | |
1913 header[0x5a]; | 1922 header[0x5A]; |
1914 #endif /* 0 */ | 1923 #endif /* 0 */ |
1915 offset = 128 + ( ( dlen + 127 ) & ~127 ); | 1924 offset = 128 + ( ( dlen + 127 ) & ~127 ); |
1916 | 1925 |
1917 return IsMacResource( library, stream, offset, face_index, aface ); | 1926 return IsMacResource( library, stream, offset, face_index, aface ); |
1918 | 1927 |
1919 Exit: | 1928 Exit: |
1920 return error; | 1929 return error; |
1921 } | 1930 } |
1922 | 1931 |
1923 | 1932 |
1924 static FT_Error | 1933 static FT_Error |
1925 load_face_in_embedded_rfork( FT_Library library, | 1934 load_face_in_embedded_rfork( FT_Library library, |
1926 FT_Stream stream, | 1935 FT_Stream stream, |
1927 FT_Long face_index, | 1936 FT_Long face_index, |
1928 FT_Face *aface, | 1937 FT_Face *aface, |
1929 const FT_Open_Args *args ) | 1938 const FT_Open_Args *args ) |
1930 { | 1939 { |
1931 | 1940 |
1932 #undef FT_COMPONENT | 1941 #undef FT_COMPONENT |
1933 #define FT_COMPONENT trace_raccess | 1942 #define FT_COMPONENT trace_raccess |
1934 | 1943 |
1935 FT_Memory memory = library->memory; | 1944 FT_Memory memory = library->memory; |
1936 FT_Error error = FT_ERR( Unknown_File_Format ); | 1945 FT_Error error = FT_ERR( Unknown_File_Format ); |
1937 int i; | 1946 FT_UInt i; |
1938 | 1947 |
1939 char * file_names[FT_RACCESS_N_RULES]; | 1948 char * file_names[FT_RACCESS_N_RULES]; |
1940 FT_Long offsets[FT_RACCESS_N_RULES]; | 1949 FT_Long offsets[FT_RACCESS_N_RULES]; |
1941 FT_Error errors[FT_RACCESS_N_RULES]; | 1950 FT_Error errors[FT_RACCESS_N_RULES]; |
1942 FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */ | 1951 FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */ |
1943 | 1952 |
1944 FT_Open_Args args2; | 1953 FT_Open_Args args2; |
1945 FT_Stream stream2 = 0; | 1954 FT_Stream stream2 = NULL; |
1946 | 1955 |
1947 | 1956 |
1948 FT_Raccess_Guess( library, stream, | 1957 FT_Raccess_Guess( library, stream, |
1949 args->pathname, file_names, offsets, errors ); | 1958 args->pathname, file_names, offsets, errors ); |
1950 | 1959 |
1951 for ( i = 0; i < FT_RACCESS_N_RULES; i++ ) | 1960 for ( i = 0; i < FT_RACCESS_N_RULES; i++ ) |
1952 { | 1961 { |
1953 is_darwin_vfs = ft_raccess_rule_by_darwin_vfs( library, i ); | 1962 is_darwin_vfs = ft_raccess_rule_by_darwin_vfs( library, i ); |
1954 if ( is_darwin_vfs && vfs_rfork_has_no_font ) | 1963 if ( is_darwin_vfs && vfs_rfork_has_no_font ) |
1955 { | 1964 { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 FT_UNUSED( args ); | 2038 FT_UNUSED( args ); |
2030 | 2039 |
2031 | 2040 |
2032 error = IsMacBinary( library, stream, face_index, aface ); | 2041 error = IsMacBinary( library, stream, face_index, aface ); |
2033 if ( FT_ERR_EQ( error, Unknown_File_Format ) ) | 2042 if ( FT_ERR_EQ( error, Unknown_File_Format ) ) |
2034 { | 2043 { |
2035 | 2044 |
2036 #undef FT_COMPONENT | 2045 #undef FT_COMPONENT |
2037 #define FT_COMPONENT trace_raccess | 2046 #define FT_COMPONENT trace_raccess |
2038 | 2047 |
2039 FT_TRACE3(( "Try as dfont: %s ...", args->pathname )); | 2048 #ifdef FT_DEBUG_LEVEL_TRACE |
| 2049 FT_TRACE3(( "Try as dfont: " )); |
| 2050 if ( !( args->flags & FT_OPEN_MEMORY ) ) |
| 2051 FT_TRACE3(( "%s ...", args->pathname )); |
| 2052 #endif |
2040 | 2053 |
2041 error = IsMacResource( library, stream, 0, face_index, aface ); | 2054 error = IsMacResource( library, stream, 0, face_index, aface ); |
2042 | 2055 |
2043 FT_TRACE3(( "%s\n", error ? "failed" : "successful" )); | 2056 FT_TRACE3(( "%s\n", error ? "failed" : "successful" )); |
2044 | 2057 |
2045 #undef FT_COMPONENT | 2058 #undef FT_COMPONENT |
2046 #define FT_COMPONENT trace_objs | 2059 #define FT_COMPONENT trace_objs |
2047 | 2060 |
2048 } | 2061 } |
2049 | 2062 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 /* If the font driver is specified in the `args' structure, use */ | 2109 /* If the font driver is specified in the `args' structure, use */ |
2097 /* it. Otherwise, we scan the list of registered drivers. */ | 2110 /* it. Otherwise, we scan the list of registered drivers. */ |
2098 if ( ( args->flags & FT_OPEN_DRIVER ) && args->driver ) | 2111 if ( ( args->flags & FT_OPEN_DRIVER ) && args->driver ) |
2099 { | 2112 { |
2100 driver = FT_DRIVER( args->driver ); | 2113 driver = FT_DRIVER( args->driver ); |
2101 | 2114 |
2102 /* not all modules are drivers, so check... */ | 2115 /* not all modules are drivers, so check... */ |
2103 if ( FT_MODULE_IS_DRIVER( driver ) ) | 2116 if ( FT_MODULE_IS_DRIVER( driver ) ) |
2104 { | 2117 { |
2105 FT_Int num_params = 0; | 2118 FT_Int num_params = 0; |
2106 FT_Parameter* params = 0; | 2119 FT_Parameter* params = NULL; |
2107 | 2120 |
2108 | 2121 |
2109 if ( args->flags & FT_OPEN_PARAMS ) | 2122 if ( args->flags & FT_OPEN_PARAMS ) |
2110 { | 2123 { |
2111 num_params = args->num_params; | 2124 num_params = args->num_params; |
2112 params = args->params; | 2125 params = args->params; |
2113 } | 2126 } |
2114 | 2127 |
2115 error = open_face( driver, &stream, external_stream, face_index, | 2128 error = open_face( driver, &stream, external_stream, face_index, |
2116 num_params, params, &face ); | 2129 num_params, params, &face ); |
(...skipping 13 matching lines...) Expand all Loading... |
2130 /* check each font driver for an appropriate format */ | 2143 /* check each font driver for an appropriate format */ |
2131 cur = library->modules; | 2144 cur = library->modules; |
2132 limit = cur + library->num_modules; | 2145 limit = cur + library->num_modules; |
2133 | 2146 |
2134 for ( ; cur < limit; cur++ ) | 2147 for ( ; cur < limit; cur++ ) |
2135 { | 2148 { |
2136 /* not all modules are font drivers, so check... */ | 2149 /* not all modules are font drivers, so check... */ |
2137 if ( FT_MODULE_IS_DRIVER( cur[0] ) ) | 2150 if ( FT_MODULE_IS_DRIVER( cur[0] ) ) |
2138 { | 2151 { |
2139 FT_Int num_params = 0; | 2152 FT_Int num_params = 0; |
2140 FT_Parameter* params = 0; | 2153 FT_Parameter* params = NULL; |
2141 | 2154 |
2142 | 2155 |
2143 driver = FT_DRIVER( cur[0] ); | 2156 driver = FT_DRIVER( cur[0] ); |
2144 | 2157 |
2145 if ( args->flags & FT_OPEN_PARAMS ) | 2158 if ( args->flags & FT_OPEN_PARAMS ) |
2146 { | 2159 { |
2147 num_params = args->num_params; | 2160 num_params = args->num_params; |
2148 params = args->params; | 2161 params = args->params; |
2149 } | 2162 } |
2150 | 2163 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2441 | 2454 |
2442 FT_EXPORT_DEF( FT_Error ) | 2455 FT_EXPORT_DEF( FT_Error ) |
2443 FT_New_Size( FT_Face face, | 2456 FT_New_Size( FT_Face face, |
2444 FT_Size *asize ) | 2457 FT_Size *asize ) |
2445 { | 2458 { |
2446 FT_Error error; | 2459 FT_Error error; |
2447 FT_Memory memory; | 2460 FT_Memory memory; |
2448 FT_Driver driver; | 2461 FT_Driver driver; |
2449 FT_Driver_Class clazz; | 2462 FT_Driver_Class clazz; |
2450 | 2463 |
2451 FT_Size size = 0; | 2464 FT_Size size = NULL; |
2452 FT_ListNode node = 0; | 2465 FT_ListNode node = NULL; |
2453 | 2466 |
2454 | 2467 |
2455 if ( !face ) | 2468 if ( !face ) |
2456 return FT_THROW( Invalid_Face_Handle ); | 2469 return FT_THROW( Invalid_Face_Handle ); |
2457 | 2470 |
2458 if ( !asize ) | 2471 if ( !asize ) |
2459 return FT_THROW( Invalid_Argument ); | 2472 return FT_THROW( Invalid_Argument ); |
2460 | 2473 |
2461 if ( !face->driver ) | 2474 if ( !face->driver ) |
2462 return FT_THROW( Invalid_Driver_Handle ); | 2475 return FT_THROW( Invalid_Driver_Handle ); |
2463 | 2476 |
2464 *asize = 0; | 2477 *asize = NULL; |
2465 | 2478 |
2466 driver = face->driver; | 2479 driver = face->driver; |
2467 clazz = driver->clazz; | 2480 clazz = driver->clazz; |
2468 memory = face->memory; | 2481 memory = face->memory; |
2469 | 2482 |
2470 /* Allocate new size object and perform basic initialisation */ | 2483 /* Allocate new size object and perform basic initialisation */ |
2471 if ( FT_ALLOC( size, clazz->size_object_size ) || FT_NEW( node ) ) | 2484 if ( FT_ALLOC( size, clazz->size_object_size ) || FT_NEW( node ) ) |
2472 goto Exit; | 2485 goto Exit; |
2473 | 2486 |
2474 size->face = face; | 2487 size->face = face; |
2475 | 2488 |
2476 /* for now, do not use any internal fields in size objects */ | 2489 /* for now, do not use any internal fields in size objects */ |
2477 size->internal = 0; | 2490 size->internal = NULL; |
2478 | 2491 |
2479 if ( clazz->init_size ) | 2492 if ( clazz->init_size ) |
2480 error = clazz->init_size( size ); | 2493 error = clazz->init_size( size ); |
2481 | 2494 |
2482 /* in case of success, add to the face's list */ | 2495 /* in case of success, add to the face's list */ |
2483 if ( !error ) | 2496 if ( !error ) |
2484 { | 2497 { |
2485 *asize = size; | 2498 *asize = size; |
2486 node->data = size; | 2499 node->data = size; |
2487 FT_List_Add( &face->sizes_list, node ); | 2500 FT_List_Add( &face->sizes_list, node ); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 | 2538 |
2526 error = FT_Err_Ok; | 2539 error = FT_Err_Ok; |
2527 node = FT_List_Find( &face->sizes_list, size ); | 2540 node = FT_List_Find( &face->sizes_list, size ); |
2528 if ( node ) | 2541 if ( node ) |
2529 { | 2542 { |
2530 FT_List_Remove( &face->sizes_list, node ); | 2543 FT_List_Remove( &face->sizes_list, node ); |
2531 FT_FREE( node ); | 2544 FT_FREE( node ); |
2532 | 2545 |
2533 if ( face->size == size ) | 2546 if ( face->size == size ) |
2534 { | 2547 { |
2535 face->size = 0; | 2548 face->size = NULL; |
2536 if ( face->sizes_list.head ) | 2549 if ( face->sizes_list.head ) |
2537 face->size = (FT_Size)(face->sizes_list.head->data); | 2550 face->size = (FT_Size)(face->sizes_list.head->data); |
2538 } | 2551 } |
2539 | 2552 |
2540 destroy_size( memory, size, driver ); | 2553 destroy_size( memory, size, driver ); |
2541 } | 2554 } |
2542 else | 2555 else |
2543 error = FT_THROW( Invalid_Size_Handle ); | 2556 error = FT_THROW( Invalid_Size_Handle ); |
2544 | 2557 |
2545 return error; | 2558 return error; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3011 pixel_width = pixel_height; | 3024 pixel_width = pixel_height; |
3012 else if ( pixel_height == 0 ) | 3025 else if ( pixel_height == 0 ) |
3013 pixel_height = pixel_width; | 3026 pixel_height = pixel_width; |
3014 | 3027 |
3015 if ( pixel_width < 1 ) | 3028 if ( pixel_width < 1 ) |
3016 pixel_width = 1; | 3029 pixel_width = 1; |
3017 if ( pixel_height < 1 ) | 3030 if ( pixel_height < 1 ) |
3018 pixel_height = 1; | 3031 pixel_height = 1; |
3019 | 3032 |
3020 /* use `>=' to avoid potential compiler warning on 16bit platforms */ | 3033 /* use `>=' to avoid potential compiler warning on 16bit platforms */ |
3021 if ( pixel_width >= 0xFFFFU ) | 3034 if ( pixel_width >= 0xFFFFU ) |
3022 pixel_width = 0xFFFFU; | 3035 pixel_width = 0xFFFFU; |
3023 if ( pixel_height >= 0xFFFFU ) | 3036 if ( pixel_height >= 0xFFFFU ) |
3024 pixel_height = 0xFFFFU; | 3037 pixel_height = 0xFFFFU; |
3025 | 3038 |
3026 req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; | 3039 req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; |
3027 req.width = pixel_width << 6; | 3040 req.width = (FT_Long)( pixel_width << 6 ); |
3028 req.height = pixel_height << 6; | 3041 req.height = (FT_Long)( pixel_height << 6 ); |
3029 req.horiResolution = 0; | 3042 req.horiResolution = 0; |
3030 req.vertResolution = 0; | 3043 req.vertResolution = 0; |
3031 | 3044 |
3032 return FT_Request_Size( face, &req ); | 3045 return FT_Request_Size( face, &req ); |
3033 } | 3046 } |
3034 | 3047 |
3035 | 3048 |
3036 /* documentation is in freetype.h */ | 3049 /* documentation is in freetype.h */ |
3037 | 3050 |
3038 FT_EXPORT_DEF( FT_Error ) | 3051 FT_EXPORT_DEF( FT_Error ) |
(...skipping 26 matching lines...) Expand all Loading... |
3065 akerning ); | 3078 akerning ); |
3066 if ( !error ) | 3079 if ( !error ) |
3067 { | 3080 { |
3068 if ( kern_mode != FT_KERNING_UNSCALED ) | 3081 if ( kern_mode != FT_KERNING_UNSCALED ) |
3069 { | 3082 { |
3070 akerning->x = FT_MulFix( akerning->x, face->size->metrics.x_scale ); | 3083 akerning->x = FT_MulFix( akerning->x, face->size->metrics.x_scale ); |
3071 akerning->y = FT_MulFix( akerning->y, face->size->metrics.y_scale ); | 3084 akerning->y = FT_MulFix( akerning->y, face->size->metrics.y_scale ); |
3072 | 3085 |
3073 if ( kern_mode != FT_KERNING_UNFITTED ) | 3086 if ( kern_mode != FT_KERNING_UNFITTED ) |
3074 { | 3087 { |
| 3088 FT_Pos orig_x = akerning->x; |
| 3089 FT_Pos orig_y = akerning->y; |
| 3090 |
| 3091 |
3075 /* we scale down kerning values for small ppem values */ | 3092 /* we scale down kerning values for small ppem values */ |
3076 /* to avoid that rounding makes them too big. */ | 3093 /* to avoid that rounding makes them too big. */ |
3077 /* `25' has been determined heuristically. */ | 3094 /* `25' has been determined heuristically. */ |
3078 if ( face->size->metrics.x_ppem < 25 ) | 3095 if ( face->size->metrics.x_ppem < 25 ) |
3079 akerning->x = FT_MulDiv( akerning->x, | 3096 akerning->x = FT_MulDiv( orig_x, |
3080 face->size->metrics.x_ppem, 25 ); | 3097 face->size->metrics.x_ppem, 25 ); |
3081 if ( face->size->metrics.y_ppem < 25 ) | 3098 if ( face->size->metrics.y_ppem < 25 ) |
3082 akerning->y = FT_MulDiv( akerning->y, | 3099 akerning->y = FT_MulDiv( orig_y, |
3083 face->size->metrics.y_ppem, 25 ); | 3100 face->size->metrics.y_ppem, 25 ); |
3084 | 3101 |
3085 akerning->x = FT_PIX_ROUND( akerning->x ); | 3102 akerning->x = FT_PIX_ROUND( akerning->x ); |
3086 akerning->y = FT_PIX_ROUND( akerning->y ); | 3103 akerning->y = FT_PIX_ROUND( akerning->y ); |
| 3104 |
| 3105 #ifdef FT_DEBUG_LEVEL_TRACE |
| 3106 { |
| 3107 FT_Pos orig_x_rounded = FT_PIX_ROUND( orig_x ); |
| 3108 FT_Pos orig_y_rounded = FT_PIX_ROUND( orig_y ); |
| 3109 |
| 3110 |
| 3111 if ( akerning->x != orig_x_rounded || |
| 3112 akerning->y != orig_y_rounded ) |
| 3113 FT_TRACE5(( "FT_Get_Kerning: horizontal kerning" |
| 3114 " (%d, %d) scaled down to (%d, %d) pixels\n", |
| 3115 orig_x_rounded / 64, orig_y_rounded / 64, |
| 3116 akerning->x / 64, akerning->y / 64 )); |
| 3117 } |
| 3118 #endif |
3087 } | 3119 } |
3088 } | 3120 } |
3089 } | 3121 } |
3090 } | 3122 } |
3091 | 3123 |
3092 return error; | 3124 return error; |
3093 } | 3125 } |
3094 | 3126 |
3095 | 3127 |
3096 /* documentation is in freetype.h */ | 3128 /* documentation is in freetype.h */ |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3347 if ( face && face->charmap ) | 3379 if ( face && face->charmap ) |
3348 { | 3380 { |
3349 FT_CMap cmap = FT_CMAP( face->charmap ); | 3381 FT_CMap cmap = FT_CMAP( face->charmap ); |
3350 | 3382 |
3351 | 3383 |
3352 if ( charcode > 0xFFFFFFFFUL ) | 3384 if ( charcode > 0xFFFFFFFFUL ) |
3353 { | 3385 { |
3354 FT_TRACE1(( "FT_Get_Char_Index: too large charcode" )); | 3386 FT_TRACE1(( "FT_Get_Char_Index: too large charcode" )); |
3355 FT_TRACE1(( " 0x%x is truncated\n", charcode )); | 3387 FT_TRACE1(( " 0x%x is truncated\n", charcode )); |
3356 } | 3388 } |
| 3389 |
3357 result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode ); | 3390 result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode ); |
| 3391 if ( result >= (FT_UInt)face->num_glyphs ) |
| 3392 result = 0; |
3358 } | 3393 } |
| 3394 |
3359 return result; | 3395 return result; |
3360 } | 3396 } |
3361 | 3397 |
3362 | 3398 |
3363 /* documentation is in freetype.h */ | 3399 /* documentation is in freetype.h */ |
3364 | 3400 |
3365 FT_EXPORT_DEF( FT_ULong ) | 3401 FT_EXPORT_DEF( FT_ULong ) |
3366 FT_Get_First_Char( FT_Face face, | 3402 FT_Get_First_Char( FT_Face face, |
3367 FT_UInt *agindex ) | 3403 FT_UInt *agindex ) |
3368 { | 3404 { |
3369 FT_ULong result = 0; | 3405 FT_ULong result = 0; |
3370 FT_UInt gindex = 0; | 3406 FT_UInt gindex = 0; |
3371 | 3407 |
3372 | 3408 |
3373 /* only do something if we have a charmap, and we have glyphs at all */ | 3409 /* only do something if we have a charmap, and we have glyphs at all */ |
3374 if ( face && face->charmap && face->num_glyphs ) | 3410 if ( face && face->charmap && face->num_glyphs ) |
3375 { | 3411 { |
3376 gindex = FT_Get_Char_Index( face, 0 ); | 3412 gindex = FT_Get_Char_Index( face, 0 ); |
3377 if ( gindex == 0 || gindex >= (FT_UInt)face->num_glyphs ) | 3413 if ( gindex == 0 ) |
3378 result = FT_Get_Next_Char( face, 0, &gindex ); | 3414 result = FT_Get_Next_Char( face, 0, &gindex ); |
3379 } | 3415 } |
3380 | 3416 |
3381 if ( agindex ) | 3417 if ( agindex ) |
3382 *agindex = gindex; | 3418 *agindex = gindex; |
3383 | 3419 |
3384 return result; | 3420 return result; |
3385 } | 3421 } |
3386 | 3422 |
3387 | 3423 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3641 | 3677 |
3642 if ( !face ) | 3678 if ( !face ) |
3643 return FT_THROW( Invalid_Face_Handle ); | 3679 return FT_THROW( Invalid_Face_Handle ); |
3644 | 3680 |
3645 if ( !buffer || buffer_max == 0 ) | 3681 if ( !buffer || buffer_max == 0 ) |
3646 return FT_THROW( Invalid_Argument ); | 3682 return FT_THROW( Invalid_Argument ); |
3647 | 3683 |
3648 /* clean up buffer */ | 3684 /* clean up buffer */ |
3649 ((FT_Byte*)buffer)[0] = '\0'; | 3685 ((FT_Byte*)buffer)[0] = '\0'; |
3650 | 3686 |
3651 if ( (FT_Long)glyph_index > face->num_glyphs || | 3687 if ( (FT_Long)glyph_index >= face->num_glyphs ) |
3652 !FT_HAS_GLYPH_NAMES( face ) ) | 3688 return FT_THROW( Invalid_Glyph_Index ); |
| 3689 |
| 3690 if ( !FT_HAS_GLYPH_NAMES( face ) ) |
3653 return FT_THROW( Invalid_Argument ); | 3691 return FT_THROW( Invalid_Argument ); |
3654 | 3692 |
3655 FT_FACE_LOOKUP_SERVICE( face, service, GLYPH_DICT ); | 3693 FT_FACE_LOOKUP_SERVICE( face, service, GLYPH_DICT ); |
3656 if ( service && service->get_name ) | 3694 if ( service && service->get_name ) |
3657 error = service->get_name( face, glyph_index, buffer, buffer_max ); | 3695 error = service->get_name( face, glyph_index, buffer, buffer_max ); |
3658 else | 3696 else |
3659 error = FT_THROW( Invalid_Argument ); | 3697 error = FT_THROW( Invalid_Argument ); |
3660 | 3698 |
3661 return error; | 3699 return error; |
3662 } | 3700 } |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3843 /*************************************************************************/ | 3881 /*************************************************************************/ |
3844 /*************************************************************************/ | 3882 /*************************************************************************/ |
3845 | 3883 |
3846 /* lookup a renderer by glyph format in the library's list */ | 3884 /* lookup a renderer by glyph format in the library's list */ |
3847 FT_BASE_DEF( FT_Renderer ) | 3885 FT_BASE_DEF( FT_Renderer ) |
3848 FT_Lookup_Renderer( FT_Library library, | 3886 FT_Lookup_Renderer( FT_Library library, |
3849 FT_Glyph_Format format, | 3887 FT_Glyph_Format format, |
3850 FT_ListNode* node ) | 3888 FT_ListNode* node ) |
3851 { | 3889 { |
3852 FT_ListNode cur; | 3890 FT_ListNode cur; |
3853 FT_Renderer result = 0; | 3891 FT_Renderer result = NULL; |
3854 | 3892 |
3855 | 3893 |
3856 if ( !library ) | 3894 if ( !library ) |
3857 goto Exit; | 3895 goto Exit; |
3858 | 3896 |
3859 cur = library->renderers.head; | 3897 cur = library->renderers.head; |
3860 | 3898 |
3861 if ( node ) | 3899 if ( node ) |
3862 { | 3900 { |
3863 if ( *node ) | 3901 if ( *node ) |
3864 cur = (*node)->next; | 3902 cur = (*node)->next; |
3865 *node = 0; | 3903 *node = NULL; |
3866 } | 3904 } |
3867 | 3905 |
3868 while ( cur ) | 3906 while ( cur ) |
3869 { | 3907 { |
3870 FT_Renderer renderer = FT_RENDERER( cur->data ); | 3908 FT_Renderer renderer = FT_RENDERER( cur->data ); |
3871 | 3909 |
3872 | 3910 |
3873 if ( renderer->glyph_format == format ) | 3911 if ( renderer->glyph_format == format ) |
3874 { | 3912 { |
3875 if ( node ) | 3913 if ( node ) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4075 | 4113 |
4076 | 4114 |
4077 /* if it is already a bitmap, no need to do anything */ | 4115 /* if it is already a bitmap, no need to do anything */ |
4078 switch ( slot->format ) | 4116 switch ( slot->format ) |
4079 { | 4117 { |
4080 case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */ | 4118 case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */ |
4081 break; | 4119 break; |
4082 | 4120 |
4083 default: | 4121 default: |
4084 { | 4122 { |
4085 FT_ListNode node = 0; | 4123 FT_ListNode node = NULL; |
4086 FT_Bool update = 0; | |
4087 | 4124 |
4088 | 4125 |
4089 /* small shortcut for the very common case */ | 4126 /* small shortcut for the very common case */ |
4090 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) | 4127 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) |
4091 { | 4128 { |
4092 renderer = library->cur_renderer; | 4129 renderer = library->cur_renderer; |
4093 node = library->renderers.head; | 4130 node = library->renderers.head; |
4094 } | 4131 } |
4095 else | 4132 else |
4096 renderer = FT_Lookup_Renderer( library, slot->format, &node ); | 4133 renderer = FT_Lookup_Renderer( library, slot->format, &node ); |
4097 | 4134 |
4098 error = FT_ERR( Unimplemented_Feature ); | 4135 error = FT_ERR( Unimplemented_Feature ); |
4099 while ( renderer ) | 4136 while ( renderer ) |
4100 { | 4137 { |
4101 error = renderer->render( renderer, slot, render_mode, NULL ); | 4138 error = renderer->render( renderer, slot, render_mode, NULL ); |
4102 if ( !error || | 4139 if ( !error || |
4103 FT_ERR_NEQ( error, Cannot_Render_Glyph ) ) | 4140 FT_ERR_NEQ( error, Cannot_Render_Glyph ) ) |
4104 break; | 4141 break; |
4105 | 4142 |
4106 /* FT_Err_Cannot_Render_Glyph is returned if the render mode */ | 4143 /* FT_Err_Cannot_Render_Glyph is returned if the render mode */ |
4107 /* is unsupported by the current renderer for this glyph image */ | 4144 /* is unsupported by the current renderer for this glyph image */ |
4108 /* format. */ | 4145 /* format. */ |
4109 | 4146 |
4110 /* now, look for another renderer that supports the same */ | 4147 /* now, look for another renderer that supports the same */ |
4111 /* format. */ | 4148 /* format. */ |
4112 renderer = FT_Lookup_Renderer( library, slot->format, &node ); | 4149 renderer = FT_Lookup_Renderer( library, slot->format, &node ); |
4113 update = 1; | |
4114 } | |
4115 | |
4116 /* if we changed the current renderer for the glyph image format */ | |
4117 /* we need to select it as the next current one */ | |
4118 if ( !error && update && renderer ) | |
4119 { | |
4120 error = FT_Set_Renderer( library, renderer, 0, 0 ); | |
4121 if ( error ) | |
4122 break; | |
4123 } | 4150 } |
4124 } | 4151 } |
4125 } | 4152 } |
4126 | 4153 |
4127 #ifdef FT_DEBUG_LEVEL_TRACE | 4154 #ifdef FT_DEBUG_LEVEL_TRACE |
4128 | 4155 |
4129 #undef FT_COMPONENT | 4156 #undef FT_COMPONENT |
4130 #define FT_COMPONENT trace_bitmap | 4157 #define FT_COMPONENT trace_bitmap |
4131 | 4158 |
4132 /* we convert to a single bitmap format for computing the checksum */ | 4159 /* we convert to a single bitmap format for computing the checksum */ |
4133 if ( !error ) | 4160 if ( !error ) |
4134 { | 4161 { |
4135 FT_Bitmap bitmap; | 4162 FT_Bitmap bitmap; |
4136 FT_Error err; | 4163 FT_Error err; |
4137 | 4164 |
4138 | 4165 |
4139 FT_Bitmap_New( &bitmap ); | 4166 FT_Bitmap_Init( &bitmap ); |
4140 | 4167 |
4141 /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */ | 4168 /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */ |
4142 err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 ); | 4169 err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 ); |
4143 if ( !err ) | 4170 if ( !err ) |
4144 { | 4171 { |
4145 MD5_CTX ctx; | 4172 MD5_CTX ctx; |
4146 unsigned char md5[16]; | 4173 unsigned char md5[16]; |
4147 int i; | 4174 int i; |
| 4175 unsigned int rows = bitmap.rows; |
| 4176 unsigned int pitch = (unsigned int)bitmap.pitch; |
4148 | 4177 |
4149 | 4178 |
4150 MD5_Init( &ctx); | 4179 MD5_Init( &ctx ); |
4151 MD5_Update( &ctx, bitmap.buffer, bitmap.rows * bitmap.pitch ); | 4180 MD5_Update( &ctx, bitmap.buffer, rows * pitch ); |
4152 MD5_Final( md5, &ctx ); | 4181 MD5_Final( md5, &ctx ); |
4153 | 4182 |
4154 FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n" | 4183 FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n" |
4155 " ", | 4184 " ", |
4156 bitmap.rows, bitmap.pitch )); | 4185 rows, pitch )); |
4157 for ( i = 0; i < 16; i++ ) | 4186 for ( i = 0; i < 16; i++ ) |
4158 FT_TRACE3(( "%02X", md5[i] )); | 4187 FT_TRACE3(( "%02X", md5[i] )); |
4159 FT_TRACE3(( "\n" )); | 4188 FT_TRACE3(( "\n" )); |
4160 } | 4189 } |
4161 | 4190 |
4162 FT_Bitmap_Done( library, &bitmap ); | 4191 FT_Bitmap_Done( library, &bitmap ); |
4163 } | 4192 } |
4164 | 4193 |
4165 #undef FT_COMPONENT | 4194 #undef FT_COMPONENT |
4166 #define FT_COMPONENT trace_objs | 4195 #define FT_COMPONENT trace_objs |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4219 /* */ | 4248 /* */ |
4220 static void | 4249 static void |
4221 Destroy_Module( FT_Module module ) | 4250 Destroy_Module( FT_Module module ) |
4222 { | 4251 { |
4223 FT_Memory memory = module->memory; | 4252 FT_Memory memory = module->memory; |
4224 FT_Module_Class* clazz = module->clazz; | 4253 FT_Module_Class* clazz = module->clazz; |
4225 FT_Library library = module->library; | 4254 FT_Library library = module->library; |
4226 | 4255 |
4227 | 4256 |
4228 if ( library && library->auto_hinter == module ) | 4257 if ( library && library->auto_hinter == module ) |
4229 library->auto_hinter = 0; | 4258 library->auto_hinter = NULL; |
4230 | 4259 |
4231 /* if the module is a renderer */ | 4260 /* if the module is a renderer */ |
4232 if ( FT_MODULE_IS_RENDERER( module ) ) | 4261 if ( FT_MODULE_IS_RENDERER( module ) ) |
4233 ft_remove_renderer( module ); | 4262 ft_remove_renderer( module ); |
4234 | 4263 |
4235 /* if the module is a font driver, add some steps */ | 4264 /* if the module is a font driver, add some steps */ |
4236 if ( FT_MODULE_IS_DRIVER( module ) ) | 4265 if ( FT_MODULE_IS_DRIVER( module ) ) |
4237 Destroy_Driver( FT_DRIVER( module ) ); | 4266 Destroy_Driver( FT_DRIVER( module ) ); |
4238 | 4267 |
4239 /* finalize the module object */ | 4268 /* finalize the module object */ |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4315 goto Fail; | 4344 goto Fail; |
4316 } | 4345 } |
4317 | 4346 |
4318 /* is the module a auto-hinter? */ | 4347 /* is the module a auto-hinter? */ |
4319 if ( FT_MODULE_IS_HINTER( module ) ) | 4348 if ( FT_MODULE_IS_HINTER( module ) ) |
4320 library->auto_hinter = module; | 4349 library->auto_hinter = module; |
4321 | 4350 |
4322 /* if the module is a font driver */ | 4351 /* if the module is a font driver */ |
4323 if ( FT_MODULE_IS_DRIVER( module ) ) | 4352 if ( FT_MODULE_IS_DRIVER( module ) ) |
4324 { | 4353 { |
4325 /* allocate glyph loader if needed */ | |
4326 FT_Driver driver = FT_DRIVER( module ); | 4354 FT_Driver driver = FT_DRIVER( module ); |
4327 | 4355 |
4328 | 4356 |
4329 driver->clazz = (FT_Driver_Class)module->clazz; | 4357 driver->clazz = (FT_Driver_Class)module->clazz; |
4330 if ( FT_DRIVER_USES_OUTLINES( driver ) ) | |
4331 { | |
4332 error = FT_GlyphLoader_New( memory, &driver->glyph_loader ); | |
4333 if ( error ) | |
4334 goto Fail; | |
4335 } | |
4336 } | 4358 } |
4337 | 4359 |
4338 if ( clazz->module_init ) | 4360 if ( clazz->module_init ) |
4339 { | 4361 { |
4340 error = clazz->module_init( module ); | 4362 error = clazz->module_init( module ); |
4341 if ( error ) | 4363 if ( error ) |
4342 goto Fail; | 4364 goto Fail; |
4343 } | 4365 } |
4344 | 4366 |
4345 /* add module to the library's table */ | 4367 /* add module to the library's table */ |
4346 library->modules[library->num_modules++] = module; | 4368 library->modules[library->num_modules++] = module; |
4347 | 4369 |
4348 Exit: | 4370 Exit: |
4349 return error; | 4371 return error; |
4350 | 4372 |
4351 Fail: | 4373 Fail: |
4352 if ( FT_MODULE_IS_DRIVER( module ) ) | |
4353 { | |
4354 FT_Driver driver = FT_DRIVER( module ); | |
4355 | |
4356 | |
4357 if ( FT_DRIVER_USES_OUTLINES( driver ) ) | |
4358 FT_GlyphLoader_Done( driver->glyph_loader ); | |
4359 } | |
4360 | |
4361 if ( FT_MODULE_IS_RENDERER( module ) ) | 4374 if ( FT_MODULE_IS_RENDERER( module ) ) |
4362 { | 4375 { |
4363 FT_Renderer renderer = FT_RENDERER( module ); | 4376 FT_Renderer renderer = FT_RENDERER( module ); |
4364 | 4377 |
4365 | 4378 |
4366 if ( renderer->clazz && | 4379 if ( renderer->clazz && |
4367 renderer->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE && | 4380 renderer->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE && |
4368 renderer->raster ) | 4381 renderer->raster ) |
4369 renderer->clazz->raster_class->raster_done( renderer->raster ); | 4382 renderer->clazz->raster_class->raster_done( renderer->raster ); |
4370 } | 4383 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4485 if ( cur[0] == module ) | 4498 if ( cur[0] == module ) |
4486 { | 4499 { |
4487 /* remove it from the table */ | 4500 /* remove it from the table */ |
4488 library->num_modules--; | 4501 library->num_modules--; |
4489 limit--; | 4502 limit--; |
4490 while ( cur < limit ) | 4503 while ( cur < limit ) |
4491 { | 4504 { |
4492 cur[0] = cur[1]; | 4505 cur[0] = cur[1]; |
4493 cur++; | 4506 cur++; |
4494 } | 4507 } |
4495 limit[0] = 0; | 4508 limit[0] = NULL; |
4496 | 4509 |
4497 /* destroy the module */ | 4510 /* destroy the module */ |
4498 Destroy_Module( module ); | 4511 Destroy_Module( module ); |
4499 | 4512 |
4500 return FT_Err_Ok; | 4513 return FT_Err_Ok; |
4501 } | 4514 } |
4502 } | 4515 } |
4503 } | 4516 } |
4504 return FT_THROW( Invalid_Driver_Handle ); | 4517 return FT_THROW( Invalid_Driver_Handle ); |
4505 } | 4518 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4668 | 4681 |
4669 library->memory = memory; | 4682 library->memory = memory; |
4670 | 4683 |
4671 #ifdef FT_CONFIG_OPTION_PIC | 4684 #ifdef FT_CONFIG_OPTION_PIC |
4672 /* initialize position independent code containers */ | 4685 /* initialize position independent code containers */ |
4673 error = ft_pic_container_init( library ); | 4686 error = ft_pic_container_init( library ); |
4674 if ( error ) | 4687 if ( error ) |
4675 goto Fail; | 4688 goto Fail; |
4676 #endif | 4689 #endif |
4677 | 4690 |
4678 /* allocate the render pool */ | 4691 /* we don't use raster_pool anymore. */ |
4679 library->raster_pool_size = FT_RENDER_POOL_SIZE; | 4692 library->raster_pool_size = 0; |
4680 #if FT_RENDER_POOL_SIZE > 0 | 4693 library->raster_pool = NULL; |
4681 if ( FT_ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) ) | |
4682 goto Fail; | |
4683 #endif | |
4684 | 4694 |
4685 library->version_major = FREETYPE_MAJOR; | 4695 library->version_major = FREETYPE_MAJOR; |
4686 library->version_minor = FREETYPE_MINOR; | 4696 library->version_minor = FREETYPE_MINOR; |
4687 library->version_patch = FREETYPE_PATCH; | 4697 library->version_patch = FREETYPE_PATCH; |
4688 | 4698 |
4689 library->refcount = 1; | 4699 library->refcount = 1; |
4690 | 4700 |
4691 /* That's ok now */ | 4701 /* That's ok now */ |
4692 *alibrary = library; | 4702 *alibrary = library; |
4693 | 4703 |
4694 return FT_Err_Ok; | 4704 return FT_Err_Ok; |
4695 | 4705 |
| 4706 #ifdef FT_CONFIG_OPTION_PIC |
4696 Fail: | 4707 Fail: |
4697 #ifdef FT_CONFIG_OPTION_PIC | |
4698 ft_pic_container_destroy( library ); | 4708 ft_pic_container_destroy( library ); |
4699 #endif | 4709 #endif |
4700 FT_FREE( library ); | 4710 FT_FREE( library ); |
4701 return error; | 4711 return error; |
4702 } | 4712 } |
4703 | 4713 |
4704 | 4714 |
4705 /* documentation is in freetype.h */ | 4715 /* documentation is in freetype.h */ |
4706 | 4716 |
4707 FT_EXPORT_DEF( void ) | 4717 FT_EXPORT_DEF( void ) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4816 | 4826 |
4817 | 4827 |
4818 for ( n = 0; n < library->num_modules; n++ ) | 4828 for ( n = 0; n < library->num_modules; n++ ) |
4819 { | 4829 { |
4820 FT_Module module = library->modules[n]; | 4830 FT_Module module = library->modules[n]; |
4821 | 4831 |
4822 | 4832 |
4823 if ( module ) | 4833 if ( module ) |
4824 { | 4834 { |
4825 Destroy_Module( module ); | 4835 Destroy_Module( module ); |
4826 library->modules[n] = 0; | 4836 library->modules[n] = NULL; |
4827 } | 4837 } |
4828 } | 4838 } |
4829 } | 4839 } |
4830 #endif | 4840 #endif |
4831 | 4841 |
4832 /* Destroy raster objects */ | |
4833 FT_FREE( library->raster_pool ); | |
4834 library->raster_pool_size = 0; | |
4835 | |
4836 #ifdef FT_CONFIG_OPTION_PIC | 4842 #ifdef FT_CONFIG_OPTION_PIC |
4837 /* Destroy pic container contents */ | 4843 /* Destroy pic container contents */ |
4838 ft_pic_container_destroy( library ); | 4844 ft_pic_container_destroy( library ); |
4839 #endif | 4845 #endif |
4840 | 4846 |
4841 FT_FREE( library ); | 4847 FT_FREE( library ); |
4842 | 4848 |
4843 Exit: | 4849 Exit: |
4844 return FT_Err_Ok; | 4850 return FT_Err_Ok; |
4845 } | 4851 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4918 *p_transform = subg->transform; | 4924 *p_transform = subg->transform; |
4919 | 4925 |
4920 error = FT_Err_Ok; | 4926 error = FT_Err_Ok; |
4921 } | 4927 } |
4922 | 4928 |
4923 return error; | 4929 return error; |
4924 } | 4930 } |
4925 | 4931 |
4926 | 4932 |
4927 /* END */ | 4933 /* END */ |
OLD | NEW |