Oran Agra | 2e7a4e9 | 2009-04-05 18:03:02 +0300 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* ttpic.c */ |
| 4 | /* */ |
| 5 | /* The FreeType position independent code services for truetype module. */ |
| 6 | /* */ |
Werner Lemberg | f765e44 | 2010-06-24 10:34:29 +0200 | [diff] [blame] | 7 | /* Copyright 2009, 2010 by */ |
Oran Agra | 2e7a4e9 | 2009-04-05 18:03:02 +0300 | [diff] [blame] | 8 | /* Oran Agra and Mickey Gabel. */ |
| 9 | /* */ |
| 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 */ |
| 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 13 | /* this file you indicate that you have read the license and */ |
| 14 | /* understand and accept it fully. */ |
| 15 | /* */ |
| 16 | /***************************************************************************/ |
| 17 | |
| 18 | |
| 19 | #include <ft2build.h> |
| 20 | #include FT_FREETYPE_H |
| 21 | #include FT_INTERNAL_OBJECTS_H |
| 22 | #include "ttpic.h" |
| 23 | |
| 24 | #ifdef FT_CONFIG_OPTION_PIC |
| 25 | |
| 26 | /* forward declaration of PIC init functions from ttdriver.c */ |
| 27 | FT_Error FT_Create_Class_tt_services( FT_Library, FT_ServiceDescRec**); |
| 28 | void FT_Destroy_Class_tt_services( FT_Library, FT_ServiceDescRec*); |
| 29 | void FT_Init_Class_tt_service_gx_multi_masters(FT_Service_MultiMastersRec*); |
| 30 | void FT_Init_Class_tt_service_truetype_glyf(FT_Service_TTGlyfRec*); |
| 31 | |
| 32 | void |
| 33 | tt_driver_class_pic_free( FT_Library library ) |
| 34 | { |
| 35 | FT_PIC_Container* pic_container = &library->pic_container; |
| 36 | FT_Memory memory = library->memory; |
| 37 | if ( pic_container->truetype ) |
| 38 | { |
| 39 | TTModulePIC* container = (TTModulePIC*)pic_container->truetype; |
| 40 | if(container->tt_services) |
| 41 | FT_Destroy_Class_tt_services(library, container->tt_services); |
| 42 | container->tt_services = NULL; |
| 43 | FT_FREE( container ); |
| 44 | pic_container->truetype = NULL; |
| 45 | } |
| 46 | } |
| 47 | |
Werner Lemberg | f765e44 | 2010-06-24 10:34:29 +0200 | [diff] [blame] | 48 | |
Oran Agra | 2e7a4e9 | 2009-04-05 18:03:02 +0300 | [diff] [blame] | 49 | FT_Error |
Werner Lemberg | f765e44 | 2010-06-24 10:34:29 +0200 | [diff] [blame] | 50 | tt_driver_class_pic_init( FT_Library library ) |
Oran Agra | 2e7a4e9 | 2009-04-05 18:03:02 +0300 | [diff] [blame] | 51 | { |
Werner Lemberg | f765e44 | 2010-06-24 10:34:29 +0200 | [diff] [blame] | 52 | FT_PIC_Container* pic_container = &library->pic_container; |
| 53 | FT_Error error = TT_Err_Ok; |
| 54 | TTModulePIC* container; |
| 55 | FT_Memory memory = library->memory; |
| 56 | |
Oran Agra | 2e7a4e9 | 2009-04-05 18:03:02 +0300 | [diff] [blame] | 57 | |
| 58 | /* allocate pointer, clear and set global container pointer */ |
| 59 | if ( FT_ALLOC ( container, sizeof ( *container ) ) ) |
| 60 | return error; |
| 61 | FT_MEM_SET( container, 0, sizeof(*container) ); |
| 62 | pic_container->truetype = container; |
| 63 | |
| 64 | /* initialize pointer table - this is how the module usually expects this data */ |
| 65 | error = FT_Create_Class_tt_services(library, &container->tt_services); |
| 66 | if(error) |
| 67 | goto Exit; |
| 68 | #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT |
| 69 | FT_Init_Class_tt_service_gx_multi_masters(&container->tt_service_gx_multi_masters); |
| 70 | #endif |
| 71 | FT_Init_Class_tt_service_truetype_glyf(&container->tt_service_truetype_glyf); |
| 72 | Exit: |
| 73 | if(error) |
| 74 | tt_driver_class_pic_free(library); |
| 75 | return error; |
| 76 | } |
| 77 | |
| 78 | #endif /* FT_CONFIG_OPTION_PIC */ |
| 79 | |
| 80 | |
| 81 | /* END */ |