Commit 974b193bcc6f9ca10097a646fdea7d26cd95c830

Werner Lemberg 2013-12-20T17:26:26

[autofit] Introduce `styles'. This is the new top-level structure for handling glyph input data; scripts are now defined separately. * src/autofit/aftypes.h (SCRIPT): Updated. (AF_ScriptClassRec): Move `blue_stringset' and `writing_system' members to ... (AF_Style_ClassRec): ... this new structure. (AF_Style): New enumeration. (AF_StyleMetricsRec): Replace `script' enumeration with `style_class' pointer. (AF_DEFINE_SCRIPT_CLASS, AF_DECLARE_SCRIPT_CLASS): Updated. (AF_DEFINE_STYLE_CLASS, AF_DECLARE_STYLE_CLASS): New macros. * src/autofit/afstyles.h: New file, using data from `afscript.h'. * src/autofit/afscript.h: Updated. * src/autofit/afcjk.c (af_cjk_metrics_init_widths, af_cjk_metrics_init_blues, af_cjk_hint_edges): Updated. * src/autofit/afglobal.c (SCRIPT): Updated. (STYLE): Redefine macro to load `afstyles.h'. (af_script_names) [FT_DEBUG_LEVEL_TRACE]: Replace with... (af_style_names): ... this array. (af_face_globals_compute_script_coverage): Renamed to... (af_face_globals_compute_style_coverage): ... this. Updated. (af_face_globals_new, af_face_globals_free, af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (SCRIPT): Updated. (STYLE): Redefine macro to load `afstyles.h'. (AF_SCRIPT_FALLBACK): Update definition. This will get more refinements with later on. (AF_SCRIPT_UNASSIGNED): Replace with... (AF_STYLE_UNASSIGNED): ... this macro. (AF_FaceGlobalsRec): Updated. * src/autofit/aflatin.c (af_latin_metrics_init_widths, af_latin_metrics_init_blues, af_latin_metrics_scale_dim, af_latin_hint_edges): Updated. * src/autofit/aflatin2.c (af_latin2_metrics_init_widths): Updated. (af_ltn2_uniranges): Removed. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated. * src/autofit/afpic.h (AF_STYLE_CLASSES_GET): New macro. (AFModulePIC): Add `af_style_classes' and `af_style_classes_rec' members. * src/autofit/afranges.h: Updated. * src/autofit/rules.mk (AUTOF_DRV_H): Add `afstyles.h'.

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
diff --git a/ChangeLog b/ChangeLog
index e3b88e1..5783d43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,63 @@
+2013-12-20  Werner Lemberg  <wl@gnu.org>
+
+	[autofit] Introduce `styles'.
+
+	This is the new top-level structure for handling glyph input data;
+	scripts are now defined separately.
+
+	* src/autofit/aftypes.h (SCRIPT): Updated.
+	(AF_ScriptClassRec): Move `blue_stringset' and `writing_system'
+	members to ...
+	(AF_Style_ClassRec): ... this new structure.
+	(AF_Style): New enumeration.
+	(AF_StyleMetricsRec): Replace `script' enumeration with
+	`style_class' pointer.
+	(AF_DEFINE_SCRIPT_CLASS, AF_DECLARE_SCRIPT_CLASS): Updated.
+	(AF_DEFINE_STYLE_CLASS, AF_DECLARE_STYLE_CLASS): New macros.
+
+	* src/autofit/afstyles.h: New file, using data from `afscript.h'.
+	* src/autofit/afscript.h: Updated.
+
+	* src/autofit/afcjk.c (af_cjk_metrics_init_widths,
+	af_cjk_metrics_init_blues, af_cjk_hint_edges): Updated.
+
+	* src/autofit/afglobal.c (SCRIPT): Updated.
+	(STYLE): Redefine macro to load `afstyles.h'.
+	(af_script_names) [FT_DEBUG_LEVEL_TRACE]: Replace with...
+	(af_style_names): ... this array.
+	(af_face_globals_compute_script_coverage): Renamed to...
+	(af_face_globals_compute_style_coverage): ... this.
+	Updated.
+	(af_face_globals_new, af_face_globals_free,
+	af_face_globals_get_metrics): Updated.
+
+	* src/autofit/afglobal.h (SCRIPT): Updated.
+	(STYLE): Redefine macro to load `afstyles.h'.
+	(AF_SCRIPT_FALLBACK): Update definition.  This will get more
+	refinements with later on.
+	(AF_SCRIPT_UNASSIGNED): Replace with...
+	(AF_STYLE_UNASSIGNED): ... this macro.
+	(AF_FaceGlobalsRec): Updated.
+
+	* src/autofit/aflatin.c (af_latin_metrics_init_widths,
+	af_latin_metrics_init_blues, af_latin_metrics_scale_dim,
+	af_latin_hint_edges): Updated.
+
+	* src/autofit/aflatin2.c (af_latin2_metrics_init_widths): Updated.
+	(af_ltn2_uniranges): Removed.
+
+	* src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph):
+	Updated.
+
+	* src/autofit/afpic.c (autofit_module_class_pic_init): Updated.
+	* src/autofit/afpic.h (AF_STYLE_CLASSES_GET): New macro.
+	(AFModulePIC): Add `af_style_classes' and `af_style_classes_rec'
+	members.
+
+	* src/autofit/afranges.h: Updated.
+
+	* src/autofit/rules.mk (AUTOF_DRV_H): Add `afstyles.h'.
+
 2013-12-19  Werner Lemberg  <wl@gnu.org>
 
 	[autofit] Factor scripts and uniranges out of writing system files.
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index e29a9e1..38d83af 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -75,10 +75,10 @@
 
 
     FT_TRACE5(( "\n"
-                "cjk standard widths computation (script `%s')\n"
+                "cjk standard widths computation (style `%s')\n"
                 "===============================================\n"
                 "\n",
-                af_script_names[metrics->root.script] ));
+                af_style_names[metrics->root.style_class->style] ));
 
     af_glyph_hints_init( hints, face->memory );
 
@@ -92,8 +92,9 @@
       AF_CJKMetricsRec  dummy[1];
       AF_Scaler         scaler = &dummy->root.scaler;
 
-      AF_ScriptClass    script_class =
-                          AF_SCRIPT_CLASSES_GET[metrics->root.script];
+      AF_StyleClass   style_class  = metrics->root.style_class;
+      AF_ScriptClass  script_class = AF_SCRIPT_CLASSES_GET
+                                       [style_class->script];
 
 
       glyph_index = FT_Get_Char_Index( face, script_class->standard_char );
@@ -228,7 +229,7 @@
     AF_CJKAxis  axis;
     FT_Outline  outline;
 
-    AF_ScriptClass  sc = AF_SCRIPT_CLASSES_GET[metrics->root.script];
+    AF_StyleClass  sc = metrics->root.style_class;
 
     AF_Blue_Stringset         bss = sc->blue_stringset;
     const AF_Blue_StringRec*  bs  = &af_blue_stringsets[bss];
@@ -250,9 +251,9 @@
 #endif
 
 
-    /* we walk over the blue character strings as specified in the    */
-    /* script's entry in the `af_blue_stringset' array, computing its */
-    /* extremum points (depending on the string properties)           */
+    /* we walk over the blue character strings as specified in the   */
+    /* style's entry in the `af_blue_stringset' array, computing its */
+    /* extremum points (depending on the string properties)          */
 
     FT_TRACE5(( "cjk blue zones computation\n"
                 "==========================\n"
@@ -1669,9 +1670,9 @@
 #endif
 
 
-    FT_TRACE5(( "cjk %s edge hinting (script `%s')\n",
+    FT_TRACE5(( "cjk %s edge hinting (style `%s')\n",
                 dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
-                af_script_names[hints->metrics->script] ));
+                af_style_names[hints->metrics->style_class->style] ));
 
     /* we begin by aligning all stems relative to the blue zone */
 
diff --git a/src/autofit/afdummy.h b/src/autofit/afdummy.h
index 75efd94..ad1b0d3 100644
--- a/src/autofit/afdummy.h
+++ b/src/autofit/afdummy.h
@@ -25,9 +25,7 @@
 
 FT_BEGIN_HEADER
 
- /*  A dummy writing system and script class used when no hinting should be
-  *  performed.
-  */
+  /* A dummy writing system used when no hinting should be performed. */
 
   AF_DECLARE_WRITING_SYSTEM_CLASS( af_dummy_writing_system_class )
 
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index e3bbdb9..d19ce88 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -45,12 +45,10 @@
 
 
 #undef  SCRIPT
-#define SCRIPT( s, S, d, ss, ws, dc )  \
+#define SCRIPT( s, S, d, dc )          \
           AF_DEFINE_SCRIPT_CLASS(      \
             af_ ## s ## _script_class, \
             AF_SCRIPT_ ## S,           \
-            ss,                        \
-            ws,                        \
             af_ ## s ## _uniranges,    \
             dc )
 
@@ -58,7 +56,7 @@
 
 
 #undef  SCRIPT
-#define SCRIPT( s, S, d, ss, ws, dc ) \
+#define SCRIPT( s, S, d, dc )         \
           &af_ ## s ## _script_class,
 
   FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
@@ -70,29 +68,55 @@
     NULL  /* do not remove */
   };
 
+
+#undef  STYLE
+#define STYLE( s, S, d, ws, sc, ss )  \
+          AF_DEFINE_STYLE_CLASS(      \
+            af_ ## s ## _style_class, \
+            AF_STYLE_ ## S,           \
+            ws,                       \
+            sc,                       \
+            ss )
+
+#include "afstyles.h"
+
+
+#undef  STYLE
+#define STYLE( s, S, d, ws, sc, ss ) \
+          &af_ ## s ## _style_class,
+
+  FT_LOCAL_ARRAY_DEF( AF_StyleClass )
+  af_style_classes[] =
+  {
+
+#include "afstyles.h"
+
+    NULL  /* do not remove */
+  };
+
 #endif /* !FT_CONFIG_OPTION_PIC */
 
 
 #ifdef FT_DEBUG_LEVEL_TRACE
 
-#undef  SCRIPT
-#define SCRIPT( s, S, d, ss, ws, dc )  #s,
+#undef  STYLE
+#define STYLE( s, S, d, ws, sc, ss )  #s,
 
   FT_LOCAL_ARRAY_DEF( char* )
-  af_script_names[] =
+  af_style_names[] =
   {
 
-#include "afscript.h"
+#include "afstyles.h"
 
   };
 
 #endif /* FT_DEBUG_LEVEL_TRACE */
 
 
-  /* Compute the script index of each glyph within a given face. */
+  /* Compute the style index of each glyph within a given face. */
 
   static FT_Error
-  af_face_globals_compute_script_coverage( AF_FaceGlobals  globals )
+  af_face_globals_compute_style_coverage( AF_FaceGlobals  globals )
   {
     FT_Error    error;
     FT_Face     face        = globals->face;
@@ -102,9 +126,9 @@
     FT_UInt     i;
 
 
-    /* the value AF_SCRIPT_UNASSIGNED means `uncovered glyph' */
+    /* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
     FT_MEM_SET( globals->glyph_styles,
-                AF_SCRIPT_UNASSIGNED,
+                AF_STYLE_UNASSIGNED,
                 globals->glyph_count );
 
     error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
@@ -118,10 +142,13 @@
       goto Exit;
     }
 
-    /* scan each script in a Unicode charmap */
-    for ( ss = 0; AF_SCRIPT_CLASSES_GET[ss]; ss++ )
+    /* scan each style in a Unicode charmap */
+    for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
     {
-      AF_ScriptClass      script_class = AF_SCRIPT_CLASSES_GET[ss];
+      AF_StyleClass       style_class =
+                            AF_STYLE_CLASSES_GET[ss];
+      AF_ScriptClass      script_class =
+                            AF_SCRIPT_CLASSES_GET[style_class->script];
       AF_Script_UniRange  range;
 
 
@@ -130,7 +157,7 @@
 
       /*
        *  Scan all Unicode points in the range and set the corresponding
-       *  glyph script index.
+       *  glyph style index.
        */
       for ( range = script_class->script_uni_ranges;
             range->first != 0;
@@ -144,7 +171,7 @@
 
         if ( gindex != 0                             &&
              gindex < (FT_ULong)globals->glyph_count &&
-             gstyles[gindex] == AF_SCRIPT_UNASSIGNED )
+             gstyles[gindex] == AF_STYLE_UNASSIGNED  )
           gstyles[gindex] = (FT_Byte)ss;
 
         for (;;)
@@ -155,7 +182,7 @@
             break;
 
           if ( gindex < (FT_ULong)globals->glyph_count &&
-               gstyles[gindex] == AF_SCRIPT_UNASSIGNED )
+               gstyles[gindex] == AF_STYLE_UNASSIGNED  )
             gstyles[gindex] = (FT_Byte)ss;
         }
       }
@@ -176,16 +203,16 @@
      *  By default, all uncovered glyphs are set to the fallback script.
      *  XXX: Shouldn't we disable hinting or do something similar?
      */
-    if ( globals->module->fallback_script != AF_SCRIPT_UNASSIGNED )
+    if ( globals->module->fallback_script != AF_STYLE_UNASSIGNED )
     {
       FT_Long  nn;
 
 
       for ( nn = 0; nn < globals->glyph_count; nn++ )
       {
-        if ( ( gstyles[nn] & ~AF_DIGIT ) == AF_SCRIPT_UNASSIGNED )
+        if ( ( gstyles[nn] & ~AF_DIGIT ) == AF_STYLE_UNASSIGNED )
         {
-          gstyles[nn] &= ~AF_SCRIPT_UNASSIGNED;
+          gstyles[nn] &= ~AF_STYLE_UNASSIGNED;
           gstyles[nn] |= globals->module->fallback_script;
         }
       }
@@ -217,7 +244,7 @@
     globals->glyph_styles = (FT_Byte*)( globals + 1 );
     globals->module       = module;
 
-    error = af_face_globals_compute_script_coverage( globals );
+    error = af_face_globals_compute_style_coverage( globals );
     if ( error )
     {
       af_face_globals_free( globals );
@@ -241,14 +268,14 @@
       FT_UInt    nn;
 
 
-      for ( nn = 0; nn < AF_SCRIPT_MAX; nn++ )
+      for ( nn = 0; nn < AF_STYLE_MAX; nn++ )
       {
         if ( globals->metrics[nn] )
         {
-          AF_ScriptClass         script_class =
-            AF_SCRIPT_CLASSES_GET[nn];
+          AF_StyleClass          style_class =
+            AF_STYLE_CLASSES_GET[nn];
           AF_WritingSystemClass  writing_system_class =
-            AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
+            AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
 
 
           if ( writing_system_class->style_metrics_done )
@@ -275,9 +302,9 @@
   {
     AF_StyleMetrics  metrics = NULL;
 
-    AF_Script              script = (AF_Script)( options & 15 );
+    AF_Style               style = (AF_Style)( options & 15 );
     AF_WritingSystemClass  writing_system_class;
-    AF_ScriptClass         script_class;
+    AF_StyleClass          style_class;
 
     FT_Error  error = FT_Err_Ok;
 
@@ -288,17 +315,17 @@
       goto Exit;
     }
 
-    /* if we have a forced script (via `options'), use it, */
-    /* otherwise look into `glyph_styles' array            */
-    if ( script == AF_SCRIPT_NONE || script + 1 >= AF_SCRIPT_MAX )
-      script = (AF_Script)( globals->glyph_styles[gindex] &
-                            AF_SCRIPT_UNASSIGNED          );
+    /* if we have a forced style (via `options'), use it, */
+    /* otherwise look into `glyph_styles' array           */
+    if ( style == AF_STYLE_NONE_DEFAULT || style + 1 >= AF_STYLE_MAX )
+      style = (AF_Style)( globals->glyph_styles[gindex] &
+                          AF_STYLE_UNASSIGNED           );
 
-    script_class         = AF_SCRIPT_CLASSES_GET[script];
+    style_class          = AF_STYLE_CLASSES_GET[style];
     writing_system_class = AF_WRITING_SYSTEM_CLASSES_GET
-                             [script_class->writing_system];
+                             [style_class->writing_system];
 
-    metrics = globals->metrics[script];
+    metrics = globals->metrics[style];
     if ( metrics == NULL )
     {
       /* create the global metrics object if necessary */
@@ -308,8 +335,8 @@
       if ( FT_ALLOC( metrics, writing_system_class->style_metrics_size ) )
         goto Exit;
 
-      metrics->script  = script;
-      metrics->globals = globals;
+      metrics->style_class = style_class;
+      metrics->globals     = globals;
 
       if ( writing_system_class->style_metrics_init )
       {
@@ -325,7 +352,7 @@
         }
       }
 
-      globals->metrics[script] = metrics;
+      globals->metrics[style] = metrics;
     }
 
   Exit:
diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h
index cc0ed2d..c4fcc54 100644
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -32,7 +32,7 @@ FT_BEGIN_HEADER
   af_writing_system_classes[];
 
 #undef  SCRIPT
-#define SCRIPT( s, S, d, ss, ws, dc )                          \
+#define SCRIPT( s, S, d, dc )                                  \
           AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class )
 
 #include "afscript.h"
@@ -40,24 +40,36 @@ FT_BEGIN_HEADER
   FT_LOCAL_ARRAY( AF_ScriptClass )
   af_script_classes[];
 
+
+#undef  STYLE
+#define STYLE( s, S, d, ws, sc, ss )                         \
+          AF_DECLARE_STYLE_CLASS( af_ ## s ## _style_class )
+
+#include "afstyles.h"
+
+  FT_LOCAL_ARRAY( AF_StyleClass )
+  af_style_classes[];
+
+
 #ifdef FT_DEBUG_LEVEL_TRACE
   FT_LOCAL_ARRAY( char* )
-  af_script_names[];
+  af_style_names[];
 #endif
 
+
   /*
    *  Default values and flags for both autofitter globals (found in
    *  AF_ModuleRec) and face globals (in AF_FaceGlobalsRec).
    */
 
-  /* index of fallback script in `af_script_classes' */
+  /* index of fallback script in `af_style_classes' */
 #ifdef AF_CONFIG_OPTION_CJK
-#define AF_SCRIPT_FALLBACK  AF_SCRIPT_HANI
+#define AF_SCRIPT_FALLBACK  AF_STYLE_HANI_DEFAULT
 #else
-#define AF_SCRIPT_FALLBACK  AF_SCRIPT_NONE
+#define AF_SCRIPT_FALLBACK  AF_STYLE_NONE_DEFAULT
 #endif
   /* a bit mask indicating an uncovered glyph        */
-#define AF_SCRIPT_UNASSIGNED  0x7F
+#define AF_STYLE_UNASSIGNED  0x7F
   /* if this flag is set, we have an ASCII digit     */
 #define AF_DIGIT              0x80
 
@@ -77,7 +89,7 @@ FT_BEGIN_HEADER
 
   /*
    *  Note that glyph_styles[] maps each glyph to an index into the
-   *  `af_script_classes' array.
+   *  `af_style_classes' array.
    *
    */
   typedef struct  AF_FaceGlobalsRec_
@@ -89,7 +101,7 @@ FT_BEGIN_HEADER
     /* per-face auto-hinter properties */
     FT_UInt          increase_x_height;
 
-    AF_StyleMetrics  metrics[AF_SCRIPT_MAX];
+    AF_StyleMetrics  metrics[AF_STYLE_MAX];
 
     AF_Module        module;         /* to access global properties */
 
@@ -98,7 +110,7 @@ FT_BEGIN_HEADER
 
   /*
    *  model the global hints data for a given face, decomposed into
-   *  script-specific items
+   *  style-specific items
    */
 
   FT_LOCAL( FT_Error )
diff --git a/src/autofit/afhints.h b/src/autofit/afhints.h
index 34a76a8..5f1507f 100644
--- a/src/autofit/afhints.h
+++ b/src/autofit/afhints.h
@@ -27,7 +27,7 @@ FT_BEGIN_HEADER
 
   /*
    *  The definition of outline glyph hints.  These are shared by all
-   *  script analysis routines (until now).
+   *  writing system analysis routines (until now).
    */
 
   typedef enum  AF_Dimension_
@@ -361,9 +361,9 @@ FT_BEGIN_HEADER
 
     AF_AxisHintsRec  axis[AF_DIMENSION_MAX];
 
-    FT_UInt32        scaler_flags;  /* copy of scaler flags     */
-    FT_UInt32        other_flags;   /* free for script-specific */
-                                    /* implementations          */
+    FT_UInt32        scaler_flags;  /* copy of scaler flags    */
+    FT_UInt32        other_flags;   /* free for style-specific */
+                                    /* implementations         */
     AF_StyleMetrics  metrics;
 
     FT_Pos           xmin_delta;    /* used for warping */
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index e42c305..ae20f7b 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -62,10 +62,10 @@
 
 
     FT_TRACE5(( "\n"
-                "latin standard widths computation (script `%s')\n"
-                "=================================================\n"
+                "latin standard widths computation (style `%s')\n"
+                "================================================\n"
                 "\n",
-                af_script_names[metrics->root.script] ));
+                af_style_names[metrics->root.style_class->style] ));
 
     af_glyph_hints_init( hints, face->memory );
 
@@ -79,8 +79,9 @@
       AF_LatinMetricsRec  dummy[1];
       AF_Scaler           scaler = &dummy->root.scaler;
 
-      AF_ScriptClass      script_class =
-                            AF_SCRIPT_CLASSES_GET[metrics->root.script];
+      AF_StyleClass   style_class  = metrics->root.style_class;
+      AF_ScriptClass  script_class = AF_SCRIPT_CLASSES_GET
+                                       [style_class->script];
 
 
       glyph_index = FT_Get_Char_Index( face, script_class->standard_char );
@@ -216,14 +217,14 @@
     AF_LatinAxis  axis = &metrics->axis[AF_DIMENSION_VERT];
     FT_Outline    outline;
 
-    AF_ScriptClass  sc = AF_SCRIPT_CLASSES_GET[metrics->root.script];
+    AF_StyleClass  sc = metrics->root.style_class;
 
     AF_Blue_Stringset         bss = sc->blue_stringset;
     const AF_Blue_StringRec*  bs  = &af_blue_stringsets[bss];
 
 
-    /* we walk over the blue character strings as specified in the  */
-    /* script's entry in the `af_blue_stringset' array              */
+    /* we walk over the blue character strings as specified in the */
+    /* style's entry in the `af_blue_stringset' array              */
 
     FT_TRACE5(( "latin blue zones computation\n"
                 "============================\n"
@@ -883,11 +884,11 @@
 
             FT_TRACE5((
               "af_latin_metrics_scale_dim:"
-              " x height alignment (script `%s'):\n"
+              " x height alignment (style `%s'):\n"
               "                           "
               " vertical scaling changed from %.4f to %.4f (by %d%%)\n"
               "\n",
-              af_script_names[metrics->root.script],
+              af_style_names[metrics->root.style_class->style],
               axis->org_scale / 65536.0,
               scale / 65536.0,
               ( fitted - scaled ) * 100 / scaled ));
@@ -910,9 +911,9 @@
       metrics->root.scaler.y_delta = delta;
     }
 
-    FT_TRACE5(( "%s widths (script `%s')\n",
+    FT_TRACE5(( "%s widths (style `%s')\n",
                 dim == AF_DIMENSION_HORZ ? "horizontal" : "vertical",
-                af_script_names[metrics->root.script] ));
+                af_style_names[metrics->root.style_class->style] ));
 
     /* scale the widths */
     for ( nn = 0; nn < axis->width_count; nn++ )
@@ -937,15 +938,15 @@
 
 #ifdef FT_DEBUG_LEVEL_TRACE
     if ( axis->extra_light )
-      FT_TRACE5(( "`%s' script is extra light (at current resolution)\n"
+      FT_TRACE5(( "`%s' style is extra light (at current resolution)\n"
                   "\n",
-                  af_script_names[metrics->root.script] ));
+                  af_style_names[metrics->root.style_class->style] ));
 #endif
 
     if ( dim == AF_DIMENSION_VERT )
     {
-      FT_TRACE5(( "blue zones (script `%s')\n",
-                  af_script_names[metrics->root.script] ));
+      FT_TRACE5(( "blue zones (style `%s')\n",
+                  af_style_names[metrics->root.style_class->style] ));
 
       /* scale the blue zones */
       for ( nn = 0; nn < axis->blue_count; nn++ )
@@ -2152,9 +2153,9 @@
 #endif
 
 
-    FT_TRACE5(( "latin %s edge hinting (script `%s')\n",
+    FT_TRACE5(( "latin %s edge hinting (style `%s')\n",
                 dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
-                af_script_names[hints->metrics->script] ));
+                af_style_names[hints->metrics->style_class->style] ));
 
     /* we begin by aligning all stems relative to the blue zone */
     /* if needed -- that's only for horizontal edges            */
diff --git a/src/autofit/aflatin.h b/src/autofit/aflatin.h
index 99c4482..a958af3 100644
--- a/src/autofit/aflatin.h
+++ b/src/autofit/aflatin.h
@@ -46,8 +46,8 @@ FT_BEGIN_HEADER
 
   /*
    *  The following declarations could be embedded in the file `aflatin.c';
-   *  they have been made semi-public to allow alternate script hinters to
-   *  re-use some of them.
+   *  they have been made semi-public to allow alternate writing system
+   *  hinters to re-use some of them.
    */
 
 
@@ -161,7 +161,7 @@ FT_BEGIN_HEADER
 
   /*
    *  The next functions shouldn't normally be exported.  However, other
-   *  scripts might like to use these functions as-is.
+   *  writing systems might like to use these functions as-is.
    */
   FT_LOCAL( FT_Error )
   af_latin_hints_compute_segments( AF_GlyphHints  hints,
diff --git a/src/autofit/aflatin2.c b/src/autofit/aflatin2.c
index e3d17ac..930fa98 100644
--- a/src/autofit/aflatin2.c
+++ b/src/autofit/aflatin2.c
@@ -78,7 +78,7 @@
 
       glyph_index = FT_Get_Char_Index(
                       face,
-                      metrics->root.script_class->standard_char );
+                      metrics->root.style_class->standard_char );
       if ( glyph_index == 0 )
         goto Exit;
 
@@ -2396,41 +2396,4 @@
   )
 
 
-  /* XXX: this should probably fine tuned to differentiate better between */
-  /*      scripts...                                                      */
-
-  static const AF_Script_UniRangeRec  af_ltn2_uniranges[] =
-  {
-    AF_UNIRANGE_REC(  0x0020UL,  0x007FUL ),  /* Basic Latin (no control chars) */
-    AF_UNIRANGE_REC(  0x00A0UL,  0x00FFUL ),  /* Latin-1 Supplement (no control chars) */
-    AF_UNIRANGE_REC(  0x0100UL,  0x017FUL ),  /* Latin Extended-A */
-    AF_UNIRANGE_REC(  0x0180UL,  0x024FUL ),  /* Latin Extended-B */
-    AF_UNIRANGE_REC(  0x0250UL,  0x02AFUL ),  /* IPA Extensions */
-    AF_UNIRANGE_REC(  0x02B0UL,  0x02FFUL ),  /* Spacing Modifier Letters */
-    AF_UNIRANGE_REC(  0x0300UL,  0x036FUL ),  /* Combining Diacritical Marks */
-    AF_UNIRANGE_REC(  0x0370UL,  0x03FFUL ),  /* Greek and Coptic */
-    AF_UNIRANGE_REC(  0x0400UL,  0x04FFUL ),  /* Cyrillic */
-    AF_UNIRANGE_REC(  0x0500UL,  0x052FUL ),  /* Cyrillic Supplement */
-    AF_UNIRANGE_REC(  0x1D00UL,  0x1D7FUL ),  /* Phonetic Extensions */
-    AF_UNIRANGE_REC(  0x1D80UL,  0x1DBFUL ),  /* Phonetic Extensions Supplement */
-    AF_UNIRANGE_REC(  0x1DC0UL,  0x1DFFUL ),  /* Combining Diacritical Marks Supplement */
-    AF_UNIRANGE_REC(  0x1E00UL,  0x1EFFUL ),  /* Latin Extended Additional */
-    AF_UNIRANGE_REC(  0x1F00UL,  0x1FFFUL ),  /* Greek Extended */
-    AF_UNIRANGE_REC(  0x2000UL,  0x206FUL ),  /* General Punctuation */
-    AF_UNIRANGE_REC(  0x2070UL,  0x209FUL ),  /* Superscripts and Subscripts */
-    AF_UNIRANGE_REC(  0x20A0UL,  0x20CFUL ),  /* Currency Symbols */
-    AF_UNIRANGE_REC(  0x2150UL,  0x218FUL ),  /* Number Forms */
-    AF_UNIRANGE_REC(  0x2460UL,  0x24FFUL ),  /* Enclosed Alphanumerics */
-    AF_UNIRANGE_REC(  0x2C60UL,  0x2C7FUL ),  /* Latin Extended-C */
-    AF_UNIRANGE_REC(  0x2DE0UL,  0x2DFFUL ),  /* Cyrillic Extended-A */
-    AF_UNIRANGE_REC(  0x2E00UL,  0x2E7FUL ),  /* Supplemental Punctuation */
-    AF_UNIRANGE_REC(  0xA640UL,  0xA69FUL ),  /* Cyrillic Extended-B */
-    AF_UNIRANGE_REC(  0xA720UL,  0xA7FFUL ),  /* Latin Extended-D */
-    AF_UNIRANGE_REC(  0xFB00UL,  0xFB06UL ),  /* Alphab. Present. Forms (Latin Ligs) */
-    AF_UNIRANGE_REC( 0x1D400UL, 0x1D7FFUL ),  /* Mathematical Alphanumeric Symbols */
-    AF_UNIRANGE_REC( 0x1F100UL, 0x1F1FFUL ),  /* Enclosed Alphanumeric Supplement */
-    AF_UNIRANGE_REC(       0UL,       0UL )
-  };
-
-
 /* END */
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 284664f..80c3950 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -185,10 +185,9 @@
 #ifdef FT_CONFIG_OPTION_PIC
         AF_FaceGlobals         globals = loader->globals;
 #endif
-        AF_ScriptClass         script_class =
-          AF_SCRIPT_CLASSES_GET[metrics->script];
+        AF_StyleClass          style_class = metrics->style_class;
         AF_WritingSystemClass  writing_system_class =
-          AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
+          AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
 
 
         if ( writing_system_class->style_hints_apply )
@@ -531,13 +530,13 @@
     if ( !error )
     {
       AF_StyleMetrics  metrics;
-      FT_UInt          options = AF_SCRIPT_NONE;
+      FT_UInt          options = AF_STYLE_NONE_DEFAULT;
 
 
 #ifdef FT_OPTION_AUTOFIT2
       /* XXX: undocumented hook to activate the latin2 writing system */
       if ( load_flags & ( 1UL << 20 ) )
-        options = AF_SCRIPT_LTN2;
+        options = AF_STYLE_LTN2_DEFAULT;
 #endif
 
       error = af_face_globals_get_metrics( loader->globals, gindex,
@@ -547,10 +546,9 @@
 #ifdef FT_CONFIG_OPTION_PIC
         AF_FaceGlobals         globals = loader->globals;
 #endif
-        AF_ScriptClass         script_class =
-          AF_SCRIPT_CLASSES_GET[metrics->script];
+        AF_StyleClass          style_class = metrics->style_class;
         AF_WritingSystemClass  writing_system_class =
-          AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
+          AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
 
 
         loader->metrics = metrics;
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index 0389a4e..1ebe4a4 100644
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -60,8 +60,8 @@
     globals = (AF_FaceGlobals)face->autohint.data;
     if ( !globals )
     {
-      /* trigger computation of the global script data */
-      /* in case it hasn't been done yet               */
+      /* trigger computation of the global style data */
+      /* in case it hasn't been done yet              */
       error = af_face_globals_new( face, &globals, module );
       if ( !error )
       {
diff --git a/src/autofit/afpic.c b/src/autofit/afpic.c
index 997f216..2d66d76 100644
--- a/src/autofit/afpic.c
+++ b/src/autofit/afpic.c
@@ -42,7 +42,7 @@
     FT_AutoHinter_InterfaceRec*  clazz );
 
 
-  /* forward declaration of PIC init functions from script classes */
+  /* forward declaration of PIC init functions from writing system classes */
 #undef  WRITING_SYSTEM
 #define WRITING_SYSTEM( ws, WS )  /* empty */
 
@@ -107,6 +107,11 @@
         &container->af_script_classes_rec[ss];
     container->af_script_classes[AF_SCRIPT_MAX - 1] = NULL;
 
+    for ( ss = 0; ss < AF_STYLE_MAX - 1; ss++ )
+      container->af_style_classes[ss] =
+        &container->af_style_classes_rec[ss];
+    container->af_style_classes[AF_STYLE_MAX - 1] = NULL;
+
 #undef  WRITING_SYSTEM
 #define WRITING_SYSTEM( ws, WS )                             \
         FT_Init_Class_af_ ## ws ## _writing_system_class(    \
@@ -116,13 +121,21 @@
 #include "afwrtsys.h"
 
 #undef  SCRIPT
-#define SCRIPT( s, S, d, ss, ws, dc )                \
+#define SCRIPT( s, S, d, dc )                        \
         FT_Init_Class_af_ ## s ## _script_class(     \
           &container->af_script_classes_rec[ss++] );
 
     ss = 0;
 #include "afscript.h"
 
+#undef  STYLE
+#define STYLE( s, S, d, ws, sc, ss )                \
+        FT_Init_Class_af_ ## s ## _style_class(     \
+          &container->af_style_classes_rec[ss++] );
+
+    ss = 0;
+#include "afstyles.h"
+
     FT_Init_Class_af_autofitter_interface(
       library, &container->af_autofitter_interface );
 
diff --git a/src/autofit/afpic.h b/src/autofit/afpic.h
index 09f8258..951628f 100644
--- a/src/autofit/afpic.h
+++ b/src/autofit/afpic.h
@@ -32,6 +32,7 @@ FT_BEGIN_HEADER
 
 #define AF_WRITING_SYSTEM_CLASSES_GET  af_writing_system_classes
 #define AF_SCRIPT_CLASSES_GET          af_script_classes
+#define AF_STYLE_CLASSES_GET           af_style_classes
 #define AF_INTERFACE_GET               af_autofitter_interface
 
 #else /* FT_CONFIG_OPTION_PIC */
@@ -57,6 +58,11 @@ FT_BEGIN_HEADER
     AF_ScriptClassRec           af_script_classes_rec
                                   [AF_SCRIPT_MAX - 1];
 
+    AF_StyleClass               af_style_classes
+                                  [AF_STYLE_MAX];
+    AF_StyleClassRec            af_style_classes_rec
+                                  [AF_STYLE_MAX - 1];
+
     FT_AutoHinter_InterfaceRec  af_autofitter_interface;
 
   } AFModulePIC;
@@ -74,6 +80,8 @@ FT_BEGIN_HEADER
           ( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_writing_system_classes )
 #define AF_SCRIPT_CLASSES_GET  \
           ( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_script_classes )
+#define AF_STYLE_CLASSES_GET  \
+          ( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_style_classes )
 #define AF_INTERFACE_GET  \
           ( GET_PIC( library )->af_autofitter_interface )
 
diff --git a/src/autofit/afranges.h b/src/autofit/afranges.h
index 99d2799..8869695 100644
--- a/src/autofit/afranges.h
+++ b/src/autofit/afranges.h
@@ -26,7 +26,7 @@
 FT_BEGIN_HEADER
 
 #undef  SCRIPT
-#define SCRIPT( s, S, d, ss, ws, dc ) \
+#define SCRIPT( s, S, d, dc )                                           \
           extern const AF_Script_UniRangeRec  af_ ## s ## _uniranges[];
 
 #include "afscript.h"
diff --git a/src/autofit/afscript.h b/src/autofit/afscript.h
index 7b93fdf..063f2af 100644
--- a/src/autofit/afscript.h
+++ b/src/autofit/afscript.h
@@ -24,53 +24,31 @@
 
   SCRIPT( cyrl, CYRL,
           "Cyrillic",
-          AF_BLUE_STRINGSET_CYRL,
-          AF_WRITING_SYSTEM_LATIN,
           0x43E ) /* о */
 
   SCRIPT( deva, DEVA,
           "Indic scripts",
-          (AF_Blue_Stringset)0, /* XXX */
-          AF_WRITING_SYSTEM_INDIC,
           'o' ) /* XXX */
 
   SCRIPT( none, NONE,
           "no script",
-          (AF_Blue_Stringset)0,
-          AF_WRITING_SYSTEM_DUMMY,
           '\0' )
 
   SCRIPT( grek, GREK,
           "Greek",
-          AF_BLUE_STRINGSET_GREK,
-          AF_WRITING_SYSTEM_LATIN,
           0x3BF ) /* ο */
 
   SCRIPT( hani, HANI,
           "CJKV ideographs",
-          AF_BLUE_STRINGSET_HANI,
-          AF_WRITING_SYSTEM_CJK,
           0x7530 ) /* 田 */
 
   SCRIPT( hebr, HEBR,
           "Hebrew",
-          AF_BLUE_STRINGSET_HEBR,
-          AF_WRITING_SYSTEM_LATIN,
           0x5DD ) /* ם */
 
   SCRIPT( latn, LATN,
           "Latin",
-          AF_BLUE_STRINGSET_LATN,
-          AF_WRITING_SYSTEM_LATIN,
           'o' )
 
-#ifdef FT_OPTION_AUTOFIT2
-  SCRIPT( ltn2, LTN2,
-          "Latin 2",
-          AF_BLUE_STRINGSET_LATN,
-          AF_WRITING_SYSTEM_LATIN2,
-          'o' )
-#endif
-
 
 /* END */
diff --git a/src/autofit/afstyles.h b/src/autofit/afstyles.h
new file mode 100644
index 0000000..ded8048
--- /dev/null
+++ b/src/autofit/afstyles.h
@@ -0,0 +1,76 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afstyles.h                                                             */
+/*                                                                         */
+/*    Auto-fitter styles (specification only).                             */
+/*                                                                         */
+/*  Copyright 2013 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /* The following part can be included multiple times. */
+  /* Define `STYLE' as needed.                          */
+
+
+  /* Add new styles here. */
+
+  STYLE( cyrl_default, CYRL_DEFAULT,
+         "Cyrillic default style",
+         AF_WRITING_SYSTEM_LATIN,
+         AF_SCRIPT_CYRL,
+         AF_BLUE_STRINGSET_CYRL )
+
+  STYLE( deva_default, DEVA_DEFAULT,
+         "Indic scripts default style",
+         AF_WRITING_SYSTEM_INDIC,
+         AF_SCRIPT_DEVA,
+         (AF_Blue_Stringset)0 ) /* XXX */
+
+  STYLE( none_default, NONE_DEFAULT,
+         "no style",
+         AF_WRITING_SYSTEM_DUMMY,
+         AF_SCRIPT_NONE,
+         (AF_Blue_Stringset)0 )
+
+  STYLE( grek_default, GREK_DEFAULT,
+         "Greek default style",
+         AF_WRITING_SYSTEM_LATIN,
+         AF_SCRIPT_GREK,
+         AF_BLUE_STRINGSET_GREK )
+
+  STYLE( hani_default, HANI_DEFAULT,
+         "CJKV ideographs default style",
+         AF_WRITING_SYSTEM_CJK,
+         AF_SCRIPT_HANI,
+         AF_BLUE_STRINGSET_HANI )
+
+  STYLE( hebr_default, HEBR_DEFAULT,
+         "Hebrew default style",
+         AF_WRITING_SYSTEM_LATIN,
+         AF_SCRIPT_HEBR,
+         AF_BLUE_STRINGSET_HEBR )
+
+  STYLE( latn_default, LATN_DEFAULT,
+         "Latin default style",
+         AF_WRITING_SYSTEM_LATIN,
+         AF_SCRIPT_LATN,
+         AF_BLUE_STRINGSET_LATN )
+
+#ifdef FT_OPTION_AUTOFIT2
+  STYLE( ltn2_default, LTN2_DEFAULT,
+         "Latin 2 default style",
+         AF_WRITING_SYSTEM_LATIN2,
+         AF_SCRIPT_LATN,
+         AF_BLUE_STRINGSET_LATN )
+#endif
+
+
+/* END */
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index 8ca708c..b913ee1 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -20,7 +20,7 @@
    *
    *  The auto-fitter is a complete rewrite of the old auto-hinter.
    *  Its main feature is the ability to differentiate between different
-   *  writing systems in order to apply script-specific rules.
+   *  writing systems and scripts in order to apply specific rules.
    *
    *  The code has also been compartmentized into several entities that
    *  should make algorithmic experimentation easier than with the old
@@ -200,7 +200,7 @@ extern void*  _af_debug_hints;
   typedef struct AF_StyleMetricsRec_*  AF_StyleMetrics;
 
   /*  This function parses an FT_Face to compute global metrics for
-   *  a specific script.
+   *  a specific style.
    */
   typedef FT_Error
   (*AF_WritingSystem_InitMetricsFunc)( AF_StyleMetrics  metrics,
@@ -296,14 +296,14 @@ extern void*  _af_debug_hints;
 
   /*
    *  Each script is associated with a set of Unicode ranges that gets used
-   *  to test whether the font face supports the script.  It also references
-   *  the writing system it belongs to.
+   *  to test whether the font face supports the script.
    *
-   *  We use four-letter script tags from the OpenType specification.
+   *  We use four-letter script tags from the OpenType specification,
+   *  extended by `NONE', which indicates `no script'.
    */
 
 #undef  SCRIPT
-#define SCRIPT( s, S, d, ss, ws, dc ) \
+#define SCRIPT( s, S, d, dc ) \
           AF_SCRIPT_ ## S,
 
   /* The list of known scripts. */
@@ -331,9 +331,7 @@ extern void*  _af_debug_hints;
 
   typedef struct  AF_ScriptClassRec_
   {
-    AF_Script          script;
-    AF_Blue_Stringset  blue_stringset;
-    AF_WritingSystem   writing_system;
+    AF_Script  script;
 
     AF_Script_UniRange  script_uni_ranges; /* last must be { 0, 0 }        */
     FT_UInt32           standard_char;     /* for default width and height */
@@ -346,6 +344,47 @@ extern void*  _af_debug_hints;
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
+  /*****                         S T Y L E S                           *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+  /*
+   *  The topmost structure for modelling the auto-hinter glyph input data
+   *  is a `style class', grouping everything together.
+   */
+
+#undef  STYLE
+#define STYLE( s, S, d, ws, sc, ss ) \
+          AF_STYLE_ ## S,
+
+  /* The list of known styles. */
+  typedef enum  AF_Style_
+  {
+
+#include "afstyles.h"
+
+    AF_STYLE_MAX   /* do not remove */
+
+  } AF_Style;
+
+
+  typedef struct  AF_StyleClassRec_
+  {
+    AF_Style  style;
+
+    AF_WritingSystem   writing_system;
+    AF_Script          script;
+    AF_Blue_Stringset  blue_stringset;
+
+  } AF_StyleClassRec;
+
+  typedef const AF_StyleClassRec*  AF_StyleClass;
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
   /*****                   S T Y L E   M E T R I C S                   *****/
   /*****                                                               *****/
   /*************************************************************************/
@@ -359,7 +398,7 @@ extern void*  _af_debug_hints;
 
   typedef struct  AF_StyleMetricsRec_
   {
-    AF_Script       script;
+    AF_StyleClass   style_class;
     AF_ScalerRec    scaler;
     FT_Bool         digits_have_same_width;
 
@@ -406,21 +445,37 @@ extern void*  _af_debug_hints;
 
 #define AF_DEFINE_SCRIPT_CLASS(           \
           script_class,                   \
-          script_,                        \
-          blue_stringset_,                \
-          writing_system_,                \
+          script,                         \
           ranges,                         \
           std_char )                      \
   FT_CALLBACK_TABLE_DEF                   \
   const AF_ScriptClassRec  script_class = \
   {                                       \
-    script_,                              \
-    blue_stringset_,                      \
-    writing_system_,                      \
+    script,                               \
     ranges,                               \
     std_char                              \
   };
 
+
+#define AF_DECLARE_STYLE_CLASS( style_class ) \
+  FT_CALLBACK_TABLE const AF_StyleClassRec    \
+  style_class;
+
+#define AF_DEFINE_STYLE_CLASS(          \
+          style_class,                  \
+          style,                        \
+          writing_system,               \
+          script,                       \
+          blue_stringset )              \
+  FT_CALLBACK_TABLE_DEF                 \
+  const AF_StyleClassRec  style_class = \
+  {                                     \
+    style,                              \
+    writing_system,                     \
+    script,                             \
+    blue_stringset                      \
+  };
+
 #else /* FT_CONFIG_OPTION_PIC */
 
 #define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class )            \
@@ -458,21 +513,37 @@ extern void*  _af_debug_hints;
 
 #define AF_DEFINE_SCRIPT_CLASS(                            \
           script_class,                                    \
-          script_,                                         \
-          blue_string_set_,                                \
-          writing_system_,                                 \
+          script,                                          \
           ranges,                                          \
           std_char )                                       \
   FT_LOCAL_DEF( void )                                     \
   FT_Init_Class_ ## script_class( AF_ScriptClassRec*  ac ) \
   {                                                        \
-    ac->script            = script_;                       \
-    ac->blue_stringset    = blue_stringset_;               \
-    ac->writing_system    = writing_system_;               \
+    ac->script            = script;                        \
     ac->script_uni_ranges = ranges;                        \
     ac->standard_char     = std_char;                      \
   }
 
+
+#define AF_DECLARE_STYLE_CLASS( style_class )             \
+  FT_LOCAL( void )                                        \
+  FT_Init_Class_ ## style_class( AF_StyleClassRec*  ac );
+
+#define AF_DEFINE_STYLE_CLASS(                           \
+          style_class,                                   \
+          style,                                         \
+          writing_system,                                \
+          script,                                        \
+          blue_stringset )                               \
+  FT_LOCAL_DEF( void )                                   \
+  FT_Init_Class_ ## style_class( AF_StyleClassRec*  ac ) \
+  {                                                      \
+    ac->style          = style;                          \
+    ac->writing_system = writing_system;                 \
+    ac->script         = script;                         \
+    ac->blue_stringset = blue_stringset;                 \
+  }
+
 #endif /* FT_CONFIG_OPTION_PIC */
 
 
diff --git a/src/autofit/rules.mk b/src/autofit/rules.mk
index 7bcecfc..5bf3893 100644
--- a/src/autofit/rules.mk
+++ b/src/autofit/rules.mk
@@ -44,6 +44,7 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
 AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h)  \
                $(AUTOF_DIR)/aferrors.h \
                $(AUTOF_DIR)/afscript.h \
+               $(AUTOF_DIR)/afstyles.h \
                $(AUTOF_DIR)/aftypes.h  \
                $(AUTOF_DIR)/afwrtsys.h