1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftgxval.c                                                              */
4 /*                                                                         */
5 /*    FreeType API for validating TrueTypeGX/AAT tables (body).            */
6 /*                                                                         */
7 /*  Copyright 2004-2018 by                                                 */
8 /*  Masatake YAMATO, Redhat K.K,                                           */
9 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
10 /*                                                                         */
11 /*  This file is part of the FreeType project, and may only be used,       */
12 /*  modified, and distributed under the terms of the FreeType project      */
13 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
14 /*  this file you indicate that you have read the license and              */
15 /*  understand and accept it fully.                                        */
16 /*                                                                         */
17 /***************************************************************************/
18 
19 /***************************************************************************/
20 /*                                                                         */
21 /* gxvalid is derived from both gxlayout module and otvalid module.        */
22 /* Development of gxlayout is supported by the Information-technology      */
23 /* Promotion Agency(IPA), Japan.                                           */
24 /*                                                                         */
25 /***************************************************************************/
26 
27 
28 #include <ft2build.h>
29 #include FT_INTERNAL_DEBUG_H
30 
31 #include FT_INTERNAL_OBJECTS_H
32 #include FT_SERVICE_GX_VALIDATE_H
33 
34 
35   /* documentation is in ftgxval.h */
36 
37   FT_EXPORT_DEF( FT_Error )
38   FT_TrueTypeGX_Validate( FT_Face   face,
39                           FT_UInt   validation_flags,
40                           FT_Bytes  tables[FT_VALIDATE_GX_LENGTH],
41                           FT_UInt   table_length )
42   {
43     FT_Service_GXvalidate  service;
44     FT_Error               error;
45 
46 
47     if ( !face )
48     {
49       error = FT_THROW( Invalid_Face_Handle );
50       goto Exit;
51     }
52 
53     if ( !tables )
54     {
55       error = FT_THROW( Invalid_Argument );
56       goto Exit;
57     }
58 
59     FT_FACE_FIND_GLOBAL_SERVICE( face, service, GX_VALIDATE );
60 
61     if ( service )
62       error = service->validate( face,
63                                  validation_flags,
64                                  tables,
65                                  table_length );
66     else
67       error = FT_THROW( Unimplemented_Feature );
68 
69   Exit:
70     return error;
71   }
72 
73 
74   FT_EXPORT_DEF( void )
75   FT_TrueTypeGX_Free( FT_Face   face,
76                       FT_Bytes  table )
77   {
78     FT_Memory  memory;
79 
80 
81     if ( !face )
82       return;
83 
84     memory = FT_FACE_MEMORY( face );
85 
86     FT_FREE( table );
87   }
88 
89 
90   FT_EXPORT_DEF( FT_Error )
91   FT_ClassicKern_Validate( FT_Face    face,
92                            FT_UInt    validation_flags,
93                            FT_Bytes  *ckern_table )
94   {
95     FT_Service_CKERNvalidate  service;
96     FT_Error                  error;
97 
98 
99     if ( !face )
100     {
101       error = FT_THROW( Invalid_Face_Handle );
102       goto Exit;
103     }
104 
105     if ( !ckern_table )
106     {
107       error = FT_THROW( Invalid_Argument );
108       goto Exit;
109     }
110 
111     FT_FACE_FIND_GLOBAL_SERVICE( face, service, CLASSICKERN_VALIDATE );
112 
113     if ( service )
114       error = service->validate( face,
115                                  validation_flags,
116                                  ckern_table );
117     else
118       error = FT_THROW( Unimplemented_Feature );
119 
120   Exit:
121     return error;
122   }
123 
124 
125   FT_EXPORT_DEF( void )
126   FT_ClassicKern_Free( FT_Face   face,
127                        FT_Bytes  table )
128   {
129     FT_Memory  memory;
130 
131 
132     if ( !face )
133       return;
134 
135     memory = FT_FACE_MEMORY( face );
136 
137 
138     FT_FREE( table );
139   }
140 
141 
142 /* END */
143