int *cmd_ids;
 } FontLayoutCmdCond;
 
-typedef struct
-{
-  MSymbol script;
-  MSymbol langsys;
-  MSymbol gsub_features;
-  MSymbol gpos_features;
-} FontLayoutCmdOTF;
-
 enum FontLayoutCmdType
   {
     FontLayoutCmdTypeRule,
   int cluster_end_pos;
   int combining_code;
   int left_padding;
-  MRealizedFont *rfont;
 } FontLayoutContext;
 
 static int run_command (int depth,
 {
 #ifdef HAVE_OTF
   int gidx = gstring->used;
+  MGlyph *g = MGLYPH (from), *gend = MGLYPH (to);
+
+  for (; g < gend; g++)
+    g->otf_cmd = otf_cmd;
 
-  to = mfont__ft_drive_otf (gstring, from, to, ctx->rfont,
-                           otf_cmd->script, otf_cmd->langsys,
-                           otf_cmd->gsub_features, otf_cmd->gpos_features);
+  to = mfont__ft_drive_gsub (gstring, from, to);
   if (gidx < gstring->used)
     MGLYPH (gidx)->left_padding = ctx->left_padding;
 #endif
 
   /* Setup CTX.  */
   memset (&ctx, 0, sizeof ctx);
-  ctx.rfont = rface->rfont;
   table = MPLIST_VAL (layouter);
   layouter = MPLIST_NEXT (layouter);
   stage = (FontLayoutStage *) MPLIST_VAL (layouter);
            ctx.encoded[i - from] = ' ';
          else if (! g->otf_encoded)
            ctx.encoded[i - from] = (int) mchartable_lookup (table, g->code);
-#ifdef HAVE_FREETYPE
+#if defined (HAVE_FREETYPE) && defined (HAVE_OTF)
          else
            {
              int c = mfont__ft_decode_otf (g);
                }
              ctx.encoded[i - from] = (c >= 0 ? c : 1);
            }
-#endif /* HAVE_FREETYPE */
+#endif /* HAVE_FREETYPE && HAVE_OTF */
        }
       ctx.encoded[i - from] = '\0';
       ctx.encoded_offset = from;