- if (hfillExpansion(par, row, pos)) {
- x += singleWidth(par, pos);
- if (pos >= body_pos)
- x += m.hfill;
- else
- x += m.label_hfill;
- } else if (par.isSeparator(pos)) {
- x += singleWidth(par, pos);
- if (pos >= body_pos)
- x += m.separator;
- } else
- x += singleWidth(par, pos);
+ // Use font span to speed things up, see above
+ if (pos < font_span.first || pos > font_span.last) {
+ font_span = par.fontSpan(pos);
+ font = getFont(par, pos);
+ }
+
+ x += singleWidth(par, pos, par.getChar(pos), font);
+
+ if (hfillExpansion(par, row, pos))
+ x += (pos >= body_pos) ? m.hfill : m.label_hfill;
+ else if (par.isSeparator(pos) && pos >= body_pos)
+ x += m.separator;
+ }
+
+ // see correction above
+ if (boundary_correction)
+ if (getFont(par, ppos).isVisibleRightToLeft())
+ x -= singleWidth(par, ppos);
+ else
+ x += singleWidth(par, ppos);
+
+ // Make sure inside an inset we always count from the left
+ // edge (bidi!) -- MV
+ if (sl.pos() < par.size()) {
+ font = getFont(par, sl.pos());
+ if (!boundary && font.isVisibleRightToLeft()
+ && par.isInset(sl.pos()))
+ x -= par.getInset(sl.pos())->width();