Disabling auto-refresh of game list by default, as it is causing bugs sometimes
[open-ps2-loader.git] / thirdparty / freetype-2.3.12 / src / otvalid / otvjstf.c
bloba616a23432cc4748be47b436bc5010f30e6a0117
1 /***************************************************************************/
2 /* */
3 /* otvjstf.c */
4 /* */
5 /* OpenType JSTF table validation (body). */
6 /* */
7 /* Copyright 2004, 2007 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 /***************************************************************************/
19 #include "otvalid.h"
20 #include "otvcommn.h"
21 #include "otvgpos.h"
24 /*************************************************************************/
25 /* */
26 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
27 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
28 /* messages during execution. */
29 /* */
30 #undef FT_COMPONENT
31 #define FT_COMPONENT trace_otvjstf
34 #define JstfPriorityFunc otv_JstfPriority_validate
35 #define JstfLookupFunc otv_GPOS_subtable_validate
37 /* uses valid->extra1 (GSUB lookup count) */
38 /* uses valid->extra2 (GPOS lookup count) */
39 /* sets valid->extra1 (counter) */
41 static void
42 otv_JstfPriority_validate( FT_Bytes table,
43 OTV_Validator valid )
45 FT_Bytes p = table;
46 FT_UInt table_size;
47 FT_UInt gsub_lookup_count, gpos_lookup_count;
49 OTV_OPTIONAL_TABLE( ShrinkageEnableGSUB );
50 OTV_OPTIONAL_TABLE( ShrinkageDisableGSUB );
51 OTV_OPTIONAL_TABLE( ShrinkageEnableGPOS );
52 OTV_OPTIONAL_TABLE( ShrinkageDisableGPOS );
53 OTV_OPTIONAL_TABLE( ExtensionEnableGSUB );
54 OTV_OPTIONAL_TABLE( ExtensionDisableGSUB );
55 OTV_OPTIONAL_TABLE( ExtensionEnableGPOS );
56 OTV_OPTIONAL_TABLE( ExtensionDisableGPOS );
57 OTV_OPTIONAL_TABLE( ShrinkageJstfMax );
58 OTV_OPTIONAL_TABLE( ExtensionJstfMax );
61 OTV_ENTER;
62 OTV_TRACE(( "JstfPriority table\n" ));
64 OTV_LIMIT_CHECK( 20 );
66 gsub_lookup_count = valid->extra1;
67 gpos_lookup_count = valid->extra2;
69 table_size = 20;
71 valid->extra1 = gsub_lookup_count;
73 OTV_OPTIONAL_OFFSET( ShrinkageEnableGSUB );
74 OTV_SIZE_CHECK( ShrinkageEnableGSUB );
75 if ( ShrinkageEnableGSUB )
76 otv_x_ux( table + ShrinkageEnableGSUB, valid );
78 OTV_OPTIONAL_OFFSET( ShrinkageDisableGSUB );
79 OTV_SIZE_CHECK( ShrinkageDisableGSUB );
80 if ( ShrinkageDisableGSUB )
81 otv_x_ux( table + ShrinkageDisableGSUB, valid );
83 valid->extra1 = gpos_lookup_count;
85 OTV_OPTIONAL_OFFSET( ShrinkageEnableGPOS );
86 OTV_SIZE_CHECK( ShrinkageEnableGPOS );
87 if ( ShrinkageEnableGPOS )
88 otv_x_ux( table + ShrinkageEnableGPOS, valid );
90 OTV_OPTIONAL_OFFSET( ShrinkageDisableGPOS );
91 OTV_SIZE_CHECK( ShrinkageDisableGPOS );
92 if ( ShrinkageDisableGPOS )
93 otv_x_ux( table + ShrinkageDisableGPOS, valid );
95 OTV_OPTIONAL_OFFSET( ShrinkageJstfMax );
96 OTV_SIZE_CHECK( ShrinkageJstfMax );
97 if ( ShrinkageJstfMax )
99 /* XXX: check lookup types? */
100 OTV_NEST2( JstfMax, JstfLookup );
101 OTV_RUN( table + ShrinkageJstfMax, valid );
104 valid->extra1 = gsub_lookup_count;
106 OTV_OPTIONAL_OFFSET( ExtensionEnableGSUB );
107 OTV_SIZE_CHECK( ExtensionEnableGSUB );
108 if ( ExtensionEnableGSUB )
109 otv_x_ux( table + ExtensionEnableGSUB, valid );
111 OTV_OPTIONAL_OFFSET( ExtensionDisableGSUB );
112 OTV_SIZE_CHECK( ExtensionDisableGSUB );
113 if ( ExtensionDisableGSUB )
114 otv_x_ux( table + ExtensionDisableGSUB, valid );
116 valid->extra1 = gpos_lookup_count;
118 OTV_OPTIONAL_OFFSET( ExtensionEnableGPOS );
119 OTV_SIZE_CHECK( ExtensionEnableGPOS );
120 if ( ExtensionEnableGPOS )
121 otv_x_ux( table + ExtensionEnableGPOS, valid );
123 OTV_OPTIONAL_OFFSET( ExtensionDisableGPOS );
124 OTV_SIZE_CHECK( ExtensionDisableGPOS );
125 if ( ExtensionDisableGPOS )
126 otv_x_ux( table + ExtensionDisableGPOS, valid );
128 OTV_OPTIONAL_OFFSET( ExtensionJstfMax );
129 OTV_SIZE_CHECK( ExtensionJstfMax );
130 if ( ExtensionJstfMax )
132 /* XXX: check lookup types? */
133 OTV_NEST2( JstfMax, JstfLookup );
134 OTV_RUN( table + ExtensionJstfMax, valid );
137 valid->extra1 = gsub_lookup_count;
138 valid->extra2 = gpos_lookup_count;
140 OTV_EXIT;
144 /* sets valid->extra (glyph count) */
145 /* sets valid->func1 (otv_JstfPriority_validate) */
147 static void
148 otv_JstfScript_validate( FT_Bytes table,
149 OTV_Validator valid )
151 FT_Bytes p = table;
152 FT_UInt table_size;
153 FT_UInt JstfLangSysCount;
155 OTV_OPTIONAL_TABLE( ExtGlyph );
156 OTV_OPTIONAL_TABLE( DefJstfLangSys );
159 OTV_NAME_ENTER( "JstfScript" );
161 OTV_LIMIT_CHECK( 6 );
162 OTV_OPTIONAL_OFFSET( ExtGlyph );
163 OTV_OPTIONAL_OFFSET( DefJstfLangSys );
164 JstfLangSysCount = FT_NEXT_USHORT( p );
166 OTV_TRACE(( " (JstfLangSysCount = %d)\n", JstfLangSysCount ));
168 table_size = JstfLangSysCount * 6 + 6;
170 OTV_SIZE_CHECK( ExtGlyph );
171 if ( ExtGlyph )
173 valid->extra1 = valid->glyph_count;
174 OTV_NEST1( ExtenderGlyph );
175 OTV_RUN( table + ExtGlyph, valid );
178 OTV_SIZE_CHECK( DefJstfLangSys );
179 if ( DefJstfLangSys )
181 OTV_NEST2( JstfLangSys, JstfPriority );
182 OTV_RUN( table + DefJstfLangSys, valid );
185 OTV_LIMIT_CHECK( 6 * JstfLangSysCount );
187 /* JstfLangSysRecord */
188 OTV_NEST2( JstfLangSys, JstfPriority );
189 for ( ; JstfLangSysCount > 0; JstfLangSysCount-- )
191 p += 4; /* skip JstfLangSysTag */
193 OTV_RUN( table + FT_NEXT_USHORT( p ), valid );
196 OTV_EXIT;
200 /* sets valid->extra1 (GSUB lookup count) */
201 /* sets valid->extra2 (GPOS lookup count) */
202 /* sets valid->glyph_count */
204 FT_LOCAL_DEF( void )
205 otv_JSTF_validate( FT_Bytes table,
206 FT_Bytes gsub,
207 FT_Bytes gpos,
208 FT_UInt glyph_count,
209 FT_Validator ftvalid )
211 OTV_ValidatorRec validrec;
212 OTV_Validator valid = &validrec;
213 FT_Bytes p = table;
214 FT_UInt JstfScriptCount;
217 valid->root = ftvalid;
219 FT_TRACE3(( "validating JSTF table\n" ));
220 OTV_INIT;
222 OTV_LIMIT_CHECK( 6 );
224 if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
225 FT_INVALID_FORMAT;
227 JstfScriptCount = FT_NEXT_USHORT( p );
229 FT_TRACE3(( " (JstfScriptCount = %d)\n", JstfScriptCount ));
231 OTV_LIMIT_CHECK( JstfScriptCount * 6 );
233 if ( gsub )
234 valid->extra1 = otv_GSUBGPOS_get_Lookup_count( gsub );
235 else
236 valid->extra1 = 0;
238 if ( gpos )
239 valid->extra2 = otv_GSUBGPOS_get_Lookup_count( gpos );
240 else
241 valid->extra2 = 0;
243 valid->glyph_count = glyph_count;
245 /* JstfScriptRecord */
246 for ( ; JstfScriptCount > 0; JstfScriptCount-- )
248 p += 4; /* skip JstfScriptTag */
250 /* JstfScript */
251 otv_JstfScript_validate( table + FT_NEXT_USHORT( p ), valid );
254 FT_TRACE4(( "\n" ));
258 /* END */