Commit 80ed03e2bbb1c890869f5c8e53571cd091518e96

Werner Lemberg 2004-08-13T06:09:08

* src/otlayout/otlcommn.c (otl_gsubgpos_get_lookup_count): New function. * src/otlayout/otlcommn.h: Updated. * src/otlayout/otlbase.c: Rename counting variables to be more meaningful. Add copyright message. * src/otlayout/otlbase.h: Add copyright message. * src/otlayout/otlgdef.c: Rename counting variables to be more meaningful. Add copyright message. Use OTL_CHECK everywhere. (otl_caret_value_validate): Remove unused variable. (otl_gdef_validate): All tables are optional. * src/otlayout/otlgdef.h: Add copyright message. * src/otlayout/otljstf.c: Rename counting variables to be more meaningful. Add copyright message. (otl_jstf_gsub_mods_validate, otl_jstf_gpos_mods_validate): Add parameter to pass lookup count. Update all callers. Check lookup array. (otl_jstf_max_validate): s/otl_gpos_subtable_check/otl_gpos_subtable_validate/. (otl_jstf_priority_validate, otl_jstf_lang_validate, otl_jstf_script_validate): Add two parameters to pass lookup counts. Update all callers. (otl_jstf_validate): Add two parameters to pass GPOS and GSUB table offsets; use otl_gsubgpos_get_lookup_count to convert extract lookup counts. Fix typo. * src/otlayout/otljstf.h: Updated. Add copyright message. * src/otlayout/otlgpos.c (otl_gpos_subtable_validate): New function. (otl_gpos_validate): Use it. * src/otlayout/otlgpos.h: Updated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
diff --git a/ChangeLog b/ChangeLog
index 6f22db7..23f4501 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,47 @@
 2004-08-13  Werner Lemberg  <wl@gnu.org>
 
+	* src/otlayout/otlcommn.c (otl_gsubgpos_get_lookup_count): New
+	function.
+	* src/otlayout/otlcommn.h: Updated.
+
+	* src/otlayout/otlbase.c: Rename counting variables to be more
+	meaningful.
+	Add copyright message.
+	* src/otlayout/otlbase.h: Add copyright message.
+
+	* src/otlayout/otlgdef.c: Rename counting variables to be more
+	meaningful.
+	Add copyright message.
+	Use OTL_CHECK everywhere.
+	(otl_caret_value_validate): Remove unused variable.
+	(otl_gdef_validate): All tables are optional.
+	* src/otlayout/otlgdef.h: Add copyright message.
+
+	* src/otlayout/otljstf.c: Rename counting variables to be more
+	meaningful.
+	Add copyright message.
+	(otl_jstf_gsub_mods_validate, otl_jstf_gpos_mods_validate): Add
+	parameter to pass lookup count.
+	Update all callers.
+	Check lookup array.
+	(otl_jstf_max_validate):
+	s/otl_gpos_subtable_check/otl_gpos_subtable_validate/.
+	(otl_jstf_priority_validate, otl_jstf_lang_validate,
+	otl_jstf_script_validate): Add two parameters to pass lookup counts.
+	Update all callers.
+	(otl_jstf_validate): Add two parameters to pass GPOS and GSUB
+	table offsets; use otl_gsubgpos_get_lookup_count to convert extract
+	lookup counts.
+	Fix typo.
+	* src/otlayout/otljstf.h: Updated.
+	Add copyright message.
+
+	* src/otlayout/otlgpos.c (otl_gpos_subtable_validate): New function.
+	(otl_gpos_validate): Use it.
+	* src/otlayout/otlgpos.h: Updated.
+
+2004-08-13  Werner Lemberg  <wl@gnu.org>
+
 	* src/otlayout/otcommn.c: Use OTL_CHECK everywhere.
 	(otl_coverage_validate): Initialize `p',
 	s/count/num_glyphs/.
diff --git a/src/otlayout/otlbase.c b/src/otlayout/otlbase.c
index 98398d4..753004d 100644
--- a/src/otlayout/otlbase.c
+++ b/src/otlayout/otlbase.c
@@ -1,6 +1,25 @@
+/***************************************************************************/
+/*                                                                         */
+/*  otlbase.c                                                              */
+/*                                                                         */
+/*    OpenType layout support, BASE table (body).                          */
+/*                                                                         */
+/*  Copyright 2002, 2004 by                                                */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "otlbase.h"
 #include "otlcommn.h"
 
+
   static void
   otl_base_coord_validate( OTL_Bytes      table,
                            OTL_Validator  valid )
@@ -8,27 +27,30 @@
     OTL_Bytes  p = table;
     OTL_UInt   format;
 
+
     OTL_CHECK( 4 );
 
     format = OTL_NEXT_USHORT( p );
-    p += 2;
+
+    p += 2;     /* skip coordinate */
 
     switch ( format )
     {
-      case 1:
-        break;
+    case 1:
+      break;
+
+    case 2:
+      OTL_CHECK( 4 );
+      break;
 
-      case 2:
-        OTL_CHECK( 4 );
-        break;
+    case 3:
+      OTL_CHECK( 2 );
 
-      case 3:
-        OTL_CHECK( 2 );
-        otl_device_table_validate( table + OTL_PEEK_USHORT( p ), valid );
-        break;
+      otl_device_table_validate( table + OTL_PEEK_USHORT( p ), valid );
+      break;
 
-      default:
-        OTL_INVALID_DATA;
+    default:
+      OTL_INVALID_DATA;
     }
   }
 
@@ -40,29 +62,31 @@
     OTL_Bytes  p = table;
     OTL_UInt   count;
 
-    OTL_CHECK(2);
+
+    OTL_CHECK( 2 );
 
     count = OTL_NEXT_USHORT( p );
-    OTL_CHECK( count*4 );
+    OTL_CHECK( count * 4 );
   }
 
 
-
   static void
   otl_base_values_validate( OTL_Bytes      table,
                             OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count;
+    OTL_UInt   num_coord;
+
 
     OTL_CHECK( 4 );
 
-    p    += 2;  /* skip default index */
-    count = OTL_NEXT_USHORT( p );
+    p        += 2;              /* skip default index */
+    num_coord = OTL_NEXT_USHORT( p );
 
-    OTL_CHECK( count*2 );
+    OTL_CHECK( num_coord * 2 );
 
-    for ( ; count > 0; count-- )
+    /* scan base coordinate records */
+    for ( ; num_coord > 0; num_coord-- )
       otl_base_coord_validate( table + OTL_NEXT_USHORT( p ), valid );
   }
 
@@ -72,12 +96,14 @@
                             OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   min_coord, max_coord, count;
+    OTL_UInt   min_coord, max_coord, num_minmax;
 
-    OTL_CHECK(6);
-    min_coord = OTL_NEXT_USHORT( p );
-    max_coord = OTL_NEXT_USHORT( p );
-    count     = OTL_NEXT_USHORT( p );
+
+    OTL_CHECK( 6 );
+
+    min_coord  = OTL_NEXT_USHORT( p );
+    max_coord  = OTL_NEXT_USHORT( p );
+    num_minmax = OTL_NEXT_USHORT( p );
 
     if ( min_coord )
       otl_base_coord_validate( table + min_coord, valid );
@@ -85,10 +111,13 @@
     if ( max_coord )
       otl_base_coord_validate( table + max_coord, valid );
 
-    OTL_CHECK( count*8 );
-    for ( ; count > 0; count-- )
+    OTL_CHECK( num_minmax * 8 );
+
+    /* scan feature minmax records */
+    for ( ; num_minmax > 0; num_minmax-- )
     {
-      p += 4;  /* ignore tag */
+      p += 4;       /* skip tag */
+
       min_coord = OTL_NEXT_USHORT( p );
       max_coord = OTL_NEXT_USHORT( p );
 
@@ -106,13 +135,14 @@
                             OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   values, default_minmax, count;
+    OTL_UInt   values, default_minmax, num_langsys;
+
 
-    OTL_CHECK(6);
+    OTL_CHECK( 6 );
 
     values         = OTL_NEXT_USHORT( p );
     default_minmax = OTL_NEXT_USHORT( p );
-    count          = OTL_NEXT_USHORT( p );
+    num_langsys    = OTL_NEXT_USHORT( p );
 
     if ( values )
       otl_base_values_validate( table + values, valid );
@@ -120,10 +150,13 @@
     if ( default_minmax )
       otl_base_minmax_validate( table + default_minmax, valid );
 
-    OTL_CHECK( count*6 );
-    for ( ; count > 0; count-- )
+    OTL_CHECK( num_langsys * 6 );
+
+    /* scan base langsys records */
+    for ( ; num_langsys > 0; num_langsys-- )
     {
-      p += 4;  /* ignore tag */
+      p += 4;       /* skip tag */
+
       otl_base_minmax_validate( table + OTL_NEXT_USHORT( p ), valid );
     }
   }
@@ -134,20 +167,24 @@
                                  OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count;
+    OTL_UInt   num_scripts;
 
-    OTL_CHECK(2);
 
-    count = OTL_NEXT_USHORT( p );
-    OTL_CHECK(count*6);
+    OTL_CHECK( 2 );
+
+    num_scripts = OTL_NEXT_USHORT( p );
+    OTL_CHECK( num_scripts * 6 );
 
-    for ( ; count > 0; count-- )
+    /* scan base script records */
+    for ( ; num_scripts > 0; num_scripts-- )
     {
-      p += 4;  /* ignore script tag */
+      p += 4;       /* skip tag */
+
       otl_base_script_validate( table + OTL_NEXT_USHORT( p ), valid );
     }
   }
 
+
   static void
   otl_axis_table_validate( OTL_Bytes      table,
                            OTL_Validator  valid )
@@ -155,7 +192,8 @@
     OTL_Bytes  p = table;
     OTL_UInt   tags;
 
-    OTL_CHECK(4);
+
+    OTL_CHECK( 4 );
 
     tags = OTL_NEXT_USHORT( p );
     if ( tags )
@@ -171,7 +209,8 @@
   {
     OTL_Bytes p = table;
 
-    OTL_CHECK(6);
+
+    OTL_CHECK( 6 );
 
     if ( OTL_NEXT_ULONG( p ) != 0x10000UL )
       OTL_INVALID_DATA;
@@ -179,3 +218,6 @@
     otl_axis_table_validate( table + OTL_NEXT_USHORT( p ), valid );
     otl_axis_table_validate( table + OTL_NEXT_USHORT( p ), valid );
   }
+
+
+/* END */
diff --git a/src/otlayout/otlbase.h b/src/otlayout/otlbase.h
index 563d300..f112735 100644
--- a/src/otlayout/otlbase.h
+++ b/src/otlayout/otlbase.h
@@ -1,14 +1,37 @@
-#ifndef __OTL_BASE_H__
-#define __OTL_BASE_H__
+/***************************************************************************/
+/*                                                                         */
+/*  otlbase.h                                                              */
+/*                                                                         */
+/*    OpenType layout support, BASE table (specification).                 */
+/*                                                                         */
+/*  Copyright 2002, 2004 by                                                */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef __OTLBASE_H__
+#define __OTLBASE_H__
 
 #include "otlayout.h"
 
 OTL_BEGIN_HEADER
 
+
   OTL_LOCAL( void )
   otl_base_validate( OTL_Bytes      table,
                      OTL_Validator  valid );
 
+
 OTL_END_HEADER
 
-#endif /* __OTL_BASE_H__ */
+#endif /* __OTLBASE_H__ */
+
+
+/* END */
diff --git a/src/otlayout/otlcommn.c b/src/otlayout/otlcommn.c
index e467627..53c38c0 100644
--- a/src/otlayout/otlcommn.c
+++ b/src/otlayout/otlcommn.c
@@ -19,13 +19,13 @@
 #include "otlayout.h"
 
 
- /*************************************************************************/
- /*************************************************************************/
- /*****                                                               *****/
- /*****                       COVERAGE TABLE                          *****/
- /*****                                                               *****/
- /*************************************************************************/
- /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                       COVERAGE TABLE                          *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
   OTL_LOCALDEF( void )
   otl_coverage_validate( OTL_Bytes      table,
@@ -871,12 +871,12 @@
 
 
   OTL_LOCALDEF( void )
-  otl_script_list_validate( OTL_Bytes      list,
+  otl_script_list_validate( OTL_Bytes      table,
                             OTL_Bytes      features,
                             OTL_Validator  valid )
   {
     OTL_UInt   num_scripts, feature_count;
-    OTL_Bytes  p = list;
+    OTL_Bytes  p = table;
 
 
     OTL_CHECK( 2 );
@@ -890,10 +890,28 @@
     {
       p += 4;       /* skip tag */
 
-      otl_script_validate( list + OTL_NEXT_USHORT( p ), feature_count,
+      otl_script_validate( table + OTL_NEXT_USHORT( p ), feature_count,
                            valid );
     }
   }
 
 
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                      UTILITY FUNCTIONS                        *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+  OTL_LOCALDEF( OTL_UInt )
+  otl_gsubgpos_get_lookup_count( OTL_Bytes  table )
+  {
+    OTL_Bytes  p = table + 8;
+
+
+    return otl_lookup_get_count( table + OTL_PEEK_USHORT( p ) );
+  }
+
+
 /* END */
diff --git a/src/otlayout/otlcommn.h b/src/otlayout/otlcommn.h
index 1e3b923..9a66f8e 100644
--- a/src/otlayout/otlcommn.h
+++ b/src/otlayout/otlcommn.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    OpenType layout support, common tables (specification).              */
 /*                                                                         */
-/*  Copyright 2002 by                                                      */
+/*  Copyright 2002, 2004 by                                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -34,17 +34,17 @@ OTL_BEGIN_HEADER
 
   /* validate coverage table */
   OTL_LOCAL( void )
-  otl_coverage_validate( OTL_Bytes      base,
+  otl_coverage_validate( OTL_Bytes      table,
                          OTL_Validator  valid );
 
   /* return number of covered glyphs */
   OTL_LOCAL( OTL_UInt )
-  otl_coverage_get_count( OTL_Bytes  base );
+  otl_coverage_get_count( OTL_Bytes  table );
 
   /* Return the coverage index corresponding to a glyph glyph index. */
   /* Return -1 if the glyph isn't covered.                           */
   OTL_LOCAL( OTL_Long )
-  otl_coverage_get_index( OTL_Bytes  base,
+  otl_coverage_get_index( OTL_Bytes  table,
                           OTL_UInt   glyph_index );
 
 
@@ -138,7 +138,7 @@ OTL_BEGIN_HEADER
 
   /* validate lookup list */
   OTL_LOCAL( void )
-  otl_lookup_list_validate( OTL_Bytes          list,
+  otl_lookup_list_validate( OTL_Bytes          table,
                             OTL_UInt           type_count,
                             OTL_ValidateFunc*  type_funcs,
                             OTL_Validator      valid );
@@ -287,10 +287,21 @@ OTL_BEGIN_HEADER
   /* validate a script list             */
   /* features must already be validated */
   OTL_LOCAL( void )
-  otl_script_list_validate( OTL_Bytes          list,
-                            OTL_Bytes          features,
-                            OTL_Validator      valid );
+  otl_script_list_validate( OTL_Bytes      table,
+                            OTL_Bytes      features,
+                            OTL_Validator  valid );
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                      UTILITY FUNCTIONS                        *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
+  OTL_LOCAL( OTL_UInt )
+  otl_gsubgpos_get_lookup_count( OTL_Bytes  table );
 
  /* */
 
diff --git a/src/otlayout/otlgdef.c b/src/otlayout/otlgdef.c
index 4cce841..b83ac20 100644
--- a/src/otlayout/otlgdef.c
+++ b/src/otlayout/otlgdef.c
@@ -1,13 +1,32 @@
+/***************************************************************************/
+/*                                                                         */
+/*  otlgdef.c                                                              */
+/*                                                                         */
+/*    OpenType layout support, GDEF table (body).                          */
+/*                                                                         */
+/*  Copyright 2002, 2004 by                                                */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "otlgdef.h"
 #include "otlcommn.h"
 
- /************************************************************************/
- /************************************************************************/
- /*****                                                              *****/
- /*****                      ATTACHMENTS LIST                        *****/
- /*****                                                              *****/
- /************************************************************************/
- /************************************************************************/
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                       ATTACHMENTS LIST                        *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
   static void
   otl_attach_point_validate( OTL_Bytes      table,
@@ -16,12 +35,11 @@
     OTL_Bytes  p = table;
     OTL_UInt   count;
 
-    if ( p + 2 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
+
+    OTL_CHECK( 2 );
 
     count = OTL_NEXT_USHORT( p );
-    if ( table + count*2 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
+    OTL_CHECK( count * 2 );
   }
 
 
@@ -31,65 +49,65 @@
   {
     OTL_Bytes  p = table;
     OTL_Bytes  coverage;
-    OTL_UInt   count;
+    OTL_UInt   num_glyphs;
 
-    if ( p + 4 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
 
-    coverage = table + OTL_NEXT_USHORT( p );
-    count    = OTL_NEXT_USHORT( p );
+    OTL_CHECK( 4 );
+
+    coverage   = table + OTL_NEXT_USHORT( p );
+    num_glyphs = OTL_NEXT_USHORT( p );
 
     otl_coverage_validate( coverage, valid );
-    if ( count != otl_coverage_get_count( coverage ) )
+    if ( num_glyphs != otl_coverage_get_count( coverage ) )
       OTL_INVALID_DATA;
 
-    if ( p + count*2 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
+    OTL_CHECK( num_glyphs * 2 );
 
-    for ( ; count > 0; count-- )
+    /* scan attach point records */
+    for ( ; num_glyphs > 0; num_glyphs-- )
       otl_attach_point_validate( table + OTL_NEXT_USHORT( p ), valid );
   }
 
 
- /************************************************************************/
- /************************************************************************/
- /*****                                                              *****/
- /*****                      LIGATURE CARETS                         *****/
- /*****                                                              *****/
- /************************************************************************/
- /************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                       LIGATURE CARETS                         *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
   static void
   otl_caret_value_validate( OTL_Bytes      table,
                             OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_Int   format;
+    OTL_Int    format;
+
 
-    if ( p + 4 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
+    OTL_CHECK( 4 );
 
     format = OTL_NEXT_USHORT( p );
     switch ( format )
     {
-      case 1:
-      case 2:
-        break;
+    case 1:
+      /* skip coordinate, no test */
+      break;
 
-      case 3:
-        {
-          OTL_Bytes  device;
+    case 2:
+      /* skip contour point index, no test */
+      break;
 
-          p += 2;
-          if ( p + 2 > valid->limit )
-            OTL_INVALID_TOO_SHORT;
+    case 3:
+      p += 2;           /* skip coordinate */
 
-          otl_device_table_validate( table + OTL_PEEK_USHORT( p ), valid );
-        }
-        break;
+      OTL_CHECK( 2 );
 
-      default:
-        OTL_INVALID_DATA;
+      otl_device_table_validate( table + OTL_PEEK_USHORT( p ), valid );
+      break;
+
+    default:
+      OTL_INVALID_DATA;
     }
   }
 
@@ -99,17 +117,15 @@
                                OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count;
-
-    if ( p + 2 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
+    OTL_UInt   num_carets;
 
-    count = OTL_NEXT_USHORT( p );
 
-    if ( p + count*2 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
+    OTL_CHECK( 2 );
+    num_carets = OTL_NEXT_USHORT( p );
+    OTL_CHECK( num_carets * 2 );
 
-    for ( ; count > 0; count-- )
+    /* scan caret value records */
+    for ( ; num_carets > 0; num_carets-- )
       otl_caret_value_validate( table + OTL_NEXT_USHORT( p ), valid );
   }
 
@@ -120,56 +136,68 @@
   {
     OTL_Bytes  p = table;
     OTL_Bytes  coverage;
-    OTL_UInt   count;
+    OTL_UInt   num_ligglyphs;
+
 
-    if ( p + 4 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
+    OTL_CHECK( 4 );
 
-    coverage = table + OTL_NEXT_USHORT( p );
-    count    = OTL_NEXT_USHORT( p );
+    coverage      = table + OTL_NEXT_USHORT( p );
+    num_ligglyphs = OTL_NEXT_USHORT( p );
 
     otl_coverage_validate( coverage, valid );
-    if ( count != otl_coverage_get_count( coverage ) )
+    if ( num_ligglyphs != otl_coverage_get_count( coverage ) )
       OTL_INVALID_DATA;
 
-    if ( p + count*2 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
+    OTL_CHECK( num_ligglyphs * 2 );
 
-    for ( ; count > 0; count-- )
+    /* scan ligature glyph records */
+    for ( ; num_ligglyphs > 0; num_ligglyphs-- )
       otl_ligature_glyph_validate( table + OTL_NEXT_USHORT( p ), valid );
   }
 
 
- /************************************************************************/
- /************************************************************************/
- /*****                                                              *****/
- /*****                         GDEF TABLE                           *****/
- /*****                                                              *****/
- /************************************************************************/
- /************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                         GDEF TABLE                            *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
   OTL_APIDEF( void )
   otl_gdef_validate( OTL_Bytes      table,
                      OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
+    OTL_UInt   val;
 
-    if ( p + 12 > valid->limit )
-      OTL_INVALID_TOO_SHORT;
+
+    OTL_CHECK( 12 );
 
     /* check format */
     if ( OTL_NEXT_ULONG( p ) != 0x00010000UL )
       OTL_INVALID_FORMAT;
 
-    /* validate class definition table */
-    otl_class_definition_validate( table + OTL_NEXT_USHORT( p ), valid );
+    /* validate glyph class definition table */
+    val = OTL_NEXT_USHORT( p );
+    if ( val )
+      otl_class_definition_validate( table + val, valid );
 
     /* validate attachment point list */
-    otl_attach_list_validate( table + OTL_NEXT_USHORT( p ), valid );
+    val = OTL_NEXT_USHORT( p );
+    if ( val )
+      otl_attach_list_validate( table + val, valid );
 
     /* validate ligature caret list */
-    otl_ligature_caret_list_validate( table + OTL_NEXT_USHORT( p ), valid );
-
-    /* validate mark attach class */
-    otl_class_definition_validate( table + OTL_NEXT_USHORT( p ), valid );
+    val = OTL_NEXT_USHORT( p );
+    if ( val )
+      otl_ligature_caret_list_validate( table + val, valid );
+
+    /* validate mark attachment class definition table */
+    val = OTL_NEXT_USHORT( p );
+    if ( val )
+      otl_class_definition_validate( table + val, valid );
   }
+
+
+/* END */
diff --git a/src/otlayout/otlgdef.h b/src/otlayout/otlgdef.h
index f296cee..359cdf9 100644
--- a/src/otlayout/otlgdef.h
+++ b/src/otlayout/otlgdef.h
@@ -1,14 +1,37 @@
-#ifndef __OTL_GDEF_H__
-#define __OTL_GDEF_H__
+/***************************************************************************/
+/*                                                                         */
+/*  otlgdef.h                                                              */
+/*                                                                         */
+/*    OpenType layout support, GDEF table (specification).                 */
+/*                                                                         */
+/*  Copyright 2002, 2004 by                                                */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef __OTLGDEF_H__
+#define __OTLGDEF_H__
 
 #include "otltable.h"
 
 OTL_BEGIN_HEADER
 
+
   OTL_API( void )
   otl_gdef_validate( OTL_Bytes      table,
                      OTL_Validator  valid );
 
+
 OTL_END_HEADER
 
-#endif /* __OTL_GDEF_H__ */
+#endif /* __OTLGDEF_H__ */
+
+
+/* END */
diff --git a/src/otlayout/otlgpos.c b/src/otlayout/otlgpos.c
index 7f81aa9..14a90f1 100644
--- a/src/otlayout/otlgpos.c
+++ b/src/otlayout/otlgpos.c
@@ -936,7 +936,7 @@
     }
   }
 
-  static OTL_ValidateFunc  otl_gpos_validate_funcs[ 9 ] =
+  static OTL_ValidateFunc  otl_gpos_validate_funcs[9] =
   {
     otl_gpos_lookup1_validate,
     otl_gpos_lookup2_validate,
@@ -950,13 +950,21 @@
   };
 
 
- /************************************************************************/
- /************************************************************************/
- /*****                                                              *****/
- /*****                         GPOS TABLE                           *****/
- /*****                                                              *****/
- /************************************************************************/
- /************************************************************************/
+  OTL_LOCALDEF( void )
+  otl_gpos_subtable_validate( OTL_Bytes      table,
+                              OTL_Validator  valid )
+  {
+    otl_lookup_list_validate( table, 9, otl_gpos_validate_funcs, valid );
+  }
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                          GPOS TABLE                           *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
 
   OTL_LOCALDEF( void )
@@ -975,8 +983,7 @@
     features = OTL_NEXT_USHORT( p );
     lookups  = OTL_NEXT_USHORT( p );
 
-    otl_lookup_list_validate( table + lookups, 9, otl_gpos_validate_funcs,
-                              valid );
+    otl_gpos_subtable_validate( table + lookups, valid );
     otl_feature_list_validate( table + features, table + lookups, valid );
     otl_script_list_validate( table + scripts, table + features, valid );
   }
diff --git a/src/otlayout/otlgpos.h b/src/otlayout/otlgpos.h
index 1d10cab..1b60e6c 100644
--- a/src/otlayout/otlgpos.h
+++ b/src/otlayout/otlgpos.h
@@ -1,14 +1,18 @@
-#ifndef __OTL_GPOS_H__
-#define __OTL_GPOS_H__
+#ifndef __OTLGPOS_H__
+#define __OTLGPOS_H__
 
 #include "otlayout.h"
 
 OTL_BEGIN_HEADER
 
   OTL_LOCAL( void )
+  otl_gpos_subtable_validate( OTL_Bytes      table,
+                              OTL_Validator  valid );
+
+  OTL_LOCAL( void )
   otl_gpos_validate( OTL_Bytes      table,
                      OTL_Validator  valid );
 
 OTL_END_HEADER
 
-#endif /* __OTL_GPOS_H__ */
+#endif /* __OTLGPOS_H__ */
diff --git a/src/otlayout/otlgsub.c b/src/otlayout/otlgsub.c
index f95ed65..b061579 100644
--- a/src/otlayout/otlgsub.c
+++ b/src/otlayout/otlgsub.c
@@ -882,3 +882,6 @@
     otl_feature_list_validate( table + features, table + lookups, valid );
     otl_script_list_validate( table + scripts, table + features, valid );
   }
+
+
+/* END */
diff --git a/src/otlayout/otlgsub.h b/src/otlayout/otlgsub.h
index db5edec..1515f11 100644
--- a/src/otlayout/otlgsub.h
+++ b/src/otlayout/otlgsub.h
@@ -1,5 +1,5 @@
-#ifndef __OTL_GSUB_H__
-#define __OTL_GSUB_H__
+#ifndef __OTLGSUB_H__
+#define __OTLGSUB_H__
 
 #include "otlayout.h"
 
@@ -10,17 +10,19 @@ OTL_BEGIN_HEADER
                                                OTL_Bytes    alternates,
                                                OTL_Pointer  data );
 
-  typedef struct OTL_GSUB_AlternateRec_
+  typedef struct  OTL_GSUB_AlternateRec_
   {
     OTL_GSUB_AlternateFunc  handler_func;
     OTL_Pointer             handler_data;
 
   } OTL_GSUB_AlternateRec, *OTL_GSUB_Alternate;
 
+
   OTL_LOCAL( void )
   otl_gsub_validate( OTL_Bytes      table,
                      OTL_Validator  valid );
 
+
 OTL_END_HEADER
 
-#endif /* __OTL_GSUB_H__ */
+#endif /* __OTLGSUB_H__ */
diff --git a/src/otlayout/otljstf.c b/src/otlayout/otljstf.c
index 8e49718..ca1976a 100644
--- a/src/otlayout/otljstf.c
+++ b/src/otlayout/otljstf.c
@@ -1,49 +1,79 @@
+/***************************************************************************/
+/*                                                                         */
+/*  otljstf.c                                                              */
+/*                                                                         */
+/*    OpenType layout support, JSTF table (body).                          */
+/*                                                                         */
+/*  Copyright 2002, 2004 by                                                */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "otljstf.h"
 #include "otlcommn.h"
 #include "otlgpos.h"
 
+
   static void
   otl_jstf_extender_validate( OTL_Bytes      table,
                               OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count;
+    OTL_UInt   num_glyphs;
+
 
     OTL_CHECK( 2 );
 
-    count = OTL_NEXT_USHORT( p );
+    num_glyphs = OTL_NEXT_USHORT( p );
+
+    OTL_CHECK( num_glyphs * 2 );
 
-    OTL_CHECK( count*2 );
+    /* XXX: check glyph indices */
   }
 
 
   static void
   otl_jstf_gsub_mods_validate( OTL_Bytes      table,
+                               OTL_UInt       lookup_count,
                                OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count;
+    OTL_UInt   num_lookups;
+
 
     OTL_CHECK( 2 );
-    count = OTL_NEXT_USHORT( p );
-    OTL_CHECK( count*2 );
+    num_lookups = OTL_NEXT_USHORT( p );
+    OTL_CHECK( num_lookups * 2 );
 
-    /* XXX: check GSUB lookup indices */
+    for ( ; num_lookups > 0; num_lookups-- )
+      if ( OTL_NEXT_USHORT( p ) >= lookup_count )
+        OTL_INVALID_DATA;
   }
 
 
   static void
   otl_jstf_gpos_mods_validate( OTL_Bytes      table,
+                               OTL_UInt       lookup_count,
                                OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count;
+    OTL_UInt   num_lookups;
+
 
     OTL_CHECK( 2 );
-    count = OTL_NEXT_USHORT( p );
-    OTL_CHECK( count*2 );
+    num_lookups = OTL_NEXT_USHORT( p );
+    OTL_CHECK( num_lookups * 2 );
 
-    /* XXX: check GPOS lookup indices */
+    for ( ; num_lookups > 0; num_lookups-- )
+      if ( OTL_NEXT_USHORT( p ) >= lookup_count )
+        OTL_INVALID_DATA;
   }
 
 
@@ -52,44 +82,49 @@
                          OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count;
+    OTL_UInt   num_lookups;
 
-    OTL_CHECK( 2 );
 
-    count = OTL_NEXT_USHORT( p );
+    OTL_CHECK( 2 );
+    num_lookups = OTL_NEXT_USHORT( p );
+    OTL_CHECK( num_lookups * 2 );
 
-    OTL_CHECK( count*2 );
-    for ( ; count > 0; count-- )
-      otl_gpos_subtable_check( table + OTL_NEXT_USHORT( p ), valid );
+    /* scan subtable records */
+    for ( ; num_lookups > 0; num_lookups-- )
+      /* XXX: check lookup types? */
+      otl_gpos_subtable_validate( table + OTL_NEXT_USHORT( p ), valid );
   }
 
 
   static void
   otl_jstf_priority_validate( OTL_Bytes      table,
+                              OTL_UInt       gsub_lookup_count,
+                              OTL_UInt       gpos_lookup_count,
                               OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   offset, val;
+    OTL_UInt   val;
+
 
     OTL_CHECK( 20 );
 
     /* shrinkage GSUB enable/disable */
     val = OTL_NEXT_USHORT( p );
     if ( val )
-      otl_jstf_gsub_mods_validate( table + val, valid );
+      otl_jstf_gsub_mods_validate( table + val, gsub_lookup_count, valid );
 
     val = OTL_NEXT_USHORT( p );
     if ( val )
-      otl_jstf_gsub_mods_validate( table + val, valid );
+      otl_jstf_gsub_mods_validate( table + val, gsub_lookup_count, valid );
 
     /* shrinkage GPOS enable/disable */
     val = OTL_NEXT_USHORT( p );
     if ( val )
-      otl_jstf_gpos_mods_validate( table + val, valid );
+      otl_jstf_gpos_mods_validate( table + val, gpos_lookup_count, valid );
 
     val = OTL_NEXT_USHORT( p );
     if ( val )
-      otl_jstf_gpos_mods_validate( table + val, valid );
+      otl_jstf_gpos_mods_validate( table + val, gpos_lookup_count, valid );
 
     /* shrinkage JSTF max */
     val = OTL_NEXT_USHORT( p );
@@ -99,20 +134,20 @@
     /* extension GSUB enable/disable */
     val = OTL_NEXT_USHORT( p );
     if ( val )
-      otl_jstf_gsub_mods_validate( table + val, valid );
+      otl_jstf_gsub_mods_validate( table + val, gsub_lookup_count, valid );
 
     val = OTL_NEXT_USHORT( p );
     if ( val )
-      otl_jstf_gsub_mods_validate( table + val, valid );
+      otl_jstf_gsub_mods_validate( table + val, gsub_lookup_count, valid );
 
     /* extension GPOS enable/disable */
     val = OTL_NEXT_USHORT( p );
     if ( val )
-      otl_jstf_gpos_mods_validate( table + val, valid );
+      otl_jstf_gpos_mods_validate( table + val, gpos_lookup_count, valid );
 
     val = OTL_NEXT_USHORT( p );
     if ( val )
-      otl_jstf_gpos_mods_validate( table + val, valid );
+      otl_jstf_gpos_mods_validate( table + val, gpos_lookup_count, valid );
 
     /* extension JSTF max */
     val = OTL_NEXT_USHORT( p );
@@ -120,69 +155,94 @@
       otl_jstf_max_validate( table + val, valid );
   }
 
+
   static void
   otl_jstf_lang_validate( OTL_Bytes      table,
+                          OTL_UInt       gsub_lookup_count,
+                          OTL_UInt       gpos_lookup_count,
                           OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count;
+    OTL_UInt   num_priorities;
 
-    OTL_CHECK( 2 );
-
-    count = OTL_NEXT_USHORT( p );
 
-    OTL_CHECK( count*2 );
-    for ( ; count > 0; count-- )
-      otl_jstf_priority_validate( table + OTL_NEXT_USHORT( p ), valid );
+    OTL_CHECK( 2 );
+    num_priorities = OTL_NEXT_USHORT( p );
+    OTL_CHECK( num_priorities * 2 );
+
+    /* scan priority records */
+    for ( ; num_priorities > 0; num_priorities-- )
+      otl_jstf_priority_validate( table + OTL_NEXT_USHORT( p ),
+                                  gsub_lookup_count, gpos_lookup_count,
+                                  valid );
   }
 
 
   static void
   otl_jstf_script_validate( OTL_Bytes      table,
+                            OTL_UInt       gsub_lookup_count,
+                            OTL_UInt       gpos_lookup_count,
                             OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count, extender, default_lang;
+    OTL_UInt   num_langsys, extender, default_lang;
+
 
     OTL_CHECK( 6 );
     extender     = OTL_NEXT_USHORT( p );
     default_lang = OTL_NEXT_USHORT( p );
-    count        = OTL_NEXT_USHORT( p );
+    num_langsys  = OTL_NEXT_USHORT( p );
 
     if ( extender )
       otl_jstf_extender_validate( table + extender, valid );
 
     if ( default_lang )
-      otl_jstf_lang_validate( table + default_lang, valid );
+      otl_jstf_lang_validate( table + default_lang,
+                              gsub_lookup_count, gpos_lookup_count, valid );
 
-    OTL_CHECK( 6*count );
+    OTL_CHECK( 6 * num_langsys );
 
-    for ( ; count > 0; count-- )
+    /* scan langsys records */
+    for ( ; num_langsys > 0; num_langsys-- )
     {
-      p += 4;  /* ignore tag */
-      otl_jstf_lang_validate( table + OTL_NEXT_USHORT( p ), valid );
+      p += 4;       /* skip tag */
+
+      otl_jstf_lang_validate( table + OTL_NEXT_USHORT( p ),
+                              gsub_lookup_count, gpos_lookup_count, valid );
     }
   }
 
 
   OTL_LOCALDEF( void )
   otl_jstf_validate( OTL_Bytes      table,
+                     OTL_Bytes      gsub,
+                     OTL_Bytes      gpos,
                      OTL_Validator  valid )
   {
     OTL_Bytes  p = table;
-    OTL_UInt   count;
+    OTL_UInt   num_scripts, gsub_lookup_count, gpos_lookup_count;
 
-    OTL_CHECK( 4 );
+
+    OTL_CHECK( 6 );
 
     if ( OTL_NEXT_ULONG( p ) != 0x10000UL )
       OTL_INVALID_DATA;
 
-    count = OTL_NEXT_USHORT( p );
-    OTL_CHECK( count*6 );
+    num_scripts = OTL_NEXT_USHORT( p );
+    OTL_CHECK( num_scripts * 6 );
+
+    gsub_lookup_count = otl_gsubgpos_get_lookup_count( gsub );
+    gpos_lookup_count = otl_gsubgpos_get_lookup_count( gpos );
 
-    for ( ; count > 0; count++ )
+    /* scan script records */
+    for ( ; num_scripts > 0; num_scripts-- )
     {
-      p += 4;  /* ignore tag */
-      otl_jstf_script_validate( table + OTL_NEXT_USHORT( p ), valid );
+      p += 4;       /* skip tag */
+
+      otl_jstf_script_validate( table + OTL_NEXT_USHORT( p ),
+                                gsub_lookup_count, gpos_lookup_count, valid );
     }
   }
+
+
+/* END */
diff --git a/src/otlayout/otljstf.h b/src/otlayout/otljstf.h
index 33947f8..2e2d008 100644
--- a/src/otlayout/otljstf.h
+++ b/src/otlayout/otljstf.h
@@ -1,14 +1,42 @@
-#ifndef __OTL_JSTF_H__
-#define __OTL_JSTF_H__
+/***************************************************************************/
+/*                                                                         */
+/*  otljstf.h                                                              */
+/*                                                                         */
+/*    OpenType layout support, JSTF table (specification).                 */
+/*                                                                         */
+/*  Copyright 2002, 2004 by                                                */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef __OTLJSTF_H__
+#define __OTLJSTF_H__
 
 #include "otlayout.h"
 
+
 OTL_BEGIN_HEADER
 
+
+  /* validate JSTF table                            */
+  /* GSUB and GPOS tables must already be validated */
   OTL_LOCAL( void )
   otl_jstf_validate( OTL_Bytes      table,
+                     OTL_Bytes      gsub,
+                     OTL_Bytes      gpos,
                      OTL_Validator  valid );
 
+
 OTL_END_HEADER
 
-#endif /* __OTL_JSTF_H__ */
+#endif /* __OTLJSTF_H__ */
+
+
+/* END */