summaryrefslogtreecommitdiff
path: root/include/freetype/internal/ftextend.h
blob: fdd2c6ef245dcd7d39e2f5235984314f77f76a54 (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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/***************************************************************************/
/*                                                                         */
/*  ftextend.h                                                             */
/*                                                                         */
/*    FreeType extensions implementation (specification).                  */
/*                                                                         */
/*  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.                                        */
/*                                                                         */
/***************************************************************************/


#ifndef FTEXTEND_H
#define FTEXTEND_H


#include <freetype/internal/ftobjs.h>


#ifdef __cplusplus
  extern "C" {
#endif


  /*************************************************************************/
  /*                                                                       */
  /* The extensions don't need to be integrated at compile time into the   */
  /* engine, only at link time.                                            */
  /*                                                                       */
  /*************************************************************************/


  /*************************************************************************/
  /*                                                                       */
  /* <FuncType>                                                            */
  /*    FT_Extension_Initializer                                           */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Each new face object can have several extensions associated with   */
  /*    it at creation time.  This function is used to initialize given    */
  /*    extension data for a given face.                                   */
  /*                                                                       */
  /* <InOut>                                                               */
  /*    ext  :: A typeless pointer to the extension data.                  */
  /*                                                                       */
  /*    face :: A handle to the source face object the extension is        */
  /*            associated with.                                           */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  /* <Note>                                                                */
  /*    In case of error, the initializer should not destroy the extension */
  /*    data, as the finalizer will get called later by the function's     */
  /*    caller.                                                            */
  /*                                                                       */
  typedef FT_Error  (*FT_Extension_Initializer)( void*    ext,
                                                 FT_Face  face );


  /*************************************************************************/
  /*                                                                       */
  /* <FuncType>                                                            */
  /*    FT_Extension_Finalizer                                             */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Each new face object can have several extensions associated with   */
  /*    it at creation time.  This function is used to finalize given      */
  /*    extension data for a given face; it occurs before the face object  */
  /*    itself is finalized.                                               */
  /*                                                                       */
  /* <InOut>                                                               */
  /*   ext  :: A typeless pointer to the extension data.                   */
  /*                                                                       */
  /*   face :: A handle to the source face object the extension is         */
  /*           associated with.                                            */
  /*                                                                       */
  typedef void  (*FT_Extension_Finalizer)( void*    ext,
                                           FT_Face  face );


  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    FT_Extension_Class                                                 */
  /*                                                                       */
  /* <Description>                                                         */
  /*    A simple structure used to describe a given extension to the       */
  /*    FreeType base layer.  An FT_Extension_Class is used as a parameter */
  /*    for FT_Register_Extension().                                       */
  /*                                                                       */
  /* <Fields>                                                              */
  /*    id        :: The extension's ID.  This is a normal C string that   */
  /*                 is used to uniquely reference the extension's         */
  /*                 interface.                                            */
  /*                                                                       */
  /*    size      :: The size in bytes of the extension data that must be  */
  /*                 associated with each face object.                     */
  /*                                                                       */
  /*    init      :: A pointer to the extension data's initializer.        */
  /*                                                                       */
  /*    finalize  :: A pointer to the extension data's finalizer.          */
  /*                                                                       */
  /*    interface :: This pointer can be anything, but should usually      */
  /*                 point to a table of function pointers which implement */
  /*                 the extension's interface.                            */
  /*                                                                       */
  /*    offset    :: This field is set and used within the base layer and  */
  /*                 should be set to 0 when registering an extension      */
  /*                 through FT_Register_Extension().  It contains an      */
  /*                 offset within the face's extension block for the      */
  /*                 current extension's data.                             */
  /*                                                                       */
  typedef struct  FT_Extension_Class_
  {
    const char*               id;
    FT_ULong                  size;
    FT_Extension_Initializer  init;
    FT_Extension_Finalizer    finalize;
    void*                     interface;

    FT_ULong                  offset;

  } FT_Extension_Class;


  FT_EXPORT_DEF( FT_Error )  FT_Register_Extension(
                               FT_Driver            driver,
                               FT_Extension_Class*  clazz );


#ifdef FT_CONFIG_OPTION_EXTEND_ENGINE


  /* Initialize the extension component */
  LOCAL_DEF
  FT_Error  FT_Init_Extensions( FT_Library  library );

  /* Finalize the extension component */
  LOCAL_DEF
  FT_Error  FT_Done_Extensions( FT_Library  library );

  /* Create an extension within a face object.  Called by the */
  /* face object constructor.                                 */
  LOCAL_DEF
  FT_Error  FT_Create_Extensions( FT_Face  face );

  /* Destroy all extensions within a face object.  Called by the */
  /* face object destructor.                                     */
  LOCAL_DEF
  FT_Error  FT_Destroy_Extensions( FT_Face  face );


#endif


  /* return an extension's data & interface according to its ID */
  FT_EXPORT_DEF( void* )  FT_Get_Extension(
                            FT_Face      face,
                            const char*  extension_id,
                            void**       extension_interface );


#ifdef __cplusplus
  }
#endif


#endif /* FTEXTEND_H */


/* END */