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