summaryrefslogtreecommitdiff
path: root/src/base/ftinit.c
blob: 0399dc4862b08335d55e9526bb872a8d8617eb84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/***************************************************************************/
/*                                                                         */
/*  ftinit.c                                                               */
/*                                                                         */
/*    FreeType initialisation layer (body).                                */
/*                                                                         */
/*  Copyright 1996-2000 by                                                 */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used        */
/*  modified and distributed under the terms of the FreeType project       */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /*  The purpose of this file is to implement the three following         */
  /*  functions:                                                           */
  /*                                                                       */
  /*  FT_Default_Drivers:                                                  */
  /*     This function is used to add the set of default drivers to a      */
  /*     fresh new library object.  The set is computed at compile time    */
  /*     from the Makefiles inclusions in Makefile.lib.  See the document  */
  /*     `FreeType Internals' for more info.                               */
  /*                                                                       */
  /*  FT_Init_FreeType:                                                    */
  /*     This function creates a system object for the current platform,   */
  /*     builds a library out of it, then calls FT_Default_Drivers().      */
  /*                                                                       */
  /*  FT_Done_FreeType:                                                    */
  /*     This function simply finalizes the library and the corresponding  */
  /*     system object.                                                    */
  /*                                                                       */
  /*  Note that even if FT_Init_FreeType() uses the implementation of the  */
  /*  system object defined at build time, client applications are still   */
  /*  able to provide their own `ftsystem.c'.                              */
  /*                                                                       */
  /*************************************************************************/


#include <freetype/config/ftconfig.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftdriver.h>

#undef  FT_COMPONENT
#define FT_COMPONENT  trace_init

#undef  FT_DRIVER
#define FT_DRIVER( x )  extern FT_DriverInterface  x;

#include <freetype/config/ftmodule.h>

#undef  FT_DRIVER
#define FT_DRIVER( x )  &x,

static
const FT_DriverInterface*  ft_default_drivers[] =
  {
#include <freetype/config/ftmodule.h>
    0
  };


  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_Default_Drivers                                                 */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Adds the set of default drivers to a given library object.         */
  /*                                                                       */
  /* <InOut>                                                               */
  /*    library :: A handle to a new library object.                       */
  /*                                                                       */
  EXPORT_FUNC
  void  FT_Default_Drivers( FT_Library  library )
  {
    FT_Error                   error;
    const FT_DriverInterface* *cur;


    cur = ft_default_drivers;
    while ( *cur )
    {
      error = FT_Add_Driver( library, *cur );
      /* notify errors, but don't stop */
      if ( error )
        FT_ERROR(( "FT.Default_Drivers: Cannot install `%s', error = %x\n",
                   (*cur)->driver_name, error ));
      cur++;
    }
  }


  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_Init_FreeType                                                   */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Initializes a new FreeType library object.  The set of drivers     */
  /*    that are registered by this function is determined at build time.  */
  /*                                                                       */
  /* <Output>                                                              */
  /*    library :: A handle to a new library object.                       */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeTyoe error code.  0 means success.                             */
  /*                                                                       */
  EXPORT_FUNC
  FT_Error  FT_Init_FreeType( FT_Library*  library )
  {
    FT_Error   error;
    FT_Memory  memory;


    /* First of all, allocate a new system object - -this function is part */
    /* of the system-specific component, i.e. `ftsystem.c'.                */

    memory = FT_New_Memory();
    if ( !memory )
    {
      FT_ERROR(( "FT_Init_FreeType:" ));
      FT_ERROR(( " cannot find memory manager" ));
      return FT_Err_Unimplemented_Feature;
    }

    /* builds a library out of it, then fill it with the set of */
    /* default drivers.                                         */

    error = FT_New_Library( memory, library );
    if ( !error )
      FT_Default_Drivers( *library );

    return error;
  }


/* END */