Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* gxvmort0.c */ |
| 4 | /* */ |
| 5 | /* TrueTypeGX/AAT mort table validation */ |
| 6 | /* body for type0 (Indic Script Rearrangement) subtable. */ |
| 7 | /* */ |
| 8 | /* Copyright 2005 by suzuki toshiya, Masatake YAMATO, Red Hat 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 | /***************************************************************************/ |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 20 | /* */ |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 21 | /* gxvalid is derived from both gxlayout module and otvalid module. */ |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 22 | /* Development of gxlayout is supported by the Information-technology */ |
| 23 | /* Promotion Agency(IPA), Japan. */ |
| 24 | /* */ |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 25 | /***************************************************************************/ |
| 26 | |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 27 | |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 28 | #include "gxvmort.h" |
| 29 | |
| 30 | |
| 31 | /*************************************************************************/ |
| 32 | /* */ |
| 33 | /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
| 34 | /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
| 35 | /* messages during execution. */ |
| 36 | /* */ |
| 37 | #undef FT_COMPONENT |
| 38 | #define FT_COMPONENT trace_gxvmort |
| 39 | |
| 40 | |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 41 | static const char* GXV_Mort_IndicScript_Msg[] = |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 42 | { |
| 43 | "no change", |
| 44 | "Ax => xA", |
| 45 | "xD => Dx", |
| 46 | "AxD => DxA", |
| 47 | "ABx => xAB", |
| 48 | "ABx => xBA", |
| 49 | "xCD => CDx", |
| 50 | "xCD => DCx", |
| 51 | "AxCD => CDxA", |
| 52 | "AxCD => DCxA", |
| 53 | "ABxD => DxAB", |
| 54 | "ABxD => DxBA", |
| 55 | "ABxCD => CDxAB", |
| 56 | "ABxCD => CDxBA", |
| 57 | "ABxCD => DCxAB", |
| 58 | "ABxCD => DCxBA", |
| 59 | |
| 60 | }; |
| 61 | |
| 62 | |
| 63 | static void |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 64 | gxv_mort_subtable_type0_entry_validate( |
| 65 | FT_Byte state, |
| 66 | FT_UShort flags, |
| 67 | GXV_StateTable_GlyphOffsetDesc glyphOffset, |
| 68 | FT_Bytes table, |
| 69 | FT_Bytes limit, |
| 70 | GXV_Validator valid ) |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 71 | { |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 72 | FT_UShort markFirst; |
| 73 | FT_UShort dontAdvance; |
| 74 | FT_UShort markLast; |
| 75 | FT_UShort reserved; |
David Turner | 92f30c8 | 2005-10-17 21:17:20 +0000 | [diff] [blame] | 76 | FT_UShort verb = 0; |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 77 | |
| 78 | FT_UNUSED( state ); |
| 79 | FT_UNUSED( table ); |
| 80 | FT_UNUSED( limit ); |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 81 | |
Werner Lemberg | 7c25946 | 2005-09-28 07:34:45 +0000 | [diff] [blame] | 82 | FT_UNUSED( GXV_Mort_IndicScript_Msg[verb] ); /* for the non-debugging */ |
| 83 | FT_UNUSED( glyphOffset ); /* case */ |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 84 | |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 85 | |
Werner Lemberg | 7c25946 | 2005-09-28 07:34:45 +0000 | [diff] [blame] | 86 | markFirst = (FT_UShort)( ( flags >> 15 ) & 1 ); |
| 87 | dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 ); |
| 88 | markLast = (FT_UShort)( ( flags >> 13 ) & 1 ); |
| 89 | |
| 90 | reserved = (FT_UShort)( flags & 0x1FF0 ); |
| 91 | verb = (FT_UShort)( flags & 0x000F ); |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 92 | |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 93 | GXV_TRACE(( " IndicScript MorphRule for glyphOffset 0x%04x", |
| 94 | glyphOffset.u )); |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 95 | GXV_TRACE(( " markFirst=%01d", markFirst )); |
| 96 | GXV_TRACE(( " dontAdvance=%01d", dontAdvance )); |
| 97 | GXV_TRACE(( " markLast=%01d", markLast )); |
| 98 | GXV_TRACE(( " %02d", verb )); |
| 99 | GXV_TRACE(( " %s\n", GXV_Mort_IndicScript_Msg[verb] )); |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 100 | |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 101 | if ( 0 < reserved ) |
| 102 | { |
| 103 | GXV_TRACE(( " non-zero bits found in reserved range\n" )); |
| 104 | FT_INVALID_DATA; |
| 105 | } |
| 106 | else |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 107 | GXV_TRACE(( "\n" )); |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 108 | } |
| 109 | |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 110 | |
Werner Lemberg | 99aa14c | 2005-09-05 19:31:27 +0000 | [diff] [blame] | 111 | FT_LOCAL_DEF( void ) |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 112 | gxv_mort_subtable_type0_validate( FT_Bytes table, |
| 113 | FT_Bytes limit, |
| 114 | GXV_Validator valid ) |
| 115 | { |
| 116 | FT_Bytes p = table; |
| 117 | |
| 118 | |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 119 | GXV_NAME_ENTER( |
| 120 | "mort chain subtable type0 (Indic-Script Rearrangement)" ); |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 121 | |
| 122 | GXV_LIMIT_CHECK( GXV_STATETABLE_HEADER_SIZE ); |
| 123 | |
| 124 | valid->statetable.optdata = NULL; |
| 125 | valid->statetable.optdata_load_func = NULL; |
| 126 | valid->statetable.subtable_setup_func = NULL; |
| 127 | valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE; |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 128 | valid->statetable.entry_validate_func = |
| 129 | gxv_mort_subtable_type0_entry_validate; |
| 130 | |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 131 | gxv_StateTable_validate( p, limit, valid ); |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 132 | |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 133 | GXV_EXIT; |
| 134 | } |
| 135 | |
| 136 | |
| 137 | /* END */ |