summaryrefslogtreecommitdiff
path: root/include/freetype/svgrenderer.h
blob: d7bb6032d43c5d9f8f67df0c73b83f34f328ed25 (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
179
180
181
182
183
184
185
186
/****************************************************************************
 *
 * svgrenderer.h
 *
 *   Interface for SVG Renderer Module (specification).
 *
 * Copyright (C) 2004-2019 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 FTSVG_RENDERER_H_
#define FTSVG_RENDERER_H_

#include <ft2build.h>
#include FT_FREETYPE_H

#ifdef FREETYPE_H
#error "freetype.h of FreeType 1 has been loaded!"
#error "Please fix the directory search order for header files"
#error "so that freetype.h of FreeType 2 is found first."
#endif

FT_BEGIN_HEADER

  /**************************************************************************
   *
   * @functype:
   *   SVG_Lib_Init
   *
   * @description:
   *   A callback used to initiate the SVG Rendering port
   *
   * @return:
   *   FreeType error code.  0 means success.
   */

  typedef FT_Error
  (*SVG_Lib_Init)(  );


  /**************************************************************************
   *
   * @functype:
   *   SVG_Lib_Free
   *
   * @description:
   *   A callback used to free the SVG Rendering port. Calling this callback
   *   shall do all cleanups that the SVG Rendering port wants to do.
   *
   * @return:
   *   FreeType error code.  0 means success.
   */

  typedef FT_Error
  (*SVG_Lib_Free)(  );


  /**************************************************************************
   *
   * @functype:
   *   SVG_Lib_Render
   *
   * @description:
   *   A callback used to render the glyph loaded in the slot.
   *
   * @input:
   *   svg_doc::
   *     A pointer to the svg document
   *
   * @return:
   *   FreeType error code.  0 means success.
   */

  typedef FT_Error
  (*SVG_Lib_Render)( FT_GlyphSlot  slot );


  /**************************************************************************
   *
   * @functype:
   *   SVG_Set_Hooks
   *
   * @description:
   *   A function that is used set SVG Hooks. Part of the SVG Renderer
   *   Interface.
   *
   * @input:
   *   module::
   *     FT_Module instance.
   *
   *   init_hook::
   *     A function pointer of the type `SVG_Lib_Init'. Read the documentation
   *     of `SVG_Lib_Init'
   *
   *   free_hook::
   *     A function pointer of the type `SVG_Lib_Free'. Read the documentation
   *     of `SVG_Lib_Free'.
   *
   *   render_hook::
   *     A function pointer of the type `SVG_Lib_Render'. Read the
   *     documentation of `SVG_Lib_Render'.
   *
   * @return:
   *   FreeType error code.  0 means success.
   */

  typedef FT_Error
  (*SVG_Set_Hooks)( FT_Module       module,
                    SVG_Lib_Init    init_hook,
                    SVG_Lib_Free    free_hook,
                    SVG_Lib_Render  render_hook );

  /**************************************************************************
   *
   * @struct:
   *   SVG_Renderer_Interface
   *
   * @description:
   *   An interface structure that function needed to inject external SVG
   *   rendering library hooks.
   *
   * @fields:
   *   set_hooks::
   *     A function that can be called to set the hooks.
   *
   * @return:
   *   FreeType error code.  0 means success.
   */

  typedef struct SVG_Renderer_Interface_
  {
    SVG_Set_Hooks  set_hooks;
  } SVG_Renderer_Interface;


  /* TODO: to document */
  FT_Error
  FT_Set_Svg_Hooks( FT_Library      library,
                    SVG_Lib_Init    init_hook,
                    SVG_Lib_Free    free_hook,
                    SVG_Lib_Render  render_hook );

  /**************************************************************************
   *
   * @struct:
   *   FT_SVG_DocumentRec_
   *
   * @description:
   *   A structure that models one SVG document.
   *
   * @fields:
   *   svg_document ::
   *     A pointer to the SVG document string.
   *
   *   svg_document_length ::
   *     The length of the SVG document string.
   */

  typedef struct FT_SVG_DocumentRec_
  {
    FT_Byte*         svg_document;
    FT_ULong         svg_document_length;
    FT_Size_Metrics  metrics;
  } FT_SVG_DocumentRec;

  /**************************************************************************
   *
   * @type:
   *   FT_SVG_Document
   *
   * @description:
   *   A handle to a FT_SVG_DocumentRec object.
   */
  typedef struct FT_SVG_DocumentRec_*  FT_SVG_Document;

FT_END_HEADER

#endif