shithub: freetype+ttf2subf

Download patch

ref: d3cba0ed30bedaca23a2f4aab2d28d2afae7e087
parent: 696b712691400aae977f0f12a66bb0b02503797a
author: Werner Lemberg <[email protected]>
date: Fri Sep 4 06:28:53 EDT 2015

[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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,37 @@
 2015-09-04  Werner Lemberg  <[email protected]>
 
+	[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  <[email protected]>
+
 	[autofit] Redesign code ranges (1/2).
 
 	This patch introduces auxiliary code ranges that identify no-base
--- 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                          },
--- a/src/autofit/afblue.dat
+++ b/src/autofit/afblue.dat
@@ -131,6 +131,31 @@
   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
@@ -346,6 +371,26 @@
     { AF_BLUE_STRING_LATIN_SMALL,           0                                 }
     { 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 }
--- a/src/autofit/afblue.h
+++ b/src/autofit/afblue.h
@@ -98,16 +98,26 @@
     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 @@
     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,
--- 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,9 +202,38 @@
             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;
           }
         }
       }
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -73,13 +73,15 @@
   /* 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
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -2846,9 +2846,7 @@
 
     AF_LatinAxis  axis;
 
-    FT_UNUSED( glyph_index );
 
-
     error = af_glyph_hints_reload( hints, outline );
     if ( error )
       goto Exit;
@@ -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 */
--- a/src/autofit/afranges.h
+++ b/src/autofit/afranges.h
@@ -31,6 +31,12 @@
 
 #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
--- 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",
@@ -55,6 +59,16 @@
           "Latin",
           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",
--- 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
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -294,8 +294,9 @@
   /*************************************************************************/
 
   /*
-   *  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 @@
   {
     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 @@
           script_class,                   \
           script,                         \
           ranges,                         \
+          nobase_ranges,                  \
           std_char1,                      \
           std_char2,                      \
           std_char3 )                     \
@@ -520,6 +524,7 @@
   {                                       \
     script,                               \
     ranges,                               \
+    nobase_ranges,                        \
     std_char1,                            \
     std_char2,                            \
     std_char3                             \
@@ -586,6 +591,7 @@
           script_class,                                    \
           script_,                                         \
           ranges,                                          \
+          nobase_ranges,                                   \
           std_char1,                                       \
           std_char2,                                       \
           std_char3 )                                      \
@@ -592,11 +598,12 @@
   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;              \
   }