- while ((tmp->type == GLYPH_CHAR || tmp->type == GLYPH_SPACE)
- && tmp->rface->rfont == this->rface->rfont
- && tmp->code != MCHAR_INVALID_CODE)
- i++, tmp++;
- i = mfont__flt_run (gstring, start, i,
- this->rface->rfont->layouter,
- this->rface->ascii_rface);
+ MGlyph *prev;
+ unsigned code;
+
+ for (prev = MGLYPH (start - 1);
+ (prev->type == GLYPH_CHAR
+ && prev->category == McatCf
+ && (code = mfont__encode_char (this->rface->rfont, prev->c)
+ != MCHAR_INVALID_CODE));
+ start--, prev--)
+ prev->code = code;
+
+ for (g++;
+ (g->type == GLYPH_CHAR
+ && (g->rface->rfont == this->rface->rfont
+ || (g->category == McatCf
+ && ((code = mfont__encode_char (this->rface->rfont,
+ g->c))
+ != MCHAR_INVALID_CODE))));
+ i++, g++)
+ if (g->rface->rfont != this->rface->rfont)
+ g->code = code;
+ i = mfont__flt_run (gstring, start, i, this->rface);