1/***************************************************************************/
2/*                                                                         */
3/*  ftmm.c                                                                 */
4/*                                                                         */
5/*    Multiple Master font support (body).                                 */
6/*                                                                         */
7/*  Copyright 1996-2001, 2003, 2004, 2009, 2013 by                         */
8/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
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_INTERNAL_DEBUG_H
21
22#include FT_MULTIPLE_MASTERS_H
23#include FT_INTERNAL_OBJECTS_H
24#include FT_SERVICE_MULTIPLE_MASTERS_H
25
26
27  /*************************************************************************/
28  /*                                                                       */
29  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
30  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
31  /* messages during execution.                                            */
32  /*                                                                       */
33#undef  FT_COMPONENT
34#define FT_COMPONENT  trace_mm
35
36
37  static FT_Error
38  ft_face_get_mm_service( FT_Face                   face,
39                          FT_Service_MultiMasters  *aservice )
40  {
41    FT_Error  error;
42
43
44    *aservice = NULL;
45
46    if ( !face )
47      return FT_THROW( Invalid_Face_Handle );
48
49    error = FT_ERR( Invalid_Argument );
50
51    if ( FT_HAS_MULTIPLE_MASTERS( face ) )
52    {
53      FT_FACE_LOOKUP_SERVICE( face,
54                              *aservice,
55                              MULTI_MASTERS );
56
57      if ( *aservice )
58        error = FT_Err_Ok;
59    }
60
61    return error;
62  }
63
64
65  /* documentation is in ftmm.h */
66
67  FT_EXPORT_DEF( FT_Error )
68  FT_Get_Multi_Master( FT_Face           face,
69                       FT_Multi_Master  *amaster )
70  {
71    FT_Error                 error;
72    FT_Service_MultiMasters  service;
73
74
75    error = ft_face_get_mm_service( face, &service );
76    if ( !error )
77    {
78      error = FT_ERR( Invalid_Argument );
79      if ( service->get_mm )
80        error = service->get_mm( face, amaster );
81    }
82
83    return error;
84  }
85
86
87  /* documentation is in ftmm.h */
88
89  FT_EXPORT_DEF( FT_Error )
90  FT_Get_MM_Var( FT_Face      face,
91                 FT_MM_Var*  *amaster )
92  {
93    FT_Error                 error;
94    FT_Service_MultiMasters  service;
95
96
97    error = ft_face_get_mm_service( face, &service );
98    if ( !error )
99    {
100      error = FT_ERR( Invalid_Argument );
101      if ( service->get_mm_var )
102        error = service->get_mm_var( face, amaster );
103    }
104
105    return error;
106  }
107
108
109  /* documentation is in ftmm.h */
110
111  FT_EXPORT_DEF( FT_Error )
112  FT_Set_MM_Design_Coordinates( FT_Face   face,
113                                FT_UInt   num_coords,
114                                FT_Long*  coords )
115  {
116    FT_Error                 error;
117    FT_Service_MultiMasters  service;
118
119
120    error = ft_face_get_mm_service( face, &service );
121    if ( !error )
122    {
123      error = FT_ERR( Invalid_Argument );
124      if ( service->set_mm_design )
125        error = service->set_mm_design( face, num_coords, coords );
126    }
127
128    return error;
129  }
130
131
132  /* documentation is in ftmm.h */
133
134  FT_EXPORT_DEF( FT_Error )
135  FT_Set_Var_Design_Coordinates( FT_Face    face,
136                                 FT_UInt    num_coords,
137                                 FT_Fixed*  coords )
138  {
139    FT_Error                 error;
140    FT_Service_MultiMasters  service;
141
142
143    error = ft_face_get_mm_service( face, &service );
144    if ( !error )
145    {
146      error = FT_ERR( Invalid_Argument );
147      if ( service->set_var_design )
148        error = service->set_var_design( face, num_coords, coords );
149    }
150
151    return error;
152  }
153
154
155  /* documentation is in ftmm.h */
156
157  FT_EXPORT_DEF( FT_Error )
158  FT_Set_MM_Blend_Coordinates( FT_Face    face,
159                               FT_UInt    num_coords,
160                               FT_Fixed*  coords )
161  {
162    FT_Error                 error;
163    FT_Service_MultiMasters  service;
164
165
166    error = ft_face_get_mm_service( face, &service );
167    if ( !error )
168    {
169      error = FT_ERR( Invalid_Argument );
170      if ( service->set_mm_blend )
171         error = service->set_mm_blend( face, num_coords, coords );
172    }
173
174    return error;
175  }
176
177
178  /* documentation is in ftmm.h */
179
180  /* This is exactly the same as the previous function.  It exists for */
181  /* orthogonality.                                                    */
182
183  FT_EXPORT_DEF( FT_Error )
184  FT_Set_Var_Blend_Coordinates( FT_Face    face,
185                                FT_UInt    num_coords,
186                                FT_Fixed*  coords )
187  {
188    FT_Error                 error;
189    FT_Service_MultiMasters  service;
190
191
192    error = ft_face_get_mm_service( face, &service );
193    if ( !error )
194    {
195      error = FT_ERR( Invalid_Argument );
196      if ( service->set_mm_blend )
197         error = service->set_mm_blend( face, num_coords, coords );
198    }
199
200    return error;
201  }
202
203
204/* END */
205