PageRenderTime 23ms CodeModel.GetById 10ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/src/freetype/src/cff/cffpic.c

https://bitbucket.org/cabalistic/ogredeps/
C | 148 lines | 102 code | 25 blank | 21 comment | 7 complexity | 331a84865252966c20e5cede230c6b50 MD5 | raw file
  1/***************************************************************************/
  2/*                                                                         */
  3/*  cffpic.c                                                               */
  4/*                                                                         */
  5/*    The FreeType position independent code services for cff module.      */
  6/*                                                                         */
  7/*  Copyright 2009, 2010 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 "cffcmap.h"
 23#include "cffpic.h"
 24#include "cfferrs.h"
 25
 26#ifdef FT_CONFIG_OPTION_PIC
 27
 28  /* forward declaration of PIC init functions from cffdrivr.c */
 29  FT_Error
 30  FT_Create_Class_cff_services(
 31    FT_Library           library,
 32    FT_ServiceDescRec**  output_class );
 33
 34  void
 35  FT_Destroy_Class_cff_services(
 36    FT_Library          library,
 37    FT_ServiceDescRec*  clazz );
 38
 39  void
 40  FT_Init_Class_cff_service_ps_info(
 41    FT_Library             library,
 42    FT_Service_PsInfoRec*  clazz );
 43
 44  void
 45  FT_Init_Class_cff_service_glyph_dict(
 46    FT_Library                library,
 47    FT_Service_GlyphDictRec*  clazz );
 48
 49  void
 50  FT_Init_Class_cff_service_ps_name(
 51    FT_Library                 library,
 52    FT_Service_PsFontNameRec*  clazz );
 53
 54  void
 55  FT_Init_Class_cff_service_get_cmap_info(
 56    FT_Library              library,
 57    FT_Service_TTCMapsRec*  clazz );
 58
 59  void
 60  FT_Init_Class_cff_service_cid_info(
 61    FT_Library          library,
 62    FT_Service_CIDRec*  clazz );
 63
 64  /* forward declaration of PIC init functions from cffparse.c */
 65  FT_Error
 66  FT_Create_Class_cff_field_handlers(
 67    FT_Library           library,
 68    CFF_Field_Handler**  output_class );
 69
 70  void
 71  FT_Destroy_Class_cff_field_handlers(
 72    FT_Library          library,
 73    CFF_Field_Handler*  clazz );
 74
 75  void
 76  cff_driver_class_pic_free( FT_Library  library )
 77  {
 78    FT_PIC_Container*  pic_container = &library->pic_container;
 79    FT_Memory  memory = library->memory;
 80
 81
 82    if ( pic_container->cff )
 83    {
 84      CffModulePIC*  container = ( CffModulePIC* )pic_container->cff;
 85
 86
 87      if ( container->cff_services )
 88        FT_Destroy_Class_cff_services( library,
 89                                       container->cff_services );
 90      container->cff_services = NULL;
 91      if ( container->cff_field_handlers )
 92        FT_Destroy_Class_cff_field_handlers(
 93          library, container->cff_field_handlers );
 94      container->cff_field_handlers = NULL;
 95      FT_FREE( container );
 96      pic_container->cff = NULL;
 97    }
 98  }
 99
100
101  FT_Error
102  cff_driver_class_pic_init( FT_Library  library )
103  {
104    FT_PIC_Container*  pic_container = &library->pic_container;
105    FT_Error           error         = CFF_Err_Ok;
106    CffModulePIC*      container;
107    FT_Memory          memory        = library->memory;
108
109
110    /* allocate pointer, clear and set global container pointer */
111    if ( FT_ALLOC ( container, sizeof ( *container ) ) )
112      return error;
113    FT_MEM_SET( container, 0, sizeof ( *container ) );
114    pic_container->cff = container;
115
116    /* initialize pointer table - this is how the module usually expects this data */
117    error = FT_Create_Class_cff_services( library,
118                                          &container->cff_services );
119    if ( error )
120      goto Exit;
121    error = FT_Create_Class_cff_field_handlers(
122              library, &container->cff_field_handlers );
123    if ( error )
124      goto Exit;
125    FT_Init_Class_cff_service_ps_info(
126      library, &container->cff_service_ps_info );
127    FT_Init_Class_cff_service_glyph_dict(
128      library, &container->cff_service_glyph_dict );
129    FT_Init_Class_cff_service_ps_name(
130      library, &container->cff_service_ps_name );
131    FT_Init_Class_cff_service_get_cmap_info(
132      library, &container->cff_service_get_cmap_info );
133    FT_Init_Class_cff_service_cid_info(
134      library, &container->cff_service_cid_info );
135    FT_Init_Class_cff_cmap_encoding_class_rec(
136      library, &container->cff_cmap_encoding_class_rec );
137    FT_Init_Class_cff_cmap_unicode_class_rec(
138      library, &container->cff_cmap_unicode_class_rec );
139Exit:
140    if ( error )
141      cff_driver_class_pic_free( library );
142    return error;
143  }
144
145#endif /* FT_CONFIG_OPTION_PIC */
146
147
148/* END */