Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* afpic.c */ |
| 4 | /* */ |
| 5 | /* The FreeType position independent code services for autofit module. */ |
| 6 | /* */ |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 7 | /* Copyright 2009, 2010, 2011 by */ |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +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 "afpic.h" |
| 23 | |
| 24 | #ifdef FT_CONFIG_OPTION_PIC |
| 25 | |
| 26 | /* forward declaration of PIC init functions from afmodule.c */ |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 27 | void FT_Init_Class_af_autofitter_service( FT_Library, |
| 28 | FT_AutoHinter_ServiceRec* ); |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 29 | |
| 30 | /* forward declaration of PIC init functions from script classes */ |
| 31 | #include "aflatin.h" |
| 32 | #include "aflatin2.h" |
| 33 | #include "afcjk.h" |
| 34 | #include "afdummy.h" |
| 35 | #include "afindic.h" |
| 36 | |
| 37 | void |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 38 | autofit_module_class_pic_free( FT_Library library ) |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 39 | { |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 40 | FT_PIC_Container* pic_container = &library->pic_container; |
| 41 | FT_Memory memory = library->memory; |
| 42 | |
| 43 | |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 44 | if ( pic_container->autofit ) |
| 45 | { |
| 46 | FT_FREE( pic_container->autofit ); |
| 47 | pic_container->autofit = NULL; |
| 48 | } |
| 49 | } |
| 50 | |
Werner Lemberg | f765e44 | 2010-06-24 10:34:29 +0200 | [diff] [blame] | 51 | |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 52 | FT_Error |
Werner Lemberg | f765e44 | 2010-06-24 10:34:29 +0200 | [diff] [blame] | 53 | autofit_module_class_pic_init( FT_Library library ) |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 54 | { |
Werner Lemberg | f765e44 | 2010-06-24 10:34:29 +0200 | [diff] [blame] | 55 | FT_PIC_Container* pic_container = &library->pic_container; |
| 56 | FT_UInt ss; |
| 57 | FT_Error error = AF_Err_Ok; |
| 58 | AFModulePIC* container; |
| 59 | FT_Memory memory = library->memory; |
| 60 | |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 61 | |
| 62 | /* allocate pointer, clear and set global container pointer */ |
| 63 | if ( FT_ALLOC ( container, sizeof ( *container ) ) ) |
| 64 | return error; |
Werner Lemberg | f765e44 | 2010-06-24 10:34:29 +0200 | [diff] [blame] | 65 | FT_MEM_SET( container, 0, sizeof ( *container ) ); |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 66 | pic_container->autofit = container; |
| 67 | |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 68 | /* initialize pointer table - */ |
| 69 | /* this is how the module usually expects this data */ |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 70 | for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ ) |
| 71 | { |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 72 | container->af_script_classes[ss] = |
| 73 | &container->af_script_classes_rec[ss]; |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 74 | } |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 75 | container->af_script_classes[AF_SCRIPT_CLASSES_COUNT - 1] = NULL; |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 76 | |
| 77 | /* add call to initialization function when you add new scripts */ |
| 78 | ss = 0; |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 79 | FT_Init_Class_af_dummy_script_class( |
| 80 | &container->af_script_classes_rec[ss++] ); |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 81 | #ifdef FT_OPTION_AUTOFIT2 |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 82 | FT_Init_Class_af_latin2_script_class( |
| 83 | &container->af_script_classes_rec[ss++] ); |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 84 | #endif |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 85 | FT_Init_Class_af_latin_script_class( |
| 86 | &container->af_script_classes_rec[ss++] ); |
| 87 | FT_Init_Class_af_cjk_script_class( |
| 88 | &container->af_script_classes_rec[ss++] ); |
| 89 | FT_Init_Class_af_indic_script_class( |
| 90 | &container->af_script_classes_rec[ss++] ); |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 91 | |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 92 | FT_Init_Class_af_autofitter_service( |
| 93 | library, &container->af_autofitter_service ); |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 94 | |
Werner Lemberg | fa1e6b3 | 2011-01-03 06:50:36 +0100 | [diff] [blame] | 95 | /* Exit: */ |
| 96 | |
| 97 | if ( error ) |
| 98 | autofit_module_class_pic_free( library ); |
Oran Agra | 59b4af8 | 2009-04-05 18:23:38 +0300 | [diff] [blame] | 99 | return error; |
| 100 | } |
| 101 | |
| 102 | |
| 103 | #endif /* FT_CONFIG_OPTION_PIC */ |
| 104 | |
| 105 | |
| 106 | /* END */ |