1 /****************************************************************************
2  *
3  * ftotval.c
4  *
5  *   FreeType API for validating OpenType tables (body).
6  *
7  * Copyright (C) 2004-2020 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 #include <ft2build.h>
19 #include FT_INTERNAL_DEBUG_H
20 
21 #include FT_INTERNAL_OBJECTS_H
22 #include FT_SERVICE_OPENTYPE_VALIDATE_H
23 #include FT_OPENTYPE_VALIDATE_H
24 
25 
26   /* documentation is in ftotval.h */
27 
28   FT_EXPORT_DEF( FT_Error )
FT_OpenType_Validate(FT_Face face,FT_UInt validation_flags,FT_Bytes * BASE_table,FT_Bytes * GDEF_table,FT_Bytes * GPOS_table,FT_Bytes * GSUB_table,FT_Bytes * JSTF_table)29   FT_OpenType_Validate( FT_Face    face,
30                         FT_UInt    validation_flags,
31                         FT_Bytes  *BASE_table,
32                         FT_Bytes  *GDEF_table,
33                         FT_Bytes  *GPOS_table,
34                         FT_Bytes  *GSUB_table,
35                         FT_Bytes  *JSTF_table )
36   {
37     FT_Service_OTvalidate  service;
38     FT_Error               error;
39 
40 
41     if ( !face )
42     {
43       error = FT_THROW( Invalid_Face_Handle );
44       goto Exit;
45     }
46 
47     if ( !( BASE_table &&
48             GDEF_table &&
49             GPOS_table &&
50             GSUB_table &&
51             JSTF_table ) )
52     {
53       error = FT_THROW( Invalid_Argument );
54       goto Exit;
55     }
56 
57     FT_FACE_FIND_GLOBAL_SERVICE( face, service, OPENTYPE_VALIDATE );
58 
59     if ( service )
60       error = service->validate( face,
61                                  validation_flags,
62                                  BASE_table,
63                                  GDEF_table,
64                                  GPOS_table,
65                                  GSUB_table,
66                                  JSTF_table );
67     else
68       error = FT_THROW( Unimplemented_Feature );
69 
70   Exit:
71     return error;
72   }
73 
74 
75   FT_EXPORT_DEF( void )
FT_OpenType_Free(FT_Face face,FT_Bytes table)76   FT_OpenType_Free( FT_Face   face,
77                     FT_Bytes  table )
78   {
79     FT_Memory  memory;
80 
81 
82     if ( !face )
83       return;
84 
85     memory = FT_FACE_MEMORY( face );
86 
87     FT_FREE( table );
88   }
89 
90 
91 /* END */
92