sfntpic.c revision aacb8e1368a883fcbc9fe64fd0e460cef9c9b20c
1295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/***************************************************************************/
2295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*                                                                         */
3295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*  sfntpic.c                                                              */
4295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*                                                                         */
5295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*    The FreeType position independent code services for sfnt module.     */
6295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*                                                                         */
7aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich/*  Copyright 2009, 2010 by                                                */
8295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*  Oran Agra and Mickey Gabel.                                            */
9295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*                                                                         */
10295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*  This file is part of the FreeType project, and may only be used,       */
11295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*  modified, and distributed under the terms of the FreeType project      */
12295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*  this file you indicate that you have read the license and              */
14295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*  understand and accept it fully.                                        */
15295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*                                                                         */
16295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/***************************************************************************/
17295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
18295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
19295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#include <ft2build.h>
20295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#include FT_FREETYPE_H
21295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#include FT_INTERNAL_OBJECTS_H
22295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#include "sfntpic.h"
23295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
24295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#ifdef FT_CONFIG_OPTION_PIC
25295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
26295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  /* forward declaration of PIC init functions from sfdriver.c */
27295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  FT_Error FT_Create_Class_sfnt_services( FT_Library, FT_ServiceDescRec**);
28295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  void FT_Destroy_Class_sfnt_services( FT_Library, FT_ServiceDescRec*);
29295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  void FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec*);
30295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  void FT_Init_Class_sfnt_interface( FT_Library, SFNT_Interface*);
31295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  void FT_Init_Class_sfnt_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
32295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  void FT_Init_Class_sfnt_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
33295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  void FT_Init_Class_tt_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
34295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  void FT_Init_Class_sfnt_service_sfnt_table( FT_Service_SFNT_TableRec*);
35295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
36295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  /* forward declaration of PIC init functions from ttcmap.c */
37295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  FT_Error FT_Create_Class_tt_cmap_classes( FT_Library, TT_CMap_Class**);
38295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  void FT_Destroy_Class_tt_cmap_classes( FT_Library, TT_CMap_Class*);
39295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
40295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  void
41295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  sfnt_module_class_pic_free(  FT_Library library )
42295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  {
43295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    FT_PIC_Container* pic_container = &library->pic_container;
44295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    FT_Memory memory = library->memory;
45295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    if ( pic_container->sfnt )
46295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    {
47295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt;
48295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      if(container->sfnt_services)
49295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner        FT_Destroy_Class_sfnt_services(library, container->sfnt_services);
50295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      container->sfnt_services = NULL;
51295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      if(container->tt_cmap_classes)
52295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner        FT_Destroy_Class_tt_cmap_classes(library, container->tt_cmap_classes);
53295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      container->tt_cmap_classes = NULL;
54295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      FT_FREE( container );
55295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      pic_container->sfnt = NULL;
56295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    }
57295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  }
58295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
59295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
60295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  FT_Error
61295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  sfnt_module_class_pic_init(  FT_Library library )
62295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  {
63aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich    FT_PIC_Container*  pic_container = &library->pic_container;
64aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich    FT_Error           error = SFNT_Err_Ok;
65aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich    sfntModulePIC*     container;
66aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich    FT_Memory          memory = library->memory;
67aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich
68295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
69295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    /* allocate pointer, clear and set global container pointer */
70295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    if ( FT_ALLOC ( container, sizeof ( *container ) ) )
71295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      return error;
72aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich    FT_MEM_SET( container, 0, sizeof ( *container ) );
73295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    pic_container->sfnt = container;
74295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
75295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    /* initialize pointer table - this is how the module usually expects this data */
76295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    error = FT_Create_Class_sfnt_services(library, &container->sfnt_services);
77295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    if(error)
78295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      goto Exit;
79295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    error = FT_Create_Class_tt_cmap_classes(library, &container->tt_cmap_classes);
80295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    if(error)
81295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      goto Exit;
82295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    FT_Init_Class_sfnt_service_glyph_dict(library, &container->sfnt_service_glyph_dict);
83295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    FT_Init_Class_sfnt_service_ps_name(library, &container->sfnt_service_ps_name);
84295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    FT_Init_Class_tt_service_get_cmap_info(library, &container->tt_service_get_cmap_info);
85295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    FT_Init_Class_sfnt_service_sfnt_table(&container->sfnt_service_sfnt_table);
86295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#ifdef TT_CONFIG_OPTION_BDF
87295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    FT_Init_Class_sfnt_service_bdf(&container->sfnt_service_bdf);
88295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#endif
89295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    FT_Init_Class_sfnt_interface(library, &container->sfnt_interface);
90295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
91295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' TurnerExit:
92295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    if(error)
93295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner      sfnt_module_class_pic_free(library);
94295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    return error;
95295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  }
96295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
97295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
98295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
99295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#endif /* FT_CONFIG_OPTION_PIC */
100295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
101295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner
102295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* END */
103