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 <freetype/internal/ftdebug.h>
19 
20 #include <freetype/internal/ftobjs.h>
21 #include <freetype/internal/services/svotval.h>
22 #include <freetype/ftotval.h>
23 
24 
25   /* documentation is in ftotval.h */
26 
27   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)28   FT_OpenType_Validate( FT_Face    face,
29                         FT_UInt    validation_flags,
30                         FT_Bytes  *BASE_table,
31                         FT_Bytes  *GDEF_table,
32                         FT_Bytes  *GPOS_table,
33                         FT_Bytes  *GSUB_table,
34                         FT_Bytes  *JSTF_table )
35   {
36     FT_Service_OTvalidate  service;
37     FT_Error               error;
38 
39 
40     if ( !face )
41     {
42       error = FT_THROW( Invalid_Face_Handle );
43       goto Exit;
44     }
45 
46     if ( !( BASE_table &&
47             GDEF_table &&
48             GPOS_table &&
49             GSUB_table &&
50             JSTF_table ) )
51     {
52       error = FT_THROW( Invalid_Argument );
53       goto Exit;
54     }
55 
56     FT_FACE_FIND_GLOBAL_SERVICE( face, service, OPENTYPE_VALIDATE );
57 
58     if ( service )
59       error = service->validate( face,
60                                  validation_flags,
61                                  BASE_table,
62                                  GDEF_table,
63                                  GPOS_table,
64                                  GSUB_table,
65                                  JSTF_table );
66     else
67       error = FT_THROW( Unimplemented_Feature );
68 
69   Exit:
70     return error;
71   }
72 
73 
74   FT_EXPORT_DEF( void )
FT_OpenType_Free(FT_Face face,FT_Bytes table)75   FT_OpenType_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 /* END */
91