Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* gxvmort4.c */ |
| 4 | /* */ |
| 5 | /* TrueTypeGX/AAT mort table validation */ |
| 6 | /* body for type4 (Non-Contextual Glyph Substitution) 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 | |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 30 | |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 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 | |
| 41 | static void |
| 42 | gxv_mort_subtable_type4_lookupval_validate( FT_UShort glyph, |
| 43 | GXV_LookupValueDesc value, |
| 44 | GXV_Validator valid ) |
| 45 | { |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 46 | FT_UNUSED( glyph ); |
| 47 | |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 48 | gxv_glyphid_validate( value.u, valid ); |
| 49 | } |
| 50 | |
| 51 | /* |
| 52 | +===============+ --------+ |
| 53 | | lookup header | | |
| 54 | +===============+ | |
| 55 | | BinSrchHeader | | |
| 56 | +===============+ | |
| 57 | | lastGlyph[0] | | |
| 58 | +---------------+ | |
| 59 | | firstGlyph[0] | | head of lookup table |
| 60 | +---------------+ | + |
| 61 | | offset[0] | -> | offset [byte] |
| 62 | +===============+ | + |
| 63 | | lastGlyph[1] | | (glyphID - firstGlyph) * 2 [byte] |
| 64 | +---------------+ | |
| 65 | | firstGlyph[1] | | |
| 66 | +---------------+ | |
| 67 | | offset[1] | | |
| 68 | +===============+ | |
| 69 | | |
| 70 | .... | |
| 71 | | |
| 72 | 16bit value array | |
| 73 | +===============+ | |
| 74 | | value | <-------+ |
| 75 | .... |
| 76 | */ |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 77 | |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 78 | static GXV_LookupValueDesc |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 79 | gxv_mort_subtable_type4_lookupfmt4_transit( |
| 80 | FT_UShort relative_gindex, |
| 81 | GXV_LookupValueDesc base_value, |
| 82 | FT_Bytes lookuptbl_limit, |
| 83 | GXV_Validator valid ) |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 84 | { |
| 85 | FT_Bytes p; |
| 86 | FT_Bytes limit; |
| 87 | FT_UShort offset; |
| 88 | GXV_LookupValueDesc value; |
| 89 | |
Werner Lemberg | 7c25946 | 2005-09-28 07:34:45 +0000 | [diff] [blame] | 90 | /* XXX: check range? */ |
| 91 | offset = (FT_UShort)( base_value.u + |
| 92 | relative_gindex * sizeof ( FT_UShort ) ); |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 93 | |
| 94 | p = valid->lookuptbl_head + offset; |
| 95 | limit = lookuptbl_limit; |
| 96 | |
| 97 | GXV_LIMIT_CHECK( 2 ); |
| 98 | value.u = FT_NEXT_USHORT( p ); |
| 99 | |
| 100 | return value; |
| 101 | } |
| 102 | |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 103 | |
Werner Lemberg | 99aa14c | 2005-09-05 19:31:27 +0000 | [diff] [blame] | 104 | FT_LOCAL_DEF( void ) |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 105 | gxv_mort_subtable_type4_validate( FT_Bytes table, |
| 106 | FT_Bytes limit, |
| 107 | GXV_Validator valid ) |
| 108 | { |
| 109 | FT_Bytes p = table; |
| 110 | |
| 111 | |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 112 | GXV_NAME_ENTER( "mort chain subtable type4 " |
| 113 | "(Non-Contextual Glyph Substitution)" ); |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 114 | |
| 115 | valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED; |
| 116 | valid->lookupval_func = gxv_mort_subtable_type4_lookupval_validate; |
| 117 | valid->lookupfmt4_trans = gxv_mort_subtable_type4_lookupfmt4_transit; |
Werner Lemberg | a4aa1c5 | 2005-08-31 22:39:23 +0000 | [diff] [blame] | 118 | |
Suzuki, Toshiya (鈴木俊哉) | a438621 | 2005-08-24 04:31:31 +0000 | [diff] [blame] | 119 | gxv_LookupTable_validate( p, limit, valid ); |
| 120 | |
| 121 | GXV_EXIT; |
| 122 | } |
| 123 | |
| 124 | |
| 125 | /* END */ |