Commit d3cba0ed30bedaca23a2f4aab2d28d2afae7e087

Werner Lemberg 2015-09-04T10:28:53

[autofit] Redesign code ranges (2/2). This commit adds two fallback scripts (`latb', `latp') and implements support for the no-base character ranges introduced in the previous commit. * src/autofit/aftypes.h (AF_ScriptClassRec): Add `script_uni_nobase_ranges' field. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afscript.h, src/autofit/afstyles.h: Add `latb' and `latp' fallback scripts. * src/autofit/afblue.dat: Add blue zones for Latin subscript and superscript fallback scripts. * src/autofit/afblue.c, src/autofit/afblue.h: Regenerated. * src/autofit/afglobal.h (AF_NOBASE): New style flag for no-base characters. (AF_STYLE_MASK): Updated. * src/autofit/afglobal.c (SCRIPT): Updated. (af_face_globals_compute_style_coverage): Handle new style flag. * src/autofit/aflatin.c (af_latin_hints_apply): Handle new style flag. * src/autofit/afranges.h (SCRIPT): Use it to export no-base ranges.

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
diff --git a/ChangeLog b/ChangeLog
index b87bf74..977473a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,37 @@
 2015-09-04  Werner Lemberg  <wl@gnu.org>
 
+	[autofit] Redesign code ranges (2/2).
+
+	This commit adds two fallback scripts (`latb', `latp') and
+	implements support for the no-base character ranges introduced in
+	the previous commit.
+
+	* src/autofit/aftypes.h (AF_ScriptClassRec): Add
+	`script_uni_nobase_ranges' field.
+	(AF_DEFINE_SCRIPT_CLASS): Updated.
+
+	* src/autofit/afscript.h, src/autofit/afstyles.h: Add `latb' and
+	`latp' fallback scripts.
+
+	* src/autofit/afblue.dat: Add blue zones for Latin subscript and
+	superscript fallback scripts.
+
+	* src/autofit/afblue.c, src/autofit/afblue.h: Regenerated.
+
+	* src/autofit/afglobal.h (AF_NOBASE): New style flag for no-base
+	characters.
+	(AF_STYLE_MASK): Updated.
+
+	* src/autofit/afglobal.c (SCRIPT): Updated.
+	(af_face_globals_compute_style_coverage): Handle new style flag.
+
+	* src/autofit/aflatin.c (af_latin_hints_apply): Handle new style
+	flag.
+
+	* src/autofit/afranges.h (SCRIPT): Use it to export no-base ranges.
+
+2015-09-04  Werner Lemberg  <wl@gnu.org>
+
 	[autofit] Redesign code ranges (1/2).
 
 	This patch introduces auxiliary code ranges that identify no-base
diff --git a/src/autofit/afblue.c b/src/autofit/afblue.c
index 62da0f2..437fa65 100644
--- a/src/autofit/afblue.c
+++ b/src/autofit/afblue.c
@@ -74,6 +74,26 @@
     '\0',
     'p', 'q', 'g', 'j', 'y',  /* pqgjy */
     '\0',
+    '\xE2', '\x82', '\x80', '\xE2', '\x82', '\x83', '\xE2', '\x82', '\x85', '\xE2', '\x82', '\x87', '\xE2', '\x82', '\x88',  /* ₀₃₅₇₈ */
+    '\0',
+    '\xE2', '\x82', '\x80', '\xE2', '\x82', '\x81', '\xE2', '\x82', '\x82', '\xE2', '\x82', '\x83', '\xE2', '\x82', '\x88',  /* ₀₁₂₃₈ */
+    '\0',
+    '\xE1', '\xB5', '\xA2', '\xE2', '\xB1', '\xBC', '\xE2', '\x82', '\x95', '\xE2', '\x82', '\x96', '\xE2', '\x82', '\x97',  /* ᵢⱼₕₖₗ */
+    '\0',
+    '\xE2', '\x82', '\x90', '\xE2', '\x82', '\x91', '\xE2', '\x82', '\x92', '\xE2', '\x82', '\x93', '\xE2', '\x82', '\x99', '\xE2', '\x82', '\x9B', '\xE1', '\xB5', '\xA5', '\xE1', '\xB5', '\xA4', '\xE1', '\xB5', '\xA3',  /* ₐₑₒₓₙₛᵥᵤᵣ */
+    '\0',
+    '\xE1', '\xB5', '\xA6', '\xE1', '\xB5', '\xA7', '\xE1', '\xB5', '\xA8', '\xE1', '\xB5', '\xA9', '\xE2', '\x82', '\x9A',  /* ᵦᵧᵨᵩₚ */
+    '\0',
+    '\xE2', '\x81', '\xB0', '\xC2', '\xB3', '\xE2', '\x81', '\xB5', '\xE2', '\x81', '\xB7', '\xE1', '\xB5', '\x80', '\xE1', '\xB4', '\xB4', '\xE1', '\xB4', '\xB1', '\xE1', '\xB4', '\xBC',  /* ⁰³⁵⁷ᵀᴴᴱᴼ */
+    '\0',
+    '\xE2', '\x81', '\xB0', '\xC2', '\xB9', '\xC2', '\xB2', '\xC2', '\xB3', '\xE1', '\xB4', '\xB1', '\xE1', '\xB4', '\xB8', '\xE1', '\xB4', '\xBC', '\xE1', '\xB5', '\x81',  /* ⁰¹²³ᴱᴸᴼᵁ */
+    '\0',
+    '\xE1', '\xB5', '\x87', '\xE1', '\xB5', '\x88', '\xE1', '\xB5', '\x8F', '\xCA', '\xB0', '\xCA', '\xB2', '\xE1', '\xB6', '\xA0', '\xE2', '\x81', '\xB1',  /* ᵇᵈᵏʰʲᶠⁱ */
+    '\0',
+    '\xE1', '\xB5', '\x89', '\xE1', '\xB5', '\x92', '\xCA', '\xB3', '\xCB', '\xA2', '\xCB', '\xA3', '\xE1', '\xB6', '\x9C', '\xE1', '\xB6', '\xBB',  /* ᵉᵒʳˢˣᶜᶻ */
+    '\0',
+    '\xE1', '\xB5', '\x96', '\xCA', '\xB8', '\xE1', '\xB5', '\x8D',  /* ᵖʸᵍ */
+    '\0',
     '\xE0', '\xB0', '\x87', '\xE0', '\xB0', '\x8C', '\xE0', '\xB0', '\x99', '\xE0', '\xB0', '\x9E', '\xE0', '\xB0', '\xA3', '\xE0', '\xB0', '\xB1', '\xE0', '\xB1', '\xAF',  /* ఇ ఌ ఙ ఞ ణ ఱ ౯ */
     '\0',
     '\xE0', '\xB0', '\x85', '\xE0', '\xB0', '\x95', '\xE0', '\xB0', '\x9A', '\xE0', '\xB0', '\xB0', '\xE0', '\xB0', '\xBD', '\xE0', '\xB1', '\xA8', '\xE0', '\xB1', '\xAC',  /* అ క చ ర ఽ ౨ ౬ */
@@ -181,6 +201,22 @@
     { AF_BLUE_STRING_LATIN_SMALL,           0                                 },
     { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                 },
     { AF_BLUE_STRING_MAX,                   0                                 },
+    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
+    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM,  0                                 },
+    { AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
+    { AF_BLUE_STRING_LATIN_SUBS_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
+                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
+    { AF_BLUE_STRING_LATIN_SUBS_SMALL,           0                                 },
+    { AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER, 0                                 },
+    { AF_BLUE_STRING_MAX,                        0                                 },
+    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
+    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM,  0                                 },
+    { AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
+    { AF_BLUE_STRING_LATIN_SUPS_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
+                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
+    { AF_BLUE_STRING_LATIN_SUPS_SMALL,           0                                 },
+    { AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0                                 },
+    { AF_BLUE_STRING_MAX,                        0                                 },
     { AF_BLUE_STRING_TELUGU_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
     { AF_BLUE_STRING_TELUGU_BOTTOM, 0                          },
     { AF_BLUE_STRING_MAX,           0                          },
diff --git a/src/autofit/afblue.dat b/src/autofit/afblue.dat
index 8facfec..aadef92 100644
--- a/src/autofit/afblue.dat
+++ b/src/autofit/afblue.dat
@@ -131,6 +131,31 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
   AF_BLUE_STRING_LATIN_SMALL_DESCENDER
     "pqgjy"
 
+  // we assume that both the subscript and superscript ranges
+  // don't contain oldstyle digits (actually, most fonts probably
+  // have digits only in those ranges)
+  AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP
+    "₀₃₅₇₈"
+  AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM
+    "₀₁₂₃₈"
+  AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP
+    "ᵢⱼₕₖₗ"
+  AF_BLUE_STRING_LATIN_SUBS_SMALL
+    "ₐₑₒₓₙₛᵥᵤᵣ"
+  AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER
+    "ᵦᵧᵨᵩₚ"
+
+  AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP
+    "⁰³⁵⁷ᵀᴴᴱᴼ"
+  AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM
+    "⁰¹²³ᴱᴸᴼᵁ"
+  AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP
+    "ᵇᵈᵏʰʲᶠⁱ"
+  AF_BLUE_STRING_LATIN_SUPS_SMALL
+    "ᵉᵒʳˢˣᶜᶻ"
+  AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER
+    "ᵖʸᵍ"
+
   // we separate the letters with spaces to avoid ligatures;
   // this is just for convenience to simplify reading
   AF_BLUE_STRING_TELUGU_TOP
@@ -347,6 +372,26 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
     { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                 }
     { AF_BLUE_STRING_MAX,                   0                                 }
 
+  AF_BLUE_STRINGSET_LATB
+    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
+    { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM,  0                                 }
+    { AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
+    { AF_BLUE_STRING_LATIN_SUBS_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
+                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
+    { AF_BLUE_STRING_LATIN_SUBS_SMALL,           0                                 }
+    { AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER, 0                                 }
+    { AF_BLUE_STRING_MAX,                        0                                 }
+
+  AF_BLUE_STRINGSET_LATP
+    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
+    { AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM,  0                                 }
+    { AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
+    { AF_BLUE_STRING_LATIN_SUPS_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
+                                                 AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
+    { AF_BLUE_STRING_LATIN_SUPS_SMALL,           0                                 }
+    { AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0                                 }
+    { AF_BLUE_STRING_MAX,                        0                                 }
+
   AF_BLUE_STRINGSET_TELU
     { AF_BLUE_STRING_TELUGU_TOP,    AF_BLUE_PROPERTY_LATIN_TOP }
     { AF_BLUE_STRING_TELUGU_BOTTOM, 0                          }
diff --git a/src/autofit/afblue.h b/src/autofit/afblue.h
index 2080e31..18b4361 100644
--- a/src/autofit/afblue.h
+++ b/src/autofit/afblue.h
@@ -98,16 +98,26 @@ FT_BEGIN_HEADER
     AF_BLUE_STRING_LATIN_SMALL_F_TOP = 301,
     AF_BLUE_STRING_LATIN_SMALL = 309,
     AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 317,
-    AF_BLUE_STRING_TELUGU_TOP = 323,
-    AF_BLUE_STRING_TELUGU_BOTTOM = 345,
-    AF_BLUE_STRING_THAI_TOP = 367,
-    AF_BLUE_STRING_THAI_BOTTOM = 386,
-    AF_BLUE_STRING_THAI_ASCENDER = 408,
-    AF_BLUE_STRING_THAI_LARGE_ASCENDER = 418,
-    AF_BLUE_STRING_THAI_DESCENDER = 428,
-    AF_BLUE_STRING_THAI_LARGE_DESCENDER = 441,
-    AF_BLUE_STRING_THAI_DIGIT_TOP = 448,
-    af_blue_1_1 = 457,
+    AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 323,
+    AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 339,
+    AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 355,
+    AF_BLUE_STRING_LATIN_SUBS_SMALL = 371,
+    AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 399,
+    AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 415,
+    AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 439,
+    AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 461,
+    AF_BLUE_STRING_LATIN_SUPS_SMALL = 481,
+    AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 500,
+    AF_BLUE_STRING_TELUGU_TOP = 509,
+    AF_BLUE_STRING_TELUGU_BOTTOM = 531,
+    AF_BLUE_STRING_THAI_TOP = 553,
+    AF_BLUE_STRING_THAI_BOTTOM = 572,
+    AF_BLUE_STRING_THAI_ASCENDER = 594,
+    AF_BLUE_STRING_THAI_LARGE_ASCENDER = 604,
+    AF_BLUE_STRING_THAI_DESCENDER = 614,
+    AF_BLUE_STRING_THAI_LARGE_DESCENDER = 627,
+    AF_BLUE_STRING_THAI_DIGIT_TOP = 634,
+    af_blue_1_1 = 643,
 #ifdef AF_CONFIG_OPTION_CJK
     AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1,
     AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 153,
@@ -171,9 +181,11 @@ FT_BEGIN_HEADER
     AF_BLUE_STRINGSET_GREK = 16,
     AF_BLUE_STRINGSET_HEBR = 23,
     AF_BLUE_STRINGSET_LATN = 27,
-    AF_BLUE_STRINGSET_TELU = 34,
-    AF_BLUE_STRINGSET_THAI = 37,
-    af_blue_2_1 = 45,
+    AF_BLUE_STRINGSET_LATB = 34,
+    AF_BLUE_STRINGSET_LATP = 41,
+    AF_BLUE_STRINGSET_TELU = 48,
+    AF_BLUE_STRINGSET_THAI = 51,
+    af_blue_2_1 = 59,
 #ifdef AF_CONFIG_OPTION_CJK
     AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0,
     af_blue_2_1_1 = af_blue_2_1 + 2,
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index cd0e2ab..c1cc276 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -47,6 +47,7 @@
             af_ ## s ## _script_class,      \
             AF_SCRIPT_ ## S,                \
             af_ ## s ## _uniranges,         \
+            af_ ## s ## _nobase_uniranges,  \
             sc1, sc2, sc3 )
 
 #include "afscript.h"
@@ -189,9 +190,9 @@
 
           gindex = FT_Get_Char_Index( face, charcode );
 
-          if ( gindex != 0                             &&
-               gindex < (FT_ULong)globals->glyph_count &&
-               gstyles[gindex] == AF_STYLE_UNASSIGNED  )
+          if ( gindex != 0                                                &&
+               gindex < (FT_ULong)globals->glyph_count                    &&
+               ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
             gstyles[gindex] = (FT_UShort)ss;
 
           for (;;)
@@ -201,11 +202,40 @@
             if ( gindex == 0 || charcode > range->last )
               break;
 
-            if ( gindex < (FT_ULong)globals->glyph_count &&
-                 gstyles[gindex] == AF_STYLE_UNASSIGNED  )
+            if ( gindex < (FT_ULong)globals->glyph_count                    &&
+                 ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
               gstyles[gindex] = (FT_UShort)ss;
           }
         }
+
+        /* do the same for the script's no-base characters */
+        for ( range = script_class->script_uni_nobase_ranges;
+              range->first != 0;
+              range++ )
+        {
+          FT_ULong  charcode = range->first;
+          FT_UInt   gindex;
+
+
+          gindex = FT_Get_Char_Index( face, charcode );
+
+          if ( gindex != 0                                          &&
+               gindex < (FT_ULong)globals->glyph_count              &&
+               ( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
+            gstyles[gindex] |= AF_NOBASE;
+
+          for (;;)
+          {
+            charcode = FT_Get_Next_Char( face, charcode, &gindex );
+
+            if ( gindex == 0 || charcode > range->last )
+              break;
+
+            if ( gindex < (FT_ULong)globals->glyph_count              &&
+                 ( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
+              gstyles[gindex] |= AF_NOBASE;
+          }
+        }
       }
       else
       {
diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h
index 284f6a0..8189f48 100644
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -73,13 +73,15 @@ FT_BEGIN_HEADER
   /* default script for OpenType; ignored if HarfBuzz isn't used */
 #define AF_SCRIPT_DEFAULT    AF_SCRIPT_LATN
 
-  /* a bit mask for TA_DIGIT */
-#define AF_STYLE_MASK        0x7FFF
+  /* a bit mask for AF_DIGIT and AF_NOBASE */
+#define AF_STYLE_MASK        0x3FFF
   /* an uncovered glyph      */
 #define AF_STYLE_UNASSIGNED  AF_STYLE_MASK
 
-  /* if this flag is set, we have an ASCII digit     */
+  /* if this flag is set, we have an ASCII digit   */
 #define AF_DIGIT             0x8000U
+  /* if this flag is set, we have a no-base character */
+#define AF_NOBASE            0x4000U
 
   /* `increase-x-height' property */
 #define AF_PROP_INCREASE_X_HEIGHT_MIN  6
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index ae2c46d..954da07 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -2846,8 +2846,6 @@
 
     AF_LatinAxis  axis;
 
-    FT_UNUSED( glyph_index );
-
 
     error = af_glyph_hints_reload( hints, outline );
     if ( error )
@@ -2881,7 +2879,9 @@
       if ( error )
         goto Exit;
 
-      af_latin_hints_compute_blue_edges( hints, metrics );
+      /* apply blue zones to base characters only */
+      if ( !( metrics->root.globals->glyph_styles[glyph_index] & AF_NOBASE ) )
+        af_latin_hints_compute_blue_edges( hints, metrics );
     }
 
     /* grid-fit the outline */
diff --git a/src/autofit/afranges.h b/src/autofit/afranges.h
index 7c78ab0..38e40cd 100644
--- a/src/autofit/afranges.h
+++ b/src/autofit/afranges.h
@@ -31,6 +31,12 @@ FT_BEGIN_HEADER
 
 #include "afscript.h"
 
+#undef  SCRIPT
+#define SCRIPT( s, S, d, h, sc1, sc2, sc3 )                                    \
+          extern const AF_Script_UniRangeRec  af_ ## s ## _nobase_uniranges[];
+
+#include "afscript.h"
+
  /* */
 
 FT_END_HEADER
diff --git a/src/autofit/afscript.h b/src/autofit/afscript.h
index dfcc830..8ef5f0e 100644
--- a/src/autofit/afscript.h
+++ b/src/autofit/afscript.h
@@ -25,6 +25,10 @@
   /* by a description string.  Then comes the corresponding HarfBuzz  */
   /* script name tag, followed by a string of standard characters (to */
   /* derive the standard width and height of stems).                  */
+  /*                                                                  */
+  /* Note that fallback scripts only have a default style, thus we    */
+  /* use `HB_SCRIPT_INVALID' as the HarfBuzz script name tag for      */
+  /* them.                                                            */
 
   SCRIPT( arab, ARAB,
           "Arabic",
@@ -34,7 +38,7 @@
   SCRIPT( cyrl, CYRL,
           "Cyrillic",
           HB_SCRIPT_CYRILLIC,
-          0x43E, 0x41E, 0x0 ) /* оО */
+          0x43E, 0x41E, 0x0 ) /* о О */
 
   SCRIPT( deva, DEVA,
           "Devanagari",
@@ -44,7 +48,7 @@
   SCRIPT( grek, GREK,
           "Greek",
           HB_SCRIPT_GREEK,
-          0x3BF, 0x39F, 0x0 ) /* οΟ */
+          0x3BF, 0x39F, 0x0 ) /* ο Ο */
 
   SCRIPT( hebr, HEBR,
           "Hebrew",
@@ -56,6 +60,16 @@
           HB_SCRIPT_LATIN,
           'o', 'O', '0' )
 
+  SCRIPT( latb, LATB,
+          "Latin Subscript Fallback",
+          HB_SCRIPT_INVALID,
+          0x2092, 0x2080, 0x0 ) /* ₒ ₀ */
+
+  SCRIPT( latp, LATP,
+          "Latin Superscript Fallback",
+          HB_SCRIPT_INVALID,
+          0x1D52, 0x1D3C, 0x2070 ) /* ᵒ ᴼ ⁰ */
+
   SCRIPT( none, NONE,
           "no script",
           HB_SCRIPT_INVALID,
diff --git a/src/autofit/afstyles.h b/src/autofit/afstyles.h
index bfd5bb9..42f5d2f 100644
--- a/src/autofit/afstyles.h
+++ b/src/autofit/afstyles.h
@@ -27,7 +27,9 @@
   /* coverage.                                                     */
   /*                                                               */
   /* Note that styles using `AF_COVERAGE_DEFAULT' should always    */
-  /* come after styles with other coverages.                       */
+  /* come after styles with other coverages.  Also note that       */
+  /* fallback scripts only use `AF_COVERAGE_DEFAULT' for its       */
+  /* style.                                                        */
   /*                                                               */
   /* Example:                                                      */
   /*                                                               */
@@ -90,6 +92,13 @@
 
   META_STYLE_LATIN( cyrl, CYRL, "Cyrillic" )
 
+  STYLE( deva_dflt, DEVA_DFLT,
+         "Devanagari default style",
+         AF_WRITING_SYSTEM_LATIN,
+         AF_SCRIPT_DEVA,
+         AF_BLUE_STRINGSET_DEVA,
+         AF_COVERAGE_DEFAULT )
+
   META_STYLE_LATIN( grek, GREK, "Greek" )
 
   STYLE( hebr_dflt, HEBR_DFLT,
@@ -98,13 +107,21 @@
          AF_SCRIPT_HEBR,
          AF_BLUE_STRINGSET_HEBR,
          AF_COVERAGE_DEFAULT )
+
   META_STYLE_LATIN( latn, LATN, "Latin" )
 
-  STYLE( deva_dflt, DEVA_DFLT,
-         "Devanagari default style",
+  STYLE( latb_dflt, LATB_DFLT,
+         "Latin subscript fallback default style",
          AF_WRITING_SYSTEM_LATIN,
-         AF_SCRIPT_DEVA,
-         AF_BLUE_STRINGSET_DEVA,
+         AF_SCRIPT_LATB,
+         AF_BLUE_STRINGSET_LATB,
+         AF_COVERAGE_DEFAULT )
+
+  STYLE( latp_dflt, LATP_DFLT,
+         "Latin superscript fallback default style",
+         AF_WRITING_SYSTEM_LATIN,
+         AF_SCRIPT_LATP,
+         AF_BLUE_STRINGSET_LATP,
          AF_COVERAGE_DEFAULT )
 
 #ifdef FT_OPTION_AUTOFIT2
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index d6b1bf7..54fa37f 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -294,8 +294,9 @@ 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.
+   *  Each script is associated with two sets of Unicode ranges to test
+   *  whether the font face supports the script, and which no-base characters
+   *  the script contains.
    *
    *  We use four-letter script tags from the OpenType specification,
    *  extended by `NONE', which indicates `no script'.
@@ -332,7 +333,9 @@ extern void*  _af_debug_hints;
   {
     AF_Script  script;
 
-    AF_Script_UniRange  script_uni_ranges; /* last must be { 0, 0 }        */
+    /* last element in the ranges must be { 0, 0 } */
+    AF_Script_UniRange  script_uni_ranges;
+    AF_Script_UniRange  script_uni_nobase_ranges;
 
     FT_UInt32  standard_char1;             /* for default width and height */
     FT_UInt32  standard_char2;             /* ditto                        */
@@ -512,6 +515,7 @@ extern void*  _af_debug_hints;
           script_class,                   \
           script,                         \
           ranges,                         \
+          nobase_ranges,                  \
           std_char1,                      \
           std_char2,                      \
           std_char3 )                     \
@@ -520,6 +524,7 @@ extern void*  _af_debug_hints;
   {                                       \
     script,                               \
     ranges,                               \
+    nobase_ranges,                        \
     std_char1,                            \
     std_char2,                            \
     std_char3                             \
@@ -586,17 +591,19 @@ extern void*  _af_debug_hints;
           script_class,                                    \
           script_,                                         \
           ranges,                                          \
+          nobase_ranges,                                   \
           std_char1,                                       \
           std_char2,                                       \
           std_char3 )                                      \
   FT_LOCAL_DEF( void )                                     \
   FT_Init_Class_ ## script_class( AF_ScriptClassRec*  ac ) \
   {                                                        \
-    ac->script            = script_;                       \
-    ac->script_uni_ranges = ranges;                        \
-    ac->standard_char1    = std_char1;                     \
-    ac->standard_char2    = std_char2;                     \
-    ac->standard_char3    = std_char3;                     \
+    ac->script                   = script_;                \
+    ac->script_uni_ranges        = ranges;                 \
+    ac->script_uni_nobase_ranges = nobase_ranges;          \
+    ac->standard_char1           = std_char1;              \
+    ac->standard_char2           = std_char2;              \
+    ac->standard_char3           = std_char3;              \
   }