| 1 | /**************************************************************************** | 
| 2 |  * | 
| 3 |  * gxvmorx0.c | 
| 4 |  * | 
| 5 |  *   TrueTypeGX/AAT morx table validation | 
| 6 |  *   body for type0 (Indic Script Rearrangement) subtable. | 
| 7 |  * | 
| 8 |  * Copyright (C) 2005-2023 by | 
| 9 |  * suzuki toshiya, Masatake YAMATO, Red Hat K.K., | 
| 10 |  * David Turner, Robert Wilhelm, and Werner Lemberg. | 
| 11 |  * | 
| 12 |  * This file is part of the FreeType project, and may only be used, | 
| 13 |  * modified, and distributed under the terms of the FreeType project | 
| 14 |  * license, LICENSE.TXT.  By continuing to use, modify, or distribute | 
| 15 |  * this file you indicate that you have read the license and | 
| 16 |  * understand and accept it fully. | 
| 17 |  * | 
| 18 |  */ | 
| 19 |  | 
| 20 | /**************************************************************************** | 
| 21 |  * | 
| 22 |  * gxvalid is derived from both gxlayout module and otvalid module. | 
| 23 |  * Development of gxlayout is supported by the Information-technology | 
| 24 |  * Promotion Agency(IPA), Japan. | 
| 25 |  * | 
| 26 |  */ | 
| 27 |  | 
| 28 |  | 
| 29 | #include "gxvmorx.h" | 
| 30 |  | 
| 31 |  | 
| 32 |   /************************************************************************** | 
| 33 |    * | 
| 34 |    * The macro FT_COMPONENT is used in trace mode.  It is an implicit | 
| 35 |    * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log | 
| 36 |    * messages during execution. | 
| 37 |    */ | 
| 38 | #undef  FT_COMPONENT | 
| 39 | #define FT_COMPONENT  gxvmorx | 
| 40 |  | 
| 41 |  | 
| 42 |   static void | 
| 43 |   gxv_morx_subtable_type0_entry_validate( | 
| 44 |     FT_UShort                        state, | 
| 45 |     FT_UShort                        flags, | 
| 46 |     GXV_XStateTable_GlyphOffsetCPtr  glyphOffset_p, | 
| 47 |     FT_Bytes                         table, | 
| 48 |     FT_Bytes                         limit, | 
| 49 |     GXV_Validator                    gxvalid ) | 
| 50 |   { | 
| 51 | #ifdef GXV_LOAD_UNUSED_VARS | 
| 52 |     FT_UShort  markFirst; | 
| 53 |     FT_UShort  dontAdvance; | 
| 54 |     FT_UShort  markLast; | 
| 55 | #endif | 
| 56 |     FT_UShort  reserved; | 
| 57 | #ifdef GXV_LOAD_UNUSED_VARS | 
| 58 |     FT_UShort  verb; | 
| 59 | #endif | 
| 60 |  | 
| 61 |     FT_UNUSED( state ); | 
| 62 |     FT_UNUSED( glyphOffset_p ); | 
| 63 |     FT_UNUSED( table ); | 
| 64 |     FT_UNUSED( limit ); | 
| 65 |  | 
| 66 |  | 
| 67 | #ifdef GXV_LOAD_UNUSED_VARS | 
| 68 |     markFirst   = (FT_UShort)( ( flags >> 15 ) & 1 ); | 
| 69 |     dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 ); | 
| 70 |     markLast    = (FT_UShort)( ( flags >> 13 ) & 1 ); | 
| 71 | #endif | 
| 72 |  | 
| 73 |     reserved = (FT_UShort)( flags & 0x1FF0 ); | 
| 74 | #ifdef GXV_LOAD_UNUSED_VARS | 
| 75 |     verb     = (FT_UShort)( flags & 0x000F ); | 
| 76 | #endif | 
| 77 |  | 
| 78 |     if ( 0 < reserved ) | 
| 79 |     { | 
| 80 |       GXV_TRACE(( " non-zero bits found in reserved range\n"  )); | 
| 81 |       FT_INVALID_DATA; | 
| 82 |     } | 
| 83 |   } | 
| 84 |  | 
| 85 |  | 
| 86 |   FT_LOCAL_DEF( void ) | 
| 87 |   gxv_morx_subtable_type0_validate( FT_Bytes       table, | 
| 88 |                                     FT_Bytes       limit, | 
| 89 |                                     GXV_Validator  gxvalid ) | 
| 90 |   { | 
| 91 |     FT_Bytes  p = table; | 
| 92 |  | 
| 93 |  | 
| 94 |     GXV_NAME_ENTER( | 
| 95 |       "morx chain subtable type0 (Indic-Script Rearrangement)"  ); | 
| 96 |  | 
| 97 |     GXV_LIMIT_CHECK( GXV_STATETABLE_HEADER_SIZE ); | 
| 98 |  | 
| 99 |     gxvalid->xstatetable.optdata               = NULL; | 
| 100 |     gxvalid->xstatetable.optdata_load_func     = NULL; | 
| 101 |     gxvalid->xstatetable.subtable_setup_func   = NULL; | 
| 102 |     gxvalid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE; | 
| 103 |     gxvalid->xstatetable.entry_validate_func = | 
| 104 |       gxv_morx_subtable_type0_entry_validate; | 
| 105 |  | 
| 106 |     gxv_XStateTable_validate( p, limit, gxvalid ); | 
| 107 |  | 
| 108 |     GXV_EXIT; | 
| 109 |   } | 
| 110 |  | 
| 111 |  | 
| 112 | /* END */ | 
| 113 |  |