src/java.desktop/share/native/libfreetype/src/sfnt/sfntpic.c
changeset 54876 da3834261f0c
parent 54875 bcfedddcf4ce
child 54877 dde07ac16610
equal deleted inserted replaced
54875:bcfedddcf4ce 54876:da3834261f0c
     1 /***************************************************************************/
       
     2 /*                                                                         */
       
     3 /*  sfntpic.c                                                              */
       
     4 /*                                                                         */
       
     5 /*    The FreeType position independent code services for sfnt module.     */
       
     6 /*                                                                         */
       
     7 /*  Copyright 2009-2018 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 "sfntpic.h"
       
    23 #include "sferrors.h"
       
    24 
       
    25 
       
    26 #ifdef FT_CONFIG_OPTION_PIC
       
    27 
       
    28   /* forward declaration of PIC init functions from sfdriver.c */
       
    29   FT_Error
       
    30   FT_Create_Class_sfnt_services( FT_Library           library,
       
    31                                  FT_ServiceDescRec**  output_class );
       
    32   void
       
    33   FT_Destroy_Class_sfnt_services( FT_Library          library,
       
    34                                   FT_ServiceDescRec*  clazz );
       
    35   void
       
    36   FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec*  clazz );
       
    37   void
       
    38   FT_Init_Class_sfnt_interface( FT_Library       library,
       
    39                                 SFNT_Interface*  clazz );
       
    40   void
       
    41   FT_Init_Class_sfnt_service_glyph_dict(
       
    42     FT_Library                library,
       
    43     FT_Service_GlyphDictRec*  clazz );
       
    44   void
       
    45   FT_Init_Class_sfnt_service_ps_name(
       
    46     FT_Library                 library,
       
    47     FT_Service_PsFontNameRec*  clazz );
       
    48   void
       
    49   FT_Init_Class_tt_service_get_cmap_info(
       
    50     FT_Library              library,
       
    51     FT_Service_TTCMapsRec*  clazz );
       
    52   void
       
    53   FT_Init_Class_sfnt_service_sfnt_table(
       
    54     FT_Service_SFNT_TableRec*  clazz );
       
    55 
       
    56 
       
    57   /* forward declaration of PIC init functions from ttcmap.c */
       
    58   FT_Error
       
    59   FT_Create_Class_tt_cmap_classes( FT_Library       library,
       
    60                                    TT_CMap_Class**  output_class );
       
    61   void
       
    62   FT_Destroy_Class_tt_cmap_classes( FT_Library      library,
       
    63                                     TT_CMap_Class*  clazz );
       
    64 
       
    65 
       
    66   void
       
    67   sfnt_module_class_pic_free( FT_Library  library )
       
    68   {
       
    69     FT_PIC_Container*  pic_container = &library->pic_container;
       
    70     FT_Memory          memory        = library->memory;
       
    71 
       
    72 
       
    73     if ( pic_container->sfnt )
       
    74     {
       
    75       sfntModulePIC*  container = (sfntModulePIC*)pic_container->sfnt;
       
    76 
       
    77 
       
    78       if ( container->sfnt_services )
       
    79         FT_Destroy_Class_sfnt_services( library,
       
    80                                         container->sfnt_services );
       
    81       container->sfnt_services = NULL;
       
    82 
       
    83       if ( container->tt_cmap_classes )
       
    84         FT_Destroy_Class_tt_cmap_classes( library,
       
    85                                           container->tt_cmap_classes );
       
    86       container->tt_cmap_classes = NULL;
       
    87 
       
    88       FT_FREE( container );
       
    89       pic_container->sfnt = NULL;
       
    90     }
       
    91   }
       
    92 
       
    93 
       
    94   FT_Error
       
    95   sfnt_module_class_pic_init( FT_Library  library )
       
    96   {
       
    97     FT_PIC_Container*  pic_container = &library->pic_container;
       
    98     FT_Error           error         = FT_Err_Ok;
       
    99     sfntModulePIC*     container     = NULL;
       
   100     FT_Memory          memory        = library->memory;
       
   101 
       
   102 
       
   103     /* allocate pointer, clear and set global container pointer */
       
   104     if ( FT_ALLOC( container, sizeof ( *container ) ) )
       
   105       return error;
       
   106     FT_MEM_SET( container, 0, sizeof ( *container ) );
       
   107     pic_container->sfnt = container;
       
   108 
       
   109     /* initialize pointer table -                       */
       
   110     /* this is how the module usually expects this data */
       
   111     error = FT_Create_Class_sfnt_services( library,
       
   112                                            &container->sfnt_services );
       
   113     if ( error )
       
   114       goto Exit;
       
   115 
       
   116     error = FT_Create_Class_tt_cmap_classes( library,
       
   117                                              &container->tt_cmap_classes );
       
   118     if ( error )
       
   119       goto Exit;
       
   120 
       
   121     FT_Init_Class_sfnt_service_glyph_dict(
       
   122       library, &container->sfnt_service_glyph_dict );
       
   123     FT_Init_Class_sfnt_service_ps_name(
       
   124       library, &container->sfnt_service_ps_name );
       
   125     FT_Init_Class_tt_service_get_cmap_info(
       
   126       library, &container->tt_service_get_cmap_info );
       
   127     FT_Init_Class_sfnt_service_sfnt_table(
       
   128       &container->sfnt_service_sfnt_table );
       
   129 #ifdef TT_CONFIG_OPTION_BDF
       
   130     FT_Init_Class_sfnt_service_bdf( &container->sfnt_service_bdf );
       
   131 #endif
       
   132     FT_Init_Class_sfnt_interface( library, &container->sfnt_interface );
       
   133 
       
   134   Exit:
       
   135     if ( error )
       
   136       sfnt_module_class_pic_free( library );
       
   137     return error;
       
   138   }
       
   139 
       
   140 #endif /* FT_CONFIG_OPTION_PIC */
       
   141 
       
   142 
       
   143 /* END */