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-2011 by */ | 7 /* Copyright 1996-2012 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 while ( cur ) | 439 while ( cur ) |
440 { | 440 { |
441 if ( cur == slot ) | 441 if ( cur == slot ) |
442 { | 442 { |
443 if ( !prev ) | 443 if ( !prev ) |
444 slot->face->glyph = cur->next; | 444 slot->face->glyph = cur->next; |
445 else | 445 else |
446 prev->next = cur->next; | 446 prev->next = cur->next; |
447 | 447 |
| 448 /* finalize client-specific data */ |
| 449 if ( slot->generic.finalizer ) |
| 450 slot->generic.finalizer( slot ); |
| 451 |
448 ft_glyphslot_done( slot ); | 452 ft_glyphslot_done( slot ); |
449 FT_FREE( slot ); | 453 FT_FREE( slot ); |
450 break; | 454 break; |
451 } | 455 } |
452 prev = cur; | 456 prev = cur; |
453 cur = cur->next; | 457 cur = cur->next; |
454 } | 458 } |
455 } | 459 } |
456 } | 460 } |
457 | 461 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 * - Exception: The font is `tricky' and requires the native hinter to | 617 * - Exception: The font is `tricky' and requires the native hinter to |
614 * load properly. | 618 * load properly. |
615 */ | 619 */ |
616 | 620 |
617 if ( hinter && | 621 if ( hinter && |
618 !( load_flags & FT_LOAD_NO_HINTING ) && | 622 !( load_flags & FT_LOAD_NO_HINTING ) && |
619 !( load_flags & FT_LOAD_NO_AUTOHINT ) && | 623 !( load_flags & FT_LOAD_NO_AUTOHINT ) && |
620 FT_DRIVER_IS_SCALABLE( driver ) && | 624 FT_DRIVER_IS_SCALABLE( driver ) && |
621 FT_DRIVER_USES_OUTLINES( driver ) && | 625 FT_DRIVER_USES_OUTLINES( driver ) && |
622 !FT_IS_TRICKY( face ) && | 626 !FT_IS_TRICKY( face ) && |
623 ( ( face->internal->transform_matrix.yx == 0 && | 627 ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) || |
| 628 ( face->internal->transform_matrix.yx == 0 && |
624 face->internal->transform_matrix.xx != 0 ) || | 629 face->internal->transform_matrix.xx != 0 ) || |
625 ( face->internal->transform_matrix.xx == 0 && | 630 ( face->internal->transform_matrix.xx == 0 && |
626 face->internal->transform_matrix.yx != 0 ) ) ) | 631 face->internal->transform_matrix.yx != 0 ) ) ) |
627 { | 632 { |
628 if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) || | 633 if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) || |
629 !FT_DRIVER_HAS_HINTER( driver ) ) | 634 !FT_DRIVER_HAS_HINTER( driver ) ) |
630 autohint = TRUE; | 635 autohint = TRUE; |
631 else | 636 else |
632 { | 637 { |
633 FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); | 638 FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 | 754 |
750 | 755 |
751 if ( renderer ) | 756 if ( renderer ) |
752 error = renderer->clazz->transform_glyph( | 757 error = renderer->clazz->transform_glyph( |
753 renderer, slot, | 758 renderer, slot, |
754 &internal->transform_matrix, | 759 &internal->transform_matrix, |
755 &internal->transform_delta ); | 760 &internal->transform_delta ); |
756 else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) | 761 else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) |
757 { | 762 { |
758 /* apply `standard' transformation if no renderer is available */ | 763 /* apply `standard' transformation if no renderer is available */ |
759 if ( &internal->transform_matrix ) | 764 if ( internal->transform_flags & 1 ) |
760 FT_Outline_Transform( &slot->outline, | 765 FT_Outline_Transform( &slot->outline, |
761 &internal->transform_matrix ); | 766 &internal->transform_matrix ); |
762 | 767 |
763 if ( &internal->transform_delta ) | 768 if ( internal->transform_flags & 2 ) |
764 FT_Outline_Translate( &slot->outline, | 769 FT_Outline_Translate( &slot->outline, |
765 internal->transform_delta.x, | 770 internal->transform_delta.x, |
766 internal->transform_delta.y ); | 771 internal->transform_delta.y ); |
767 } | 772 } |
768 | 773 |
769 /* transform advance */ | 774 /* transform advance */ |
770 FT_Vector_Transform( &slot->advance, &internal->transform_matrix ); | 775 FT_Vector_Transform( &slot->advance, &internal->transform_matrix ); |
771 } | 776 } |
772 } | 777 } |
773 | 778 |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 *aface = 0; | 1184 *aface = 0; |
1180 } | 1185 } |
1181 | 1186 |
1182 return error; | 1187 return error; |
1183 } | 1188 } |
1184 | 1189 |
1185 | 1190 |
1186 /* there's a Mac-specific extended implementation of FT_New_Face() */ | 1191 /* there's a Mac-specific extended implementation of FT_New_Face() */ |
1187 /* in src/base/ftmac.c */ | 1192 /* in src/base/ftmac.c */ |
1188 | 1193 |
1189 #if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON ) | 1194 #ifndef FT_MACINTOSH |
1190 | 1195 |
1191 /* documentation is in freetype.h */ | 1196 /* documentation is in freetype.h */ |
1192 | 1197 |
1193 FT_EXPORT_DEF( FT_Error ) | 1198 FT_EXPORT_DEF( FT_Error ) |
1194 FT_New_Face( FT_Library library, | 1199 FT_New_Face( FT_Library library, |
1195 const char* pathname, | 1200 const char* pathname, |
1196 FT_Long face_index, | 1201 FT_Long face_index, |
1197 FT_Face *aface ) | 1202 FT_Face *aface ) |
1198 { | 1203 { |
1199 FT_Open_Args args; | 1204 FT_Open_Args args; |
1200 | 1205 |
1201 | 1206 |
1202 /* test for valid `library' and `aface' delayed to FT_Open_Face() */ | 1207 /* test for valid `library' and `aface' delayed to FT_Open_Face() */ |
1203 if ( !pathname ) | 1208 if ( !pathname ) |
1204 return FT_Err_Invalid_Argument; | 1209 return FT_Err_Invalid_Argument; |
1205 | 1210 |
1206 args.flags = FT_OPEN_PATHNAME; | 1211 args.flags = FT_OPEN_PATHNAME; |
1207 args.pathname = (char*)pathname; | 1212 args.pathname = (char*)pathname; |
1208 args.stream = NULL; | 1213 args.stream = NULL; |
1209 | 1214 |
1210 return FT_Open_Face( library, &args, face_index, aface ); | 1215 return FT_Open_Face( library, &args, face_index, aface ); |
1211 } | 1216 } |
1212 | 1217 |
1213 #endif /* defined( FT_MACINTOSH ) && !defined( DARWIN_NO_CARBON ) */ | 1218 #endif |
1214 | 1219 |
1215 | 1220 |
1216 /* documentation is in freetype.h */ | 1221 /* documentation is in freetype.h */ |
1217 | 1222 |
1218 FT_EXPORT_DEF( FT_Error ) | 1223 FT_EXPORT_DEF( FT_Error ) |
1219 FT_New_Memory_Face( FT_Library library, | 1224 FT_New_Memory_Face( FT_Library library, |
1220 const FT_Byte* file_base, | 1225 const FT_Byte* file_base, |
1221 FT_Long file_size, | 1226 FT_Long file_size, |
1222 FT_Long face_index, | 1227 FT_Long face_index, |
1223 FT_Face *aface ) | 1228 FT_Face *aface ) |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 error1 = FT_Stream_Seek( stream, pos ); | 1517 error1 = FT_Stream_Seek( stream, pos ); |
1513 if ( error1 ) | 1518 if ( error1 ) |
1514 return error1; | 1519 return error1; |
1515 } | 1520 } |
1516 | 1521 |
1517 return error; | 1522 return error; |
1518 } | 1523 } |
1519 } | 1524 } |
1520 | 1525 |
1521 | 1526 |
1522 #if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON ) | 1527 #ifndef FT_MACINTOSH |
1523 | 1528 |
1524 /* The resource header says we've got resource_cnt `POST' (type1) */ | 1529 /* The resource header says we've got resource_cnt `POST' (type1) */ |
1525 /* resources in this file. They all need to be coalesced into */ | 1530 /* resources in this file. They all need to be coalesced into */ |
1526 /* one lump which gets passed on to the type1 driver. */ | 1531 /* one lump which gets passed on to the type1 driver. */ |
1527 /* Here can be only one PostScript font in a file so face_index */ | 1532 /* Here can be only one PostScript font in a file so face_index */ |
1528 /* must be 0 (or -1). */ | 1533 /* must be 0 (or -1). */ |
1529 /* */ | 1534 /* */ |
1530 static FT_Error | 1535 static FT_Error |
1531 Mac_Read_POST_Resource( FT_Library library, | 1536 Mac_Read_POST_Resource( FT_Library library, |
1532 FT_Stream stream, | 1537 FT_Stream stream, |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 | 1872 |
1868 FT_Open_Args args2; | 1873 FT_Open_Args args2; |
1869 FT_Stream stream2 = 0; | 1874 FT_Stream stream2 = 0; |
1870 | 1875 |
1871 | 1876 |
1872 FT_Raccess_Guess( library, stream, | 1877 FT_Raccess_Guess( library, stream, |
1873 args->pathname, file_names, offsets, errors ); | 1878 args->pathname, file_names, offsets, errors ); |
1874 | 1879 |
1875 for ( i = 0; i < FT_RACCESS_N_RULES; i++ ) | 1880 for ( i = 0; i < FT_RACCESS_N_RULES; i++ ) |
1876 { | 1881 { |
1877 is_darwin_vfs = raccess_rule_by_darwin_vfs( i ); | 1882 is_darwin_vfs = ft_raccess_rule_by_darwin_vfs( library, i ); |
1878 if ( is_darwin_vfs && vfs_rfork_has_no_font ) | 1883 if ( is_darwin_vfs && vfs_rfork_has_no_font ) |
1879 { | 1884 { |
1880 FT_TRACE3(( "Skip rule %d: darwin vfs resource fork" | 1885 FT_TRACE3(( "Skip rule %d: darwin vfs resource fork" |
1881 " is already checked and" | 1886 " is already checked and" |
1882 " no font is found\n", i )); | 1887 " no font is found\n", i )); |
1883 continue; | 1888 continue; |
1884 } | 1889 } |
1885 | 1890 |
1886 if ( errors[i] ) | 1891 if ( errors[i] ) |
1887 { | 1892 { |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 } | 2611 } |
2607 else | 2612 else |
2608 { | 2613 { |
2609 metrics->x_scale = 1L << 16; | 2614 metrics->x_scale = 1L << 16; |
2610 metrics->y_scale = 1L << 16; | 2615 metrics->y_scale = 1L << 16; |
2611 metrics->ascender = bsize->y_ppem; | 2616 metrics->ascender = bsize->y_ppem; |
2612 metrics->descender = 0; | 2617 metrics->descender = 0; |
2613 metrics->height = bsize->height << 6; | 2618 metrics->height = bsize->height << 6; |
2614 metrics->max_advance = bsize->x_ppem; | 2619 metrics->max_advance = bsize->x_ppem; |
2615 } | 2620 } |
| 2621 |
| 2622 FT_TRACE5(( "FT_Select_Metrics:\n" )); |
| 2623 FT_TRACE5(( " x scale: %d (%f)\n", |
| 2624 metrics->x_scale, metrics->x_scale / 65536.0 )); |
| 2625 FT_TRACE5(( " y scale: %d (%f)\n", |
| 2626 metrics->y_scale, metrics->y_scale / 65536.0 )); |
| 2627 FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); |
| 2628 FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); |
| 2629 FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); |
| 2630 FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); |
| 2631 FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); |
| 2632 FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); |
2616 } | 2633 } |
2617 | 2634 |
2618 | 2635 |
2619 FT_BASE_DEF( void ) | 2636 FT_BASE_DEF( void ) |
2620 FT_Request_Metrics( FT_Face face, | 2637 FT_Request_Metrics( FT_Face face, |
2621 FT_Size_Request req ) | 2638 FT_Size_Request req ) |
2622 { | 2639 { |
2623 FT_Size_Metrics* metrics; | 2640 FT_Size_Metrics* metrics; |
2624 | 2641 |
2625 | 2642 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2714 metrics->y_ppem = (FT_UShort)( ( scaled_h + 32 ) >> 6 ); | 2731 metrics->y_ppem = (FT_UShort)( ( scaled_h + 32 ) >> 6 ); |
2715 | 2732 |
2716 ft_recompute_scaled_metrics( face, metrics ); | 2733 ft_recompute_scaled_metrics( face, metrics ); |
2717 } | 2734 } |
2718 else | 2735 else |
2719 { | 2736 { |
2720 FT_ZERO( metrics ); | 2737 FT_ZERO( metrics ); |
2721 metrics->x_scale = 1L << 16; | 2738 metrics->x_scale = 1L << 16; |
2722 metrics->y_scale = 1L << 16; | 2739 metrics->y_scale = 1L << 16; |
2723 } | 2740 } |
| 2741 |
| 2742 FT_TRACE5(( "FT_Request_Metrics:\n" )); |
| 2743 FT_TRACE5(( " x scale: %d (%f)\n", |
| 2744 metrics->x_scale, metrics->x_scale / 65536.0 )); |
| 2745 FT_TRACE5(( " y scale: %d (%f)\n", |
| 2746 metrics->y_scale, metrics->y_scale / 65536.0 )); |
| 2747 FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); |
| 2748 FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); |
| 2749 FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); |
| 2750 FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); |
| 2751 FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); |
| 2752 FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); |
2724 } | 2753 } |
2725 | 2754 |
2726 | 2755 |
2727 /* documentation is in freetype.h */ | 2756 /* documentation is in freetype.h */ |
2728 | 2757 |
2729 FT_EXPORT_DEF( FT_Error ) | 2758 FT_EXPORT_DEF( FT_Error ) |
2730 FT_Select_Size( FT_Face face, | 2759 FT_Select_Size( FT_Face face, |
2731 FT_Int strike_index ) | 2760 FT_Int strike_index ) |
2732 { | 2761 { |
2733 FT_Driver_Class clazz; | 2762 FT_Driver_Class clazz; |
2734 | 2763 |
2735 | 2764 |
2736 if ( !face || !FT_HAS_FIXED_SIZES( face ) ) | 2765 if ( !face || !FT_HAS_FIXED_SIZES( face ) ) |
2737 return FT_Err_Invalid_Face_Handle; | 2766 return FT_Err_Invalid_Face_Handle; |
2738 | 2767 |
2739 if ( strike_index < 0 || strike_index >= face->num_fixed_sizes ) | 2768 if ( strike_index < 0 || strike_index >= face->num_fixed_sizes ) |
2740 return FT_Err_Invalid_Argument; | 2769 return FT_Err_Invalid_Argument; |
2741 | 2770 |
2742 clazz = face->driver->clazz; | 2771 clazz = face->driver->clazz; |
2743 | 2772 |
2744 if ( clazz->select_size ) | 2773 if ( clazz->select_size ) |
2745 return clazz->select_size( face->size, (FT_ULong)strike_index ); | 2774 { |
| 2775 FT_Error error; |
| 2776 |
| 2777 |
| 2778 error = clazz->select_size( face->size, (FT_ULong)strike_index ); |
| 2779 |
| 2780 #ifdef FT_DEBUG_LEVEL_TRACE |
| 2781 { |
| 2782 FT_Size_Metrics* metrics = &face->size->metrics; |
| 2783 |
| 2784 |
| 2785 FT_TRACE5(( "FT_Select_Size (font driver's `select_size'):\n" )); |
| 2786 FT_TRACE5(( " x scale: %d (%f)\n", |
| 2787 metrics->x_scale, metrics->x_scale / 65536.0 )); |
| 2788 FT_TRACE5(( " y scale: %d (%f)\n", |
| 2789 metrics->y_scale, metrics->y_scale / 65536.0 )); |
| 2790 FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); |
| 2791 FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); |
| 2792 FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); |
| 2793 FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); |
| 2794 FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); |
| 2795 FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); |
| 2796 } |
| 2797 #endif |
| 2798 |
| 2799 return error; |
| 2800 } |
2746 | 2801 |
2747 FT_Select_Metrics( face, (FT_ULong)strike_index ); | 2802 FT_Select_Metrics( face, (FT_ULong)strike_index ); |
2748 | 2803 |
2749 return FT_Err_Ok; | 2804 return FT_Err_Ok; |
2750 } | 2805 } |
2751 | 2806 |
2752 | 2807 |
2753 /* documentation is in freetype.h */ | 2808 /* documentation is in freetype.h */ |
2754 | 2809 |
2755 FT_EXPORT_DEF( FT_Error ) | 2810 FT_EXPORT_DEF( FT_Error ) |
2756 FT_Request_Size( FT_Face face, | 2811 FT_Request_Size( FT_Face face, |
2757 FT_Size_Request req ) | 2812 FT_Size_Request req ) |
2758 { | 2813 { |
2759 FT_Driver_Class clazz; | 2814 FT_Driver_Class clazz; |
2760 FT_ULong strike_index; | 2815 FT_ULong strike_index; |
2761 | 2816 |
2762 | 2817 |
2763 if ( !face ) | 2818 if ( !face ) |
2764 return FT_Err_Invalid_Face_Handle; | 2819 return FT_Err_Invalid_Face_Handle; |
2765 | 2820 |
2766 if ( !req || req->width < 0 || req->height < 0 || | 2821 if ( !req || req->width < 0 || req->height < 0 || |
2767 req->type >= FT_SIZE_REQUEST_TYPE_MAX ) | 2822 req->type >= FT_SIZE_REQUEST_TYPE_MAX ) |
2768 return FT_Err_Invalid_Argument; | 2823 return FT_Err_Invalid_Argument; |
2769 | 2824 |
2770 clazz = face->driver->clazz; | 2825 clazz = face->driver->clazz; |
2771 | 2826 |
2772 if ( clazz->request_size ) | 2827 if ( clazz->request_size ) |
2773 return clazz->request_size( face->size, req ); | 2828 { |
| 2829 FT_Error error; |
| 2830 |
| 2831 |
| 2832 error = clazz->request_size( face->size, req ); |
| 2833 |
| 2834 #ifdef FT_DEBUG_LEVEL_TRACE |
| 2835 { |
| 2836 FT_Size_Metrics* metrics = &face->size->metrics; |
| 2837 |
| 2838 |
| 2839 FT_TRACE5(( "FT_Request_Size (font driver's `request_size'):\n" )); |
| 2840 FT_TRACE5(( " x scale: %d (%f)\n", |
| 2841 metrics->x_scale, metrics->x_scale / 65536.0 )); |
| 2842 FT_TRACE5(( " y scale: %d (%f)\n", |
| 2843 metrics->y_scale, metrics->y_scale / 65536.0 )); |
| 2844 FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 )); |
| 2845 FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 )); |
| 2846 FT_TRACE5(( " height: %f\n", metrics->height / 64.0 )); |
| 2847 FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 )); |
| 2848 FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem )); |
| 2849 FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem )); |
| 2850 } |
| 2851 #endif |
| 2852 |
| 2853 return error; |
| 2854 } |
2774 | 2855 |
2775 /* | 2856 /* |
2776 * The reason that a driver doesn't have `request_size' defined is | 2857 * The reason that a driver doesn't have `request_size' defined is |
2777 * either that the scaling here suffices or that the supported formats | 2858 * either that the scaling here suffices or that the supported formats |
2778 * are bitmap-only and size matching is not implemented. | 2859 * are bitmap-only and size matching is not implemented. |
2779 * | 2860 * |
2780 * In the latter case, a simple size matching is done. | 2861 * In the latter case, a simple size matching is done. |
2781 */ | 2862 */ |
2782 if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) ) | 2863 if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) ) |
2783 { | 2864 { |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4001 /*************************************************************************/ | 4082 /*************************************************************************/ |
4002 /* */ | 4083 /* */ |
4003 /* <Function> */ | 4084 /* <Function> */ |
4004 /* Destroy_Module */ | 4085 /* Destroy_Module */ |
4005 /* */ | 4086 /* */ |
4006 /* <Description> */ | 4087 /* <Description> */ |
4007 /* Destroys a given module object. For drivers, this also destroys */ | 4088 /* Destroys a given module object. For drivers, this also destroys */ |
4008 /* all child faces. */ | 4089 /* all child faces. */ |
4009 /* */ | 4090 /* */ |
4010 /* <InOut> */ | 4091 /* <InOut> */ |
4011 /* module :: A handle to the target driver object. */ | 4092 /* module :: A handle to the target driver object. */ |
4012 /* */ | 4093 /* */ |
4013 /* <Note> */ | 4094 /* <Note> */ |
4014 /* The driver _must_ be LOCKED! */ | 4095 /* The driver _must_ be LOCKED! */ |
4015 /* */ | 4096 /* */ |
4016 static void | 4097 static void |
4017 Destroy_Module( FT_Module module ) | 4098 Destroy_Module( FT_Module module ) |
4018 { | 4099 { |
4019 FT_Memory memory = module->memory; | 4100 FT_Memory memory = module->memory; |
4020 FT_Module_Class* clazz = module->clazz; | 4101 FT_Module_Class* clazz = module->clazz; |
4021 FT_Library library = module->library; | 4102 FT_Library library = module->library; |
4022 | 4103 |
4023 | 4104 |
4024 /* finalize client-data - before anything else */ | |
4025 if ( module->generic.finalizer ) | |
4026 module->generic.finalizer( module ); | |
4027 | |
4028 if ( library && library->auto_hinter == module ) | 4105 if ( library && library->auto_hinter == module ) |
4029 library->auto_hinter = 0; | 4106 library->auto_hinter = 0; |
4030 | 4107 |
4031 /* if the module is a renderer */ | 4108 /* if the module is a renderer */ |
4032 if ( FT_MODULE_IS_RENDERER( module ) ) | 4109 if ( FT_MODULE_IS_RENDERER( module ) ) |
4033 ft_remove_renderer( module ); | 4110 ft_remove_renderer( module ); |
4034 | 4111 |
4035 /* if the module is a font driver, add some steps */ | 4112 /* if the module is a font driver, add some steps */ |
4036 if ( FT_MODULE_IS_DRIVER( module ) ) | 4113 if ( FT_MODULE_IS_DRIVER( module ) ) |
4037 Destroy_Driver( FT_DRIVER( module ) ); | 4114 Destroy_Driver( FT_DRIVER( module ) ); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4234 result = module->clazz->get_interface( module, service_id ); | 4311 result = module->clazz->get_interface( module, service_id ); |
4235 | 4312 |
4236 if ( result == NULL ) | 4313 if ( result == NULL ) |
4237 { | 4314 { |
4238 /* we didn't find it, look in all other modules then | 4315 /* we didn't find it, look in all other modules then |
4239 */ | 4316 */ |
4240 FT_Library library = module->library; | 4317 FT_Library library = module->library; |
4241 FT_Module* cur = library->modules; | 4318 FT_Module* cur = library->modules; |
4242 FT_Module* limit = cur + library->num_modules; | 4319 FT_Module* limit = cur + library->num_modules; |
4243 | 4320 |
| 4321 |
4244 for ( ; cur < limit; cur++ ) | 4322 for ( ; cur < limit; cur++ ) |
4245 { | 4323 { |
4246 if ( cur[0] != module ) | 4324 if ( cur[0] != module ) |
4247 { | 4325 { |
4248 FT_ASSERT( cur[0]->clazz ); | 4326 FT_ASSERT( cur[0]->clazz ); |
4249 | 4327 |
4250 if ( cur[0]->clazz->get_interface ) | 4328 if ( cur[0]->clazz->get_interface ) |
4251 { | 4329 { |
4252 result = cur[0]->clazz->get_interface( cur[0], service_id ); | 4330 result = cur[0]->clazz->get_interface( cur[0], service_id ); |
4253 if ( result != NULL ) | 4331 if ( result != NULL ) |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4427 | 4505 |
4428 if ( !library ) | 4506 if ( !library ) |
4429 return FT_Err_Invalid_Library_Handle; | 4507 return FT_Err_Invalid_Library_Handle; |
4430 | 4508 |
4431 library->refcount--; | 4509 library->refcount--; |
4432 if ( library->refcount > 0 ) | 4510 if ( library->refcount > 0 ) |
4433 goto Exit; | 4511 goto Exit; |
4434 | 4512 |
4435 memory = library->memory; | 4513 memory = library->memory; |
4436 | 4514 |
4437 /* Discard client-data */ | |
4438 if ( library->generic.finalizer ) | |
4439 library->generic.finalizer( library ); | |
4440 | |
4441 /* | 4515 /* |
4442 * Close all faces in the library. If we don't do this, we can have | 4516 * Close all faces in the library. If we don't do this, we can have |
4443 * some subtle memory leaks. | 4517 * some subtle memory leaks. |
4444 * | 4518 * |
4445 * Example: | 4519 * Example: |
4446 * | 4520 * |
4447 * - the cff font driver uses the pshinter module in cff_size_done | 4521 * - the cff font driver uses the pshinter module in cff_size_done |
4448 * - if the pshinter module is destroyed before the cff font driver, | 4522 * - if the pshinter module is destroyed before the cff font driver, |
4449 * opened FT_Face objects managed by the driver are not properly | 4523 * opened FT_Face objects managed by the driver are not properly |
4450 * destroyed, resulting in a memory leak | 4524 * destroyed, resulting in a memory leak |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4668 *p_arg1 = subg->arg1; | 4742 *p_arg1 = subg->arg1; |
4669 *p_arg2 = subg->arg2; | 4743 *p_arg2 = subg->arg2; |
4670 *p_transform = subg->transform; | 4744 *p_transform = subg->transform; |
4671 } | 4745 } |
4672 | 4746 |
4673 return error; | 4747 return error; |
4674 } | 4748 } |
4675 | 4749 |
4676 | 4750 |
4677 /* END */ | 4751 /* END */ |
OLD | NEW |