cffpic.c revision 295ffce55e0198e7a9f7d46b33f5c2b4147bf821
1/***************************************************************************/
2/*                                                                         */
3/*  cffpic.c                                                               */
4/*                                                                         */
5/*    The FreeType position independent code services for cff module.      */
6/*                                                                         */
7/*  Copyright 2009 by                                                      */
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 "cffpic.h"
23
24#ifdef FT_CONFIG_OPTION_PIC
25
26  /* forward declaration of PIC init functions from cffdrivr.c */
27  FT_Error FT_Create_Class_cff_services( FT_Library, FT_ServiceDescRec**);
28  void FT_Destroy_Class_cff_services( FT_Library, FT_ServiceDescRec*);
29  void FT_Init_Class_cff_service_ps_info( FT_Library, FT_Service_PsInfoRec*);
30  void FT_Init_Class_cff_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
31  void FT_Init_Class_cff_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
32  void FT_Init_Class_cff_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
33  void FT_Init_Class_cff_service_cid_info( FT_Library, FT_Service_CIDRec*);
34
35  /* forward declaration of PIC init functions from cffparse.c */
36  FT_Error FT_Create_Class_cff_field_handlers( FT_Library, CFF_Field_Handler**);
37  void FT_Destroy_Class_cff_field_handlers( FT_Library, CFF_Field_Handler*);
38
39  /* forward declaration of PIC init functions from cffcmap.c */
40  void FT_Init_Class_cff_cmap_encoding_class_rec( FT_Library, FT_CMap_ClassRec*);
41  void FT_Init_Class_cff_cmap_unicode_class_rec( FT_Library, FT_CMap_ClassRec*);
42
43  void
44  cff_driver_class_pic_free(  FT_Library library )
45  {
46    FT_PIC_Container* pic_container = &library->pic_container;
47    FT_Memory memory = library->memory;
48    if ( pic_container->cff )
49    {
50      CffModulePIC* container = (CffModulePIC*)pic_container->cff;
51      if(container->cff_services)
52        FT_Destroy_Class_cff_services(library, container->cff_services);
53      container->cff_services = NULL;
54      if(container->cff_field_handlers)
55        FT_Destroy_Class_cff_field_handlers(library, container->cff_field_handlers);
56      container->cff_field_handlers = NULL;
57      FT_FREE( container );
58      pic_container->cff = NULL;
59    }
60  }
61
62  FT_Error
63  cff_driver_class_pic_init(  FT_Library library )
64  {
65    FT_PIC_Container* pic_container = &library->pic_container;
66    FT_Error        error = FT_Err_Ok;
67    CffModulePIC* container;
68    FT_Memory memory = library->memory;
69
70    /* allocate pointer, clear and set global container pointer */
71    if ( FT_ALLOC ( container, sizeof ( *container ) ) )
72      return error;
73    FT_MEM_SET( container, 0, sizeof(*container) );
74    pic_container->cff = container;
75
76    /* initialize pointer table - this is how the module usually expects this data */
77    error = FT_Create_Class_cff_services(library, &container->cff_services);
78    if(error)
79      goto Exit;
80    error = FT_Create_Class_cff_field_handlers(library, &container->cff_field_handlers);
81    if(error)
82      goto Exit;
83    FT_Init_Class_cff_service_ps_info(library, &container->cff_service_ps_info);
84    FT_Init_Class_cff_service_glyph_dict(library, &container->cff_service_glyph_dict);
85    FT_Init_Class_cff_service_ps_name(library, &container->cff_service_ps_name);
86    FT_Init_Class_cff_service_get_cmap_info(library, &container->cff_service_get_cmap_info);
87    FT_Init_Class_cff_service_cid_info(library, &container->cff_service_cid_info);
88    FT_Init_Class_cff_cmap_encoding_class_rec(library, &container->cff_cmap_encoding_class_rec);
89    FT_Init_Class_cff_cmap_unicode_class_rec(library, &container->cff_cmap_unicode_class_rec);
90Exit:
91    if(error)
92      cff_driver_class_pic_free(library);
93    return error;
94  }
95
96#endif /* FT_CONFIG_OPTION_PIC */
97
98
99/* END */
100